@aiot-toolkit/emulator 2.0.6-beta.15 → 2.0.6-beta.17
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/emulatorutil/running.js +1 -4
- package/lib/emulatorutil/skinLayoutParser.js +0 -2
- package/lib/instance/common.d.ts +1 -0
- package/lib/instance/common.js +7 -7
- package/lib/instance/dev.js +5 -4
- package/lib/instance/minisound.js +1 -1
- package/lib/instance/miwear.js +4 -3
- package/lib/instance/miwear5.js +1 -1
- package/lib/instance/openSmartspeaker5.js +1 -1
- package/lib/instance/pre.js +5 -3
- package/lib/instance/vela5.js +1 -1
- package/lib/utils/index.js +6 -2
- package/lib/vvd/grpc/grpcError.js +0 -1
- package/lib/vvd/grpc/index.d.ts +1 -0
- package/lib/vvd/grpc/index.js +8 -8
- package/lib/vvd/index.d.ts +1 -0
- package/lib/vvd/index.js +13 -18
- package/lib/vvd/logcat.js +15 -14
- package/package.json +4 -3
|
@@ -11,8 +11,6 @@ exports.getRunningAvdConfigByName = getRunningAvdConfigByName;
|
|
|
11
11
|
exports.getRunningAvdConfigFiles = getRunningAvdConfigFiles;
|
|
12
12
|
exports.getRunningVvdDebugPort = getRunningVvdDebugPort;
|
|
13
13
|
exports.getRunningVvds = getRunningVvds;
|
|
14
|
-
require("core-js/modules/es.error.cause.js");
|
|
15
|
-
require("core-js/modules/es.array.push.js");
|
|
16
14
|
var _os = _interopRequireDefault(require("os"));
|
|
17
15
|
var _fs = _interopRequireDefault(require("fs"));
|
|
18
16
|
var _ini = _interopRequireDefault(require("ini"));
|
|
@@ -112,8 +110,7 @@ function getRunningAvdConfigByName(name) {
|
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
function getRunningVvdDebugPort(name) {
|
|
115
|
-
var _e$cmdline;
|
|
116
113
|
const e = getRunningAvdConfigByName(name);
|
|
117
114
|
const regex = /hostfwd=tcp:(.*?):(\d+)-10\.0\.2\.15:101/;
|
|
118
|
-
return e
|
|
115
|
+
return e?.cmdline?.match(regex)?.[2];
|
|
119
116
|
}
|
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Status = exports.ConfigParser = void 0;
|
|
7
|
-
require("core-js/modules/es.error.cause.js");
|
|
8
|
-
require("core-js/modules/es.array.push.js");
|
|
9
7
|
let Status = exports.Status = /*#__PURE__*/function (Status) {
|
|
10
8
|
Status[Status["NAME"] = 1] = "NAME";
|
|
11
9
|
Status[Status["VALUE"] = 2] = "VALUE";
|
package/lib/instance/common.d.ts
CHANGED
package/lib/instance/common.js
CHANGED
|
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
require("core-js/
|
|
8
|
-
require("core-js/modules/es.promise.with-resolvers.js");
|
|
7
|
+
require("core-js/actual/promise/with-resolvers");
|
|
9
8
|
var _ColorConsole = _interopRequireDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
10
9
|
var _ILog = require("@aiot-toolkit/shared-utils/lib/interface/ILog");
|
|
11
10
|
var _adb = _interopRequireWildcard(require("@miwt/adb"));
|
|
@@ -27,8 +26,8 @@ class CommonEmulatorInstance {
|
|
|
27
26
|
static appInstallFailedFlag = /uv_mq_read_cb: install prepare failed/;
|
|
28
27
|
static appUninstalledFlag = /uninstalled app/;
|
|
29
28
|
static appStartedFlag = /Start App loop/;
|
|
30
|
-
static isAppInstalled(
|
|
31
|
-
const log =
|
|
29
|
+
static isAppInstalled() {
|
|
30
|
+
const log = arguments.length <= 0 ? undefined : arguments[0];
|
|
32
31
|
return this.appInstalledFlag.test(log);
|
|
33
32
|
}
|
|
34
33
|
static isAppInstallFailed(log) {
|
|
@@ -52,7 +51,7 @@ class CommonEmulatorInstance {
|
|
|
52
51
|
level: _ILog.Loglevel.INFO,
|
|
53
52
|
message: msg
|
|
54
53
|
});
|
|
55
|
-
params.customLogger(`${prefix[1]} ${msg
|
|
54
|
+
params.customLogger(`${prefix[1]} ${msg?.trim()}`);
|
|
56
55
|
};
|
|
57
56
|
} else {
|
|
58
57
|
this.logger = _ColorConsole.default.info;
|
|
@@ -130,7 +129,7 @@ class CommonEmulatorInstance {
|
|
|
130
129
|
const devices = await adbMiwt.getAdbDevices();
|
|
131
130
|
this.logger(`adb devices: ${JSON.stringify(devices)}`);
|
|
132
131
|
const curDev = devices.find(t => t.sn === this.sn);
|
|
133
|
-
return
|
|
132
|
+
return curDev?.status === 'device';
|
|
134
133
|
}, 10, 500);
|
|
135
134
|
}
|
|
136
135
|
async pushAndInstall(rpkPath, appName) {
|
|
@@ -157,7 +156,8 @@ class CommonEmulatorInstance {
|
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
/** 关闭模拟器 */
|
|
160
|
-
poweroff(
|
|
159
|
+
poweroff() {
|
|
160
|
+
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10 * 1000;
|
|
161
161
|
return new Promise((resolve, reject) => {
|
|
162
162
|
const t = setTimeout(() => {
|
|
163
163
|
(0, _utils.killProcessByCmd)(this.vvdName).then(resolve).catch(e => {
|
package/lib/instance/dev.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
require("core-js/modules/es.error.cause.js");
|
|
8
7
|
var adbMiwt = _interopRequireWildcard(require("@miwt/adb"));
|
|
9
8
|
var _common = _interopRequireDefault(require("./common"));
|
|
10
9
|
var _Vvd = require("../typing/Vvd");
|
|
@@ -21,7 +20,7 @@ class GoldfishInstance extends _common.default {
|
|
|
21
20
|
closeApp() {
|
|
22
21
|
throw new Error('Method not implemented.');
|
|
23
22
|
}
|
|
24
|
-
imageType = _Vvd.VelaImageType.DEV;
|
|
23
|
+
imageType = (() => _Vvd.VelaImageType.DEV)();
|
|
25
24
|
static appDir = '/data/app';
|
|
26
25
|
static emulatorStartedFlag = /(NSH)/;
|
|
27
26
|
async install(rpkPath, opt) {
|
|
@@ -41,7 +40,8 @@ class GoldfishInstance extends _common.default {
|
|
|
41
40
|
* 通过vapp命令启动,调试时需额外配置--jsdebugger参数
|
|
42
41
|
* @param options
|
|
43
42
|
*/
|
|
44
|
-
async startApp(packageName
|
|
43
|
+
async startApp(packageName) {
|
|
44
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
45
45
|
try {
|
|
46
46
|
let vappCmd = `adb -s ${this.sn} shell vapp app/${packageName} &`;
|
|
47
47
|
if (debug) {
|
|
@@ -56,7 +56,8 @@ class GoldfishInstance extends _common.default {
|
|
|
56
56
|
this.logger(`Failed to startup quickapp: ${e.message}`);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
async reloadApp(appName
|
|
59
|
+
async reloadApp(appName) {
|
|
60
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
60
61
|
await this.reboot();
|
|
61
62
|
await this.startApp(appName, debug);
|
|
62
63
|
}
|
|
@@ -11,7 +11,7 @@ var _util = require("util");
|
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
13
|
class MiniSound5 extends _miwear.VelaMiwear5 {
|
|
14
|
-
imageType = _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5;
|
|
14
|
+
imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5)();
|
|
15
15
|
appDir = '/data/app';
|
|
16
16
|
xmsInitedFlag = /AMS/;
|
|
17
17
|
static appStartedFlag = /Start main loop/;
|
package/lib/instance/miwear.js
CHANGED
|
@@ -20,7 +20,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
20
20
|
class MiwearInstance extends _common.default {
|
|
21
21
|
xmsInitedFlag = /quickapp_rpk_installer_init|rpk installer init done/;
|
|
22
22
|
static appInstalledFlag = /InstallState_Finished|install finished/;
|
|
23
|
-
imageType = _Vvd.VelaImageType.REL;
|
|
23
|
+
imageType = (() => _Vvd.VelaImageType.REL)();
|
|
24
24
|
appDir = '/data/quickapp/app';
|
|
25
25
|
static isAppInstalled(log, targetRpk) {
|
|
26
26
|
// 注意:targetRpk 可能包含特殊字符,需要转义
|
|
@@ -68,7 +68,7 @@ class MiwearInstance extends _common.default {
|
|
|
68
68
|
const mu = size / 1024 / 1024;
|
|
69
69
|
return mu < 1 ? 20 * 1000 : mu < 4 ? 60 * 1000 : 2 * 60 * 1000;
|
|
70
70
|
}
|
|
71
|
-
const timeout = getTimeout(options
|
|
71
|
+
const timeout = getTimeout(options?.size);
|
|
72
72
|
let timer = setTimeout(() => {
|
|
73
73
|
this.stdoutReadline.off('line', func);
|
|
74
74
|
this.logger(`Install to ${this.vvdName} ${targeRpk} timeout`);
|
|
@@ -109,7 +109,8 @@ class MiwearInstance extends _common.default {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/** 使用 am start 启动快应用 */
|
|
112
|
-
async startApp(packageName
|
|
112
|
+
async startApp(packageName) {
|
|
113
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
113
114
|
// 等待 xms 服务初始化完成之后才能进行安装
|
|
114
115
|
await this.xmsStatus.promise;
|
|
115
116
|
// 调试模式需要push一个文件至miwear中
|
package/lib/instance/miwear5.js
CHANGED
|
@@ -8,7 +8,7 @@ var _Vvd = require("../typing/Vvd");
|
|
|
8
8
|
var _miwear = _interopRequireDefault(require("./miwear"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
class VelaMiwear5 extends _miwear.default {
|
|
11
|
-
imageType = _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5;
|
|
11
|
+
imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5)();
|
|
12
12
|
appDir = '/data/app';
|
|
13
13
|
}
|
|
14
14
|
exports.VelaMiwear5 = VelaMiwear5;
|
|
@@ -12,7 +12,7 @@ var _util = require("util");
|
|
|
12
12
|
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); }
|
|
13
13
|
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; }
|
|
14
14
|
class OpenSmartspeaker5 extends _miwear.VelaMiwear5 {
|
|
15
|
-
imageType = _Vvd.VelaImageType.OPENVELA_SMARTSPEAKER_5;
|
|
15
|
+
imageType = (() => _Vvd.VelaImageType.OPENVELA_SMARTSPEAKER_5)();
|
|
16
16
|
appDir = '/data/app';
|
|
17
17
|
xmsInitedFlag = /AMS/;
|
|
18
18
|
static appStartedFlag = /Start main loop/;
|
package/lib/instance/pre.js
CHANGED
|
@@ -14,7 +14,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
14
14
|
* 不带 miwear 的 4.0 镜像
|
|
15
15
|
*/
|
|
16
16
|
class PreInstance extends _common.default {
|
|
17
|
-
imageType = _Vvd.VelaImageType.PRE;
|
|
17
|
+
imageType = (() => _Vvd.VelaImageType.PRE)();
|
|
18
18
|
appDir = '/data/quickapp/app';
|
|
19
19
|
xmsInitedFlag = /(NSH)/;
|
|
20
20
|
async install(rpkPath, opt) {
|
|
@@ -43,7 +43,8 @@ class PreInstance extends _common.default {
|
|
|
43
43
|
* 通过vapp命令启动,调试时需额外配置--jsdebugger参数
|
|
44
44
|
* @param options
|
|
45
45
|
*/
|
|
46
|
-
async startApp(packageName
|
|
46
|
+
async startApp(packageName) {
|
|
47
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
47
48
|
try {
|
|
48
49
|
let vappCmd = `adb -s ${this.sn} shell vapp app/${packageName} &`;
|
|
49
50
|
if (debug) {
|
|
@@ -61,7 +62,8 @@ class PreInstance extends _common.default {
|
|
|
61
62
|
async closeApp() {
|
|
62
63
|
await this.reboot();
|
|
63
64
|
}
|
|
64
|
-
async reloadApp(appName
|
|
65
|
+
async reloadApp(appName) {
|
|
66
|
+
let debug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
65
67
|
await this.reboot();
|
|
66
68
|
this.startApp(appName, debug);
|
|
67
69
|
}
|
package/lib/instance/vela5.js
CHANGED
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
16
16
|
class Vela5Instance extends _miwear.default {
|
|
17
17
|
xmsInitedFlag = /booting completed|Boot completed/;
|
|
18
18
|
static appStartedFlag = /Start main loop/;
|
|
19
|
-
imageType = _Vvd.VelaImageType.VELA_WATCH_5;
|
|
19
|
+
imageType = (() => _Vvd.VelaImageType.VELA_WATCH_5)();
|
|
20
20
|
appDir = '/data/app';
|
|
21
21
|
|
|
22
22
|
/**
|
package/lib/utils/index.js
CHANGED
|
@@ -82,7 +82,10 @@ async function sleep(time) {
|
|
|
82
82
|
* @param {Number=} maxCount 最大重试次数
|
|
83
83
|
* @param {number=} duration 每次重试的间隔
|
|
84
84
|
*/
|
|
85
|
-
async function tryRun(task
|
|
85
|
+
async function tryRun(task) {
|
|
86
|
+
let maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
|
|
87
|
+
let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
88
|
+
let currentCount = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
86
89
|
if (currentCount > maxCount) return false;
|
|
87
90
|
return Boolean(await task()) || (await delayRun(() => tryRun(task, maxCount, duration, currentCount + 1), duration));
|
|
88
91
|
}
|
|
@@ -93,7 +96,8 @@ async function tryRun(task, maxCount = 5, duration = 1000, currentCount = 0) {
|
|
|
93
96
|
* @param duration
|
|
94
97
|
* @returns
|
|
95
98
|
*/
|
|
96
|
-
async function delayRun(task
|
|
99
|
+
async function delayRun(task) {
|
|
100
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
97
101
|
return new Promise(resolve => {
|
|
98
102
|
setTimeout(async () => {
|
|
99
103
|
return resolve(task());
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleGrpcErrorMsg = handleGrpcErrorMsg;
|
|
7
|
-
require("core-js/modules/es.error.cause.js");
|
|
8
7
|
function handleGrpcErrorMsg(err) {
|
|
9
8
|
if (typeof err === 'string') err = new Error(err);
|
|
10
9
|
console.error(err);
|
package/lib/vvd/grpc/index.d.ts
CHANGED
package/lib/vvd/grpc/index.js
CHANGED
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.GrpcEmulator = exports.AuthorizationKey = void 0;
|
|
7
7
|
exports.createGrpcClient = createGrpcClient;
|
|
8
|
-
require("core-js/
|
|
9
|
-
require("core-js/modules/es.promise.with-resolvers.js");
|
|
8
|
+
require("core-js/actual/promise/with-resolvers");
|
|
10
9
|
var _path = _interopRequireDefault(require("path"));
|
|
11
10
|
var _protoLoader = require("@grpc/proto-loader");
|
|
12
11
|
var _grpcError = require("./grpcError");
|
|
@@ -19,7 +18,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
19
18
|
const AuthorizationKey = exports.AuthorizationKey = 'Authorization';
|
|
20
19
|
class GrpcEmulator {
|
|
21
20
|
connected = false;
|
|
22
|
-
constructor(eConf, protoPath
|
|
21
|
+
constructor(eConf, protoPath) {
|
|
22
|
+
let ip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '127.0.0.1';
|
|
23
23
|
this.eConf = eConf;
|
|
24
24
|
this.protoPath = protoPath;
|
|
25
25
|
this.ip = ip;
|
|
@@ -43,9 +43,8 @@ class GrpcEmulator {
|
|
|
43
43
|
this.uiClient = new this.controller.UiController(`127.0.0.1:${eConf['grpc.port']}`, _grpcJs.credentials.createInsecure());
|
|
44
44
|
}
|
|
45
45
|
close() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(_this$logcatStream = this.logcatStream) === null || _this$logcatStream === void 0 || _this$logcatStream.destroy();
|
|
46
|
+
this.screenshotStream?.destroy();
|
|
47
|
+
this.logcatStream?.destroy();
|
|
49
48
|
this.client.getChannel().close();
|
|
50
49
|
this.client.close();
|
|
51
50
|
}
|
|
@@ -156,7 +155,8 @@ class GrpcEmulator {
|
|
|
156
155
|
if (err) console.error(err);
|
|
157
156
|
});
|
|
158
157
|
}
|
|
159
|
-
showExtendedControls(
|
|
158
|
+
showExtendedControls() {
|
|
159
|
+
let paneIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
160
160
|
if (!this.uiClient) return Promise.reject('UiController not available');
|
|
161
161
|
return new Promise((resolve, reject) => {
|
|
162
162
|
this.uiClient.showExtendedControls({
|
|
@@ -202,7 +202,7 @@ class GrpcEmulator {
|
|
|
202
202
|
const logMessage = params || {};
|
|
203
203
|
this.logcatStream = this.client.streamLogcat(logMessage, this.authMate);
|
|
204
204
|
this.logcatStream.on('error', err => {
|
|
205
|
-
console.error('streamLogcat error:',
|
|
205
|
+
console.error('streamLogcat error:', err?.message || err);
|
|
206
206
|
});
|
|
207
207
|
return this.logcatStream;
|
|
208
208
|
}
|
package/lib/vvd/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'core-js/actual/promise/with-resolvers';
|
|
1
2
|
import { IVvdParams, IVvdResourcePaths, SDKParts, SDKDownloadOpt, SkinInfo, VelaImageType } from '../typing/Vvd';
|
|
2
3
|
import { IStartOptions, IStartWithSerialPort } from '../typing/Instance';
|
|
3
4
|
import { EmulatorConfig } from '../emulatorutil';
|
package/lib/vvd/index.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isHeadlessEnvironment = exports.VvdManager = void 0;
|
|
7
|
-
require("core-js/
|
|
8
|
-
require("core-js/modules/es.array.push.js");
|
|
9
|
-
require("core-js/modules/es.promise.with-resolvers.js");
|
|
7
|
+
require("core-js/actual/promise/with-resolvers");
|
|
10
8
|
var _ColorConsole = _interopRequireDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
11
9
|
var _promises = _interopRequireDefault(require("fs/promises"));
|
|
12
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
@@ -65,7 +63,8 @@ exports.isHeadlessEnvironment = isHeadlessEnvironment;
|
|
|
65
63
|
class VvdManager {
|
|
66
64
|
// 需要复制的文件
|
|
67
65
|
binFiles = ['system.img', 'data.img', 'coredump.core', 'vela_data.bin', 'vela_resource.bin', 'vela_system.bin'];
|
|
68
|
-
constructor(
|
|
66
|
+
constructor() {
|
|
67
|
+
let vvdResourcePaths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
69
68
|
const {
|
|
70
69
|
vvdHome,
|
|
71
70
|
sdkHome
|
|
@@ -263,7 +262,6 @@ class VvdManager {
|
|
|
263
262
|
const skinDir = skinPath;
|
|
264
263
|
const layoutPath = _path.default.join(skinDir, 'layout');
|
|
265
264
|
if (_fs.default.existsSync(layoutPath)) {
|
|
266
|
-
var _skinInfo$parts$defau;
|
|
267
265
|
const layoutContent = _fs.default.readFileSync(layoutPath, 'utf-8');
|
|
268
266
|
const parser = new _skinLayoutParser.ConfigParser();
|
|
269
267
|
const skinInfo = parser.toObject(parser.parse(layoutContent));
|
|
@@ -271,7 +269,7 @@ class VvdManager {
|
|
|
271
269
|
defaultLayout.part1.value = skinInfo.parts[defaultLayout.part1.name];
|
|
272
270
|
defaultLayout.part2.value = skinInfo.parts[defaultLayout.part2.name];
|
|
273
271
|
const backgroundImage = _path.default.join(skinDir, skinInfo.parts[defaultLayout.part1.name].background.image);
|
|
274
|
-
const maskImage =
|
|
272
|
+
const maskImage = skinInfo.parts[defaultLayout.part1.name]?.foreground?.mask;
|
|
275
273
|
const maskImagePath = maskImage ? _path.default.join(skinDir, maskImage) : undefined;
|
|
276
274
|
return {
|
|
277
275
|
name: skinName,
|
|
@@ -367,7 +365,6 @@ class VvdManager {
|
|
|
367
365
|
|
|
368
366
|
// 旧的模拟器迁移
|
|
369
367
|
async oldEmulatorMigrate(vvdName) {
|
|
370
|
-
var _normalizePath, _normalizePath3, _normalizePath4;
|
|
371
368
|
const configIni = _path.default.join(this.getVvdDir(vvdName), 'config.ini');
|
|
372
369
|
const contents = await _promises.default.readFile(configIni, 'utf-8');
|
|
373
370
|
const config = (0, _ini.parse)(contents);
|
|
@@ -383,9 +380,8 @@ class VvdManager {
|
|
|
383
380
|
|
|
384
381
|
// 检查皮肤路径
|
|
385
382
|
const skinPath = config['skin.path'];
|
|
386
|
-
if (skinPath &&
|
|
387
|
-
|
|
388
|
-
if ((_normalizePath2 = normalizePath(skinPath.toString())) !== null && _normalizePath2 !== void 0 && _normalizePath2.includes('.export_dev/skins/user')) {
|
|
383
|
+
if (skinPath && normalizePath(skinPath.toString())?.includes('.export_dev/skins')) {
|
|
384
|
+
if (normalizePath(skinPath.toString())?.includes('.export_dev/skins/user')) {
|
|
389
385
|
// 自定义的皮肤,将自定义皮肤迁移到新的 sdk 目录中
|
|
390
386
|
const oldUserSkinDir = _path.default.join(_os.default.homedir(), '.export_dev/skins/user');
|
|
391
387
|
const newUserSkinDir = _path.default.join(this.sdkHome, 'skins', 'user');
|
|
@@ -409,7 +405,7 @@ class VvdManager {
|
|
|
409
405
|
}
|
|
410
406
|
|
|
411
407
|
// 迁移 原来 user 目录中的 xiaomi_band_10
|
|
412
|
-
if (skinPath &&
|
|
408
|
+
if (skinPath && normalizePath(skinPath.toString())?.endsWith('/user/xiaomi_band_10')) {
|
|
413
409
|
_ColorConsole.default.log('migrate user/xiaomi_band_10 to builtin/xiaomi_band_10');
|
|
414
410
|
config['skin.path'] = normalizePath(skinPath.toString()).replace('/user/xiaomi_band_10', '/builtin/xiaomi_band_10');
|
|
415
411
|
needUpdate = true;
|
|
@@ -422,7 +418,7 @@ class VvdManager {
|
|
|
422
418
|
}
|
|
423
419
|
|
|
424
420
|
// 检查镜像路径
|
|
425
|
-
if (config['image.sysdir.2'] &&
|
|
421
|
+
if (config['image.sysdir.2'] && normalizePath(config['image.sysdir.2'].toString())?.includes('.export_dev/system-images')) {
|
|
426
422
|
needUpdate = true;
|
|
427
423
|
config['image.sysdir.2'] = normalizePath(config['image.sysdir.2'].toString()).replace('.export_dev/system-images', '.vela/sdk/system-images');
|
|
428
424
|
}
|
|
@@ -530,7 +526,7 @@ class VvdManager {
|
|
|
530
526
|
level: _ILog.Loglevel.INFO,
|
|
531
527
|
message: msg
|
|
532
528
|
});
|
|
533
|
-
options.customLogger(`${prefix[1]} ${msg
|
|
529
|
+
options.customLogger(`${prefix[1]} ${msg?.trim()}`);
|
|
534
530
|
};
|
|
535
531
|
} else {
|
|
536
532
|
logger = _ColorConsole.default.info;
|
|
@@ -566,10 +562,9 @@ class VvdManager {
|
|
|
566
562
|
|
|
567
563
|
// 该模拟器已经启动,则创建一个日志流返回
|
|
568
564
|
if (e) {
|
|
569
|
-
var _e$cmdline;
|
|
570
565
|
// 找出来它原来使用的 debugPort
|
|
571
566
|
const regex = /hostfwd=tcp:(.*?):(\d+)-10\.0\.2\.15:101/;
|
|
572
|
-
const debugPort =
|
|
567
|
+
const debugPort = e.cmdline?.match(regex)?.[2];
|
|
573
568
|
const imageType = await getImageType(e['port.serial']);
|
|
574
569
|
const emulatorInstance = (0, _instance.findInstance)(imageType, {
|
|
575
570
|
serialPort: e['port.serial'],
|
|
@@ -676,7 +671,8 @@ class VvdManager {
|
|
|
676
671
|
});
|
|
677
672
|
return promise;
|
|
678
673
|
}
|
|
679
|
-
stopVvd(name
|
|
674
|
+
stopVvd(name) {
|
|
675
|
+
let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10 * 1000;
|
|
680
676
|
return new Promise((resolve, reject) => {
|
|
681
677
|
const config = (0, _emulatorutil.getRunningAvdConfigByName)(name);
|
|
682
678
|
if (!config) {
|
|
@@ -691,8 +687,7 @@ class VvdManager {
|
|
|
691
687
|
clearTimeout(t);
|
|
692
688
|
resolve();
|
|
693
689
|
}).catch(e => {
|
|
694
|
-
|
|
695
|
-
if (e !== null && e !== void 0 && (_e$message = e.message) !== null && _e$message !== void 0 && _e$message.includes(`device 'emulator-${config['port.serial']}' not found`)) {
|
|
690
|
+
if (e?.message?.includes(`device 'emulator-${config['port.serial']}' not found`)) {
|
|
696
691
|
// 清理之前的文件
|
|
697
692
|
_fs.default.unlinkSync(config.path);
|
|
698
693
|
}
|
package/lib/vvd/logcat.js
CHANGED
|
@@ -8,7 +8,11 @@ exports.creatLogcat = creatLogcat;
|
|
|
8
8
|
var _readline = _interopRequireDefault(require("readline"));
|
|
9
9
|
var _adb = require("@miwt/adb");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
function creatLogcat(sn
|
|
11
|
+
function creatLogcat(sn) {
|
|
12
|
+
let onStdout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : console.log;
|
|
13
|
+
let onErrout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : console.log;
|
|
14
|
+
let p = arguments.length > 3 ? arguments[3] : undefined;
|
|
15
|
+
let rls = arguments.length > 4 ? arguments[4] : undefined;
|
|
12
16
|
const logcatProcess = p || (0, _adb.spawnAdbCmd)('adb', ['-s', sn, 'logcat']);
|
|
13
17
|
const readlines = rls || attachReadline(logcatProcess, onStdout, onErrout);
|
|
14
18
|
return {
|
|
@@ -23,7 +27,7 @@ function attachReadline(p, onStdout, onErrout) {
|
|
|
23
27
|
let stderrReadline;
|
|
24
28
|
|
|
25
29
|
// 利用 readline 接口可解决子进程日志换行的问题
|
|
26
|
-
if (p
|
|
30
|
+
if (p?.stdout) {
|
|
27
31
|
stdoutReadline = _readline.default.createInterface({
|
|
28
32
|
input: p.stdout
|
|
29
33
|
});
|
|
@@ -31,12 +35,11 @@ function attachReadline(p, onStdout, onErrout) {
|
|
|
31
35
|
onStdout(str);
|
|
32
36
|
});
|
|
33
37
|
p.stdout.on('close', () => {
|
|
34
|
-
|
|
35
|
-
(_stdoutReadline = stdoutReadline) === null || _stdoutReadline === void 0 || _stdoutReadline.close();
|
|
38
|
+
stdoutReadline?.close();
|
|
36
39
|
stdoutReadline = undefined;
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
if (p
|
|
42
|
+
if (p?.stderr) {
|
|
40
43
|
stderrReadline = _readline.default.createInterface({
|
|
41
44
|
input: p.stderr
|
|
42
45
|
});
|
|
@@ -44,21 +47,19 @@ function attachReadline(p, onStdout, onErrout) {
|
|
|
44
47
|
onErrout(str);
|
|
45
48
|
});
|
|
46
49
|
p.stderr.on('close', () => {
|
|
47
|
-
|
|
48
|
-
(_stderrReadline = stderrReadline) === null || _stderrReadline === void 0 || _stderrReadline.close();
|
|
50
|
+
stderrReadline?.close();
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
function dispose() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
(_stderrReadline3 = stderrReadline) === null || _stderrReadline3 === void 0 || _stderrReadline3.close();
|
|
54
|
+
p?.removeAllListeners();
|
|
55
|
+
stdoutReadline?.removeAllListeners();
|
|
56
|
+
stderrReadline?.removeAllListeners();
|
|
57
|
+
stdoutReadline?.close();
|
|
58
|
+
stderrReadline?.close();
|
|
58
59
|
stdoutReadline = undefined;
|
|
59
60
|
stderrReadline = undefined;
|
|
60
61
|
}
|
|
61
|
-
p
|
|
62
|
+
p?.on('exit', () => {
|
|
62
63
|
dispose();
|
|
63
64
|
});
|
|
64
65
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/emulator",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.17",
|
|
4
4
|
"description": "vela emulator tool.",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"emulator"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@aiot-toolkit/shared-utils": "2.0.6-beta.
|
|
35
|
+
"@aiot-toolkit/shared-utils": "2.0.6-beta.17",
|
|
36
36
|
"@grpc/grpc-js": "^1.13.3",
|
|
37
37
|
"@grpc/proto-loader": "^0.7.13",
|
|
38
38
|
"@miwt/adb": "0.10.5",
|
|
39
39
|
"adm-zip": "^0.5.16",
|
|
40
|
+
"core-js": "^3.48.0",
|
|
40
41
|
"dayjs": "^1.11.12",
|
|
41
42
|
"find-process": "^1.4.7",
|
|
42
43
|
"get-port": "^7.1.0",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"@types/adm-zip": "^0.5.5",
|
|
50
51
|
"@types/ini": "^4.1.1"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "d9d60157e951ebbc58f6a6f6fac63efd9d9d4fd5"
|
|
53
54
|
}
|