Socket
Socket
Sign inDemoInstall

phonegap-plugin-barcodescanner

Package Overview
Dependencies
Maintainers
5
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phonegap-plugin-barcodescanner - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

2

package.json
{
"name": "phonegap-plugin-barcodescanner",
"version": "5.0.0",
"version": "5.0.1",
"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.",

@@ -5,0 +5,0 @@ "cordova": {

@@ -45,2 +45,5 @@ # PhoneGap Plugin BarcodeScanner

### PhoneGap Build
If you're using [PhoneGap Build](https://build.phonegap.com/) please make sure you specify `gradle` as your Android build tool in `config.xml`: `<preference name="android-build-tool" value="gradle" />`.
## Using the plugin ##

@@ -47,0 +50,0 @@ The plugin creates the object `cordova/plugin/BarcodeScanner` with the method `scan(success, fail)`.

@@ -13,2 +13,7 @@ /*

var CAMERA_STREAM_STATE_CHECK_RETRY_TIMEOUT = 200; // milliseconds
var OPERATION_IS_IN_PROGRESS = -2147024567;
var INITIAL_FOCUS_DELAY = 200; // milliseconds
var CHECK_PLAYING_TIMEOUT = 100; // milliseconds
/**

@@ -211,2 +216,22 @@ * List of supported barcode formats from ZXing library. Used to return format

function degreesToRotation(degrees) {
switch (degrees) {
// portrait
case 90:
return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
// landscape
case 0:
return Windows.Media.Capture.VideoRotation.none;
// portrait-flipped
case 270:
return Windows.Media.Capture.VideoRotation.clockwise270Degrees;
// landscape-flipped
case 180:
return Windows.Media.Capture.VideoRotation.clockwise180Degrees;
default:
// Falling back to portrait default
return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
}
}
module.exports = {

@@ -235,4 +260,2 @@

var ROTATION_KEY = "C380465D-2271-428C-9B83-ECEA3B4A85C1";
var displayInformation = (evt && evt.target) || Windows.Graphics.Display.DisplayInformation.getForCurrentView();

@@ -246,6 +269,4 @@ var currentOrientation = displayInformation.currentOrientation;

// rotate the preview video
var videoEncodingProperties = capture.videoDeviceController.getMediaStreamProperties(Windows.Media.Capture.MediaStreamType.videoPreview);
videoEncodingProperties.properties.insert(ROTATION_KEY, rotDegree);
return capture.videoDeviceController.setMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.videoPreview, videoEncodingProperties);
capture.setPreviewRotation(degreesToRotation(rotDegree));
return WinJS.Promise.as();
}

@@ -289,2 +310,3 @@

BarcodeReader.scanCancelled = false;
closeButton.addEventListener("click", cancelPreview, false);

@@ -321,3 +343,21 @@ document.addEventListener('backbutton', cancelPreview, false);

return controller.focusControl.focusAsync();
// Multiple calls to focusAsync leads to internal focusing hang on some Windows Phone 8.1 devices
if (controller.focusControl.focusState === Windows.Media.Devices.MediaCaptureFocusState.searching) {
return result;
}
// The delay prevents focus hang on slow devices
return WinJS.Promise.timeout(INITIAL_FOCUS_DELAY)
.then(function () {
try {
return controller.focusControl.focusAsync();
} catch (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;
}
});
}

@@ -339,2 +379,5 @@

// Determine a focus position if the focus search fails:
focusConfig.disableDriverFallback = false;
if (supportsFocusMode(FocusMode.continuous)) {

@@ -349,10 +392,31 @@ console.log("Device supports continuous focus mode");

focusControl.configure(focusConfig);
// Need to wrap this in setTimeout since continuous focus should start only after preview has started. See
// 'Remarks' at https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.devices.focuscontrol.configure.aspx
return WinJS.Promise.timeout(200)
.then(function () {
return focusControl.focusAsync();
});
// Continuous focus should start only after preview has started. See 'Remarks' at
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.devices.focuscontrol.configure.aspx
function waitForIsPlaying() {
var isPlaying = !capturePreview.paused && !capturePreview.ended && capturePreview.readyState > 2;
if (!isPlaying) {
return WinJS.Promise.timeout(CHECK_PLAYING_TIMEOUT)
.then(function () {
return waitForIsPlaying();
});
}
return focus();
}
return waitForIsPlaying();
}
function disableZoomAndScroll() {
document.body.classList.add('no-zoom');
document.body.classList.add('no-scroll');
}
function enableZoomAndScroll() {
document.body.classList.remove('no-zoom');
document.body.classList.remove('no-scroll');
}
/**

@@ -405,2 +469,4 @@ * Starts stream transmission to preview frame and then run barcode search

disableZoomAndScroll();
return setupFocus(captureSettings.capture.videoDeviceController.focusControl)

@@ -412,2 +478,26 @@ .then(function () {

.then(function () {
if (!Windows.Media.Devices.CameraStreamState) {
// CameraStreamState is available starting with Windows 10 so skip this check for 8.1
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.devices.camerastreamstate
return WinJS.Promise.as();
}
function checkCameraStreamState() {
if (capture.cameraStreamState !== Windows.Media.Devices.CameraStreamState.streaming) {
// Using loop as MediaCapture.CameraStreamStateChanged does not fire with CameraStreamState.streaming state.
return WinJS.Promise.timeout(CAMERA_STREAM_STATE_CHECK_RETRY_TIMEOUT)
.then(function () {
return checkCameraStreamState();
});
}
return WinJS.Promise.as();
}
// Ensure CameraStreamState is Streaming
return checkCameraStreamState();
})
.then(function () {
return captureSettings;

@@ -438,2 +528,4 @@ });

capture = null;
enableZoomAndScroll();
}

@@ -446,10 +538,19 @@

function cancelPreview() {
BarcodeReader.scanCancelled = true;
reader && reader.stop();
}
function checkCancelled() {
if (BarcodeReader.scanCancelled) {
throw new Error('Canceled');
}
}
WinJS.Promise.wrap(createPreview())
.then(function () {
checkCancelled();
return startPreview();
})
.then(function (captureSettings) {
checkCancelled();
reader = BarcodeReader.get(captureSettings.capture);

@@ -462,2 +563,3 @@ reader.init(captureSettings.capture, captureSettings.width, captureSettings.height);

.then(function () {
checkCancelled();
return reader.readCode();

@@ -475,3 +577,10 @@ });

destroyPreview();
fail(error);
if (error.message == 'Canceled') {
success({
cancelled: true
});
} else {
fail(error);
}
});

@@ -478,0 +587,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

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