aiot-toolkit 2.0.2-dev.7 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/bin.js +43 -46
  2. package/lib/builder/AndroidUxBuilder.d.ts +10 -0
  3. package/lib/builder/AndroidUxBuilder.js +20 -0
  4. package/lib/builder/UxBuilderBase.d.ts +36 -0
  5. package/lib/builder/UxBuilderBase.js +105 -0
  6. package/lib/builder/VelaUxBuilder.d.ts +23 -0
  7. package/lib/builder/VelaUxBuilder.js +66 -0
  8. package/lib/builder/XtsBuilder.js +14 -17
  9. package/lib/interface/VelaEmulatorInterface.d.ts +7 -6
  10. package/lib/starter/AndroidUxStart.d.ts +40 -0
  11. package/lib/starter/AndroidUxStart.js +171 -0
  12. package/lib/starter/IStarter.d.ts +2 -1
  13. package/lib/starter/IStarter.js +5 -1
  14. package/lib/starter/VelaUxStarter.d.ts +23 -0
  15. package/lib/starter/VelaUxStarter.js +198 -0
  16. package/lib/starter/XtsStarter.d.ts +2 -2
  17. package/lib/starter/androidRouter/LinkMode.d.ts +9 -0
  18. package/lib/starter/androidRouter/LinkMode.js +12 -0
  19. package/lib/starter/androidRouter/PackageRouter.d.ts +55 -0
  20. package/lib/starter/androidRouter/PackageRouter.js +152 -0
  21. package/lib/starter/androidRouter/h5/index.css +167 -0
  22. package/lib/starter/androidRouter/h5/index.html +58 -0
  23. package/lib/starter/androidRouter/h5/index.js +66 -0
  24. package/lib/utils/AdbUtils.d.ts +0 -1
  25. package/lib/utils/AdbUtils.js +3 -14
  26. package/lib/utils/DeviceUtil.js +42 -29
  27. package/lib/utils/RequestUtils.js +5 -5
  28. package/lib/utils/VelaAvdUtils.d.ts +25 -9
  29. package/lib/utils/VelaAvdUtils.js +262 -100
  30. package/package.json +20 -12
  31. package/lib/builder/UxBuilder.d.ts +0 -27
  32. package/lib/builder/UxBuilder.js +0 -128
  33. package/lib/starter/UxStarter.d.ts +0 -10
  34. package/lib/starter/UxStarter.js +0 -139
  35. package/lib/utils/UxBuilderUtils.d.ts +0 -8
  36. package/lib/utils/UxBuilderUtils.js +0 -51
