UNPKG

one

Version:

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

255 lines (252 loc) • 9.07 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var index_native_exports = {}; __export(index_native_exports, { DataScannerViewController: () => DataScannerViewController }); module.exports = __toCommonJS(index_native_exports); var import_react_native_nitro_modules = require("react-native-nitro-modules"); var import_nativeError = require("../nativeError.native.js"); var import_configuration = require("./configuration.native.js"); var import_recognizedItems = require("./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 (!import_react_native_nitro_modules.NitroModules.hasHybridObject("OneDataScanner")) throw new Error("DataScannerViewController needs an iOS build"); return import_react_native_nitro_modules.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 = (0, import_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 (0, import_recognizedItems.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(import_nativeError.rethrowNativeError); } }, { key: "dismiss", value: function dismiss() { var animated = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; return this.native.dismiss(animated).catch(import_nativeError.rethrowNativeError); } }, { key: "startScanning", value: function startScanning() { try { this.native.startScanning(); } catch (error) { (0, import_nativeError.rethrowNativeError)(error); } } }, { key: "stopScanning", value: function stopScanning() { this.native.stopScanning(); } }, { key: "capturePhoto", value: function capturePhoto() { return this.native.capturePhoto().catch(import_nativeError.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", import_configuration.RecognizedDataType); //# sourceMappingURL=index.native.js.map