@aiot-toolkit/emulator 2.0.5-widget-provider-beta.2 → 2.0.6-alpha.0

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 (50) hide show
  1. package/README.md +173 -173
  2. package/lib/emulatorutil/constants.js +11 -11
  3. package/lib/emulatorutil/running.js +14 -6
  4. package/lib/index.d.ts +5 -2
  5. package/lib/index.js +48 -0
  6. package/lib/instance/common.d.ts +5 -2
  7. package/lib/instance/common.js +26 -5
  8. package/lib/instance/dev.d.ts +4 -1
  9. package/lib/instance/dev.js +9 -9
  10. package/lib/instance/index.js +7 -7
  11. package/lib/instance/minisound.js +6 -6
  12. package/lib/instance/miwear.d.ts +5 -1
  13. package/lib/instance/miwear.js +44 -22
  14. package/lib/instance/miwear5.d.ts +0 -1
  15. package/lib/instance/miwear5.js +0 -1
  16. package/lib/instance/pre.d.ts +4 -1
  17. package/lib/instance/pre.js +9 -9
  18. package/lib/instance/vela5.d.ts +5 -0
  19. package/lib/instance/vela5.js +63 -4
  20. package/lib/shared/index.d.ts +9 -0
  21. package/lib/shared/index.js +16 -4
  22. package/lib/static/advancedFeatures.ini +1 -1
  23. package/lib/static/avdConfigIni.json +45 -39
  24. package/lib/static/debugger_ip.cfg +1 -1
  25. package/lib/static/proto/README.MD +2 -2
  26. package/lib/static/proto/emulator_controller.proto +1476 -1321
  27. package/lib/static/proto/rtc_service.proto +117 -117
  28. package/lib/static/proto/ui_controller_service.proto +147 -0
  29. package/lib/typing/Instance.js +3 -3
  30. package/lib/typing/Vvd.d.ts +3 -3
  31. package/lib/typing/Vvd.js +1 -2
  32. package/lib/utils/file.d.ts +8 -0
  33. package/lib/utils/file.js +48 -1
  34. package/lib/utils/index.js +19 -19
  35. package/lib/vvd/grpc/index.d.ts +16 -7
  36. package/lib/vvd/grpc/index.js +89 -11
  37. package/lib/vvd/grpc/types/GrpcClient.d.ts +43 -2
  38. package/lib/vvd/grpc/types/UiControllerClient.d.ts +23 -0
  39. package/lib/vvd/grpc/types/index.d.ts +3 -0
  40. package/lib/vvd/grpc/types/index.js +38 -0
  41. package/lib/vvd/grpc/types/proto-types.d.ts +178 -0
  42. package/lib/vvd/grpc/types/proto-types.js +50 -0
  43. package/lib/vvd/index.d.ts +7 -3
  44. package/lib/vvd/index.js +141 -50
  45. package/lib/vvd/logcat.js +3 -3
  46. package/package.json +4 -8
  47. package/lib/vvd/grpc/types/KeyEvent.d.ts +0 -19
  48. package/lib/vvd/grpc/types/KeyEvent.js +0 -20
  49. package/lib/vvd/grpc/types/MouseEvent.d.ts +0 -30
  50. /package/lib/vvd/grpc/types/{MouseEvent.js → UiControllerClient.js} +0 -0
