UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

232 lines (229 loc) • 7.91 kB
import { NitroModules } from "react-native-nitro-modules"; import { rethrowNativeError } from "../nativeError.native.js"; import { RecognizedDataType, scannerConfiguration } from "./configuration.native.js"; import { recognizedItems } from "./recognizedItems.native.js"; function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }); } else obj[key] = value; return obj; } function create() { if (!NitroModules.hasHybridObject("OneDataScanner")) throw new Error("DataScannerViewController needs an iOS build"); return NitroModules.createHybridObject("OneDataScanner"); } var capabilities; var DataScannerViewController = /* @__PURE__ */ (function() { "use strict"; function DataScannerViewController2(options) { var _this = this; _class_call_check(this, DataScannerViewController2); _define_property(this, "native", create()); _define_property(this, "configuration", void 0); _define_property(this, "delegate", null); this.configuration = scannerConfiguration(options); this.native.configure(this.configuration); this.native.setDelegate(function() { var _this_delegate_dataScannerDidZoom, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_dataScannerDidZoom = _this_delegate.dataScannerDidZoom) === null || _this_delegate_dataScannerDidZoom === void 0 ? void 0 : _this_delegate_dataScannerDidZoom.call(_this_delegate, _this); }, function(item) { var _this_delegate_dataScanner, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_dataScanner = _this_delegate.dataScanner) === null || _this_delegate_dataScanner === void 0 ? void 0 : _this_delegate_dataScanner.call(_this_delegate, _this, { didTapOn: item }); }, function(items, allItems) { var _this_delegate_dataScanner, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_dataScanner = _this_delegate.dataScanner) === null || _this_delegate_dataScanner === void 0 ? void 0 : _this_delegate_dataScanner.call(_this_delegate, _this, { didAdd: items, allItems }); }, function(items, allItems) { var _this_delegate_dataScanner, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_dataScanner = _this_delegate.dataScanner) === null || _this_delegate_dataScanner === void 0 ? void 0 : _this_delegate_dataScanner.call(_this_delegate, _this, { didUpdate: items, allItems }); }, function(items, allItems) { var _this_delegate_dataScanner, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_dataScanner = _this_delegate.dataScanner) === null || _this_delegate_dataScanner === void 0 ? void 0 : _this_delegate_dataScanner.call(_this_delegate, _this, { didRemove: items, allItems }); }, function(error) { var _this_delegate_dataScanner, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_dataScanner = _this_delegate.dataScanner) === null || _this_delegate_dataScanner === void 0 ? void 0 : _this_delegate_dataScanner.call(_this_delegate, _this, { becameUnavailableWithError: error }); }); } _create_class(DataScannerViewController2, [ { key: "recognizedDataTypes", get: function get() { return this.configuration.recognizedDataTypes.map(function(value) { var _value_languages, _value_symbologies; return { ...value, languages: (_value_languages = value.languages) === null || _value_languages === void 0 ? void 0 : _value_languages.slice(), symbologies: (_value_symbologies = value.symbologies) === null || _value_symbologies === void 0 ? void 0 : _value_symbologies.slice() }; }); } }, { key: "qualityLevel", get: function get() { return this.configuration.qualityLevel; } }, { key: "recognizesMultipleItems", get: function get() { return this.configuration.recognizesMultipleItems; } }, { key: "isHighFrameRateTrackingEnabled", get: function get() { return this.configuration.isHighFrameRateTrackingEnabled; } }, { key: "isPinchToZoomEnabled", get: function get() { return this.configuration.isPinchToZoomEnabled; } }, { key: "isGuidanceEnabled", get: function get() { return this.configuration.isGuidanceEnabled; } }, { key: "isHighlightingEnabled", get: function get() { return this.configuration.isHighlightingEnabled; } }, { key: "regionOfInterest", get: function get() { return this.native.regionOfInterest; }, set: function set(value) { this.native.regionOfInterest = value; } }, { key: "isScanning", get: function get() { return this.native.isScanning; } }, { key: "minZoomFactor", get: function get() { return this.native.getMinZoomFactor(); } }, { key: "maxZoomFactor", get: function get() { return this.native.getMaxZoomFactor(); } }, { key: "zoomFactor", get: function get() { return this.native.zoomFactor; }, set: function set(value) { this.native.zoomFactor = value; } }, { key: "recognizedItems", get: function get() { return recognizedItems(this.native); } }, { key: "present", value: function present() { var animated = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; return this.native.present(animated).catch(rethrowNativeError); } }, { key: "dismiss", value: function dismiss() { var animated = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; return this.native.dismiss(animated).catch(rethrowNativeError); } }, { key: "startScanning", value: function startScanning() { try { this.native.startScanning(); } catch (error) { rethrowNativeError(error); } } }, { key: "stopScanning", value: function stopScanning() { this.native.stopScanning(); } }, { key: "capturePhoto", value: function capturePhoto() { return this.native.capturePhoto().catch(rethrowNativeError); } } ], [ { key: "isSupported", get: function get() { return (capabilities !== null && capabilities !== void 0 ? capabilities : capabilities = create()).isSupported; } }, { key: "isAvailable", get: function get() { return (capabilities !== null && capabilities !== void 0 ? capabilities : capabilities = create()).isAvailable; } }, { key: "supportedTextRecognitionLanguages", get: function get() { return (capabilities !== null && capabilities !== void 0 ? capabilities : capabilities = create()).supportedTextRecognitionLanguages; } } ]); return DataScannerViewController2; })(); _define_property(DataScannerViewController, "RecognizedDataType", RecognizedDataType); export { DataScannerViewController }; //# sourceMappingURL=index.native.js.map