@@ -1,128 +0,0 @@
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 __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const CompileMode_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode"));
27
- const JavascriptDefaultCompileOption_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption"));
28
- const UxConfig_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/config/UxConfig"));
29
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
30
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
31
- const file_lane_1 = require("file-lane");
32
- const fs_extra_1 = __importDefault(require("fs-extra"));
33
- const lodash_1 = __importDefault(require("lodash"));
34
- const path_1 = __importDefault(require("path"));
35
- const UxBuilderUtils_1 = __importDefault(require("../utils/UxBuilderUtils"));
36
- /**
37
- * UxBuilder
38
- */
39
- class UxBuilder {
40
- constructor() {
41
- this.QUICKAPP_CONFIG = 'quickapp.config.js';
42
- this.params = [
43
- {
44
- name: 'enable-e2e',
45
- description: 'inject test-suite for current project'
46
- },
47
- {
48
- type: 'string',
49
- name: 'devtool',
50
- description: 'source map config'
51
- },
52
- {
53
- name: 'disable-subpackages',
54
- description: 'disable subpackages'
55
- },
56
- {
57
- type: 'confirm',
58
- name: 'disabled-jsc',
59
- description: 'disabled jsc bundle',
60
- defaultValue: false
61
- },
62
- {
63
- name: 'enable-protobuf',
64
- description: 'enable protobuf',
65
- type: 'confirm',
66
- defaultValue: false
67
- }
68
- ];
69
- }
70
- /**
71
- * ux项目的build函数
72
- * @param projectPath 项目路径
73
- * @param options 命令参数
74
- * @param watch 是否开启监听
75
- */
76
- build(projectPath, options) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- const watch = options.watch || false;
79
- // 读取项目中文件的配置
80
- const quickappConfig = this.readQuickAppConfig(projectPath);
81
- const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
82
- options = lodash_1.default.merge({}, options, cli);
83
- // 项目配置
84
- const uxProjectConfig = new UxConfig_1.default(projectPath);
85
- // 编译配置
86
- const compileMode = options.mode || CompileMode_1.default.DEVELOPMENT;
87
- const compilerOption = lodash_1.default.merge({
88
- projectPath: path_1.default.join(projectPath, uxProjectConfig.output),
89
- mode: compileMode,
90
- disabledJSC: options.disabledJsc,
91
- enableProtobuf: options.enableProtobuf,
92
- devtool: UxBuilderUtils_1.default.getDevtoolValue(compileMode, options.devtool)
93
- }, JavascriptDefaultCompileOption_1.default, otherConfig);
94
- ColorConsole_1.default.info('start build: ', {
95
- style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Info),
96
- word: JSON.stringify({
97
- projectPath,
98
- options,
99
- watch,
100
- node: process.version,
101
- platform: process.platform,
102
- arch: process.arch,
103
- toolkit: require('../../package.json').version
104
- }, null, 2)
105
- });
106
- // 开始编译项目
107
- yield new file_lane_1.FileLane(uxProjectConfig, projectPath, compilerOption).start({ watch });
108
- });
109
- }
110
- readQuickAppConfig(projectPath) {
111
- const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
112
- if (fs_extra_1.default.existsSync(path)) {
113
- try {
114
- const data = require(path);
115
- return data;
116
- }
117
- catch (error) {
118
- ColorConsole_1.default.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
119
- }
120
- }
121
- return;
122
- }
123
- match(projectPath) {
124
- return projectPath.includes('ux');
125
- }
126
- }
127
- UxBuilder.PROJECT_TYPE = 'ux quick app';
128
- exports.default = UxBuilder;
@@ -1,10 +0,0 @@
1
- import ParamType from '@aiot-toolkit/commander/lib/interface/IParam';
2
- import { IStartOptions } from '@aiot-toolkit/emulator';
3
- import UxBuilder from '../builder/UxBuilder';
4
- import IStarter from './IStarter';
5
- declare class UxStarter extends IStarter<IStartOptions> {
6
- builder: UxBuilder;
7
- params: ParamType[];
8
- start(projectPath: string, options: any): Promise<void>;
9
- }
10
- export default UxStarter;
@@ -1,139 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- const JavascriptDefaultCompileOption_1 = __importStar(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption"));
39
- const emulator_1 = require("@aiot-toolkit/emulator");
40
- const constants_1 = require("@aiot-toolkit/emulator/lib/static/constants");
41
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
42
- const prompts_1 = require("@inquirer/prompts");
43
- const os_1 = __importDefault(require("os"));
44
- const path_1 = __importDefault(require("path"));
45
- const portfinder_1 = __importDefault(require("portfinder"));
46
- const UxBuilder_1 = __importDefault(require("../builder/UxBuilder"));
47
- const VelaAvdUtils_1 = __importDefault(require("../utils/VelaAvdUtils"));
48
- const IStarter_1 = __importDefault(require("./IStarter"));
49
- class UxStarter extends IStarter_1.default {
50
- constructor() {
51
- super(...arguments);
52
- this.builder = new UxBuilder_1.default();
53
- this.params = [
54
- {
55
- name: 'disableNSH',
56
- description: 'disable goldfish NSH terminal',
57
- defaultValue: false,
58
- type: 'confirm'
59
- },
60
- {
61
- name: 'watch',
62
- description: 'recompile project while file changes',
63
- defaultValue: false,
64
- type: 'confirm'
65
- },
66
- {
67
- name: 'openVNC',
68
- description: 'open vnc',
69
- defaultValue: false,
70
- type: 'confirm'
71
- },
72
- ...this.builder.params
73
- ];
74
- }
75
- start(projectPath, options) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const avdList = VelaAvdUtils_1.default.velaAvdCls.getVelaAvdList();
78
- if (avdList.length === 0) {
79
- ColorConsole_1.default.error('### goldfish start ### No vela emulator available, please create it first.');
80
- VelaAvdUtils_1.default.createVelaAvdByInquire();
81
- return;
82
- }
83
- const avdName = yield (0, prompts_1.select)({
84
- message: 'name of the avd to start',
85
- choices: avdList.map((item) => {
86
- return { value: item.avdName };
87
- })
88
- });
89
- let serverPort;
90
- // watch模型下开启server
91
- if (options.watch) {
92
- serverPort = yield portfinder_1.default.getPortPromise({
93
- port: JavascriptDefaultCompileOption_1.default.serverPort
94
- });
95
- (0, JavascriptDefaultCompileOption_1.setServerPort)(serverPort);
96
- }
97
- // build
98
- yield this.builder.build(projectPath, options);
99
- // start
100
- const params = {
101
- sdkHome: path_1.default.resolve(os_1.default.homedir(), '.export'),
102
- avdHome: path_1.default.resolve(os_1.default.homedir(), '.android/avd'),
103
- projectPath
104
- };
105
- const goldfishInstance = (0, emulator_1.findInstance)(avdName, params);
106
- if (!goldfishInstance)
107
- return;
108
- let vncPort;
109
- if (options.openVNC) {
110
- vncPort = yield portfinder_1.default.getPortPromise({ port: constants_1.defaultVncPort, stopPort: constants_1.defaultVncPort + 100 });
111
- }
112
- const startOptions = {
113
- avdName,
114
- devtool: options.devtool,
115
- disableNSH: options.disableNSH,
116
- serverPort,
117
- vncPort,
118
- };
119
- goldfishInstance.start(startOptions);
120
- // waiter
121
- // const startWaiter: PersistentCommand = new PersistentCommand({
122
- // description: 'aiot-toolkit start 的常驻命令',
123
- // options: [
124
- // {
125
- // key: '?',
126
- // description: '显示所有命令',
127
- // action() {
128
- // startWaiter.clearLog()
129
- // startWaiter.describe()
130
- // }
131
- // }
132
- // ]
133
- // })
134
- // startWaiter.describe()
135
- // startWaiter.start()
136
- });
137
- }
138
- }
139
- exports.default = UxStarter;
@@ -1,8 +0,0 @@
1
- import CompileMode from '@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode';
2
- /**
3
- * UxBuilderUtils
4
- */
5
- declare class UxBuilderUtils {
6
- static getDevtoolValue(mode: CompileMode, devtool: string): string | boolean;
7
- }
8
- export default UxBuilderUtils;
@@ -1,51 +0,0 @@
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 ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
7
- /**
8
- * UxBuilderUtils
9
- */
10
- class UxBuilderUtils {
11
- static getDevtoolValue(mode, devtool) {
12
- const sourcemaps = {
13
- development: {
14
- default: 'cheap-source-map',
15
- options: [
16
- false,
17
- 'cheap-source-map',
18
- 'cheap-module-source-map',
19
- 'inline-cheap-source-map',
20
- 'inline-cheap-module-source-map',
21
- 'source-map',
22
- 'inline-source-map',
23
- 'hidden-source-map',
24
- 'nosources-source-map'
25
- ]
26
- },
27
- production: {
28
- default: false,
29
- options: [
30
- false,
31
- 'cheap-source-map',
32
- 'cheap-module-source-map',
33
- 'source-map',
34
- 'hidden-source-map',
35
- 'nosources-source-map'
36
- ]
37
- }
38
- };
39
- const sourcemapArr = sourcemaps[mode].options;
40
- const defaultSourcemap = sourcemaps[mode].default;
41
- if (typeof devtool !== 'string' && typeof devtool !== 'boolean') {
42
- return defaultSourcemap;
43
- }
44
- if (sourcemapArr.indexOf(devtool) === -1) {
45
- ColorConsole_1.default.warn(`The devtool in ${mode} mode does not support '${devtool}', change to default '${defaultSourcemap}'`);
46
- return defaultSourcemap;
47
- }
48
- return devtool;
49
- }
50
- }
51
- exports.default = UxBuilderUtils;