phonegap-plugin-barcodescanner
Advanced tools
Comparing version 5.0.1 to 6.0.0
{ | ||
"name": "phonegap-plugin-barcodescanner", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.", | ||
@@ -10,3 +10,2 @@ "cordova": { | ||
"android", | ||
"windows8", | ||
"windows", | ||
@@ -27,3 +26,2 @@ "wp8", | ||
"cordova-android", | ||
"cordova-windows8", | ||
"cordova-windows", | ||
@@ -30,0 +28,0 @@ "cordova-wp8", |
@@ -253,2 +253,9 @@ /* | ||
// Save call state for suspend/resume | ||
BarcodeReader.scanCallArgs = { | ||
success: success, | ||
fail: fail, | ||
args: args | ||
}; | ||
function updatePreviewForRotation(evt) { | ||
@@ -348,3 +355,12 @@ if (!capture) { | ||
try { | ||
return controller.focusControl.focusAsync(); | ||
return controller.focusControl.focusAsync().then(function () { | ||
return result; | ||
}, function (e) { | ||
// This happens on mutliple taps | ||
if (e.number !== OPERATION_IS_IN_PROGRESS) { | ||
console.error('focusAsync failed: ' + e); | ||
return WinJS.Promise.wrapError(e); | ||
} | ||
return result; | ||
}); | ||
} catch (e) { | ||
@@ -504,2 +520,3 @@ // This happens on mutliple taps | ||
function destroyPreview() { | ||
var promise = WinJS.Promise.as(); | ||
@@ -515,2 +532,3 @@ Windows.Graphics.Display.DisplayInformation.getForCurrentView().removeEventListener("orientationchanged", updatePreviewForRotation, false); | ||
} | ||
capturePreviewFrame = null; | ||
@@ -520,6 +538,10 @@ reader && reader.stop(); | ||
capture && capture.stopRecordAsync(); | ||
if (capture) { | ||
promise = capture.stopRecordAsync(); | ||
} | ||
capture = null; | ||
enableZoomAndScroll(); | ||
return promise; | ||
} | ||
@@ -542,3 +564,3 @@ | ||
WinJS.Promise.wrap(createPreview()) | ||
BarcodeReader.scanPromise = WinJS.Promise.wrap(createPreview()) | ||
.then(function () { | ||
@@ -561,3 +583,8 @@ checkCancelled(); | ||
}) | ||
.done(function (result) { | ||
.then(function (result) { | ||
// Suppress null result (cancel) on suspending | ||
if (BarcodeReader.suspended) { | ||
return; | ||
} | ||
destroyPreview(); | ||
@@ -580,2 +607,8 @@ success({ | ||
}); | ||
BarcodeReader.videoPreviewIsVisible = function () { | ||
return capturePreviewFrame !== null; | ||
} | ||
BarcodeReader.destroyPreview = destroyPreview; | ||
}, | ||
@@ -594,2 +627,25 @@ | ||
var app = WinJS.Application; | ||
function waitForScanEnd() { | ||
return BarcodeReader.scanPromise || WinJS.Promise.as(); | ||
} | ||
// About to be suspended | ||
app.addEventListener('checkpoint', function (args) { | ||
if (BarcodeReader.videoPreviewIsVisible && BarcodeReader.videoPreviewIsVisible() && BarcodeReader.destroyPreview) { | ||
BarcodeReader.suspended = true; | ||
args.setPromise(BarcodeReader.destroyPreview() | ||
.then(waitForScanEnd, waitForScanEnd)); | ||
} | ||
}); | ||
// Resuming from a user suspension | ||
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", function () { | ||
if (BarcodeReader.suspended) { | ||
BarcodeReader.suspended = false; | ||
module.exports.scan(BarcodeReader.scanCallArgs.success, BarcodeReader.scanCallArgs.fail, BarcodeReader.scanCallArgs.args); | ||
} | ||
}, false); | ||
require("cordova/exec/proxy").add("BarcodeScanner", module.exports); |
@@ -12,2 +12,4 @@ /** | ||
var scanInProgress = false; | ||
/** | ||
@@ -101,3 +103,22 @@ * Constructor. | ||
exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', config); | ||
if (scanInProgress) { | ||
errorCallback('Scan is already in progress'); | ||
return; | ||
} | ||
scanInProgress = true; | ||
exec( | ||
function(result) { | ||
scanInProgress = false; | ||
successCallback(result); | ||
}, | ||
function(error) { | ||
scanInProgress = false; | ||
errorCallback(error); | ||
}, | ||
'BarcodeScanner', | ||
'scan', | ||
config | ||
); | ||
}; | ||
@@ -104,0 +125,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6509052
69
1639