@aiot-toolkit/emulator 2.0.3-beta.1 → 2.0.3-beta.11
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 +133 -8
- package/lib/emulatorutil/EmulatorLog.js +22 -18
- package/lib/emulatorutil/constants.d.ts +18 -5
- package/lib/emulatorutil/constants.js +94 -53
- package/lib/emulatorutil/index.d.ts +3 -2
- package/lib/emulatorutil/index.js +38 -8
- package/lib/emulatorutil/running.d.ts +24 -0
- package/lib/emulatorutil/running.js +108 -0
- package/lib/emulatorutil/skinLayoutParser.d.ts +14 -0
- package/lib/emulatorutil/skinLayoutParser.js +111 -0
- package/lib/index.d.ts +5 -5
- package/lib/index.js +76 -26
- package/lib/instance/common.d.ts +39 -39
- package/lib/instance/common.js +151 -221
- package/lib/instance/dev.d.ts +7 -42
- package/lib/instance/dev.js +53 -235
- package/lib/instance/index.d.ts +6 -5
- package/lib/instance/index.js +51 -35
- package/lib/instance/miwear.d.ts +14 -75
- package/lib/instance/miwear.js +92 -370
- package/lib/instance/pre.d.ts +11 -3
- package/lib/instance/pre.js +54 -93
- package/lib/instance/pre5.d.ts +11 -0
- package/lib/instance/pre5.js +37 -0
- package/lib/static/avdConfigIni.json +5 -5
- package/lib/typing/Instance.d.ts +32 -15
- package/lib/typing/Instance.js +13 -6
- package/lib/typing/Vvd.d.ts +105 -0
- package/lib/typing/Vvd.js +31 -0
- package/lib/utils/file.d.ts +0 -0
- package/lib/utils/file.js +1 -0
- package/lib/utils/index.js +86 -100
- package/lib/vvd/index.d.ts +107 -0
- package/lib/vvd/index.js +715 -0
- package/lib/vvd/logcat.d.ts +16 -0
- package/lib/vvd/logcat.js +67 -0
- package/package.json +9 -8
- package/lib/avd/index.d.ts +0 -28
- package/lib/avd/index.js +0 -173
- package/lib/emulatorutil/EmulatorCmd.d.ts +0 -9
- package/lib/emulatorutil/EmulatorCmd.js +0 -226
- package/lib/instance/preDev.d.ts +0 -53
- package/lib/instance/preDev.js +0 -249
- package/lib/typing/Avd.d.ts +0 -23
- package/lib/typing/Avd.js +0 -8
package/lib/instance/common.js
CHANGED
|
@@ -1,230 +1,160 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
17
5
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
43
|
-
const os_1 = __importDefault(require("os"));
|
|
44
|
-
const path_1 = __importDefault(require("path"));
|
|
45
|
-
const ws_1 = require("ws");
|
|
46
|
-
const avd_1 = __importDefault(require("../avd"));
|
|
47
|
-
const constants_1 = require("../emulatorutil/constants");
|
|
48
|
-
const utils_1 = require("../utils");
|
|
49
|
-
/**
|
|
50
|
-
* CommonInstance
|
|
51
|
-
*/
|
|
52
|
-
class CommonInstance {
|
|
53
|
-
constructor(params) {
|
|
54
|
-
this.quickappStartedFlag = /Start App loop/;
|
|
55
|
-
this.isFirstStart = true;
|
|
56
|
-
this.isDistributedApp = false;
|
|
57
|
-
this.projectPath = params.projectPath;
|
|
58
|
-
this.sdkHome = params.sdkHome || constants_1.defaultSDKHome;
|
|
59
|
-
this.avdHome = params.avdHome || constants_1.defaultAvdHome;
|
|
60
|
-
this.isRpk = params.sourceRoot === './';
|
|
61
|
-
const projectJsonFile = path_1.default.resolve(this.projectPath, '.project.json');
|
|
62
|
-
const projectJsonExist = fs_extra_1.default.existsSync(projectJsonFile);
|
|
63
|
-
if (projectJsonExist) {
|
|
64
|
-
const projectJsonInfo = fs_extra_1.default.readJSONSync(projectJsonFile);
|
|
65
|
-
this.isDistributedApp = projectJsonInfo.projectType === 'distributed';
|
|
66
|
-
}
|
|
67
|
-
this.velaAvdCls = new avd_1.default({
|
|
68
|
-
sdkHome: this.sdkHome,
|
|
69
|
-
avdHome: this.avdHome
|
|
70
|
-
});
|
|
71
|
-
this.projectInfo = UxFileUtils_1.default.getMainfestInfo(this.projectPath, params.sourceRoot);
|
|
72
|
-
}
|
|
73
|
-
/** 获取模拟器二进制文件所在位置 */
|
|
74
|
-
getEmulatorBinPath() {
|
|
75
|
-
const osPlatform = os_1.default.platform();
|
|
76
|
-
const arch = (0, utils_1.getSystemArch)();
|
|
77
|
-
const platform = osPlatform === 'win32' ? 'windows' : osPlatform;
|
|
78
|
-
const emulatorHome = path_1.default.resolve(this.sdkHome, 'emulator');
|
|
79
|
-
return path_1.default.resolve(emulatorHome, `${platform}-${arch}`, 'emulator');
|
|
80
|
-
}
|
|
81
|
-
/** 在goldfish模拟器中运行快应用 */
|
|
82
|
-
start(options) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
throw new Error(`start method not implemented, ${options}`);
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ColorConsole = _interopRequireDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
8
|
+
var _ILog = require("@aiot-toolkit/shared-utils/lib/interface/ILog");
|
|
9
|
+
var adbMiwt = _interopRequireWildcard(require("@miwt/adb"));
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _logcat = require("../vvd/logcat");
|
|
12
|
+
var _emulatorutil = require("../emulatorutil");
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
class CommonEmulatorInstance {
|
|
17
|
+
appDir = '/data/quickapp/app';
|
|
18
|
+
quickappStartedFlag = /Start App loop/;
|
|
19
|
+
constructor(params) {
|
|
20
|
+
this.sn = `emulator-${params.serialPort}`;
|
|
21
|
+
this.vvdName = params.vvdName;
|
|
22
|
+
this.onStdout = params.onStdout || console.log;
|
|
23
|
+
this.onErrout = params.onErrout || console.error;
|
|
24
|
+
this.debugPort = params.debugPort || (0, _emulatorutil.getRunningVvdDebugPort)(this.vvdName);
|
|
25
|
+
if (params.customLogger) {
|
|
26
|
+
this.logger = msg => {
|
|
27
|
+
const prefix = _ColorConsole.default.createDefaultPrefix({
|
|
28
|
+
level: _ILog.Loglevel.INFO,
|
|
29
|
+
message: msg
|
|
85
30
|
});
|
|
31
|
+
params.customLogger(`${prefix[1]} ${msg?.trim()}`);
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
this.logger = _ColorConsole.default.info;
|
|
86
35
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
36
|
+
if (params.logcatProcess) {
|
|
37
|
+
this.logcatProcess = params.logcatProcess;
|
|
38
|
+
if (!params.stdoutReadline || !params.stderrReadline) {
|
|
39
|
+
const readlines = (0, _logcat.attachReadline)(params.logcatProcess, this.onStdout, this.onErrout);
|
|
40
|
+
params.stdoutReadline = readlines.stdoutReadline;
|
|
41
|
+
params.stderrReadline = readlines.stderrReadline;
|
|
42
|
+
params.dispose = readlines.dispose;
|
|
43
|
+
}
|
|
44
|
+
this.stdoutReadline = params.stdoutReadline;
|
|
45
|
+
this.stderrReadline = params.stderrReadline;
|
|
46
|
+
this.disposeReadlines = params.dispose;
|
|
47
|
+
} else {
|
|
48
|
+
const r = (0, _logcat.creatLogcat)(this.sn, this.onStdout, this.onErrout);
|
|
49
|
+
this.logcatProcess = r.logcatProcess;
|
|
50
|
+
this.stdoutReadline = r.stdoutReadline;
|
|
51
|
+
this.stderrReadline = r.stderrReadline;
|
|
52
|
+
this.disposeReadlines = r.dispose;
|
|
99
53
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 推送指定文件 */
|
|
57
|
+
async push(sourcePath, targetPath) {
|
|
58
|
+
// 1. adb push应用的rpk
|
|
59
|
+
const pushCmd = `adb -s ${this.sn} push "${sourcePath}" ${targetPath}`;
|
|
60
|
+
this.logger(`Excuting: ${pushCmd}`);
|
|
61
|
+
const res = await adbMiwt.execAdbCmdAsync(pushCmd);
|
|
62
|
+
this.logger(`Push result: ${res}`);
|
|
63
|
+
return targetPath;
|
|
64
|
+
}
|
|
65
|
+
async unzip(zipPath, targetPath) {
|
|
66
|
+
const unzipCmd = `adb -s ${this.sn} shell unzip -o ${zipPath} -d ${targetPath}`;
|
|
67
|
+
this.logger(`Excuting: ${unzipCmd}`);
|
|
68
|
+
const res = await adbMiwt.execAdbCmdAsync(unzipCmd);
|
|
69
|
+
this.logger(`Unzip result: ${res}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 推送指定 rpk */
|
|
73
|
+
async pushRpk(rpkPath, appPackageName) {
|
|
74
|
+
// 1. adb push应用的rpk
|
|
75
|
+
const targetPath = `${this.appDir}/${appPackageName}.rpk`;
|
|
76
|
+
const pushCmd = `adb -s ${this.sn} push "${rpkPath}" ${targetPath}`;
|
|
77
|
+
this.logger(`Excuting: ${pushCmd}`);
|
|
78
|
+
const res = await adbMiwt.execAdbCmdAsync(pushCmd);
|
|
79
|
+
this.logger(`Push ${this.vvdName} rpk result: ${res}`);
|
|
80
|
+
return targetPath;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 判断模拟器是否 ready
|
|
85
|
+
*/
|
|
86
|
+
async isConnected() {
|
|
87
|
+
return (0, _utils.tryRun)(async () => {
|
|
88
|
+
const devices = await adbMiwt.getAdbDevices();
|
|
89
|
+
_ColorConsole.default.log(`adb devices: ${JSON.stringify(devices)}`);
|
|
90
|
+
const curDev = devices.find(t => t.sn === this.sn);
|
|
91
|
+
return curDev?.status === 'device';
|
|
92
|
+
}, 10, 500);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 安装应用,留给子类实现 */
|
|
96
|
+
async install(rpkPath, packageName) {}
|
|
97
|
+
|
|
98
|
+
/** 卸载应用,留给子类实现 */
|
|
99
|
+
async uninstall(packageName) {}
|
|
100
|
+
|
|
101
|
+
/** 启动应用,留给子类实现 */
|
|
102
|
+
async startApp(packageName) {
|
|
103
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
104
|
+
}
|
|
105
|
+
async pushAndInstall(rpkPath, appName) {
|
|
106
|
+
const targetPath = await this.pushRpk(rpkPath, appName);
|
|
107
|
+
await this.install(targetPath, appName);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** 重启应用 */
|
|
111
|
+
async reloadApp(appName) {
|
|
112
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** 关闭应用 */
|
|
116
|
+
async closeApp(appName) {}
|
|
117
|
+
|
|
118
|
+
/** 关闭模拟器 */
|
|
119
|
+
poweroff() {
|
|
120
|
+
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10 * 1000;
|
|
121
|
+
return new Promise((resolve, reject) => {
|
|
122
|
+
const t = setTimeout(() => {
|
|
123
|
+
(0, _utils.killProcessByCmd)(this.vvdName).then(resolve).catch(e => {
|
|
124
|
+
reject(`poweroff ${this.vvdName} failed ${e}`);
|
|
142
125
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
process.kill(currProcess.pid);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
currProcess.kill();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
ColorConsole_1.default.log(`### Emulator ### kill process get error :\n${err.stack}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/** 停止模拟器并释放相关资源 */
|
|
165
|
-
stop() {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
adbMiwt.execAdbCmdSync(`adb -s ${this.sn} shell poweroff`);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
/** 重启模拟器 */
|
|
171
|
-
restart() {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
yield this.stop();
|
|
174
|
-
this.start(this.startOptions);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/** 创建server */
|
|
178
|
-
createWebsockeServer() {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
var _a;
|
|
181
|
-
const wsServer = new ws_1.WebSocketServer({
|
|
182
|
-
port: (_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.serverPort
|
|
183
|
-
});
|
|
184
|
-
wsServer.on('connection', (socket) => {
|
|
185
|
-
ColorConsole_1.default.success(`### App Socket server ### Websocket connects to websocket server`);
|
|
186
|
-
socket.on('error', (err) => {
|
|
187
|
-
ColorConsole_1.default.error(`### App Socket server ### Websocket server error: ${err.message}`);
|
|
188
|
-
});
|
|
189
|
-
socket.on('message', (data) => {
|
|
190
|
-
const message = JSON.parse(data.toString());
|
|
191
|
-
ColorConsole_1.default.log(`### App Socket server ### Websocket server get data: ${data}`);
|
|
192
|
-
if (message.type === 'restart') {
|
|
193
|
-
this.restart();
|
|
194
|
-
}
|
|
195
|
-
else if (message.type === 'stop') {
|
|
196
|
-
this.stop();
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
connectDevice() {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
const adbConnectCmd = `adb connect ${this.sn}`;
|
|
205
|
-
ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbConnectCmd}`);
|
|
206
|
-
let pending = true;
|
|
207
|
-
const p1 = adbMiwt.execAdbCmdAsync(adbConnectCmd);
|
|
208
|
-
let timer;
|
|
209
|
-
// 超过一定时间还没有连接成功,则 kill-server 后再试
|
|
210
|
-
// 用于处理 adb connect 一直 pending 的情况
|
|
211
|
-
const p2 = new Promise((resolve) => {
|
|
212
|
-
timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
if (pending) {
|
|
214
|
-
const adbKillCmd = `adb kill-server`;
|
|
215
|
-
ColorConsole_1.default.log(`### Emulator ### Excuting adb cmd: ${adbKillCmd}`);
|
|
216
|
-
yield adbMiwt.execAdbCmdAsync(adbKillCmd);
|
|
217
|
-
}
|
|
218
|
-
resolve();
|
|
219
|
-
}), 10 * 1000);
|
|
220
|
-
});
|
|
221
|
-
p1.then((r) => {
|
|
222
|
-
pending = false;
|
|
223
|
-
clearTimeout(timer);
|
|
224
|
-
console.log(r);
|
|
225
|
-
});
|
|
226
|
-
return Promise.race([p1, p2]);
|
|
126
|
+
}, timeout);
|
|
127
|
+
adbMiwt.execAdbCmdAsync(`adb -s ${this.sn} shell poweroff`).then(() => {
|
|
128
|
+
clearTimeout(t);
|
|
129
|
+
resolve();
|
|
130
|
+
}).catch(() => {
|
|
131
|
+
(0, _utils.killProcessByCmd)(this.vvdName).then(() => {
|
|
132
|
+
clearTimeout(t);
|
|
133
|
+
resolve();
|
|
134
|
+
}).catch(e => {
|
|
135
|
+
reject(`poweroff ${this.vvdName} failed ${e}`);
|
|
227
136
|
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
systemed() {
|
|
141
|
+
return adbMiwt.execAdbCmdAsync(`adb -s ${this.sn} shell systemd &`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** 重启模拟器 */
|
|
145
|
+
async reboot() {
|
|
146
|
+
const rebootCmd = `adb -s ${this.sn} shell reboot`;
|
|
147
|
+
_ColorConsole.default.log(`Excuting: ${rebootCmd}`);
|
|
148
|
+
await adbMiwt.execAdbCmdAsync(rebootCmd);
|
|
149
|
+
await this.isConnected();
|
|
150
|
+
if (!this.logcatProcess.exitCode !== undefined) {
|
|
151
|
+
// 如果 logcat 进程被杀死,则重新创建
|
|
152
|
+
const r = (0, _logcat.creatLogcat)(this.sn, this.onStdout, this.onErrout);
|
|
153
|
+
this.logcatProcess = r.logcatProcess;
|
|
154
|
+
this.stdoutReadline = r.stdoutReadline;
|
|
155
|
+
this.stderrReadline = r.stderrReadline;
|
|
156
|
+
this.disposeReadlines = r.dispose;
|
|
228
157
|
}
|
|
158
|
+
}
|
|
229
159
|
}
|
|
230
|
-
exports.default =
|
|
160
|
+
var _default = exports.default = CommonEmulatorInstance;
|
package/lib/instance/dev.d.ts
CHANGED
|
@@ -1,51 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import CommonEmulatorInstance from './common';
|
|
2
|
+
import { VelaImageType } from '../typing/Vvd';
|
|
3
|
+
declare class GoldfishInstance extends CommonEmulatorInstance {
|
|
4
|
+
imageType: VelaImageType;
|
|
5
5
|
appDir: string;
|
|
6
6
|
emulatorStartedFlag: string;
|
|
7
|
-
|
|
8
|
-
stderrReadline: readline.Interface;
|
|
9
|
-
constructor(params: INewGoldfishInstanceParams);
|
|
10
|
-
/**
|
|
11
|
-
* 1. 启动模拟器
|
|
12
|
-
* 2. 启动成功后,adb连接模拟器
|
|
13
|
-
* 3. 连接成功后,在模拟器中启动快应用
|
|
14
|
-
*/
|
|
15
|
-
start(options: IStartOptions): Promise<void>;
|
|
7
|
+
install(rpkPath: string, appPackageName?: string): Promise<void>;
|
|
16
8
|
/**
|
|
17
9
|
* 在模拟器中启动快应用
|
|
18
10
|
* 通过vapp命令启动,调试时需额外配置--jsdebugger参数
|
|
19
11
|
* @param options
|
|
20
12
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* 启动模拟器
|
|
24
|
-
* 1. 通过options生成模拟器的启动命令
|
|
25
|
-
* 2. 执行启动命令
|
|
26
|
-
* 3. 判断模拟器是否启动成功
|
|
27
|
-
* 3.1 若disableNSH=true,输出流中匹配到(NSH),认为模拟器启动成功了
|
|
28
|
-
* 3.2 若disableNSH=false,认为2s过后模拟器启动成功了
|
|
29
|
-
* @param options
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
startGoldfish(options: IStartOptions): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* 将目录通过adb push到模拟器中
|
|
35
|
-
*/
|
|
36
|
-
pushAndInstall(rpkPath?: string): Promise<void>;
|
|
37
|
-
/** 通过命令行启动时,在watich模式下监听websocket消息,
|
|
38
|
-
* 在文件发生变动时,重新启动应用
|
|
39
|
-
*/
|
|
40
|
-
restart(): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* 重新推送,然后重启应用
|
|
43
|
-
*/
|
|
44
|
-
pushAndReloadApp(): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* 重启应用
|
|
47
|
-
*/
|
|
48
|
-
reloadApp(): Promise<void>;
|
|
49
|
-
reboot(): Promise<boolean>;
|
|
13
|
+
startApp(packageName: string, debug?: boolean): Promise<void>;
|
|
14
|
+
reloadApp(appName: string, debug?: boolean): Promise<void>;
|
|
50
15
|
}
|
|
51
16
|
export default GoldfishInstance;
|