@aiot-toolkit/aiotpack 2.0.1-alpha.9 → 2.0.2-beta.1
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/enum/CompileMode.js +0 -2
- package/lib/compiler/interface/ICompileParam.js +0 -2
- package/lib/compiler/interface/ICompiler.js +0 -2
- package/lib/compiler/interface/ISignConfig.js +0 -2
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +1 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +40 -18
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +1 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +5 -3
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +8 -4
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +0 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +0 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +1 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +0 -5
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +0 -2
- package/lib/compiler/javascript/vela/enum/EntryType.js +0 -2
- package/lib/compiler/javascript/vela/interface/IChunk.js +0 -2
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +3 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +0 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +0 -2
- package/lib/compiler/javascript/vela/model/Package.js +2 -4
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +0 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +19 -24
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +4 -7
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +2 -4
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +5 -7
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +0 -2
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +0 -2
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +14 -12
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +0 -2
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.js +20 -0
- package/lib/config/UxConfig.d.ts +3 -3
- package/lib/config/UxConfig.js +17 -6
- package/lib/config/XtsConfig.js +0 -2
- package/lib/followWorks/xts/entryTemplate.d.ts +2 -2
- package/lib/followWorks/xts/entryTemplate.js +61 -44
- package/lib/followWorks/xts/generateRpk.js +1 -3
- package/lib/followWorks/xts/ts2wasm.js +3 -14
- package/lib/index.js +0 -2
- package/lib/interface/ICompileOptions.d.ts +1 -1
- package/lib/interface/ICompileOptions.js +1 -3
- package/lib/interface/IDeviceList.js +0 -2
- package/lib/loader/ux/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/AppUxLoader.js +1 -3
- package/lib/loader/ux/JsLoader.d.ts +9 -0
- package/lib/loader/ux/JsLoader.js +39 -0
- package/lib/loader/ux/PngLoader.js +4 -9
- package/lib/loader/ux/UxLoader.d.ts +2 -0
- package/lib/loader/ux/UxLoader.js +15 -4
- package/lib/loader/xts/XtsLoader.js +3 -9
- package/lib/preWorks/xts/preInstall.js +4 -12
- package/lib/utils/PngUtils.js +0 -2
- package/lib/utils/PreWorkUtils.d.ts +5 -0
- package/lib/utils/PreWorkUtils.js +39 -9
- package/lib/utils/ux/ManifestSchema.d.ts +3 -0
- package/lib/utils/ux/ManifestSchema.js +207 -0
- package/lib/utils/ux/UxFileUtils.d.ts +21 -4
- package/lib/utils/ux/UxFileUtils.js +74 -5
- package/lib/utils/ux/UxFollowWorks.d.ts +1 -0
- package/lib/utils/ux/UxFollowWorks.js +60 -7
- package/lib/utils/ux/UxLoaderUtils.d.ts +11 -7
- package/lib/utils/ux/UxLoaderUtils.js +119 -33
- package/lib/utils/ux/UxPreWorks.d.ts +10 -0
- package/lib/utils/ux/UxPreWorks.js +31 -0
- package/lib/utils/xts/XtsFollowWorks.js +3 -12
- package/package.json +5 -10
- package/lib/compiler/enum/CompileMode.js.map +0 -1
- package/lib/compiler/interface/ICompileParam.js.map +0 -1
- package/lib/compiler/interface/ICompiler.js.map +0 -1
- package/lib/compiler/interface/ISignConfig.js.map +0 -1
- package/lib/compiler/javascript/JavascriptCompiler.js.map +0 -1
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +0 -1
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +0 -1
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +0 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +0 -1
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +0 -1
- package/lib/compiler/javascript/vela/enum/EntryType.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IChunk.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +0 -1
- package/lib/compiler/javascript/vela/model/Package.js.map +0 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +0 -1
- package/lib/config/UxConfig.js.map +0 -1
- package/lib/config/XtsConfig.js.map +0 -1
- package/lib/followWorks/xts/entryTemplate.js.map +0 -1
- package/lib/followWorks/xts/generateRpk.js.map +0 -1
- package/lib/followWorks/xts/ts2wasm.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface/ICompileOptions.js.map +0 -1
- package/lib/interface/IDeviceList.js.map +0 -1
- package/lib/loader/ux/AppUxLoader.js.map +0 -1
- package/lib/loader/ux/PngLoader.js.map +0 -1
- package/lib/loader/ux/UxLoader.js.map +0 -1
- package/lib/loader/xts/XtsLoader.js.map +0 -1
- package/lib/preWorks/xts/preInstall.js.map +0 -1
- package/lib/utils/PngUtils.js.map +0 -1
- package/lib/utils/PreWorkUtils.js.map +0 -1
- package/lib/utils/ux/UxFileUtils.js.map +0 -1
- package/lib/utils/ux/UxFollowWorks.js.map +0 -1
- package/lib/utils/ux/UxLoaderUtils.js.map +0 -1
- package/lib/utils/xts/XtsFollowWorks.js.map +0 -1
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IFileLaneConfig } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
3
|
import AppUxLoader from '../loader/ux/AppUxLoader';
|
|
4
|
-
import
|
|
4
|
+
import JsLoader from '../loader/ux/JsLoader';
|
|
5
5
|
import UxLoader from '../loader/ux/UxLoader';
|
|
6
6
|
declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
7
7
|
readonly projectPath: string;
|
|
8
8
|
constructor(projectPath: string);
|
|
9
9
|
exclude: RegExp[];
|
|
10
|
-
include: RegExp[];
|
|
11
10
|
get output(): string;
|
|
12
11
|
module: {
|
|
13
12
|
rules: ({
|
|
@@ -20,11 +19,12 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
|
20
19
|
loader: (typeof UxLoader)[];
|
|
21
20
|
} | {
|
|
22
21
|
test: RegExp[];
|
|
23
|
-
loader: (typeof
|
|
22
|
+
loader: (typeof JsLoader)[];
|
|
24
23
|
exclude?: undefined;
|
|
25
24
|
})[];
|
|
26
25
|
};
|
|
27
26
|
preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<IJavascriptCompileOption>[];
|
|
28
27
|
followWorks: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<IJavascriptCompileOption>[];
|
|
28
|
+
watchIgnores: RegExp[];
|
|
29
29
|
}
|
|
30
30
|
export default UxConfig;
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -5,15 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const AppUxLoader_1 = __importDefault(require("../loader/ux/AppUxLoader"));
|
|
8
|
+
const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
|
|
8
9
|
const PngLoader_1 = __importDefault(require("../loader/ux/PngLoader"));
|
|
9
10
|
const UxLoader_1 = __importDefault(require("../loader/ux/UxLoader"));
|
|
10
11
|
const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
|
|
11
12
|
const UxFollowWorks_1 = __importDefault(require("../utils/ux/UxFollowWorks"));
|
|
13
|
+
const UxPreWorks_1 = __importDefault(require("../utils/ux/UxPreWorks"));
|
|
12
14
|
class UxConfig {
|
|
13
15
|
constructor(projectPath) {
|
|
14
16
|
this.projectPath = projectPath;
|
|
15
17
|
this.exclude = [/node_modules/, /dist/, /build/];
|
|
16
|
-
this.include = [/src/];
|
|
17
18
|
this.module = {
|
|
18
19
|
rules: [
|
|
19
20
|
{
|
|
@@ -26,20 +27,32 @@ class UxConfig {
|
|
|
26
27
|
loader: [UxLoader_1.default]
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
|
-
test: [/.+\.
|
|
30
|
+
test: [/.+\.js$/],
|
|
31
|
+
loader: [JsLoader_1.default]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
test: [/.+\.9.png/],
|
|
30
35
|
loader: [PngLoader_1.default]
|
|
31
36
|
}
|
|
32
37
|
]
|
|
33
38
|
};
|
|
34
|
-
this.preWorks = [
|
|
39
|
+
this.preWorks = [
|
|
40
|
+
UxPreWorks_1.default.validateManifest,
|
|
41
|
+
UxPreWorks_1.default.validateSitemap,
|
|
42
|
+
PreWorkUtils_1.default.clean,
|
|
43
|
+
PreWorkUtils_1.default.getEntries,
|
|
44
|
+
PreWorkUtils_1.default.getGlobalVar
|
|
45
|
+
];
|
|
35
46
|
this.followWorks = [
|
|
36
47
|
UxFollowWorks_1.default.symlinkNodeModule,
|
|
37
48
|
UxFollowWorks_1.default.webpack,
|
|
38
49
|
UxFollowWorks_1.default.copyResource,
|
|
39
50
|
UxFollowWorks_1.default.jsc,
|
|
40
51
|
UxFollowWorks_1.default.toRpk,
|
|
41
|
-
UxFollowWorks_1.default.moveBackResult
|
|
52
|
+
UxFollowWorks_1.default.moveBackResult,
|
|
53
|
+
UxFollowWorks_1.default.protobuf
|
|
42
54
|
];
|
|
55
|
+
this.watchIgnores = [/node_modules/];
|
|
43
56
|
}
|
|
44
57
|
get output() {
|
|
45
58
|
const name = path_1.default.basename(this.projectPath);
|
|
@@ -48,5 +61,3 @@ class UxConfig {
|
|
|
48
61
|
}
|
|
49
62
|
}
|
|
50
63
|
exports.default = UxConfig;
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=UxConfig.js.map
|
package/lib/config/XtsConfig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
2
2
|
export interface Aspects {
|
|
3
3
|
path: string;
|
|
4
4
|
name: string;
|
|
@@ -18,4 +18,4 @@ export declare const XtsEntryFileName = "__entry__.ts";
|
|
|
18
18
|
* 生成 __entry__.ts 文件
|
|
19
19
|
* @param context
|
|
20
20
|
*/
|
|
21
|
-
export declare
|
|
21
|
+
export declare const generateEntryFile: FollowWork;
|
|
@@ -14,9 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.generateEntryFile = exports.XtsEntryFileName = exports.entryTemplate = void 0;
|
|
16
16
|
const Framework_1 = require("@aiot-toolkit/parser/lib/xts/enum/Framework");
|
|
17
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
17
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
20
18
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
19
|
const path_1 = __importDefault(require("path"));
|
|
22
20
|
const entryTemplate = (options) => {
|
|
@@ -41,20 +39,24 @@ const entryTemplate = (options) => {
|
|
|
41
39
|
for (let i = 0; i < aspects.length; i++) {
|
|
42
40
|
const aspect = aspects[i];
|
|
43
41
|
const { routes = [] } = aspect;
|
|
42
|
+
res += `
|
|
43
|
+
const aspectName_${i + 1} = '${aspect.name}'
|
|
44
|
+
const pathPages_${i + 1} = new Map()`;
|
|
44
45
|
for (let r = 0; r < routes.length; r++) {
|
|
45
46
|
const route = routes[r];
|
|
46
47
|
res += `
|
|
47
|
-
|
|
48
|
-
pathPages${i + 1}_${r + 1}.set('${route.route}', function (params?: ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
|
|
48
|
+
pathPages_${i + 1}.set('${route.route}', function (params?: ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
|
|
49
49
|
return new Page${i + 1}_${r + 1}(params)
|
|
50
50
|
})
|
|
51
|
-
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
res += `
|
|
52
54
|
const aspectDef_${i + 1}: AspectDefinition = {
|
|
53
55
|
newFn: (): ViewAspect => new AspectClass${i + 1}(),
|
|
54
|
-
pathPages:
|
|
56
|
+
pathPages: pathPages_${i + 1}
|
|
55
57
|
}
|
|
56
|
-
aspectDefs.set(aspectName_${i + 1}, aspectDef_${i + 1})
|
|
57
|
-
|
|
58
|
+
aspectDefs.set(aspectName_${i + 1}, aspectDef_${i + 1})
|
|
59
|
+
`;
|
|
58
60
|
}
|
|
59
61
|
return res;
|
|
60
62
|
}
|
|
@@ -110,57 +112,72 @@ export { entry, on }
|
|
|
110
112
|
`;
|
|
111
113
|
};
|
|
112
114
|
exports.entryTemplate = entryTemplate;
|
|
115
|
+
function getManifest(manifestPath) {
|
|
116
|
+
const content = fs_extra_1.default.readFileSync(manifestPath, 'utf-8');
|
|
117
|
+
const data = JSON.parse(content);
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
113
120
|
exports.XtsEntryFileName = '__entry__.ts';
|
|
114
121
|
/**
|
|
115
122
|
* 生成 __entry__.ts 文件
|
|
116
123
|
* @param context
|
|
117
124
|
*/
|
|
118
|
-
function generateEntryFile(context) {
|
|
119
|
-
var _a, _b
|
|
125
|
+
const generateEntryFile = function generateEntryFile(context, _, compilerOptions) {
|
|
126
|
+
var _a, _b;
|
|
120
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
128
|
const { projectPath, output } = context;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
130
|
+
ColorConsole_1.default.info(`### skip generate entry file due to --skip xts2ts}`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
ColorConsole_1.default.info(`Generating entry file`);
|
|
134
|
+
const buildDir = path_1.default.resolve(projectPath, output);
|
|
135
|
+
const appManifestPath = path_1.default.join(buildDir, 'app', 'manifest.json');
|
|
136
|
+
const appManifest = getManifest(appManifestPath);
|
|
137
|
+
if (!appManifest) {
|
|
138
|
+
ColorConsole_1.default.throw('not find app/manifest.json file !');
|
|
130
139
|
}
|
|
131
|
-
const appTs =
|
|
132
|
-
if (appTs
|
|
133
|
-
ColorConsole_1.default.
|
|
140
|
+
const appTs = path_1.default.join(buildDir, 'app', 'app.ts');
|
|
141
|
+
if (!fs_extra_1.default.existsSync(appTs)) {
|
|
142
|
+
ColorConsole_1.default.throw('not find app/app.ts file !');
|
|
143
|
+
}
|
|
144
|
+
function relativeDist(tar) {
|
|
145
|
+
return path_1.default.join('.', path_1.default.relative(buildDir, tar)).replace(path_1.default.sep, '/');
|
|
134
146
|
}
|
|
135
147
|
let opt = {
|
|
136
|
-
appPath: relativeDist(appTs
|
|
148
|
+
appPath: relativeDist(appTs.replace('.ts', '')),
|
|
137
149
|
aspects: []
|
|
138
150
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
function getAspectRoutes(aspectPath) {
|
|
152
|
+
var _a;
|
|
153
|
+
const aspectManifestPath = path_1.default.join(aspectPath, 'src', 'manifest.json');
|
|
154
|
+
const aspectManifest = getManifest(aspectManifestPath);
|
|
155
|
+
if (!((_a = aspectManifest === null || aspectManifest === void 0 ? void 0 : aspectManifest.router) === null || _a === void 0 ? void 0 : _a.pages))
|
|
156
|
+
return [];
|
|
157
|
+
return Object.entries(aspectManifest.router.pages).map(([k, v]) => {
|
|
158
|
+
return {
|
|
159
|
+
importPath: relativeDist(path_1.default.resolve(path_1.default.dirname(aspectManifestPath), v.path)),
|
|
160
|
+
name: k,
|
|
161
|
+
route: v.path
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if ((_b = appManifest === null || appManifest === void 0 ? void 0 : appManifest.router) === null || _b === void 0 ? void 0 : _b.aspects) {
|
|
166
|
+
Object.entries(appManifest.router.aspects).forEach(([name, aspects]) => {
|
|
167
|
+
aspects.forEach((aspect) => {
|
|
168
|
+
var _a;
|
|
169
|
+
const aspectPath = path_1.default.join(buildDir, aspect.path);
|
|
170
|
+
(_a = opt.aspects) === null || _a === void 0 ? void 0 : _a.push({
|
|
171
|
+
name: name,
|
|
172
|
+
path: relativeDist(path_1.default.resolve(buildDir, aspect.path, 'src', 'aspect')),
|
|
173
|
+
routes: getAspectRoutes(aspectPath)
|
|
174
|
+
});
|
|
153
175
|
});
|
|
154
|
-
}
|
|
176
|
+
});
|
|
155
177
|
}
|
|
156
178
|
const template = (0, exports.entryTemplate)(opt);
|
|
157
179
|
fs_extra_1.default.writeFileSync(path_1.default.join(projectPath, output, exports.XtsEntryFileName), template);
|
|
158
|
-
ColorConsole_1.default.
|
|
159
|
-
level: shared_utils_1.LOG_LEVEL.Info,
|
|
160
|
-
message: `Entry file built`
|
|
161
|
-
});
|
|
180
|
+
ColorConsole_1.default.info(`entry file built`);
|
|
162
181
|
});
|
|
163
|
-
}
|
|
182
|
+
};
|
|
164
183
|
exports.generateEntryFile = generateEntryFile;
|
|
165
|
-
|
|
166
|
-
//# sourceMappingURL=entryTemplate.js.map
|
|
@@ -43,7 +43,7 @@ const ts2wasm_1 = require("./ts2wasm");
|
|
|
43
43
|
const generateRpk = (context, _, compilerOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
44
|
var _a;
|
|
45
45
|
if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('package')) {
|
|
46
|
-
ColorConsole_1.default.
|
|
46
|
+
ColorConsole_1.default.info(`### skip package due to --skip ${compilerOptions.skip.join(',')}`);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
const manifestPath = path_1.default.resolve(context.projectPath, 'app', 'manifest.json');
|
|
@@ -54,5 +54,3 @@ const generateRpk = (context, _, compilerOptions) => __awaiter(void 0, void 0, v
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
exports.generateRpk = generateRpk;
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=generateRpk.js.map
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ts2wasm = exports.wasmPackageName = void 0;
|
|
16
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
16
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
18
17
|
const child_process_1 = require("child_process");
|
|
19
18
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
@@ -38,22 +37,14 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
|
|
|
38
37
|
function compile() {
|
|
39
38
|
// TODO: 后续修改为 @mi
|
|
40
39
|
const ts2wasmpath = path_1.default.resolve(projectPath, 'node_modules', 'mi/wasmnizer-ts');
|
|
41
|
-
ColorConsole_1.default.
|
|
42
|
-
level: shared_utils_1.LOG_LEVEL.Info,
|
|
43
|
-
message: 'Waiting for generating app.wasm file.'
|
|
44
|
-
});
|
|
40
|
+
ColorConsole_1.default.info('### Waiting for generating app.wasm file.');
|
|
45
41
|
const res = (0, child_process_1.execSync)(`node ${ts2wasmpath}/build/cli/ts2wasm.js ${entryFile} -o ${wasmDir}/app.wasm`, {
|
|
46
42
|
encoding: 'utf-8'
|
|
47
43
|
});
|
|
48
|
-
ColorConsole_1.default.
|
|
49
|
-
level: shared_utils_1.LOG_LEVEL.Info,
|
|
50
|
-
message: res
|
|
51
|
-
});
|
|
44
|
+
ColorConsole_1.default.info(`### ts2wasm ### ${res.toString()}`);
|
|
52
45
|
}
|
|
53
46
|
if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
|
|
54
|
-
ColorConsole_1.default.
|
|
55
|
-
message: `skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`
|
|
56
|
-
});
|
|
47
|
+
ColorConsole_1.default.info(`### skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`);
|
|
57
48
|
}
|
|
58
49
|
else {
|
|
59
50
|
compile();
|
|
@@ -76,5 +67,3 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
|
|
|
76
67
|
fs_1.default.copyFileSync(path_1.default.resolve(fast_glob_1.default.convertPathToPattern(projectPath), output, 'app', 'manifest.json'), path_1.default.resolve(fast_glob_1.default.convertPathToPattern(projectPath), exports.wasmPackageName, 'manifest.json'));
|
|
77
68
|
});
|
|
78
69
|
exports.ts2wasm = ts2wasm;
|
|
79
|
-
|
|
80
|
-
//# sourceMappingURL=ts2wasm.js.map
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.skipList = void 0;
|
|
4
|
-
exports.skipList = ['install', 'ts2wasm', 'package'];
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=ICompileOptions.js.map
|
|
4
|
+
exports.skipList = ['xts2ts', 'install', 'ts2wasm', 'package'];
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
2
3
|
/**
|
|
3
4
|
* 处理app.ux的Loader
|
|
4
5
|
* AppUxLoader
|
|
5
6
|
*/
|
|
6
7
|
declare class AppUxLoader implements ILoader {
|
|
7
8
|
context: IFileLaneContext;
|
|
9
|
+
compilerOption: IJavascriptCompileOption;
|
|
8
10
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
9
11
|
}
|
|
10
12
|
export default AppUxLoader;
|
|
@@ -21,11 +21,9 @@ class AppUxLoader {
|
|
|
21
21
|
parser(files) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const resultFiles = [];
|
|
24
|
-
yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], resultFiles, this.context);
|
|
24
|
+
yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], resultFiles, this.context, this.compilerOption);
|
|
25
25
|
return resultFiles;
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.default = AppUxLoader;
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=AppUxLoader.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
/**
|
|
3
|
+
* JsLoader
|
|
4
|
+
*/
|
|
5
|
+
declare class JsLoader implements ILoader {
|
|
6
|
+
context: IFileLaneContext;
|
|
7
|
+
parser(files: IFileParam<any>[]): IFileParam<any>[] | Promise<IFileParam<any>[]>;
|
|
8
|
+
}
|
|
9
|
+
export default JsLoader;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 ParserUtil_1 = __importDefault(require("@aiot-toolkit/parser/lib/utils/ParserUtil"));
|
|
7
|
+
const ScriptParser_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/parser/ScriptParser"));
|
|
8
|
+
const ScriptToTypescript_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/ScriptToTypescript"));
|
|
9
|
+
/**
|
|
10
|
+
* JsLoader
|
|
11
|
+
*/
|
|
12
|
+
class JsLoader {
|
|
13
|
+
parser(files) {
|
|
14
|
+
const project = ParserUtil_1.default.createProject();
|
|
15
|
+
const onLog = () => { };
|
|
16
|
+
return files.map((item) => {
|
|
17
|
+
if (!item.content) {
|
|
18
|
+
return {
|
|
19
|
+
path: item.path,
|
|
20
|
+
content: item.content
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const options = {
|
|
24
|
+
filePath: item.path,
|
|
25
|
+
projectPath: this.context.projectPath,
|
|
26
|
+
onLog
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
path: item.path,
|
|
30
|
+
content: new ScriptToTypescript_1.default(project, options)
|
|
31
|
+
.translate({
|
|
32
|
+
content: new ScriptParser_1.default(options).parser(item.content.toString()).ast.content
|
|
33
|
+
}, [])
|
|
34
|
+
.targetTree.getFullText()
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = JsLoader;
|
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
15
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
17
16
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
18
17
|
const path_1 = __importDefault(require("path"));
|
|
@@ -31,10 +30,7 @@ class PngLoader {
|
|
|
31
30
|
const fullName = `${name}${ext}`;
|
|
32
31
|
//判断文本,空文本则结束该文件处理
|
|
33
32
|
if (!content) {
|
|
34
|
-
ColorConsole_1.default.
|
|
35
|
-
level: shared_utils_1.LOG_LEVEL.Warn,
|
|
36
|
-
message: `【XtsLoader】the file '${fullName}' under the path '${filePath}' has no content `
|
|
37
|
-
});
|
|
33
|
+
ColorConsole_1.default.warn(`The file '${fullName}' under the path '${filePath}' has no content `);
|
|
38
34
|
return [];
|
|
39
35
|
}
|
|
40
36
|
// 判断传入的.png资源是不是.9.png资源
|
|
@@ -58,13 +54,12 @@ class PngLoader {
|
|
|
58
54
|
yield aaptjs.singleCrunch(filePath, outputFile);
|
|
59
55
|
}
|
|
60
56
|
catch (error) {
|
|
61
|
-
|
|
62
|
-
console.error('.9.png资源文件优化失败', error);
|
|
57
|
+
ColorConsole_1.default.throw(`.9.png resource file processing failed`);
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
60
|
});
|
|
66
61
|
}
|
|
67
62
|
}
|
|
63
|
+
;
|
|
64
|
+
PngLoader.raw = true;
|
|
68
65
|
exports.default = PngLoader;
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=PngLoader.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
2
3
|
declare class UxLoader implements ILoader {
|
|
3
4
|
context: IFileLaneContext;
|
|
5
|
+
compilerOption: IJavascriptCompileOption;
|
|
4
6
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
5
7
|
}
|
|
6
8
|
export default UxLoader;
|
|
@@ -12,20 +12,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
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 path_1 = __importDefault(require("path"));
|
|
15
18
|
const UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"));
|
|
16
19
|
class UxLoader {
|
|
17
20
|
parser(files) {
|
|
18
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
22
|
const resultFiles = [];
|
|
23
|
+
const { projectPath } = this.context;
|
|
20
24
|
for (const file of files) {
|
|
21
25
|
// 转换每个文件
|
|
22
|
-
const
|
|
23
|
-
|
|
26
|
+
const { files, logs } = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
|
|
27
|
+
if (logs) {
|
|
28
|
+
logs.forEach((item) => {
|
|
29
|
+
ColorConsole_1.default.logger(Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' }));
|
|
30
|
+
});
|
|
31
|
+
// 如果有 error throw,则停止
|
|
32
|
+
if (logs.some((item) => item.level && [shared_utils_1.LOG_LEVEL.Throw].includes(item.level))) {
|
|
33
|
+
throw new Error('stop!');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
resultFiles.push(...files);
|
|
24
37
|
}
|
|
25
38
|
return resultFiles;
|
|
26
39
|
});
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
exports.default = UxLoader;
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=UxLoader.js.map
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const generator_1 = require("@aiot-toolkit/generator");
|
|
7
7
|
const parser_1 = require("@aiot-toolkit/parser");
|
|
8
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
9
8
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
10
9
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
11
10
|
const path_1 = __importDefault(require("path"));
|
|
@@ -24,14 +23,11 @@ class XtsLoader {
|
|
|
24
23
|
const newFileName = `${name}.ts`;
|
|
25
24
|
//判断文本,空文本则结束该文件处理
|
|
26
25
|
if (!content) {
|
|
27
|
-
ColorConsole_1.default.
|
|
28
|
-
level: shared_utils_1.LOG_LEVEL.Warn,
|
|
29
|
-
message: `【XtsLoader】the file '${fullName}' under the path '${path}' has no content `
|
|
30
|
-
});
|
|
26
|
+
ColorConsole_1.default.warn(`The file '${fullName}' under the path '${path}' has no content `);
|
|
31
27
|
return [];
|
|
32
28
|
}
|
|
33
|
-
const parserResult = new parser_1.XtsParser(project, ColorConsole_1.default.
|
|
34
|
-
const { ast, mapList } = new parser_1.XtsToTypescript(project, ColorConsole_1.default.
|
|
29
|
+
const parserResult = new parser_1.XtsParser(project, ColorConsole_1.default.logger).parser(content.toString(), fullName);
|
|
30
|
+
const { ast, mapList } = new parser_1.XtsToTypescript(project, ColorConsole_1.default.logger, this.context, path).translate(parserResult.ast, parserResult.offsetList);
|
|
35
31
|
const { code, sourcemap } = new generator_1.TypescriptGenerator().generate({
|
|
36
32
|
sourceFilePath: fullName,
|
|
37
33
|
targetFilePath: newFileName,
|
|
@@ -51,5 +47,3 @@ class XtsLoader {
|
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
exports.default = XtsLoader;
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=XtsLoader.js.map
|
|
@@ -20,16 +20,14 @@ const path_1 = __importDefault(require("path"));
|
|
|
20
20
|
const preInstall = (context, _, __, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
var _a;
|
|
22
22
|
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('install')) {
|
|
23
|
-
ColorConsole_1.default.
|
|
24
|
-
message: `skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`
|
|
25
|
-
});
|
|
23
|
+
ColorConsole_1.default.info(`### skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
26
|
const { projectPath } = context;
|
|
29
27
|
const packagePath = path_1.default.resolve(projectPath, 'package.json');
|
|
30
28
|
const preContent = {
|
|
31
29
|
dependencies: {
|
|
32
|
-
'@mi/ts-framework': 'https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@mi/ts-framework/-/@mi/ts-framework-1.0.
|
|
30
|
+
'@mi/ts-framework': 'https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@mi/ts-framework/-/@mi/ts-framework-1.0.9.tgz',
|
|
33
31
|
'@mi/wasmnizer-ts': 'https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@mi/wasmnizer-ts/-/@mi/wasmnizer-ts-0.0.12.tgz'
|
|
34
32
|
}
|
|
35
33
|
};
|
|
@@ -49,18 +47,12 @@ const preInstall = (context, _, __, compilerOption) => __awaiter(void 0, void 0,
|
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
ColorConsole_1.default.
|
|
53
|
-
message: 'Installing pre-dependencies. The initial build may take some time, please be patient...'
|
|
54
|
-
});
|
|
50
|
+
ColorConsole_1.default.info('### Installing pre-dependencies. The initial build may take some time, please be patient...');
|
|
55
51
|
(0, child_process_1.execSync)('npm install', {
|
|
56
52
|
cwd: projectPath
|
|
57
53
|
});
|
|
58
54
|
// 目前ts2wasm不支持@符号
|
|
59
55
|
fs_1.default.renameSync(path_1.default.resolve(projectPath, 'node_modules/@mi'), path_1.default.resolve(projectPath, 'node_modules/mi'));
|
|
60
|
-
ColorConsole_1.default.
|
|
61
|
-
message: 'Dependencies installation complete.'
|
|
62
|
-
});
|
|
56
|
+
ColorConsole_1.default.info('### Dependencies installation complete.');
|
|
63
57
|
});
|
|
64
58
|
exports.preInstall = preInstall;
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=preInstall.js.map
|
package/lib/utils/PngUtils.js
CHANGED
|
@@ -13,5 +13,10 @@ declare class PreWorkUtils {
|
|
|
13
13
|
*/
|
|
14
14
|
static getEntries(context: IFileLaneContext): Promise<void>;
|
|
15
15
|
static clean: PreWork<IJavascriptCompileOption>;
|
|
16
|
+
/**
|
|
17
|
+
* 获取项目的全局样式变量配置
|
|
18
|
+
* @param context
|
|
19
|
+
*/
|
|
20
|
+
static getGlobalVar(context: IFileLaneContext): Promise<void>;
|
|
16
21
|
}
|
|
17
22
|
export default PreWorkUtils;
|