Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-barcodescanner

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-barcodescanner - npm Package Compare versions

Comparing version 3.4.2 to 4.0.0

3

barcodescanner-common.d.ts

@@ -1,3 +0,2 @@

import { ContentView } from "tns-core-modules/ui/content-view";
import { Property } from "tns-core-modules/ui/core/properties";
import { ContentView, Property } from "@nativescript/core";
export declare type BarcodeFormat = "QR_CODE" | "PDF_417" | "AZTEC" | "UPC_E" | "CODE_39" | "CODE_39_MOD_43" | "CODE_93" | "CODE_128" | "DATA_MATRIX" | "EAN_8" | "ITF" | "EAN_13" | "UPC_A" | "CODABAR" | "MAXICODE" | "RSS_14" | "INTERLEAVED_2_OF_5";

@@ -4,0 +3,0 @@ export interface ScanResult {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var content_view_1 = require("tns-core-modules/ui/content-view");
var properties_1 = require("tns-core-modules/ui/core/properties");
var view_base_1 = require("tns-core-modules/ui/core/view-base");
exports.formatsProperty = new properties_1.Property({
exports.BarcodeScannerView = exports.pauseProperty = exports.reportDuplicatesProperty = exports.beepOnScanProperty = exports.preferFrontCameraProperty = exports.formatsProperty = void 0;
const core_1 = require("@nativescript/core");
exports.formatsProperty = new core_1.Property({
name: "formats",
defaultValue: null,
});
exports.preferFrontCameraProperty = new properties_1.Property({
exports.preferFrontCameraProperty = new core_1.Property({
name: "preferFrontCamera",
defaultValue: false,
valueConverter: view_base_1.booleanConverter
valueConverter: core_1.booleanConverter
});
exports.beepOnScanProperty = new properties_1.Property({
exports.beepOnScanProperty = new core_1.Property({
name: "beepOnScan",
defaultValue: true,
valueConverter: view_base_1.booleanConverter
valueConverter: core_1.booleanConverter
});
exports.reportDuplicatesProperty = new properties_1.Property({
exports.reportDuplicatesProperty = new core_1.Property({
name: "reportDuplicates",
defaultValue: false,
valueConverter: view_base_1.booleanConverter
valueConverter: core_1.booleanConverter
});
exports.pauseProperty = new properties_1.Property({
exports.pauseProperty = new core_1.Property({
name: "pause",
defaultValue: false,
valueConverter: view_base_1.booleanConverter
valueConverter: core_1.booleanConverter
});
var BarcodeScannerView = (function (_super) {
__extends(BarcodeScannerView, _super);
function BarcodeScannerView() {
return _super !== null && _super.apply(this, arguments) || this;
class BarcodeScannerView extends core_1.ContentView {
pauseScanning() {
}
BarcodeScannerView.prototype.pauseScanning = function () {
};
BarcodeScannerView.prototype.resumeScanning = function () {
};
BarcodeScannerView.prototype[exports.formatsProperty.setNative] = function (value) {
resumeScanning() {
}
[exports.formatsProperty.setNative](value) {
this.formats = value;
};
BarcodeScannerView.prototype[exports.preferFrontCameraProperty.setNative] = function (value) {
}
[exports.preferFrontCameraProperty.setNative](value) {
this.preferFrontCamera = value;
};
BarcodeScannerView.prototype[exports.beepOnScanProperty.setNative] = function (value) {
}
[exports.beepOnScanProperty.setNative](value) {
this.beepOnScan = value;
};
BarcodeScannerView.prototype[exports.reportDuplicatesProperty.setNative] = function (value) {
}
[exports.reportDuplicatesProperty.setNative](value) {
this.reportDuplicates = value;
};
BarcodeScannerView.prototype[exports.pauseProperty.setNative] = function (value) {
}
[exports.pauseProperty.setNative](value) {
this.pause = value;
this.pause ? this.pauseScanning() : this.resumeScanning();
};
BarcodeScannerView.scanResultEvent = "scanResult";
return BarcodeScannerView;
}(content_view_1.ContentView));
}
}
exports.BarcodeScannerView = BarcodeScannerView;
BarcodeScannerView.scanResultEvent = "scanResult";
exports.pauseProperty.register(BarcodeScannerView);

@@ -60,0 +54,0 @@ exports.formatsProperty.register(BarcodeScannerView);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var appModule = require("tns-core-modules/application");
var utils = require("tns-core-modules/utils/utils");
var SCANNER_REQUEST_CODE = 444;
var AppPackageName = useAndroidX() ? global.androidx.core.app : android.support.v4.app;
var ContentPackageName = useAndroidX() ? global.androidx.core.content : android.support.v4.content;
var LocalBroadcastManagerPackageName = useAndroidX() ? global.androidx.localbroadcastmanager.content : android.support.v4.content;
var _onScanReceivedCallback = undefined;
var _onContinuousScanResult = undefined;
exports.BarcodeScanner = void 0;
const core_1 = require("@nativescript/core");
const SCANNER_REQUEST_CODE = 444;
const AppPackageName = useAndroidX() ? global.androidx.core.app : android.support.v4.app;
const ContentPackageName = useAndroidX() ? global.androidx.core.content : android.support.v4.content;
const LocalBroadcastManagerPackageName = useAndroidX() ? global.androidx.localbroadcastmanager.content : android.support.v4.content;
let _onScanReceivedCallback = undefined;
let _onContinuousScanResult = undefined;
function useAndroidX() {
return global.androidx && global.androidx.appcompat;
}
var BarcodeScanner = (function () {
function BarcodeScanner() {
var _this = this;
class BarcodeScanner {
constructor() {
this.broadcastManager = null;
this.uniquelyScannedCodes = [];
appModule.android.on(appModule.AndroidApplication.activityRequestPermissionsEvent, function (args) {
for (var i = 0; i < args.permissions.length; i++) {
core_1.Application.android.on(core_1.AndroidApplication.activityRequestPermissionsEvent, (args) => {
for (let i = 0; i < args.permissions.length; i++) {
if (args.grantResults[i] === android.content.pm.PackageManager.PERMISSION_DENIED) {
if (_this.onPermissionRejected) {
_this.onPermissionRejected("Please allow access to the Camera and try again.");
if (this.onPermissionRejected) {
this.onPermissionRejected("Please allow access to the Camera and try again.");
}

@@ -31,24 +30,24 @@ else {

}
if (_this.onPermissionGranted) {
_this.onPermissionGranted();
if (this.onPermissionGranted) {
this.onPermissionGranted();
}
});
}
BarcodeScanner.prototype.wasCameraPermissionGranted = function () {
var hasPermission = android.os.Build.VERSION.SDK_INT < 23;
wasCameraPermissionGranted() {
let hasPermission = android.os.Build.VERSION.SDK_INT < 23;
if (!hasPermission) {
hasPermission = android.content.pm.PackageManager.PERMISSION_GRANTED ===
ContentPackageName.ContextCompat.checkSelfPermission(utils.ad.getApplicationContext(), android.Manifest.permission.CAMERA);
ContentPackageName.ContextCompat.checkSelfPermission(core_1.Utils.ad.getApplicationContext(), android.Manifest.permission.CAMERA);
}
return hasPermission;
};
BarcodeScanner.prototype.requestCameraPermissionInternal = function (onPermissionGranted, reject) {
}
requestCameraPermissionInternal(onPermissionGranted, reject) {
this.onPermissionGranted = onPermissionGranted;
this.onPermissionRejected = reject;
AppPackageName.ActivityCompat.requestPermissions(appModule.android.foregroundActivity, [android.Manifest.permission.CAMERA], 234);
};
BarcodeScanner.prototype.available = function () {
return new Promise(function (resolve, reject) {
AppPackageName.ActivityCompat.requestPermissions(core_1.Application.android.foregroundActivity, [android.Manifest.permission.CAMERA], 234);
}
available() {
return new Promise((resolve, reject) => {
try {
resolve(utils.ad.getApplicationContext().getPackageManager().hasSystemFeature(android.content.pm.PackageManager.FEATURE_CAMERA));
resolve(core_1.Utils.ad.getApplicationContext().getPackageManager().hasSystemFeature(android.content.pm.PackageManager.FEATURE_CAMERA));
}

@@ -60,14 +59,12 @@ catch (ex) {

});
};
BarcodeScanner.prototype.hasCameraPermission = function () {
var _this = this;
return new Promise(function (resolve) {
resolve(_this.wasCameraPermissionGranted());
}
hasCameraPermission() {
return new Promise((resolve) => {
resolve(this.wasCameraPermissionGranted());
});
};
BarcodeScanner.prototype.requestCameraPermission = function () {
var _this = this;
return new Promise(function (resolve, reject) {
}
requestCameraPermission() {
return new Promise((resolve, reject) => {
try {
_this.requestCameraPermissionInternal(resolve, reject);
this.requestCameraPermissionInternal(resolve, reject);
}

@@ -79,15 +76,14 @@ catch (ex) {

});
};
BarcodeScanner.prototype.stop = function () {
var _this = this;
return new Promise(function (resolve, reject) {
}
stop() {
return new Promise((resolve, reject) => {
try {
if (!_this.broadcastManager) {
if (!this.broadcastManager) {
reject("You found a bug in the plugin, please report that calling stop() failed with this message.");
return;
}
var stopIntent = new android.content.Intent("barcode-scanner-stop");
_this.broadcastManager.sendBroadcast(stopIntent);
const stopIntent = new android.content.Intent("barcode-scanner-stop");
this.broadcastManager.sendBroadcast(stopIntent);
if (_onScanReceivedCallback) {
_this.broadcastManager.unregisterReceiver(_onScanReceivedCallback);
this.broadcastManager.unregisterReceiver(_onScanReceivedCallback);
_onScanReceivedCallback = undefined;

@@ -101,10 +97,9 @@ }

});
};
BarcodeScanner.prototype.scan = function (arg) {
var _this = this;
return new Promise(function (resolve, reject) {
var onPermissionGranted = function () {
_this.uniquelyScannedCodes = [];
var intent = new android.content.Intent("com.google.zxing.client.android.SCAN");
intent.setPackage(appModule.android.context.getPackageName());
}
scan(arg) {
return new Promise((resolve, reject) => {
const onPermissionGranted = () => {
this.uniquelyScannedCodes = [];
const intent = new android.content.Intent("com.google.zxing.client.android.SCAN");
intent.setPackage(core_1.Application.android.context.getPackageName());
arg = arg || {};

@@ -137,16 +132,16 @@ if (arg.message) {

intent.putExtra(com.google.zxing.client.android.Intents.Scan.SAVE_HISTORY, false);
if (!_this.broadcastManager) {
_this.broadcastManager = LocalBroadcastManagerPackageName.LocalBroadcastManager.getInstance(utils.ad.getApplicationContext());
if (!this.broadcastManager) {
this.broadcastManager = LocalBroadcastManagerPackageName.LocalBroadcastManager.getInstance(core_1.Utils.ad.getApplicationContext());
}
var isContinuous = typeof arg.continuousScanCallback === "function";
const isContinuous = typeof arg.continuousScanCallback === "function";
if (isContinuous) {
_onContinuousScanResult = arg.continuousScanCallback;
intent.putExtra(com.google.zxing.client.android.Intents.Scan.BULK_SCAN, true);
var cb = android.content.BroadcastReceiver.extend({
onReceive: function (context, data) {
var format = data.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT_FORMAT);
var text = data.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT);
if (arg.reportDuplicates || _this.uniquelyScannedCodes.indexOf("[" + text + "][" + format + "]") === -1) {
_this.uniquelyScannedCodes.push("[" + text + "][" + format + "]");
var result = {
const cb = android.content.BroadcastReceiver.extend({
onReceive: (context, data) => {
const format = data.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT_FORMAT);
const text = data.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT);
if (arg.reportDuplicates || this.uniquelyScannedCodes.indexOf("[" + text + "][" + format + "]") === -1) {
this.uniquelyScannedCodes.push("[" + text + "][" + format + "]");
const result = {
format: format,

@@ -160,11 +155,11 @@ text: text

_onScanReceivedCallback = new cb();
_this.broadcastManager.registerReceiver(_onScanReceivedCallback, new android.content.IntentFilter("bulk-barcode-result"));
this.broadcastManager.registerReceiver(_onScanReceivedCallback, new android.content.IntentFilter("bulk-barcode-result"));
}
if (intent.resolveActivity(utils.ad.getApplicationContext().getPackageManager()) !== null) {
var onScanResult_1 = function (data) {
if (intent.resolveActivity(core_1.Utils.ad.getApplicationContext().getPackageManager()) !== null) {
const onScanResult = (data) => {
if (data.requestCode === SCANNER_REQUEST_CODE) {
_this.onPermissionGranted = null;
this.onPermissionGranted = null;
if (isContinuous) {
if (_onScanReceivedCallback) {
_this.broadcastManager.unregisterReceiver(_onScanReceivedCallback);
this.broadcastManager.unregisterReceiver(_onScanReceivedCallback);
_onScanReceivedCallback = undefined;

@@ -175,5 +170,5 @@ }

if (data.resultCode === android.app.Activity.RESULT_OK) {
var format = data.intent.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT_FORMAT);
var text = data.intent.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT);
var result = {
const format = data.intent.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT_FORMAT);
const text = data.intent.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT);
const result = {
format: format,

@@ -189,7 +184,7 @@ text: text

arg.closeCallback && arg.closeCallback();
appModule.android.off('activityResult', onScanResult_1);
core_1.Application.android.off('activityResult', onScanResult);
}
};
appModule.android.on('activityResult', onScanResult_1);
appModule.android.foregroundActivity.startActivityForResult(intent, SCANNER_REQUEST_CODE);
core_1.Application.android.on('activityResult', onScanResult);
core_1.Application.android.foregroundActivity.startActivityForResult(intent, SCANNER_REQUEST_CODE);
}

@@ -200,4 +195,4 @@ else {

};
if (!_this.wasCameraPermissionGranted()) {
_this.requestCameraPermissionInternal(onPermissionGranted.bind(_this), reject);
if (!this.wasCameraPermissionGranted()) {
this.requestCameraPermissionInternal(onPermissionGranted.bind(this), reject);
return;

@@ -207,6 +202,5 @@ }

});
};
return BarcodeScanner;
}());
}
}
exports.BarcodeScanner = BarcodeScanner;
//# sourceMappingURL=barcodescanner.android.js.map

@@ -6,2 +6,3 @@ import { BarcodeScannerView as BarcodeScannerBaseView, ScanOptions, ScanResult } from "./barcodescanner-common";

private _hasSupport;
private _delegate;
constructor();

@@ -8,0 +9,0 @@ createNativeView(): Object;

"use strict";
var QRCodeReaderDelegateImpl_1;
Object.defineProperty(exports, "__esModule", { value: true });
var barcodescanner_common_1 = require("./barcodescanner-common");
var BarcodeScannerView = (function (_super) {
__extends(BarcodeScannerView, _super);
function BarcodeScannerView() {
var _this = _super.call(this) || this;
_this._hasSupport = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) !== null;
if (_this._hasSupport) {
exports.BarcodeScanner = exports.BarcodeScannerView = void 0;
const barcodescanner_common_1 = require("./barcodescanner-common");
class BarcodeScannerView extends barcodescanner_common_1.BarcodeScannerView {
constructor() {
super();
this._hasSupport = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) !== null;
if (this._hasSupport) {
if (typeof AVAudioSession.sharedInstance().setCategoryModeOptionsError === "function") {

@@ -14,6 +15,5 @@ AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, 1);

}
return _this;
}
BarcodeScannerView.prototype.createNativeView = function () {
var v = _super.prototype.createNativeView.call(this);
createNativeView() {
let v = super.createNativeView();
if (this._hasSupport) {

@@ -23,11 +23,10 @@ this.initView();

return v;
};
BarcodeScannerView.prototype.initView = function () {
var _this = this;
var types = getBarcodeTypes(this.formats);
}
initView() {
const types = getBarcodeTypes(this.formats);
this._reader = QRCodeReader.readerWithMetadataObjectTypes(types);
var torch = false;
var flip = false;
var closeButtonLabel = null;
var cancelLabelBackgroundColor = null;
let torch = false;
let flip = false;
let closeButtonLabel = null;
let cancelLabelBackgroundColor = null;
if (this.preferFrontCamera) {

@@ -38,5 +37,5 @@ this._reader.switchDeviceInput();

this._scanner.modalPresentationStyle = 3;
var that = this;
var delegate = QRCodeReaderDelegateImpl.initWithOwner(new WeakRef(this));
delegate.setCallback(this.beepOnScan, true, this.reportDuplicates, this.formats, function (text, format) {
const that = this;
this._delegate = QRCodeReaderDelegateImpl.initWithOwner(new WeakRef(this));
this._delegate.setCallback(this.beepOnScan, true, this.reportDuplicates, this.formats, (text, format) => {
that.notify({

@@ -49,33 +48,32 @@ eventName: barcodescanner_common_1.BarcodeScannerView.scanResultEvent,

});
this._scanner.delegate = delegate;
setTimeout(function () {
if (_this.ios && _this.ios.layer) {
_this.ios.layer.insertSublayerAtIndex(_this._reader.previewLayer, 0);
if (!_this.pause) {
_this._reader.startScanning();
this._scanner.delegate = this._delegate;
setTimeout(() => {
if (this.ios && this.ios.layer) {
this.ios.layer.insertSublayerAtIndex(this._reader.previewLayer, 0);
if (!this.pause) {
this._reader.startScanning();
}
}
}, 0);
};
BarcodeScannerView.prototype.onLayout = function (left, top, right, bottom) {
_super.prototype.onLayout.call(this, left, top, right, bottom);
}
onLayout(left, top, right, bottom) {
super.onLayout(left, top, right, bottom);
if (this._hasSupport && this.ios && this._reader) {
this._reader.previewLayer.frame = this.ios.layer.bounds;
}
};
BarcodeScannerView.prototype.pauseScanning = function () {
}
pauseScanning() {
if (this._reader && this._reader.running()) {
this._reader.stopScanning();
}
};
BarcodeScannerView.prototype.resumeScanning = function () {
}
resumeScanning() {
if (this._reader && !this._reader.running()) {
this._reader.startScanning();
}
};
return BarcodeScannerView;
}(barcodescanner_common_1.BarcodeScannerView));
}
}
exports.BarcodeScannerView = BarcodeScannerView;
var BarcodeScanner = (function () {
function BarcodeScanner() {
class BarcodeScanner {
constructor() {
if (typeof AVAudioSession.sharedInstance().setCategoryModeOptionsError === "function") {

@@ -90,11 +88,11 @@ AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, 1);

}
BarcodeScanner.prototype._hasCameraPermission = function () {
var authStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
_hasCameraPermission() {
let authStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
return authStatus === 3;
};
BarcodeScanner.prototype._hasDeniedCameraPermission = function () {
var authStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
}
_hasDeniedCameraPermission() {
let authStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
return authStatus === 2 || authStatus === 1;
};
BarcodeScanner.prototype._addVolumeObserver = function () {
}
_addVolumeObserver() {
if (!this._observer) {

@@ -110,4 +108,4 @@ return;

}
};
BarcodeScanner.prototype._removeVolumeObserver = function () {
}
_removeVolumeObserver() {
try {

@@ -121,4 +119,4 @@ if (this._observerActive) {

}
};
BarcodeScanner.prototype._enableTorch = function () {
}
_enableTorch() {
this._device.lockForConfiguration();

@@ -128,4 +126,4 @@ this._device.setTorchModeOnWithLevelError(AVCaptureMaxAvailableTorchLevel);

this._device.unlockForConfiguration();
};
BarcodeScanner.prototype._disableTorch = function () {
}
_disableTorch() {
this._device.lockForConfiguration();

@@ -135,21 +133,19 @@ this._device.torchMode = 0;

this._device.unlockForConfiguration();
};
BarcodeScanner.prototype.available = function () {
var _this = this;
return new Promise(function (resolve, reject) {
resolve(!!_this._device);
}
available() {
return new Promise((resolve, reject) => {
resolve(!!this._device);
});
};
BarcodeScanner.prototype.hasCameraPermission = function () {
var _this = this;
return new Promise(function (resolve) {
resolve(_this._hasCameraPermission());
}
hasCameraPermission() {
return new Promise((resolve) => {
resolve(this._hasCameraPermission());
});
};
BarcodeScanner.prototype.requestCameraPermission = function () {
return new Promise(function (resolve, reject) {
var cameraStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
}
requestCameraPermission() {
return new Promise((resolve, reject) => {
const cameraStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
switch (cameraStatus) {
case 0: {
AVCaptureDevice.requestAccessForMediaTypeCompletionHandler(AVMediaTypeVideo, function (granted) { return granted ? resolve() : reject(); });
AVCaptureDevice.requestAccessForMediaTypeCompletionHandler(AVMediaTypeVideo, granted => granted ? resolve() : reject());
break;

@@ -168,13 +164,12 @@ }

});
};
BarcodeScanner.prototype.stop = function () {
var _this = this;
return new Promise(function (resolve, reject) {
}
stop() {
return new Promise((resolve, reject) => {
try {
_this.close();
_this._removeVolumeObserver();
if (_this._scanner) {
_this._scanner.stopScanning();
this.close();
this._removeVolumeObserver();
if (this._scanner) {
this._scanner.stopScanning();
}
_this._closeCallback && _this._closeCallback();
this._closeCallback && this._closeCallback();
resolve();

@@ -186,8 +181,7 @@ }

});
};
BarcodeScanner.prototype.scan = function (arg) {
var _this = this;
return new Promise(function (resolve, reject) {
}
scan(arg) {
return new Promise((resolve, reject) => {
try {
if (_this._hasDeniedCameraPermission()) {
if (this._hasDeniedCameraPermission()) {
if (arg.openSettingsIfPermissionWasPreviouslyDenied) {

@@ -199,27 +193,27 @@ UIApplication.sharedApplication.openURL(NSURL.URLWithString(UIApplicationOpenSettingsURLString));

}
_this._addVolumeObserver();
this._addVolumeObserver();
arg = arg || {};
var closeButtonLabel = arg.cancelLabel || "Close";
var isContinuous_1 = typeof arg.continuousScanCallback === "function";
_this._closeCallback = arg.closeCallback;
var types = getBarcodeTypes(arg.formats);
var reader = QRCodeReader.readerWithMetadataObjectTypes(types);
let closeButtonLabel = arg.cancelLabel || "Close";
let isContinuous = typeof arg.continuousScanCallback === "function";
this._closeCallback = arg.closeCallback;
const types = getBarcodeTypes(arg.formats);
const reader = QRCodeReader.readerWithMetadataObjectTypes(types);
if (arg.preferFrontCamera && reader.hasFrontDevice()) {
reader.switchDeviceInput();
}
var torch = arg.showTorchButton;
var flip = arg.showFlipCameraButton;
var startScanningAtLoad = true;
_this._scanner = QRCodeReaderViewController.readerWithCancelButtonTitleCodeReaderStartScanningAtLoadShowSwitchCameraButtonShowTorchButtonCancelButtonBackgroundColor(closeButtonLabel, reader, startScanningAtLoad, flip, torch, arg.cancelLabelBackgroundColor);
_this._scanner.modalPresentationStyle = arg.fullScreen ? 0 : 2;
_this._scanDelegate = QRCodeReaderDelegateImpl.initWithOwner(new WeakRef(_this));
_this._scanner.delegate = _this._scanDelegate;
_this._scanDelegate.setCallback(arg.beepOnScan !== false, isContinuous_1, arg.reportDuplicates, arg.formats, function (text, barcodeFormat) {
let torch = arg.showTorchButton;
let flip = arg.showFlipCameraButton;
let startScanningAtLoad = true;
this._scanner = QRCodeReaderViewController.readerWithCancelButtonTitleCodeReaderStartScanningAtLoadShowSwitchCameraButtonShowTorchButtonCancelButtonBackgroundColor(closeButtonLabel, reader, startScanningAtLoad, flip, torch, arg.cancelLabelBackgroundColor);
this._scanner.modalPresentationStyle = arg.fullScreen ? 0 : 2;
this._scanDelegate = QRCodeReaderDelegateImpl.initWithOwner(new WeakRef(this));
this._scanner.delegate = this._scanDelegate;
this._scanDelegate.setCallback(arg.beepOnScan !== false, isContinuous, arg.reportDuplicates, arg.formats, (text, barcodeFormat) => {
if (text === undefined) {
_this._removeVolumeObserver();
_this._closeCallback && _this._closeCallback();
this._removeVolumeObserver();
this._closeCallback && this._closeCallback();
reject("Scan aborted");
}
else {
var value = text;
let value = text;
if (shouldReturnEAN13AsUPCA(barcodeFormat, value, arg.formats)) {

@@ -229,12 +223,12 @@ barcodeFormat = "UPC_A";

}
var result = {
const result = {
format: barcodeFormat,
text: value
};
if (isContinuous_1) {
if (isContinuous) {
arg.continuousScanCallback(result);
}
else {
_this._removeVolumeObserver();
_this._closeCallback && _this._closeCallback();
this._removeVolumeObserver();
this._closeCallback && this._closeCallback();
resolve(result);

@@ -244,17 +238,17 @@ }

});
if (_this._device && _this._device.autoFocusRangeRestrictionSupported) {
_this._device.lockForConfiguration();
_this._device.autoFocusRangeRestriction = 1;
if (_this._device.smoothAutoFocusSupported) {
_this._device.smoothAutoFocusEnabled = true;
if (this._device && this._device.autoFocusRangeRestrictionSupported) {
this._device.lockForConfiguration();
this._device.autoFocusRangeRestriction = 1;
if (this._device.smoothAutoFocusSupported) {
this._device.smoothAutoFocusEnabled = true;
}
_this._device.unlockForConfiguration();
this._device.unlockForConfiguration();
}
setTimeout(function () {
_this.getViewControllerToPresentFrom(arg.presentInRootViewController).presentViewControllerAnimatedCompletion(_this._scanner, true, function () {
setTimeout(() => {
this.getViewControllerToPresentFrom(arg.presentInRootViewController).presentViewControllerAnimatedCompletion(this._scanner, true, () => {
if (arg.torchOn) {
_this._enableTorch();
this._enableTorch();
}
});
}, _this.isPresentingModally() ? 650 : 0);
}, this.isPresentingModally() ? 650 : 0);
}

@@ -266,7 +260,7 @@ catch (ex) {

});
};
BarcodeScanner.prototype.isPresentingModally = function () {
var frame = require("tns-core-modules/ui/frame");
var viewController;
var topMostFrame = frame.topmost();
}
isPresentingModally() {
let frame = require("tns-core-modules/ui/frame");
let viewController;
let topMostFrame = frame.topmost();
if (frame.topmost()) {

@@ -282,4 +276,4 @@ viewController = topMostFrame.currentPage && topMostFrame.currentPage.ios;

return false;
};
BarcodeScanner.prototype.close = function () {
}
close() {
if (this._lastScanViewController) {

@@ -292,7 +286,7 @@ this._lastScanViewController.dismissViewControllerAnimatedCompletion(true, null);

}
};
BarcodeScanner.prototype.getViewControllerToPresentFrom = function (presentInRootViewController) {
var frame = require("tns-core-modules/ui/frame");
var viewController;
var topMostFrame = frame.topmost();
}
getViewControllerToPresentFrom(presentInRootViewController) {
let frame = require("tns-core-modules/ui/frame");
let viewController;
let topMostFrame = frame.topmost();
if (topMostFrame && presentInRootViewController !== true) {

@@ -314,11 +308,10 @@ viewController = topMostFrame.currentPage && topMostFrame.currentPage.ios;

return viewController;
};
return BarcodeScanner;
}());
}
}
exports.BarcodeScanner = BarcodeScanner;
var shouldReturnEAN13AsUPCA = function (barcodeFormat, value, requestedFormats) {
const shouldReturnEAN13AsUPCA = (barcodeFormat, value, requestedFormats) => {
return barcodeFormat === "EAN_13" &&
value.indexOf("0") === 0;
};
var getBarcodeFormat = function (nativeFormat) {
const getBarcodeFormat = (nativeFormat) => {
if (nativeFormat === AVMetadataObjectTypeQRCode)

@@ -355,8 +348,7 @@ return "QR_CODE";

};
var getBarcodeTypes = function (formatsString) {
var types = [];
const getBarcodeTypes = (formatsString) => {
const types = [];
if (formatsString) {
var formats = formatsString.split(",");
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
var format = formats_1[_i];
let formats = formatsString.split(",");
for (let format of formats) {
format = format.trim();

@@ -396,15 +388,13 @@ if (format === "QR_CODE")

};
var QRCodeReaderDelegateImpl = (function (_super) {
__extends(QRCodeReaderDelegateImpl, _super);
function QRCodeReaderDelegateImpl() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._lastScanResultTs = new Date().getTime();
return _this;
let QRCodeReaderDelegateImpl = QRCodeReaderDelegateImpl_1 = class QRCodeReaderDelegateImpl extends NSObject {
constructor() {
super(...arguments);
this._lastScanResultTs = new Date().getTime();
}
QRCodeReaderDelegateImpl.initWithOwner = function (owner) {
var delegate = QRCodeReaderDelegateImpl.new();
static initWithOwner(owner) {
let delegate = QRCodeReaderDelegateImpl_1.new();
delegate._owner = owner;
return delegate;
};
QRCodeReaderDelegateImpl.prototype.setCallback = function (beepOnScan, isContinuous, reportDuplicates, requestedFormats, callback) {
}
setCallback(beepOnScan, isContinuous, reportDuplicates, requestedFormats, callback) {
this._isContinuous = isContinuous;

@@ -416,3 +406,3 @@ this._reportDuplicates = reportDuplicates;

if (this._beepOnScan) {
var barcodeBundlePath = NSBundle.bundleWithIdentifier("com.telerik.BarcodeScannerFramework").bundlePath;
const barcodeBundlePath = NSBundle.bundleWithIdentifier("com.telerik.BarcodeScannerFramework").bundlePath;
this._player = new AVAudioPlayer({ contentsOfURL: NSURL.fileURLWithPath(barcodeBundlePath + "/beep.caf") });

@@ -423,11 +413,12 @@ this._player.numberOfLoops = 1;

}
};
QRCodeReaderDelegateImpl.prototype.readerDidCancel = function (reader) {
}
readerDidCancel(reader) {
this._owner.get().close();
this._callback();
};
QRCodeReaderDelegateImpl.prototype.readerDidScanResultForType = function (reader, result, type) {
var validResult = false;
var barcodeFormat = getBarcodeFormat(type);
var value = result;
}
readerDidScanResultForType(reader, result, type) {
let validResult = false;
console.log(1);
let barcodeFormat = getBarcodeFormat(type);
let value = result;
if (shouldReturnEAN13AsUPCA(barcodeFormat, value, this._requestedFormats)) {

@@ -437,9 +428,14 @@ barcodeFormat = "UPC_A";

}
console.log(2);
if (this._isContinuous) {
console.log(6);
if (!this._scannedArray) {
this._scannedArray = Array();
}
var newResult = this._scannedArray.indexOf("[" + value + "][" + barcodeFormat + "]") === -1;
console.log(7);
let newResult = this._scannedArray.indexOf("[" + value + "][" + barcodeFormat + "]") === -1;
console.log(8);
if (newResult || this._reportDuplicates) {
var now = new Date().getTime();
let now = new Date().getTime();
console.log(9);
if (now - this._lastScanResultTs < 1700) {

@@ -450,4 +446,7 @@ return;

validResult = true;
console.log(10);
this._scannedArray.push("[" + value + "][" + barcodeFormat + "]");
console.log(11);
this._callback(value, barcodeFormat);
console.log(12);
}

@@ -457,4 +456,8 @@ }

validResult = true;
console.log(3);
this._owner.get().close();
console.log(4);
console.log(this._callback);
this._callback(value, barcodeFormat);
console.log(5);
}

@@ -464,14 +467,12 @@ if (validResult && this._player) {

}
};
QRCodeReaderDelegateImpl.ObjCProtocols = [QRCodeReaderDelegate];
return QRCodeReaderDelegateImpl;
}(NSObject));
var VolumeObserverClass = (function (_super) {
__extends(VolumeObserverClass, _super);
function VolumeObserverClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
VolumeObserverClass.prototype.observeValueForKeyPathOfObjectChangeContext = function (path, obj, change, context) {
};
QRCodeReaderDelegateImpl.ObjCProtocols = [QRCodeReaderDelegate];
QRCodeReaderDelegateImpl = QRCodeReaderDelegateImpl_1 = __decorate([
NativeClass
], QRCodeReaderDelegateImpl);
class VolumeObserverClass extends NSObject {
observeValueForKeyPathOfObjectChangeContext(path, obj, change, context) {
if (path === "outputVolume") {
var volumeLevel = MPMusicPlayerController.applicationMusicPlayer.volume;
let volumeLevel = MPMusicPlayerController.applicationMusicPlayer.volume;
if (volumeLevel > this["_owner"]._currentVolume) {

@@ -485,5 +486,4 @@ this["_owner"]._enableTorch();

}
};
return VolumeObserverClass;
}(NSObject));
}
}
//# sourceMappingURL=barcodescanner.ios.js.map
{
"name": "nativescript-barcodescanner",
"version": "3.4.2",
"version": "4.0.0",
"description": "Scan QR/barcodes with your NativeScript app.",

@@ -9,4 +9,4 @@ "main": "barcodescanner",

"platforms": {
"android": "2.3.0",
"ios": "2.3.0"
"android": "7.0.0",
"ios": "7.0.0"
}

@@ -23,7 +23,5 @@ },

"plugin.link": "npm link && cd ../demo && npm link nativescript-barcodescanner && cd ../src",
"plugin.link.ng": "npm link && cd ../demo-ng && npm link nativescript-barcodescanner && cd ../src",
"plugin.tscwatch": "npm run tsc -- -w",
"demo.ios": "npm run build && cd ../demo && tns run ios",
"demo.reset": "cd ../demo && rimraf platforms",
"demo-ng.ios": "npm run build && cd ../publish && ./pack.sh && cd ../demo-ng && tns plugin remove nativescript-barcodescanner && tns plugin add ../publish/package/*.tgz && tns run ios",
"demo.android": "npm run build && cd ../demo && tns run android",

@@ -74,10 +72,10 @@ "demo-vue.ios": "npm run tsc && cd ../demo-vue && tns run ios --bundle",

"devDependencies": {
"tns-core-modules": "~6.1.0",
"tns-platform-declarations": "~6.1.0",
"typescript": "3.4.5",
"@nativescript/core": "^7.0.0",
"@nativescript/types": "^7.0.0",
"typescript": "~3.9.7",
"prompt": "^1.0.0",
"rimraf": "^2.6.2",
"tslint": "^5.11.0",
"rimraf": "^2.6.3",
"tslint": "^5.12.1",
"semver": "^5.6.0"
}
}

@@ -16,2 +16,4 @@ # NativeScript BarcodeScanner

> 💡 Plugin version 4.0.0+ is compatible with NativeScript 7+. If you need to target older NativeScript versions, please stick to plugin version 3.4.2.
## Want a quick demo?

@@ -35,3 +37,3 @@

```bash
npm run demo-ng.ios (or demo.ios.device)
npm run demo.ios
```

@@ -128,4 +130,2 @@

See 'demo-ng' for details. Do not run it for Android, because embedding a view is not supported on that platform.
### Embedding in Vue

@@ -132,0 +132,0 @@ main.ts:

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc