@aiot-toolkit/emulator 2.0.3-beta.6 → 2.0.3-beta.8

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 (45) hide show
  1. package/README.md +133 -8
  2. package/lib/emulatorutil/EmulatorLog.js +22 -18
  3. package/lib/emulatorutil/constants.d.ts +18 -5
  4. package/lib/emulatorutil/constants.js +94 -53
  5. package/lib/emulatorutil/index.d.ts +3 -2
  6. package/lib/emulatorutil/index.js +38 -8
  7. package/lib/emulatorutil/running.d.ts +24 -0
  8. package/lib/emulatorutil/running.js +108 -0
  9. package/lib/emulatorutil/skinLayoutParser.d.ts +14 -0
  10. package/lib/emulatorutil/skinLayoutParser.js +111 -0
  11. package/lib/index.d.ts +5 -5
  12. package/lib/index.js +76 -26
  13. package/lib/instance/common.d.ts +38 -39
  14. package/lib/instance/common.js +141 -223
  15. package/lib/instance/dev.d.ts +7 -42
  16. package/lib/instance/dev.js +54 -235
  17. package/lib/instance/index.d.ts +6 -5
  18. package/lib/instance/index.js +51 -35
  19. package/lib/instance/miwear.d.ts +14 -75
  20. package/lib/instance/miwear.js +93 -370
  21. package/lib/instance/pre.d.ts +11 -3
  22. package/lib/instance/pre.js +55 -93
  23. package/lib/instance/pre5.d.ts +11 -0
  24. package/lib/instance/pre5.js +38 -0
  25. package/lib/static/avdConfigIni.json +5 -5
  26. package/lib/typing/Instance.d.ts +30 -15
  27. package/lib/typing/Instance.js +13 -6
  28. package/lib/typing/Vvd.d.ts +105 -0
  29. package/lib/typing/Vvd.js +31 -0
  30. package/lib/utils/file.d.ts +0 -0
  31. package/lib/utils/file.js +1 -0
  32. package/lib/utils/index.js +86 -100
  33. package/lib/vvd/index.d.ts +107 -0
  34. package/lib/vvd/index.js +698 -0
  35. package/lib/vvd/logcat.d.ts +16 -0
  36. package/lib/vvd/logcat.js +67 -0
  37. package/package.json +9 -8
  38. package/lib/avd/index.d.ts +0 -28
  39. package/lib/avd/index.js +0 -173
  40. package/lib/emulatorutil/EmulatorCmd.d.ts +0 -9
  41. package/lib/emulatorutil/EmulatorCmd.js +0 -226
  42. package/lib/instance/preDev.d.ts +0 -53
  43. package/lib/instance/preDev.js +0 -249
  44. package/lib/typing/Avd.d.ts +0 -23
  45. package/lib/typing/Avd.js +0 -8
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Status = exports.ConfigParser = void 0;
7
+ let Status = exports.Status = /*#__PURE__*/function (Status) {
8
+ Status[Status["NAME"] = 1] = "NAME";
9
+ Status[Status["VALUE"] = 2] = "VALUE";
10
+ Status[Status["COMMENT"] = 3] = "COMMENT";
11
+ return Status;
12
+ }({});
13
+ class ConfigParser {
14
+ static isEndChar(char, index, str) {
15
+ return char === '\n' || index === str.length - 1;
16
+ }
17
+ parse(str) {
18
+ let result = {
19
+ comments: [],
20
+ values: {}
21
+ };
22
+ let currentValue = '';
23
+ let currentName = '';
24
+ let currentState = Status.NAME;
25
+ const resetState = () => {
26
+ currentValue = '';
27
+ currentName = '';
28
+ };
29
+ for (let i = 0; i < str.length; i++) {
30
+ const char = str[i];
31
+ switch (currentState) {
32
+ case Status.NAME:
33
+ if (char === '#') {
34
+ if (!currentName) {
35
+ currentState = Status.COMMENT;
36
+ }
37
+ } else if (char === ' ') {
38
+ if (currentName) {
39
+ currentState = Status.VALUE;
40
+ }
41
+ } else if (ConfigParser.isEndChar(char, i, str)) {
42
+ if (currentName) {
43
+ throw new Error('Unexpected end of input while in NAME state');
44
+ }
45
+ } else {
46
+ currentName += char;
47
+ }
48
+ break;
49
+ case Status.VALUE:
50
+ if (char === '{') {
51
+ let braceCount = 1;
52
+ let blockContent = '';
53
+ for (let j = i + 1; j < str.length; j++) {
54
+ const innerChar = str[j];
55
+ if (innerChar === '{') braceCount++;
56
+ if (innerChar === '}') braceCount--;
57
+ if (braceCount === 0) {
58
+ blockContent = str.substring(i + 1, j);
59
+ i = j;
60
+ break;
61
+ }
62
+ blockContent += innerChar;
63
+ }
64
+ const parser = new ConfigParser();
65
+ const parsedResult = parser.parse(blockContent);
66
+ result.values[currentName] = parsedResult;
67
+ resetState();
68
+ currentState = Status.NAME;
69
+ } else if (ConfigParser.isEndChar(char, i, str)) {
70
+ if (char !== '\n') {
71
+ currentValue += char;
72
+ }
73
+ result.values[currentName] = currentValue.trim();
74
+ resetState();
75
+ currentState = Status.NAME;
76
+ } else {
77
+ currentValue += char;
78
+ }
79
+ break;
80
+ case Status.COMMENT:
81
+ currentValue += char;
82
+ if (ConfigParser.isEndChar(char, i, str)) {
83
+ result.comments.push(currentValue.trim());
84
+ resetState();
85
+ currentState = Status.NAME;
86
+ }
87
+ break;
88
+ default:
89
+ throw new Error('Unknown state');
90
+ }
91
+ }
92
+ if (currentName) {
93
+ ;
94
+ result.values[currentName] = currentValue;
95
+ }
96
+ return result;
97
+ }
98
+ toObject(target) {
99
+ const res = {};
100
+ for (const key in target.values) {
101
+ const value = target.values[key];
102
+ if (typeof value === 'string') {
103
+ res[key] = value;
104
+ } else {
105
+ res[key] = this.toObject(value);
106
+ }
107
+ }
108
+ return res;
109
+ }
110
+ }
111
+ exports.ConfigParser = ConfigParser;
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { default as VelaAvdCls } from './avd';
2
- import { getSystemArch } from './utils';
1
+ export { VvdManager } from './vvd';
2
+ import { getSystemArch, tryRun } from './utils';
3
3
  export * from './instance';
