@aiot-toolkit/emulator 2.0.3-beta.1 → 2.0.3-beta.10
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 +38 -39
- package/lib/instance/common.js +141 -223
- package/lib/instance/dev.d.ts +7 -42
- package/lib/instance/dev.js +54 -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 +93 -370
- package/lib/instance/pre.d.ts +11 -3
- package/lib/instance/pre.js +55 -93
- package/lib/instance/pre5.d.ts +11 -0
- package/lib/instance/pre5.js +38 -0
- package/lib/static/avdConfigIni.json +5 -5
- package/lib/typing/Instance.d.ts +30 -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 +698 -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
|
@@ -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
|
-
|
|
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/
|
|
4
|
+
export * from './typing/Vvd';
|
|
5
5
|
export * from './typing/Instance';
|
|
6
|
-
export * from './emulatorutil
|
|
7
|
-
export {
|
|
6
|
+
export * from './emulatorutil';
|
|
7
|
+
export { getSystemArch, tryRun };
|
package/lib/index.js
CHANGED
|
@@ -1,28 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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, "
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
});
|
package/lib/instance/common.d.ts
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
/** 创建server */
|
|
43
|
-
createWebsockeServer(): Promise<void>;
|
|
44
|
-
connectDevice(): Promise<string | void>;
|
|
43
|
+
reboot(): Promise<void>;
|
|
45
44
|
}
|
|
46
|
-
export default
|
|
45
|
+
export default CommonEmulatorInstance;
|