@aiot-toolkit/emulator 2.0.5-beta.5 → 2.0.5-beta.7

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.
@@ -33,7 +33,7 @@ var _shared = require("../shared");
33
33
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
34
34
  const defaultSDKHome = exports.defaultSDKHome = _path.default.resolve(_os.default.homedir(), _Vvd.VELAHOME.SDK);
35
35
  const defaultVvdHome = exports.defaultVvdHome = _path.default.resolve(_os.default.homedir(), _Vvd.VELAHOME.VVD);
36
- const defaultImageHome = exports.defaultImageHome = _path.default.resolve(defaultSDKHome, 'system-images/arm');
36
+ const defaultImageHome = exports.defaultImageHome = _path.default.resolve(defaultSDKHome, 'system-images', (0, _shared.getDefaultImage)());
37
37
  const defaultEmulatorHome = exports.defaultEmulatorHome = _path.default.resolve(defaultSDKHome, 'emulator');
38
38
  const defaultSkinHome = exports.defaultSkinHome = _path.default.resolve(defaultSDKHome, 'skins');
39
39
  const defaultQuickappHome = exports.defaultQuickappHome = _path.default.resolve(defaultSDKHome, 'qa');
@@ -54,6 +54,20 @@ const systemImageBaseUrl = exports.systemImageBaseUrl = 'https://vela-ide.cnbj3-
54
54
  * vela-dev-0.0.4 : vela 4.0 dev 分支
55
55
  */