4
- export * from './typing/Avd';
4
+ export * from './typing/Vvd';
5
5
  export * from './typing/Instance';
6
- export * from './emulatorutil/constants';
7
- export { VelaAvdCls, getSystemArch };
6
+ export * from './emulatorutil';
7
+ export { getSystemArch, tryRun };
package/lib/index.js CHANGED
@@ -1,28 +1,78 @@
1
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ VvdManager: true,
8
+ getSystemArch: true,
9
+ tryRun: true
18
10
  };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.getSystemArch = exports.VelaAvdCls = void 0;
21
- const avd_1 = __importDefault(require("./avd"));
22
- Object.defineProperty(exports, "VelaAvdCls", { enumerable: true, get: function () { return avd_1.default; } });
23
- const utils_1 = require("./utils");
24
- Object.defineProperty(exports, "getSystemArch", { enumerable: true, get: function () { return utils_1.getSystemArch; } });
25
- __exportStar(require("./instance"), exports);
26
- __exportStar(require("./typing/Avd"), exports);
27
- __exportStar(require("./typing/Instance"), exports);
28
- __exportStar(require("./emulatorutil/constants"), exports);
11
+ Object.defineProperty(exports, "VvdManager", {
12
+ enumerable: true,
13
+ get: function () {
14
+ return _vvd.VvdManager;
15
+ }
16
+ });
17
+ Object.defineProperty(exports, "getSystemArch", {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _utils.getSystemArch;
21
+ }
22
+ });
23
+ Object.defineProperty(exports, "tryRun", {
24
+ enumerable: true,
25
+ get: function () {
26
+ return _utils.tryRun;
27
+ }
28
+ });
29
+ var _vvd = require("./vvd");
30
+ var _utils = require("./utils");
31
+ var _instance = require("./instance");
32
+ Object.keys(_instance).forEach(function (key) {
33
+ if (key === "default" || key === "__esModule") return;
34
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
+ if (key in exports && exports[key] === _instance[key]) return;
36
+ Object.defineProperty(exports, key, {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _instance[key];
40
+ }
41
+ });
42
+ });
43
+ var _Vvd = require("./typing/Vvd");
44
+ Object.keys(_Vvd).forEach(function (key) {
45
+ if (key === "default" || key === "__esModule") return;
46
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
47
+ if (key in exports && exports[key] === _Vvd[key]) return;
48
+ Object.defineProperty(exports, key, {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _Vvd[key];
52
+ }
53
+ });
54
+ });
55
+ var _Instance = require("./typing/Instance");
56
+ Object.keys(_Instance).forEach(function (key) {
57
+ if (key === "default" || key === "__esModule") return;
58
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
59
+ if (key in exports && exports[key] === _Instance[key]) return;
60
+ Object.defineProperty(exports, key, {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _Instance[key];
64
+ }
65
+ });
66
+ });
67
+ var _emulatorutil = require("./emulatorutil");
68
+ Object.keys(_emulatorutil).forEach(function (key) {
69
+ if (key === "default" || key === "__esModule") return;
70
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
71
+ if (key in exports && exports[key] === _emulatorutil[key]) return;
72
+ Object.defineProperty(exports, key, {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _emulatorutil[key];
76
+ }
77
+ });
78
+ });
@@ -1,46 +1,45 @@
1
- import IManifest from '@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/interface/IManifest';
2
- import { ChildProcess } from 'child_process';
3
- import VelaAvdCls from '../avd';
4
- import { INewGoldfishInstanceParams, IStartOptions } from '../typing/Instance';
5
- /**
6
- * CommonInstance
7
- */
8
- declare class CommonInstance {
1
+ import readline from 'readline';
2
+ import { IEmulatorInstanceParams } from '../typing/Instance';
3
+ import { VelaImageType } from '../typing/Vvd';
4
+ import { ChildProcessWithoutNullStreams } from 'child_process';
5
+ declare class CommonEmulatorInstance {
6
+ imageType: VelaImageType;
7
+ appDir: string;
9
8
  quickappStartedFlag: RegExp;
10
- projectPath: string;
11
- sdkHome: string;
12
- avdHome: string;
13
- velaAvdCls: VelaAvdCls;
14
- goldfishProcess: ChildProcess | undefined;
15
- isFirstStart: boolean;
16
- startOptions: IStartOptions | undefined;
17
- projectInfo: IManifest;
18
- isRpk: boolean;
19
- isDistributedApp: boolean;
20
- sn?: string;
21
- constructor(params: INewGoldfishInstanceParams);
22
- /** 获取模拟器二进制文件所在位置 */
23
- getEmulatorBinPath(): string;
24
- /** 在goldfish模拟器中运行快应用 */
25
- start(options: IStartOptions): Promise<void>;
9
+ sn: string;
10
+ vvdName: string;
11
+ debugPort?: number | string;
12
+ stdoutReadline: readline.Interface;
13
+ stderrReadline: readline.Interface;
14
+ disposeReadlines: () => void;
15
+ onStdout: (msg: string) => void;
16
+ onErrout: (msg: string) => void;
17
+ logcatProcess: ChildProcessWithoutNullStreams;
18
+ constructor(params: IEmulatorInstanceParams);
19
+ /** 推送指定文件 */
20
+ push(sourcePath: string, targetPath: string): Promise<string>;
21
+ unzip(zipPath: string, targetPath: string): Promise<void>;
22
+ /** 推送指定 rpk */
23
+ pushRpk(rpkPath: string, appPackageName: string): Promise<string>;
26
24
  /**
27
25
  * 判断模拟器是否 ready
28
26
  */
29
27
  isConnected(): Promise<boolean>;
30
- /**
31
- * 通过adb连接模拟器。
32
- * 时间限制为 @param timeout 秒,超时则表示连接失败
33
- * @returns
34
- */
35
- connectGoldfish(timeout?: number): Promise<unknown>;
36
- /** 杀死进程 */
37
- killProcess(currProcess?: ChildProcess): void;
38
- /** 停止模拟器并释放相关资源 */
39
- stop(): Promise<void>;
28
+ /** 安装应用,留给子类实现 */
29
+ install(rpkPath: string, packageName?: string): Promise<void>;
30
+ /** 卸载应用,留给子类实现 */
31
+ uninstall(packageName: string): Promise<void>;
32
+ /** 启动应用,留给子类实现 */
33
+ startApp(packageName: string, debug?: boolean): Promise<void>;
34
+ pushAndInstall(rpkPath: string, appName: string): Promise<void>;
35
+ /** 重启应用 */
36
+ reloadApp(appName: string, debug?: boolean): Promise<void>;
37
+ /** 关闭应用 */
38
+ closeApp(appName: string): Promise<void>;
39
+ /** 关闭模拟器 */
40
+ poweroff(timeout?: number): Promise<void>;
41
+ systemed(): Promise<string>;
40
42
  /** 重启模拟器 */
41
- restart(): Promise<void>;
42
- /** 创建server */
43
- createWebsockeServer(): Promise<void>;
44
- connectDevice(): Promise<string | void>;
43
+ reboot(): Promise<void>;
45
44
  }
46
- export default CommonInstance;
45
+ export default CommonEmulatorInstance;