@@ -1,117 +1,117 @@
1
- // Copyright (C) 2018 The Android Open Source Project
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- // Note that if you add/remove methods in this file you must update
16
- // the metrics sql as well by running ./android/scripts/gen-grpc-sql.py
17
- //
18
- // Please group deleted methods in a block including the date (MM/DD/YY)
19
- // it was removed. This enables us to easily keep metrics around after removal
20
- //
21
- // List of deleted methods
22
- // rpc iWasDeleted (03/12/12)
23
- // ...
24
- syntax = "proto3";
25
-
26
- option java_multiple_files = true;
27
- option java_package = "com.android.emulator.control";
28
- option objc_class_prefix = "AEC";
29
-
30
- package android.emulation.control;
31
- import "google/protobuf/empty.proto";
32
-
33
- // An RTC service lets you interact with the emulator through WebRTC
34
- // Note that this is currently an experimental feature, and that the
35
- // service definition might change without notice. Use at your own risk!
36
- //
37
- // The following endpoints are needed to establish the webrtc protocol
38
- // Due to limitiations in Javascript we cannot make use of bidirectional
39
- // endpoints See this [blog](https://grpc.io/blog/state-of-grpc-web) for
40
- // details.
41
- service Rtc {
42
- // This function will generate a new identifier that the client
43
- // should use for further interaction. It will initiate the
44
- // JSEP protocol on the server side.
45
- rpc requestRtcStream(google.protobuf.Empty) returns (RtcId) {}
46
-
47
- // Sends the given JsepMsg to the server. The RtcId in the
48
- // message should point to an active stream negotiation in
49
- // progress, otherwise the message will be ignored.
50
- rpc sendJsepMessage(JsepMsg) returns (google.protobuf.Empty) {}
51
-
52
- // Reads an available jsep messages for the given client id,
53
- // blocking until one becomes available. Do not use the polling version
54
- // above if you opt for this one.
55
- //
56
- // The ice candidates for example will trickle in on this callback,
57
- // as will the SDP negotation.
58
- rpc receiveJsepMessages(RtcId) returns (stream JsepMsg) {}
59
-
60
-
61
- // [DEPRECATED] This is only here as the go grpc webproxy used
62
- // by fuchsia does not support server side streaming. This method
63
- // will be removed in the future and should not be relied upon.
64
- //
65
- // Reads an available jsep messages for the given client id,
66
- // blocking until one becomes available. Do not use the polling version
67
- // above if you opt for this one.
68
- //
69
- // The ice candidates for example will trickle in on this callback,
70
- // as will the SDP negotation.
71
- rpc receiveJsepMessage(RtcId) returns (JsepMsg) {}
72
- }
73
-
74
- message RtcId {
75
- // The unique identifier of this connection. You will have to use the
76
- // same identifier when sending/receiving messages. The server will
77
- // generate a guid when receiving the start message.
78
- string guid = 1;
79
- }
80
-
81
- message JsepMsg {
82
- // The unique identifier of this connection. You will have to use the
83
- // same identifier when sending/receiving messages. The server will
84
- // generate a guid when receiving the start message.
85
- RtcId id = 1;
86
- // The JSON payload. This usually can be directly handled by the
87
- // Javascript library.
88
- //
89
- // The dictionary can contain the following properties
90
- //
91
- // - bye:
92
- // You can hang up now. No new message expected for you.
93
- // The server has stopped the RTC stream.
94
- //
95
- // - start:
96
- // An RTCConfiguration dictionary providing options to
97
- // configure the new connection. This can include the
98
- // turn configuration the serve is using. This dictionary can be
99
- // passed in directly to the
100
- // [RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection)
101
- // object.
102
- //
103
- // - candidate:
104
- // The WebRTC API's RTCIceCandidateInit dictionary, which
105
- // contains the information needed to fundamentally describe an
106
- // RTCIceCandidate. See
107
- // [RTCIceCandidate](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate)
108
- // and [Session
109
- // Lifetime](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Session_lifetime)
110
- // for more details.
111
- //
112
- // - sdp:
113
- // RTCSessionDescriptionInit dictionary containing the values
114
- // to that can be assigned to a
115
- // [RTCSessionDescription](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription)
116
- string message = 2;
117
- }
1
+ // Copyright (C) 2018 The Android Open Source Project
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // Note that if you add/remove methods in this file you must update
16
+ // the metrics sql as well by running ./android/scripts/gen-grpc-sql.py
17
+ //
18
+ // Please group deleted methods in a block including the date (MM/DD/YY)
19
+ // it was removed. This enables us to easily keep metrics around after removal
20
+ //
21
+ // List of deleted methods
22
+ // rpc iWasDeleted (03/12/12)
23
+ // ...
24
+ syntax = "proto3";
25
+
26
+ option java_multiple_files = true;
27
+ option java_package = "com.android.emulator.control";
28
+ option objc_class_prefix = "AEC";
29
+
30
+ package android.emulation.control;
31
+ import "google/protobuf/empty.proto";
32
+
33
+ // An RTC service lets you interact with the emulator through WebRTC
34
+ // Note that this is currently an experimental feature, and that the
35
+ // service definition might change without notice. Use at your own risk!
36
+ //
37
+ // The following endpoints are needed to establish the webrtc protocol
38
+ // Due to limitiations in Javascript we cannot make use of bidirectional
39
+ // endpoints See this [blog](https://grpc.io/blog/state-of-grpc-web) for
40
+ // details.
41
+ service Rtc {
42
+ // This function will generate a new identifier that the client
43
+ // should use for further interaction. It will initiate the
44
+ // JSEP protocol on the server side.
45
+ rpc requestRtcStream(google.protobuf.Empty) returns (RtcId) {}
46
+
47
+ // Sends the given JsepMsg to the server. The RtcId in the
48
+ // message should point to an active stream negotiation in
49
+ // progress, otherwise the message will be ignored.
50
+ rpc sendJsepMessage(JsepMsg) returns (google.protobuf.Empty) {}
51
+
52
+ // Reads an available jsep messages for the given client id,
53
+ // blocking until one becomes available. Do not use the polling version
54
+ // above if you opt for this one.
55
+ //
56
+ // The ice candidates for example will trickle in on this callback,
57
+ // as will the SDP negotation.
58
+ rpc receiveJsepMessages(RtcId) returns (stream JsepMsg) {}
59
+
60
+
61
+ // [DEPRECATED] This is only here as the go grpc webproxy used
62
+ // by fuchsia does not support server side streaming. This method
63
+ // will be removed in the future and should not be relied upon.
64
+ //
65
+ // Reads an available jsep messages for the given client id,
66
+ // blocking until one becomes available. Do not use the polling version
67
+ // above if you opt for this one.
68
+ //
69
+ // The ice candidates for example will trickle in on this callback,
70
+ // as will the SDP negotation.
71
+ rpc receiveJsepMessage(RtcId) returns (JsepMsg) {}
72
+ }
73
+
74
+ message RtcId {
75
+ // The unique identifier of this connection. You will have to use the
76
+ // same identifier when sending/receiving messages. The server will
77
+ // generate a guid when receiving the start message.
78
+ string guid = 1;
79
+ }
80
+
81
+ message JsepMsg {
82
+ // The unique identifier of this connection. You will have to use the
83
+ // same identifier when sending/receiving messages. The server will
84
+ // generate a guid when receiving the start message.
85
+ RtcId id = 1;
86
+ // The JSON payload. This usually can be directly handled by the
87
+ // Javascript library.
88
+ //
89
+ // The dictionary can contain the following properties
90
+ //
91
+ // - bye:
92
+ // You can hang up now. No new message expected for you.
93
+ // The server has stopped the RTC stream.
94
+ //
95
+ // - start:
96
+ // An RTCConfiguration dictionary providing options to
97
+ // configure the new connection. This can include the
98
+ // turn configuration the serve is using. This dictionary can be
99
+ // passed in directly to the
100
+ // [RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection)
101
+ // object.
102
+ //
103
+ // - candidate:
104
+ // The WebRTC API's RTCIceCandidateInit dictionary, which
105
+ // contains the information needed to fundamentally describe an
106
+ // RTCIceCandidate. See
107
+ // [RTCIceCandidate](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate)
108
+ // and [Session
109
+ // Lifetime](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Session_lifetime)
110
+ // for more details.
111
+ //
112
+ // - sdp:
113
+ // RTCSessionDescriptionInit dictionary containing the values
114
+ // to that can be assigned to a
115
+ // [RTCSessionDescription](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription)
116
+ string message = 2;
117
+ }
@@ -0,0 +1,147 @@
1
+ // Copyright 2020 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ option java_multiple_files = true;
18
+ option java_package = "com.android.emulator.control";
19
+ option objc_class_prefix = "AEC";
20
+
21
+ package android.emulation.control;
22
+ import "google/protobuf/empty.proto";
23
+
24
+ service UiController {
25
+ // PaneEntry specifies which pane will be selected when
26
+ // the extended control is shown. If the extended is visible already,
27
+ // this method will set visibilityChangedto to false.
28
+ rpc showExtendedControls(PaneEntry) returns (ExtendedControlsStatus) {}
29
+ // this method has no effect if the extended controls are hidden.
30
+ // In that case, visibilityChanged will be set to false;
31
+ rpc closeExtendedControls(google.protobuf.Empty)
32
+ returns (ExtendedControlsStatus) {}
33
+ rpc setUiTheme(ThemingStyle) returns (google.protobuf.Empty) {}
34
+
35
+ // Returns the user configuration of the running emulator. The user
36
+ // configuration contains information about the user interface.
37
+ rpc getUserConfig(google.protobuf.Empty) returns (UserConfig) {}
38
+ }
39
+
40
+ message UserConfigEntry {
41
+ string key = 1;
42
+ string value = 2;
43
+ }
44
+
45
+ // The user configuration of the running emulator as
46
+ // key value pairs. This contains the data you normally find
47
+ // in emulator-user.ini
48
+ message UserConfig {
49
+ repeated UserConfigEntry entries = 1;
50
+ }
51
+
52
+ message ThemingStyle {
53
+ enum Style {
54
+ LIGHT = 0;
55
+ DARK = 1;
56
+ CONTRAST = 2;
57
+ }
58
+ Style style = 1;
59
+ }
60
+
61
+ message ExtendedControlsStatus {
62
+ bool visibilityChanged = 1;
63
+ }
64
+
65
+ // The pixel coordinates are resolution independent, meaning the coordinates
66
+ // are independent from the pixel grid, resulting in a graphical user
67
+ // interface that is displayed at a consistent location, regardless of the
68
+ // resolution of the screen.
69
+ //
70
+ // For technical details: https://doc.qt.io/qt-5/highdpi.html
71
+ //
72
+ // Some things to note:
73
+ //
74
+ // - You cannot move a window offscreen.
75
+ // - There is a padding of around 10px around the frame.
76
+ //
77
+ // This means that moving to (0, 0) or (10, 10) will have the same result.
78
+ // This means that anchoring might not exactly behave as requested.
79
+ message WindowPosition {
80
+ // Anchor that is used to determine horizontal window placement.
81
+ enum HorizontalAnchor {
82
+ LEFT = 0; // The x coordinate will be treated as the left edge of the
83
+ // window.
84
+ HCENTER = 1; // The x coordinate will be treated as the middle between
85
+ // the left and right edges of the window.
86
+ RIGHT = 2; // The x coordinate will be treated as the right edge of
87
+ // the window.
88
+ }
89
+
90
+ // Anchor that is used to determine vertical window placement.
91
+ enum VerticalAnchor {
92
+ TOP = 0; // The y coordinate will be treated as the top edge of the
93
+ // window.
94
+ VCENTER = 1; // The y coordinate will be treated as the middle between
95
+ // the top and bottom edges of the window.
96
+ BOTTOM = 3; // The y coordinate will be treated as the bottom edge of
97
+ // the window.
98
+ }
99
+
100
+ // Corresponds to the x and y coordinate of the window geometry. The window
101
+ // geometry includes the window frame.
102
+ // See: https://doc.qt.io/qt-5/application-windows.html#window-geometry for
103
+ // details and pecularities on linux.
104
+ uint32 x = 1;
105
+ uint32 y = 2;
106
+
107
+ HorizontalAnchor horizontalAnchor = 3;
108
+ VerticalAnchor verticalAnchor = 4;
109
+ }
110
+
111
+ message PaneEntry {
112
+ enum PaneIndex {
113
+ // When specified as KEEP_CURRENT, extended controls will display the
114
+ // current pane.
115
+ // If it is the first time for extended controls to be shown, LOCATION
116
+ // will be used.
117
+ KEEP_CURRENT = 0;
118
+ // Referenced from
119
+ // external/qemu/android/android-emu/android/skin/qt/extended-window-styles.h
120
+ LOCATION = 1;
121
+ MULTIDISPLAY = 2;
122
+ CELLULAR = 3;
123
+ BATTERY = 4;
124
+ CAMERA = 5;
125
+ TELEPHONE = 6;
126
+ DPAD = 7;
127
+ TV_REMOTE = 8;
128
+ ROTARY = 9;
129
+ MICROPHONE = 10;
130
+ FINGER = 11;
131
+ VIRT_SENSORS = 12;
132
+ SNAPSHOT = 13;
133
+ BUGREPORT = 14;
134
+ RECORD = 15;
135
+ GOOGLE_PLAY = 16;
136
+ SETTINGS = 17;
137
+ HELP = 18;
138
+ CAR = 19;
139
+ CAR_ROTARY = 20;
140
+ SENSOR_REPLAY = 21;
141
+ };
142
+ PaneIndex index = 1;
143
+
144
+ // Set the window position to the specified coordinates if no coordinates are
145
+ // present in the AVD, otherwise this value will be igonred.
146
+ WindowPosition position = 2;
147
+ }
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.IStartOrigin = void 0;
7
- /**
8
- * 如果指定了 serialPort 则必须同时指定 grpcPort
9
- * 否则
7
+ /**
8
+ * 如果指定了 serialPort 则必须同时指定 grpcPort
9
+ * 否则
10
10
  */