56
56
  const VelaImageVersionList = exports.VelaImageVersionList = [{
57
+ label: 'vela-miwear-watch-4.0',
58
+ description: '原 vela-release-4.0 版本,适用于手表/手环的,带表盘的 vela 4.0 镜像,不可自定义模拟器尺寸',
59
+ value: _Vvd.VelaImageType.REL,
60
+ time: '20250225',
61
+ hide: false,
62
+ icon: ''
63
+ }, {
64
+ label: 'vela-watch-4.0',
65
+ description: '原 vela-pre-4.0 版本,适用于手表/手环的,不带表盘的 vela 4.0 镜像,可自定义模拟器尺寸',
66
+ value: _Vvd.VelaImageType.PRE,
67
+ time: '20250225',
68
+ hide: false,
69
+ icon: ''
70
+ }, {
57
71
  label: 'vela-miwear-watch-5.0',
58
72
  description: '适用于手表/手环的,带表盘的 vela 5.0 镜像,不可自定义模拟器尺寸',
59
73
  value: _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5,
@@ -68,17 +82,10 @@ const VelaImageVersionList = exports.VelaImageVersionList = [{
68
82
  hide: false,
69
83
  icon: ''
70
84
  }, {
71
- label: 'vela-miwear-watch-4.0',
72
- description: ' vela-release-4.0 版本,适用于手表/手环的,带表盘的 vela 4.0 镜像,不可自定义模拟器尺寸',
73
- value: _Vvd.VelaImageType.REL,
74
- time: '20250225',
75
- hide: false,
76
- icon: ''
77
- }, {
78
- label: 'vela-watch-4.0',
79
- description: '原 vela-pre-4.0 版本,适用于手表/手环的,不带表盘的 vela 4.0 镜像,可自定义模拟器尺寸',
80
- value: _Vvd.VelaImageType.PRE,
81
- time: '20250225',
85
+ label: 'vela-miwear-minisound-5.0',
86
+ description: '适用于音响的 vela-miwear 5.0 镜像,不可自定义模拟器尺寸',
87
+ value: _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5,
88
+ time: '20250318',
82
89
  hide: false,
83
90
  icon: ''
84
91
  }];
@@ -16,7 +16,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
17
  class CommonEmulatorInstance {
18
18
  appDir = '/data/quickapp/app';
19
- static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done|booting completed/;
19
+ static emulatorStartedFlag = /quickapp_rpk_installer_init|rpk installer init done|booting completed|Boot completed/;
20
20
  static appInstalledFlag = /InstallState_Finished|install finished/;
21
21
  static appUninstalledFlag = /uninstalled app/;
22
22
  static appStartedFlag = /Start App loop/;
@@ -6,7 +6,8 @@ import { VelaImageType } from '../typing/Vvd';
6
6
  import { IEmulatorInstanceParams } from '../typing/Instance';
7
7
  import { Vela5Instance } from './vela5';
8
8
  import { VelaMiwear5 } from './miwear5';
9
- declare function getInstanceClass(imageType: VelaImageType): typeof GoldfishInstance | typeof MiwearInstance | typeof PreInstance | typeof Vela5Instance | typeof VelaMiwear5;
9
+ import { MiniSound5 } from './minisound';
10
+ declare function getInstanceClass(imageType: VelaImageType): typeof GoldfishInstance | typeof MiwearInstance | typeof PreInstance | typeof Vela5Instance | typeof VelaMiwear5 | typeof MiniSound5;
10
11
  /**
11
12
  * 根据镜像决定使用哪个instance
12
13
  * Vela正式版(4.0) -> MiwearInstance
@@ -42,6 +42,7 @@ var _pre = _interopRequireDefault(require("./pre"));
42
42
  var _Vvd = require("../typing/Vvd");
43
43
  var _vela = require("./vela5");
44
44
  var _miwear2 = require("./miwear5");
45
+ var _minisound = require("./minisound");
45
46
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
46
47
  function getInstanceClass(imageType) {
47
48
  const map = {
@@ -49,7 +50,8 @@ function getInstanceClass(imageType) {
49
50
  [_Vvd.VelaImageType.REL]: _miwear.default,
50
51
  [_Vvd.VelaImageType.DEV]: _dev.default,
51
52
  [_Vvd.VelaImageType.VELA_WATCH_5]: _vela.Vela5Instance,
52
- [_Vvd.VelaImageType.VELA_MIWEAR_WATCH_5]: _miwear2.VelaMiwear5
53
+ [_Vvd.VelaImageType.VELA_MIWEAR_WATCH_5]: _miwear2.VelaMiwear5,
54
+ [_Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5]: _minisound.MiniSound5
53
55
  };
54
56
  return map[imageType] || _dev.default;
55
57
  }
@@ -0,0 +1,18 @@
1
+ import { VelaImageType } from '../typing/Vvd';
2
+ import { VelaMiwear5 } from './miwear5';
3
+ export declare class MiniSound5 extends VelaMiwear5 {
4
+ imageType: VelaImageType;
5
+ appDir: string;
6
+ static emulatorStartedFlag: RegExp;
7
+ static appStartedFlag: RegExp;
8
+ /**
9
+ * 使用 pm 安装快应用
10
+ * @param targeRpk 快应用的rpk文件路径
11
+ */
12
+ install(targeRpk: string): Promise<void>;
13
+ /**
14
+ * 使用 pm 卸载快应用
15
+ * @param packageName 快应用的包名
16
+ */
17
+ uninstall(packageName: string): Promise<void>;
18
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MiniSound5 = void 0;
7
+ var _adb = require("@miwt/adb");
8
+ var _Vvd = require("../typing/Vvd");
9
+ var _miwear = require("./miwear5");
10
+ class MiniSound5 extends _miwear.VelaMiwear5 {
11
+ imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5)();
12
+ appDir = '/data/app';
13
+ static emulatorStartedFlag = /\[launchQuickApp.*\] Start main loop/;
14
+ static appStartedFlag = /Start main loop/;
15
+
16
+ /**
17
+ * 使用 pm 安装快应用
18
+ * @param targeRpk 快应用的rpk文件路径
19
+ */
20
+ install(targeRpk) {
21
+ const installCmd = `adb -s ${this.sn} shell pm install ${targeRpk}`;
22
+ this.logger(`Excuting: ${installCmd}`);
23
+ const res = (0, _adb.execAdbCmdSync)(installCmd);
24
+ this.logger(`Install Res: ${res}`);
25
+ if (res.includes('(success 0)')) {
26
+ return Promise.resolve();
27
+ } else {
28
+ return Promise.reject(res);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * 使用 pm 卸载快应用
34
+ * @param packageName 快应用的包名
35
+ */
36
+ uninstall(packageName) {
37
+ const res = (0, _adb.execAdbCmdSync)(`adb -s ${this.sn} shell pm uninstall ${packageName}`);
38
+ if (res.includes('(success 0)')) {
39
+ return Promise.resolve();
40
+ } else {
41
+ return Promise.reject(res);
42
+ }
43
+ }
44
+ }
45
+ exports.MiniSound5 = MiniSound5;
@@ -1,4 +1,7 @@
1
+ import { VelaImageType } from '../typing/Vvd';
1
2
  import MiwearInstance from './miwear';
2
3
  export declare class VelaMiwear5 extends MiwearInstance {
4
+ imageType: VelaImageType;
3
5
  appDir: string;
6
+ static emulatorStartedFlag: RegExp;
4
7
  }
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VelaMiwear5 = void 0;
7
+ var _Vvd = require("../typing/Vvd");
7
8
  var _miwear = _interopRequireDefault(require("./miwear"));
8
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
10
  class VelaMiwear5 extends _miwear.default {
11
+ imageType = (() => _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5)();
10
12
  appDir = '/data/app';
13
+ static emulatorStartedFlag = /\[App Active Flag/;
11
14
  }
12
15
  exports.VelaMiwear5 = VelaMiwear5;
@@ -16,7 +16,7 @@ function isVelaImageType(value) {
16
16
  return Object.values(_Vvd.VelaImageType).includes(value);
17
17
  }
18
18
  function isMiwearImageType(val) {
19
- return [_Vvd.VelaImageType.REL, _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5].includes(val);
19
+ return [_Vvd.VelaImageType.REL, _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5, _Vvd.VelaImageType.VELA_MIWEAR_MINISOUND_5].includes(val);
20
20
  }
21
21
  function getDefaultImage() {
22
22
  return _Vvd.VelaImageType.VELA_MIWEAR_WATCH_5;
@@ -8,6 +8,7 @@ export declare enum IVvdArchType {
8
8
  arm64 = "arm64"
9
9
  }
10
10
  export declare enum VelaImageType {
11
+ VELA_MIWEAR_MINISOUND_5 = "vela-miwear-minisound-5.0",
11
12
  VELA_MIWEAR_WATCH_5 = "vela-miwear-watch-5.0",
12
13
  VELA_WATCH_5 = "vela-watch-5.0",
13
14
  REL = "vela-release-4.0",
package/lib/typing/Vvd.js CHANGED
@@ -10,6 +10,7 @@ let IVvdArchType = exports.IVvdArchType = /*#__PURE__*/function (IVvdArchType) {
10
10
  return IVvdArchType;
11
11
  }({});
12
12
  let VelaImageType = exports.VelaImageType = /*#__PURE__*/function (VelaImageType) {
13
+ VelaImageType["VELA_MIWEAR_MINISOUND_5"] = "vela-miwear-minisound-5.0";
13
14
  VelaImageType["VELA_MIWEAR_WATCH_5"] = "vela-miwear-watch-5.0";
14
15
  VelaImageType["VELA_WATCH_5"] = "vela-watch-5.0";
15
16
  VelaImageType["REL"] = "vela-release-4.0";
package/lib/vvd/index.js CHANGED
@@ -383,11 +383,14 @@ class VvdManager {
383
383
  _ColorConsole.default.throw(errMsg);
384
384
  throw new Error(errMsg);
385
385
  }
386
- const imageDir = _path.default.resolve(vvdInfo.customImagePath || vvdInfo.imageDir);
387
386
  for (const file of this.binFiles) {
388
387
  const pOfVvd = _path.default.join(vvdDir, file);
389
- const pOfImageDir = _path.default.join(imageDir, file);
390
- if (!_fs.default.existsSync(pOfImageDir)) continue;
388
+ let pOfImageDir;
389
+ if (vvdInfo.customImagePath && _fs.default.existsSync(_path.default.join(vvdInfo.customImagePath, file))) {
390
+ pOfImageDir = _path.default.join(vvdInfo.customImagePath, file);
391
+ } else if (vvdInfo.imageDir && _fs.default.existsSync(_path.default.join(vvdInfo.imageDir, file))) {
392
+ pOfImageDir = _path.default.join(vvdInfo.imageDir, file);
393
+ } else continue;
391
394
  if (!_fs.default.existsSync(pOfVvd)) {
392
395
  // 文件不存在则直接复制
393
396
  _fs.default.copyFileSync(pOfImageDir, pOfVvd);
@@ -465,7 +468,8 @@ class VvdManager {
465
468
  }
466
469
 
467
470
  // 利用 readline 接口可解决子进程日志换行的问题
468
- const readlines = (0, _logcat.attachReadline)(emulatorProcess, async msg => {
471
+ const readlines = (0, _logcat.attachReadline)(emulatorProcess, onStdout, onErrout);
472
+ const emulatorStartedHandler = async msg => {
469
473
  if (func(msg)) {
470
474
  const runningVvds = await (0, _emulatorutil.getRunningVvds)();
471
475
  const e = runningVvds.find(e => e['avd.id'] === vvdName);
@@ -481,6 +485,7 @@ class VvdManager {
481
485
  customLogger: options.customLogger
482
486
  });
483
487
  logger(`${options.vvdName} started successfully`);
488
+ readlines.stdoutReadline.off('line', emulatorStartedHandler);
484
489
  resolve({
485
490
  coldBoot: true,
486
491
  emulatorInstance
@@ -489,8 +494,8 @@ class VvdManager {
489
494
  reject('get emulator running config failed');
490
495
  }
491
496
  }
492
- onStdout(msg);
493
- }, onErrout);
497
+ };
498
+ readlines.stdoutReadline.on('line', emulatorStartedHandler);
494
499
 
495
500
  // 监听模拟器的退出事件
496
501
  emulatorProcess.on('exit', code => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/emulator",
3
- "version": "2.0.5-beta.5",
3
+ "version": "2.0.5-beta.7",
4
4
  "description": "vela emulator tool.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -36,7 +36,7 @@
36
36
  "emulator"
37
37
  ],
38
38
  "dependencies": {
39
- "@aiot-toolkit/shared-utils": "2.0.5-beta.5",
39
+ "@aiot-toolkit/shared-utils": "2.0.5-beta.7",
40
40
  "@miwt/adb": "^0.9.0",
41
41
  "adm-zip": "^0.5.16",
42
42
  "dayjs": "^1.11.12",
@@ -51,5 +51,5 @@
51
51
  "@types/adm-zip": "^0.5.5",
52
52
  "@types/ini": "^4.1.1"
53
53
  },
54
- "gitHead": "c90b16e8706edad7825777a1b40d367b28d76ed3"
54
+ "gitHead": "553c62c29e7ddde9cf12fe8ce3801d77bf5e0fcb"
55
55
  }