android-emulator-webrtc 1.0.16 → 1.0.17
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/.vscode/settings.json +3 -0
- package/api_descriptor.pb +0 -0
- package/dist/components/emulator/emulator.js +43 -56
- package/dist/components/emulator/net/emulator_status.js +15 -23
- package/dist/components/emulator/net/jsep_protocol_driver.js +54 -104
- package/dist/components/emulator/net/logcat.js +34 -34
- package/dist/components/emulator/views/event_handler.js +57 -75
- package/dist/components/emulator/views/resizing_component.js +86 -0
- package/dist/components/emulator/views/simple_png_view.js +90 -206
- package/dist/components/emulator/views/webrtc_view.js +110 -174
- package/dist/index.js +4 -8
- package/dist/proto/emulator_controller_grpc_web_pb.js +454 -634
- package/dist/proto/emulator_controller_pb.js +4620 -3945
- package/dist/proto/emulator_web_client.js +26 -56
- package/dist/proto/rtc_service_grpc_web_pb.js +35 -101
- package/dist/proto/rtc_service_pb.js +31 -88
- package/package.json +25 -21
- package/proto/README.MD +1 -1
- package/proto/emulator_controller.proto +1090 -804
- package/protoc-plugin/grpc_generator.cc +661 -549
- package/src/components/emulator/emulator.js +3 -10
- package/src/components/emulator/net/jsep_protocol_driver.js +0 -2
- package/src/components/emulator/views/resizing_component.js +65 -0
- package/src/components/emulator/views/simple_png_view.js +81 -134
- package/src/components/emulator/views/webrtc_view.js +87 -95
- package/test/emulator.test.js +7 -7
- package/test/event_handler.test.js +3 -0
- package/test/jsep_protocol_driver.test.js +3 -0
- package/test/resizing_component.test.js +37 -0
- package/test/simple_png_view.test.js +54 -42
- package/test/touch_event_handler.test.js +3 -1
|
@@ -1,44 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = withMouseKeyHandler;
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
17
|
var _react = _interopRequireDefault(require("react"));
|
|
29
|
-
|
|
30
18
|
var Proto = _interopRequireWildcard(require("../../../proto/emulator_controller_pb"));
|
|
31
|
-
|
|
32
19
|
var _emulator_status = _interopRequireDefault(require("../net/emulator_status"));
|
|
33
|
-
|
|
34
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
-
|
|
36
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
|
|
38
22
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
23
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /*
|
|
24
|
+
* Copyright 2019 The Android Open Source Project
|
|
25
|
+
*
|
|
26
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27
|
+
* you may not use this file except in compliance with the License.
|
|
28
|
+
* You may obtain a copy of the License at
|
|
29
|
+
*
|
|
30
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
+
*
|
|
32
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
+
* See the License for the specific language governing permissions and
|
|
36
|
+
* limitations under the License.
|
|
37
|
+
*/
|
|
42
38
|
/**
|
|
43
39
|
* A handler that extends a view to send key/mouse events to the emulator.
|
|
44
40
|
* It wraps the inner component in a div, and will use the jsep handler
|
|
@@ -50,16 +46,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
50
46
|
* You usually want to wrap a EmulatorRtcview, or EmulatorPngView in it.
|
|
51
47
|
*/
|
|
52
48
|
function withMouseKeyHandler(WrappedComponent) {
|
|
53
|
-
var _class
|
|
54
|
-
|
|
55
|
-
return _temp = _class = /*#__PURE__*/function (_React$Component) {
|
|
49
|
+
var _class;
|
|
50
|
+
return _class = /*#__PURE__*/function (_React$Component) {
|
|
56
51
|
(0, _inherits2["default"])(_class, _React$Component);
|
|
57
|
-
|
|
58
52
|
var _super = _createSuper(_class);
|
|
59
|
-
|
|
60
53
|
function _class(props) {
|
|
61
54
|
var _this;
|
|
62
|
-
|
|
63
55
|
(0, _classCallCheck2["default"])(this, _class);
|
|
64
56
|
_this = _super.call(this, props);
|
|
65
57
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onContextMenu", function (e) {
|
|
@@ -68,16 +60,15 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
68
60
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "scaleCoordinates", function (xp, yp) {
|
|
69
61
|
// It is totally possible that we send clicks that are offscreen..
|
|
70
62
|
var _this$state = _this.state,
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
deviceWidth = _this$state.deviceWidth,
|
|
64
|
+
deviceHeight = _this$state.deviceHeight;
|
|
73
65
|
var _this$handler$current = _this.handler.current,
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
clientHeight = _this$handler$current.clientHeight,
|
|
67
|
+
clientWidth = _this$handler$current.clientWidth;
|
|
76
68
|
var scaleX = deviceWidth / clientWidth;
|
|
77
69
|
var scaleY = deviceHeight / clientHeight;
|
|
78
70
|
var x = Math.round(xp * scaleX);
|
|
79
71
|
var y = Math.round(yp * scaleY);
|
|
80
|
-
|
|
81
72
|
if (isNaN(x) || isNaN(y)) {
|
|
82
73
|
console.log("Ignoring: x: " + x + ", y:" + y);
|
|
83
74
|
return {
|
|
@@ -85,7 +76,6 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
85
76
|
y: -1
|
|
86
77
|
};
|
|
87
78
|
}
|
|
88
|
-
|
|
89
79
|
return {
|
|
90
80
|
x: x,
|
|
91
81
|
y: y,
|
|
@@ -96,16 +86,14 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
96
86
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setMouseCoordinates", function () {
|
|
97
87
|
// Forward the request to the jsep engine.
|
|
98
88
|
var _this$state$mouse = _this.state.mouse,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
mouseDown = _this$state$mouse.mouseDown,
|
|
90
|
+
mouseButton = _this$state$mouse.mouseButton,
|
|
91
|
+
xp = _this$state$mouse.xp,
|
|
92
|
+
yp = _this$state$mouse.yp;
|
|
103
93
|
var request = new Proto.MouseEvent();
|
|
104
|
-
|
|
105
94
|
var _this$scaleCoordinate = _this.scaleCoordinates(xp, yp),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
x = _this$scaleCoordinate.x,
|
|
96
|
+
y = _this$scaleCoordinate.y;
|
|
109
97
|
request.setX(x);
|
|
110
98
|
request.setY(y);
|
|
111
99
|
request.setButtons(mouseDown ? mouseButton : 0);
|
|
@@ -118,7 +106,6 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
118
106
|
if (e.keyCode === 32) {
|
|
119
107
|
e.preventDefault();
|
|
120
108
|
}
|
|
121
|
-
|
|
122
109
|
var request = new Proto.KeyboardEvent();
|
|
123
110
|
request.setEventtype(eventType === "KEYDOWN" ? Proto.KeyboardEvent.KeyEventType.KEYDOWN : eventType === "KEYUP" ? Proto.KeyboardEvent.KeyEventType.KEYUP : Proto.KeyboardEvent.KeyEventType.KEYPRESS);
|
|
124
111
|
request.setKey(e.key);
|
|
@@ -126,11 +113,11 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
126
113
|
jsep.send("keyboard", request);
|
|
127
114
|
};
|
|
128
115
|
});
|
|
116
|
+
// Properly handle the mouse events.
|
|
129
117
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseDown", function (e) {
|
|
130
118
|
var _e$nativeEvent = e.nativeEvent,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
119
|
+
offsetX = _e$nativeEvent.offsetX,
|
|
120
|
+
offsetY = _e$nativeEvent.offsetY;
|
|
134
121
|
_this.setState({
|
|
135
122
|
mouse: {
|
|
136
123
|
xp: offsetX,
|
|
@@ -144,9 +131,8 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
144
131
|
});
|
|
145
132
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseUp", function (e) {
|
|
146
133
|
var _e$nativeEvent2 = e.nativeEvent,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
offsetX = _e$nativeEvent2.offsetX,
|
|
135
|
+
offsetY = _e$nativeEvent2.offsetY;
|
|
150
136
|
_this.setState({
|
|
151
137
|
mouse: {
|
|
152
138
|
xp: offsetX,
|
|
@@ -160,67 +146,67 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
160
146
|
// Let's not overload the endpoint with useless events.
|
|
161
147
|
if (!_this.state.mouse.mouseDown) return;
|
|
162
148
|
var _e$nativeEvent3 = e.nativeEvent,
|
|
163
|
-
|
|
164
|
-
|
|
149
|
+
offsetX = _e$nativeEvent3.offsetX,
|
|
150
|
+
offsetY = _e$nativeEvent3.offsetY;
|
|
165
151
|
var mouse = _this.state.mouse;
|
|
166
152
|
mouse.xp = offsetX;
|
|
167
153
|
mouse.yp = offsetY;
|
|
168
|
-
|
|
169
154
|
_this.setState({
|
|
170
155
|
mouse: mouse
|
|
171
156
|
}, _this.setMouseCoordinates);
|
|
172
157
|
});
|
|
158
|
+
/**
|
|
159
|
+
* Scales an axis to linux input codes that the emulator understands.
|
|
160
|
+
*
|
|
161
|
+
* @param {*} value The value to transform.
|
|
162
|
+
* @param {*} minIn The minimum value, the lower bound of the value param.
|
|
163
|
+
* @param {*} maxIn The maximum value, the upper bound of the value param.
|
|
164
|
+
*/
|
|
173
165
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "scaleAxis", function (value, minIn, maxIn) {
|
|
174
166
|
var minOut = 0x0; // EV_ABS_MIN
|
|
175
|
-
|
|
176
167
|
var maxOut = 0x7fff; // EV_ABS_MAX
|
|
177
|
-
|
|
178
168
|
var rangeOut = maxOut - minOut;
|
|
179
169
|
var rangeIn = maxIn - minIn;
|
|
180
|
-
|
|
181
170
|
if (rangeIn < 1) {
|
|
182
171
|
return minOut + rangeOut / 2;
|
|
183
172
|
}
|
|
184
|
-
|
|
185
173
|
return (value - minIn) * rangeOut / rangeIn + minOut | 0;
|
|
186
174
|
});
|
|
187
175
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setTouchCoordinates", function (type, touches, minForce, maxForce) {
|
|
188
176
|
// We need to calculate the offset of the touch events.
|
|
189
177
|
var rect = _this.handler.current.getBoundingClientRect();
|
|
190
|
-
|
|
191
178
|
var scaleCoordinates = _this.scaleCoordinates;
|
|
192
179
|
var touchesToSend = Object.keys(touches).map(function (index) {
|
|
193
180
|
var touch = touches[index];
|
|
194
181
|
var clientX = touch.clientX,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
182
|
+
clientY = touch.clientY,
|
|
183
|
+
identifier = touch.identifier,
|
|
184
|
+
force = touch.force,
|
|
185
|
+
radiusX = touch.radiusX,
|
|
186
|
+
radiusY = touch.radiusY;
|
|
200
187
|
var offsetX = clientX - rect.left;
|
|
201
188
|
var offsetY = clientY - rect.top;
|
|
202
|
-
|
|
203
189
|
var _scaleCoordinates = scaleCoordinates(offsetX, offsetY),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
190
|
+
x = _scaleCoordinates.x,
|
|
191
|
+
y = _scaleCoordinates.y,
|
|
192
|
+
scaleX = _scaleCoordinates.scaleX,
|
|
193
|
+
scaleY = _scaleCoordinates.scaleY;
|
|
209
194
|
var scaledRadiusX = 2 * radiusX * scaleX;
|
|
210
195
|
var scaledRadiusY = 2 * radiusY * scaleY;
|
|
211
196
|
var protoTouch = new Proto.Touch();
|
|
212
197
|
protoTouch.setX(x | 0);
|
|
213
198
|
protoTouch.setY(y | 0);
|
|
214
|
-
protoTouch.setIdentifier(identifier);
|
|
199
|
+
protoTouch.setIdentifier(identifier);
|
|
215
200
|
|
|
201
|
+
// Normalize the force
|
|
216
202
|
var MT_PRESSURE = _this.scaleAxis(Math.max(minForce, Math.min(maxForce, force)), 0, 1);
|
|
217
|
-
|
|
218
203
|
protoTouch.setPressure(MT_PRESSURE);
|
|
219
204
|
protoTouch.setTouchMajor(Math.max(scaledRadiusX, scaledRadiusY) | 0);
|
|
220
205
|
protoTouch.setTouchMinor(Math.min(scaledRadiusX, scaledRadiusY) | 0);
|
|
221
206
|
return protoTouch;
|
|
222
|
-
});
|
|
207
|
+
});
|
|
223
208
|
|
|
209
|
+
// Make the grpc call.
|
|
224
210
|
var requestTouchEvent = new Proto.TouchEvent();
|
|
225
211
|
requestTouchEvent.setTouchesList(touchesToSend);
|
|
226
212
|
var jsep = _this.props.jsep;
|
|
@@ -232,10 +218,9 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
232
218
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Touch_events
|
|
233
219
|
if (e.cancelable) {
|
|
234
220
|
e.preventDefault();
|
|
235
|
-
}
|
|
221
|
+
}
|
|
222
|
+
// Some browsers do net have a force sensor, so we have to "fake" values
|
|
236
223
|
// for start/move/end events.
|
|
237
|
-
|
|
238
|
-
|
|
239
224
|
_this.setTouchCoordinates(e.nativeEvent.type, e.nativeEvent.changedTouches, minForce, maxForce);
|
|
240
225
|
};
|
|
241
226
|
});
|
|
@@ -257,7 +242,6 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
257
242
|
_this.status = new _emulator_status["default"](emulator);
|
|
258
243
|
return _this;
|
|
259
244
|
}
|
|
260
|
-
|
|
261
245
|
(0, _createClass2["default"])(_class, [{
|
|
262
246
|
key: "componentDidMount",
|
|
263
247
|
value: function componentDidMount() {
|
|
@@ -267,7 +251,6 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
267
251
|
key: "getScreenSize",
|
|
268
252
|
value: function getScreenSize() {
|
|
269
253
|
var _this2 = this;
|
|
270
|
-
|
|
271
254
|
this.status.updateStatus(function (state) {
|
|
272
255
|
_this2.setState({
|
|
273
256
|
deviceWidth: parseInt(state.hardwareConfig["hw.lcd.width"]) || 1080,
|
|
@@ -309,8 +292,7 @@ function withMouseKeyHandler(WrappedComponent) {
|
|
|
309
292
|
}(_react["default"].Component), (0, _defineProperty2["default"])(_class, "propTypes", {
|
|
310
293
|
/** The emulator object */
|
|
311
294
|
emulator: _propTypes["default"].object.isRequired,
|
|
312
|
-
|
|
313
295
|
/** Jsep protocol driver, used to send mouse & touch events. */
|
|
314
296
|
jsep: _propTypes["default"].object.isRequired
|
|
315
|
-
}),
|
|
297
|
+
}), _class;
|
|
316
298
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _resizeObserver = _interopRequireDefault(require("@react-hook/resize-observer"));
|
|
12
|
+
/**
|
|
13
|
+
* @jest-environment jsdom
|
|
14
|
+
*/
|
|
15
|
+
/*
|
|
16
|
+
* Copyright 2023 The Android Open Source Project
|
|
17
|
+
*
|
|
18
|
+
* Licensed under the Apache License, Version 2.0 (the "License")
|
|
19
|
+
* you may not use this file except in compliance with the License.
|
|
20
|
+
* You may obtain a copy of the License at
|
|
21
|
+
*
|
|
22
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
* See the License for the specific language governing permissions and
|
|
28
|
+
* limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function useSize(target, onResize) {
|
|
32
|
+
var _React$useState = _react["default"].useState(),
|
|
33
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
34
|
+
size = _React$useState2[0],
|
|
35
|
+
setSize = _React$useState2[1];
|
|
36
|
+
_react["default"].useLayoutEffect(function () {
|
|
37
|
+
if (target) {
|
|
38
|
+
var newSize = target.getBoundingClientRect();
|
|
39
|
+
console.log("Resizing to ".concat(JSON.stringify(newSize)));
|
|
40
|
+
setSize(newSize);
|
|
41
|
+
if (onResize) {
|
|
42
|
+
onResize(newSize);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [target]);
|
|
46
|
+
|
|
47
|
+
// Where the magic happens
|
|
48
|
+
(0, _resizeObserver["default"])(target, function (entry) {
|
|
49
|
+
setSize(entry.contentRect);
|
|
50
|
+
if (onResize) {
|
|
51
|
+
console.log("Resizing to ".concat(JSON.stringify(entry.contentRect)));
|
|
52
|
+
onResize(entry.contentRect);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return size;
|
|
56
|
+
}
|
|
57
|
+
function ResizingComponent(_ref) {
|
|
58
|
+
var children = _ref.children,
|
|
59
|
+
onResize = _ref.onResize,
|
|
60
|
+
dataTestId = _ref["data-testid"];
|
|
61
|
+
// const ref = useRef();
|
|
62
|
+
var _React$useState3 = _react["default"].useState(),
|
|
63
|
+
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
64
|
+
target = _React$useState4[0],
|
|
65
|
+
setTarget = _React$useState4[1];
|
|
66
|
+
var size = useSize(target, onResize);
|
|
67
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
68
|
+
style: {
|
|
69
|
+
width: "100%",
|
|
70
|
+
height: "100%"
|
|
71
|
+
},
|
|
72
|
+
ref: setTarget,
|
|
73
|
+
"data-testid": dataTestId
|
|
74
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
75
|
+
style: {
|
|
76
|
+
width: size === null || size === void 0 ? void 0 : size.width,
|
|
77
|
+
height: size === null || size === void 0 ? void 0 : size.height
|
|
78
|
+
}
|
|
79
|
+
}, children));
|
|
80
|
+
}
|
|
81
|
+
ResizingComponent.propTypes = {
|
|
82
|
+
onResize: _propTypes["default"].func,
|
|
83
|
+
"data-testid": _propTypes["default"].string
|
|
84
|
+
};
|
|
85
|
+
var _default = ResizingComponent;
|
|
86
|
+
exports["default"] = _default;
|