11
11
  let IStartOrigin = exports.IStartOrigin = /*#__PURE__*/function (IStartOrigin) {
12
12
  IStartOrigin["Terminal"] = "terminal";
@@ -4,8 +4,7 @@ export interface IVvdResourcePaths {
4
4
  imageHome?: string;
5
5
  }
6
6
  export declare enum IVvdArchType {
7
- arm = "arm",
8
- arm64 = "arm64"
7
+ arm = "arm"
9
8
  }
10
9
  export declare enum VelaImageType {
11
10
  VELA_MIWEAR_MINISOUND_5 = "vela-miwear-minisound-5.0",
@@ -37,6 +36,7 @@ export interface EmulatorPart {
37
36
  height: string;
38
37
  x: string;
39
38
  y: string;
39
+ corner_radius: string;
40
40
  shape?: string;
41
41
  flavor?: string;
42
42
  density?: string;
@@ -103,7 +103,7 @@ export declare enum SDKParts {
103
103
  MODEM_SIMULATOR = "modem_simulator"
104
104
  }
105
105
  export declare enum VELAHOME {
106
- SDK = ".export",
106
+ SDK = ".vela/sdk",
107
107
  VVD = ".vela/vvd"
108
108
  }
109
109
  export type SDKDownloadOpt = {
package/lib/typing/Vvd.js CHANGED
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.VelaImageType = exports.VELAHOME = exports.SDKParts = exports.IVvdArchType = void 0;
7
7
  let IVvdArchType = exports.IVvdArchType = /*#__PURE__*/function (IVvdArchType) {
8
8
  IVvdArchType["arm"] = "arm";
9
- IVvdArchType["arm64"] = "arm64";
10
9
  return IVvdArchType;
11
10
  }({});
12
11
  let VelaImageType = exports.VelaImageType = /*#__PURE__*/function (VelaImageType) {
@@ -27,7 +26,7 @@ let SDKParts = exports.SDKParts = /*#__PURE__*/function (SDKParts) {
27
26
  return SDKParts;
28
27
  }({});
29
28
  let VELAHOME = exports.VELAHOME = /*#__PURE__*/function (VELAHOME) {
30
- VELAHOME["SDK"] = ".export";
29
+ VELAHOME["SDK"] = ".vela/sdk";
31
30
  VELAHOME["VVD"] = ".vela/vvd";
32
31
  return VELAHOME;
33
32
  }({});
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param mode Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE)
3
+ */
4
+ export declare function copyDir(source: string, target: string, mode?: number): Promise<void>;
5
+ /**
6
+ * @param mode Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE)
7
+ */
8
+ export declare function copyDirSync(source: string, target: string, mode?: number): void;
package/lib/utils/file.js CHANGED
@@ -1 +1,48 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.copyDir = copyDir;
7
+ exports.copyDirSync = copyDirSync;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _promises = _interopRequireDefault(require("fs/promises"));
10
+ var _fs = _interopRequireDefault(require("fs"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ /**
13
+ * @param mode Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE)
14
+ */
15
+ async function copyDir(source, target, mode) {
16
+ const entries = await _promises.default.readdir(source, {
17
+ withFileTypes: true
18
+ });
19
+ await _promises.default.mkdir(target, {
20
+ recursive: true
21
+ });
22
+ await Promise.all(entries.map(entry => {
23
+ const srcPath = _path.default.join(source, entry.name);
24
+ const destPath = _path.default.join(target, entry.name);
25
+ return entry.isDirectory() ? copyDir(srcPath, destPath, mode) : _promises.default.copyFile(srcPath, destPath, mode);
26
+ }));
27
+ }
28
+
29
+ /**
30
+ * @param mode Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE)
31
+ */
32
+ function copyDirSync(source, target, mode) {
33
+ _fs.default.mkdirSync(target, {
34
+ recursive: true
35
+ });
36
+ const entries = _fs.default.readdirSync(source, {
37
+ withFileTypes: true
38
+ });
39
+ for (const entry of entries) {
40
+ const srcPath = _path.default.join(source, entry.name);
41
+ const destPath = _path.default.join(target, entry.name);
42
+ if (entry.isDirectory()) {
43
+ copyDirSync(srcPath, destPath, mode);
44
+ } else {
45
+ _fs.default.copyFileSync(srcPath, destPath, mode);
46
+ }
47
+ }
48
+ }
@@ -24,9 +24,9 @@ const cpuArch = {
24
24
  x86_64: 'x86_64'
25
25
  };
26
26
 
27
- /** 获取mac电脑的CPU架构
28
- * node 15.0.0之后,m1芯片的mac的os.arch()才是arm64,在这之前都是x86
29
- * 所以15.0.0之前无法通过os.arch()区分,也无法通过execSync('uname -m')区分
27
+ /** 获取mac电脑的CPU架构
28
+ * node 15.0.0之后,m1芯片的mac的os.arch()才是arm64,在这之前都是x86
29
+ * 所以15.0.0之前无法通过os.arch()区分,也无法通过execSync('uname -m')区分
30
30
  */
31
31
  function getSystemArch() {
32
32
  const platform = _os.default.platform();
@@ -56,8 +56,8 @@ function killProcessByPid(pid) {
56
56
  }
57
57
  }
58
58
 
59
- /**
60
- * 根据命令杀死进程
59
+ /**
60
+ * 根据命令杀死进程
61
61
  */
62
62
  async function killProcessByCmd(cmd) {
63
63
  if (!cmd) return;
@@ -76,11 +76,11 @@ async function sleep(time) {
76
76
  return new Promise(resolve => setTimeout(resolve, time));
77
77
  }
78
78
 
79
- /**
80
- * 重复执行某个任务直到成功,或者超过最大次数
81
- * @param task 任务,需要返回 bool 值表示是否执行成功
82
- * @param {Number=} maxCount 最大重试次数
83
- * @param {number=} duration 每次重试的间隔
79
+ /**
80
+ * 重复执行某个任务直到成功,或者超过最大次数
81
+ * @param task 任务,需要返回 bool 值表示是否执行成功
82
+ * @param {Number=} maxCount 最大重试次数
83
+ * @param {number=} duration 每次重试的间隔
84
84
  */
85
85
  async function tryRun(task) {
86
86
  let maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
@@ -90,11 +90,11 @@ async function tryRun(task) {
90
90
  return Boolean(await task()) || (await delayRun(() => tryRun(task, maxCount, duration, currentCount + 1), duration));
91
91
  }
92
92
 
93
- /**
94
- * 延迟执行某个任务
95
- * @param task
96
- * @param duration
97
- * @returns
93
+ /**
94
+ * 延迟执行某个任务
95
+ * @param task
96
+ * @param duration
97
+ * @returns
98
98
  */
99
99
  async function delayRun(task) {
100
100
  let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
@@ -105,10 +105,10 @@ async function delayRun(task) {
105
105
  });
106
106
  }
107
107
 
108
- /**
109
- * 为avdPort寻找一个不被占用的端口
110
- * 端口号必须是偶数且在5555和5585之间
111
- * @returns {number}
108
+ /**
109
+ * 为avdPort寻找一个不被占用的端口
110
+ * 端口号必须是偶数且在5555和5585之间
111
+ * @returns {number}
112
112
  */
113
113
  async function getEvenPort() {
114
114
  const startPort = 5556;
@@ -1,27 +1,36 @@
1
1
  import { Readable } from 'stream';
2
- import { MouseEvent } from './types/MouseEvent';
3
- import { GrpcKeyboardEvent } from './types/KeyEvent';
4
2
  import { GrpcClient } from './types/GrpcClient';
5
3
  import { EmulatorConfig } from '../../emulatorutil/running';
6
4
  import { Metadata } from '@grpc/grpc-js';
7
- export default class GrpcEmulator {
5
+ import { ImageFormat, KeyboardEvent, LogMessage, MouseEvent, SensorValue } from './types/proto-types';
6
+ import { UiControllerClient } from './types/UiControllerClient';
7
+ import { ConnectivityState } from '@grpc/grpc-js/build/src/connectivity-state';
8
+ export declare class GrpcEmulator {
8
9
  eConf: EmulatorConfig;
9
- protoPath: string;
10
+ protoPath: string[];
10
11
  client: GrpcClient;
12
+ uiClient: UiControllerClient;
11
13
  connected: boolean;
12
14
  token: string;
13
15
  authMate: Metadata;
14
16
  deadline: Date;
15
17
  controller: any;
16
18
  screenshotStream?: Readable;
17
- constructor(eConf: EmulatorConfig, protoPath: string);
19
+ logcatStream?: Readable;
20
+ state: ConnectivityState;
21
+ constructor(eConf: EmulatorConfig, protoPath: string[]);
18
22
  close(): void;
19
23
  getAuthMeta(): Metadata;
20
24
  waitForReady(): Promise<boolean>;
21
- startStream(onStreamScreenshot: (buffer: Buffer) => void): Promise<void>;
25
+ streamScreenshot(imageFormat?: ImageFormat): Promise<Readable>;
22
26
  getScreenshot(): Promise<Buffer>;
23
27
  getStatus(): Promise<unknown>;
24
28
  sendMouse(message: MouseEvent): void;
25
- sendKey(data: GrpcKeyboardEvent): void;
29
+ sendKey(data: KeyboardEvent): void;
30
+ showExtendedControls(paneIndex?: number): Promise<unknown>;
31
+ closeExtendedControls(): Promise<unknown>;
32
+ setSensor(sensorValue: SensorValue): Promise<unknown>;
33
+ getSensor(sensorValue: SensorValue): Promise<unknown>;
34
+ streamLogcat(params?: LogMessage): Promise<Readable>;
26
35
  }
27
36
  export declare function createGrpcClient(eConf: EmulatorConfig): GrpcEmulator;