@aiot-toolkit/emulator 2.0.2-beta.16 → 2.0.2-beta.18

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import IManifest from '@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/interface/IManifest';
3
2
  import { ChildProcess } from 'child_process';
4
3
  import VelaAvdCls from '../avd';
@@ -102,8 +102,8 @@ class CommonInstance {
102
102
  * 时间限制为 @param timeout 秒,超时则表示连接失败
103
103
  * @returns
104
104
  */
105
- connectGoldfish(timeout = 10) {
106
- return __awaiter(this, void 0, void 0, function* () {
105
+ connectGoldfish() {
106
+ return __awaiter(this, arguments, void 0, function* (timeout = 10) {
107
107
  let adbConnected = false; // adb是否连接成功
108
108
  let enableLoop = true; // 是否允许循环,用于终止adb的连接
109
109
  let needKill = false;
@@ -163,8 +163,8 @@ class CommonInstance {
163
163
  }
164
164
  /** 停止模拟器并释放相关资源 */
165
165
  stop() {
166
- var _a, _b;
167
166
  return __awaiter(this, void 0, void 0, function* () {
167
+ var _a, _b;
168
168
  if (this.goldfishProcess) {
169
169
  // Linux删除goldfishProcess后,子进程仍存在,导致模拟器窗口未关闭
170
170
  // 这里的作用是手动删除创建出来的子进程
@@ -189,8 +189,8 @@ class CommonInstance {
189
189
  }
190
190
  /** 创建server */
191
191
  createWebsockeServer() {
192
- var _a;
193
192
  return __awaiter(this, void 0, void 0, function* () {
193
+ var _a;
194
194
  const wsServer = new ws_1.WebSocketServer({
195
195
  port: (_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.serverPort
196
196
  });
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import readline from 'readline';
3
2
  import { INewGoldfishInstanceParams, IStartOptions } from '../typing/Instance';
4
3
  import CommonInstance from './common';
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.findInstance = exports.PreInstance = exports.OldGoldfishInstance = exports.MiwearInstance = exports.GoldfishInstance = exports.CommonInstance = void 0;
6
+ exports.PreInstance = exports.OldGoldfishInstance = exports.MiwearInstance = exports.GoldfishInstance = exports.CommonInstance = void 0;
7
+ exports.findInstance = findInstance;
7
8
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
8
9
  const avd_1 = __importDefault(require("../avd"));
9
10
  const common_1 = __importDefault(require("./common"));
@@ -41,4 +42,3 @@ function findInstance(avdName, params) {
41
42
  }
42
43
  return new dev_1.default(params);
43
44
  }
44
- exports.findInstance = findInstance;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import readline from 'readline';
3
2
  import { INewGoldfishInstanceParams, IStartOptions } from '../typing/Instance';
4
3
  import CommonInstance from './common';
@@ -168,8 +168,8 @@ class MiwearInstance extends common_1.default {
168
168
  * @param options
169
169
  */
170
170
  startupQuickApp(options) {
171
- var _a;
172
171
  return __awaiter(this, void 0, void 0, function* () {
172
+ var _a;
173
173
  const { package: appPackageName } = this.projectInfo;
174
174
  const releaseDir = this.isRpk
175
175
  ? path_1.default.resolve(this.projectPath, '../')
@@ -190,6 +190,7 @@ class MiwearInstance extends common_1.default {
190
190
  yield adbMiwt.execAdbCmdAsync(`adb -s ${this.sn} shell rm /data/debugger_ip.cfg`);
191
191
  }
192
192
  this.pushAndInstall(rpkPath, this.appDir);
193
+ // this.launchQuickapp()
193
194
  });
194
195
  }
195
196
  /**
@@ -264,8 +265,8 @@ class MiwearInstance extends common_1.default {
264
265
  * 3. 发送Page.reload命令给调试服务,通知更新
265
266
  */
266
267
  handleUpdate() {
267
- var _a, _b;
268
268
  return __awaiter(this, void 0, void 0, function* () {
269
+ var _a, _b;
269
270
  try {
270
271
  this.reconnectCount = 0;
271
272
  yield this.initDebugSocket();
@@ -344,8 +345,8 @@ class MiwearInstance extends common_1.default {
344
345
  * 创建server端,监听打包过程中client端发来的消息
345
346
  */
346
347
  createWebsockeServer() {
347
- var _a;
348
348
  return __awaiter(this, void 0, void 0, function* () {
349
+ var _a;
349
350
  const wsServer = new ws_1.WebSocketServer({
350
351
  port: (_a = this.startOptions) === null || _a === void 0 ? void 0 : _a.serverPort
351
352
  });
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { ChildProcess } from 'child_process';
4
2
  import readline from 'readline';
5
3
  import { INewGoldfishInstanceParams, IStartOptions } from '../typing/Instance';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
3
2
  import { IAvdResourcePaths } from './Avd';
4
3
  export interface INewGoldfishInstanceParams extends IAvdResourcePaths {
@@ -12,7 +12,13 @@ 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
- exports.getEvenPort = exports.delayRun = exports.tryRun = exports.sleep = exports.killProcessByCmd = exports.killProcessByPid = exports.getSystemArch = void 0;
15
+ exports.getSystemArch = getSystemArch;
16
+ exports.killProcessByPid = killProcessByPid;
17
+ exports.killProcessByCmd = killProcessByCmd;
18
+ exports.sleep = sleep;
19
+ exports.tryRun = tryRun;
20
+ exports.delayRun = delayRun;
21
+ exports.getEvenPort = getEvenPort;
16
22
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
17
23
  const child_process_1 = require("child_process");
18
24
  const find_process_1 = __importDefault(require("find-process"));
@@ -47,7 +53,6 @@ function getSystemArch() {
47
53
  }
48
54
  return cpuArch[osArch];
49
55
  }
50
- exports.getSystemArch = getSystemArch;
51
56
  /** 根据PID杀死进程 */
52
57
  function killProcessByPid(pid) {
53
58
  try {
@@ -58,7 +63,6 @@ function killProcessByPid(pid) {
58
63
  console.error(`kill process ${pid} get error: ${e}`);
59
64
  }
60
65
  }
61
- exports.killProcessByPid = killProcessByPid;
62
66
  /**
63
67
  * 根据命令杀死进程
64
68
  */
@@ -77,37 +81,34 @@ function killProcessByCmd(cmd) {
77
81
  }
78
82
  });
79
83
  }
80
- exports.killProcessByCmd = killProcessByCmd;
81
84
  /** 延迟函数 */
82
85
  function sleep(time) {
83
86
  return __awaiter(this, void 0, void 0, function* () {
84
87
  return new Promise((resolve) => setTimeout(resolve, time));
85
88
  });
86
89
  }
87
- exports.sleep = sleep;
88
90
  /**
89
91
  * 重复执行某个任务直到成功,或者超过最大次数
90
92
  * @param task 任务,需要返回 bool 值表示是否执行成功
91
93
  * @param {Number=} maxCount 最大重试次数
92
94
  * @param {number=} duration 每次重试的间隔
93
95
  */
94
- function tryRun(task, maxCount = 5, duration = 1000, currentCount = 0) {
95
- return __awaiter(this, void 0, void 0, function* () {
96
+ function tryRun(task_1) {
97
+ return __awaiter(this, arguments, void 0, function* (task, maxCount = 5, duration = 1000, currentCount = 0) {
96
98
  if (currentCount > maxCount)
97
99
  return false;
98
100
  return (Boolean(yield task()) ||
99
101
  (yield delayRun(() => tryRun(task, maxCount, duration, currentCount + 1), duration)));
100
102
  });
101
103
  }
102
- exports.tryRun = tryRun;
103
104
  /**
104
105
  * 延迟执行某个任务
105
106
  * @param task
106
107
  * @param duration
107
108
  * @returns
108
109
  */
109
- function delayRun(task, duration = 1000) {
110
- return __awaiter(this, void 0, void 0, function* () {
110
+ function delayRun(task_1) {
111
+ return __awaiter(this, arguments, void 0, function* (task, duration = 1000) {
111
112
  return new Promise((resolve) => {
112
113
  setTimeout(() => __awaiter(this, void 0, void 0, function* () {
113
114
  return resolve(task());
@@ -115,7 +116,6 @@ function delayRun(task, duration = 1000) {
115
116
  });
116
117
  });
117
118
  }
118
- exports.delayRun = delayRun;
119
119
  /**
120
120
  * 为avdPort寻找一个不被占用的端口
121
121
  * 端口号必须是偶数且在5555和5585之间
@@ -142,4 +142,3 @@ function getEvenPort() {
142
142
  return port;
143
143
  });
144
144
  }
145
- exports.getEvenPort = getEvenPort;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/emulator",
3
- "version": "2.0.2-beta.16",
3
+ "version": "2.0.2-beta.18",
4
4
  "description": "vela emulator tool.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -35,8 +35,8 @@
35
35
  "emulator"
36
36
  ],
37
37
  "dependencies": {
38
- "@aiot-toolkit/aiotpack": "2.0.2-beta.16",
39
- "@aiot-toolkit/shared-utils": "2.0.2-beta.16",
38
+ "@aiot-toolkit/aiotpack": "2.0.2-beta.18",
39
+ "@aiot-toolkit/shared-utils": "2.0.2-beta.18",
40
40
  "@miwt/adb": "^0.9.0",
41
41
  "dayjs": "^1.11.12",
42
42
  "find-process": "^1.4.7",
@@ -50,5 +50,5 @@
50
50
  "@types/fs-extra": "^11.0.4",
51
51
  "@types/ini": "^4.1.1"
52
52
  },
53
- "gitHead": "785701c64914f50acd18ab71ea41b2f5a2cd161c"
53
+ "gitHead": "b73a79ef04edac808f316bf8b8fb1718422daa1c"
54
54
  }