UNPKG

@and2long/react-native-uvc-camera

Version:
33 lines 1.33 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { NativeModules, findNodeHandle, requireNativeComponent } from 'react-native'; const CameraModule = NativeModules.UVCCameraView; if (CameraModule == null) { console.error("Camera: Native Module 'UVCCameraView' was null!"); } const ComponentName = 'UVCCameraView'; const NativeUVCCameraView = requireNativeComponent(ComponentName); export class UVCCamera extends React.PureComponent { constructor(props) { super(props); this.ref = /*#__PURE__*/React.createRef(); } get handle() { return findNodeHandle(this.ref.current); } render() { return /*#__PURE__*/React.createElement(NativeUVCCameraView, _extends({}, this.props, { ref: this.ref })); } async openCamera() { await CameraModule.openCamera(this.handle); } async closeCamera() { await CameraModule.closeCamera(this.handle); } async takePhoto() { return await CameraModule.takePhoto(this.handle); } } //# sourceMappingURL=UVCCamera.js.map