Socket
Socket
Sign inDemoInstall

@uppy/webcam

Package Overview
Dependencies
Maintainers
5
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/webcam - npm Package Compare versions

Comparing version 1.6.5 to 1.6.6

49

lib/index.js

@@ -144,2 +144,4 @@ var _class, _temp;

allowAccessDescription: 'In order to take pictures or record video with your camera, please allow camera access for this site.',
noCameraTitle: 'Camera Not Available',
noCameraDescription: 'In order to take pictures or record video, please connect a camera device',
recordingStoppedMaxSize: 'Recording stopped because the file size is about to exceed the limit',

@@ -201,4 +203,12 @@ recordingLength: 'Recording length %{recording_length}'

_proto.isSupported = function isSupported() {
return !!this.mediaDevices;
_proto.hasCameraCheck = function hasCameraCheck() {
if (!this.mediaDevices) {
return Promise.resolve(false);
}
return this.mediaDevices.enumerateDevices().then(function (devices) {
return devices.some(function (device) {
return device.kind === 'videoinput';
});
});
};

@@ -220,3 +230,3 @@

if (!this.isSupported()) {
if (!this.supportsUserMedia) {
return Promise.reject(new Error('Webcam access not supported'));

@@ -226,14 +236,20 @@ }

this.webcamActive = true;
var constraints = this.getConstraints(); // ask user for access to their camera
var constraints = this.getConstraints();
this.hasCameraCheck().then(function (hasCamera) {
_this2.setPluginState({
hasCamera: hasCamera
}); // ask user for access to their camera
return this.mediaDevices.getUserMedia(constraints).then(function (stream) {
_this2.stream = stream; // this.streamSrc = URL.createObjectURL(this.stream)
_this2.setPluginState({
cameraReady: true
return _this2.mediaDevices.getUserMedia(constraints).then(function (stream) {
_this2.stream = stream;
_this2.setPluginState({
cameraReady: true
});
}).catch(function (err) {
_this2.setPluginState({
cameraError: err
});
});
}).catch(function (err) {
_this2.setPluginState({
cameraError: err
});
});

@@ -513,3 +529,3 @@ }

_proto.render = function render(state) {
_proto.render = function render() {
if (!this.webcamActive) {

@@ -521,6 +537,7 @@ this._start();

if (!webcamState.cameraReady) {
if (!webcamState.cameraReady || !webcamState.hasCamera) {
return h(PermissionsScreen, {
icon: CameraIcon,
i18n: this.i18n
i18n: this.i18n,
hasCamera: webcamState.hasCamera
});

@@ -566,2 +583,2 @@ }

return Webcam;
}(Plugin), _class.VERSION = "1.6.5", _temp);
}(Plugin), _class.VERSION = "1.6.6", _temp);

@@ -11,3 +11,3 @@ var _require = require('preact'),

class: "uppy-Webcam-title"
}, props.i18n('allowAccessTitle')), h("p", null, props.i18n('allowAccessDescription')));
}, props.hasCamera ? props.i18n('allowAccessTitle') : props.i18n('noCameraTitle')), h("p", null, props.hasCamera ? props.i18n('allowAccessDescription') : props.i18n('noCameraDescription')));
};
{
"name": "@uppy/webcam",
"description": "Uppy plugin that takes photos or records videos using the device's camera.",
"version": "1.6.5",
"version": "1.6.6",
"license": "MIT",

@@ -29,3 +29,3 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/utils": "^2.4.4",
"@uppy/utils": "^3.0.0",
"preact": "8.2.9"

@@ -36,3 +36,3 @@ },

},
"gitHead": "5528c6f6eae8873a363be5a45862459f168a7c90"
"gitHead": "6a0152327386cb6dd1ae8aada13f13062d326b61"
}

@@ -69,3 +69,2 @@ const { h } = require('preact')

}
/**

@@ -102,2 +101,4 @@ * Webcam

allowAccessDescription: 'In order to take pictures or record video with your camera, please allow camera access for this site.',
noCameraTitle: 'Camera Not Available',
noCameraDescription: 'In order to take pictures or record video, please connect a camera device',
recordingStoppedMaxSize: 'Recording stopped because the file size is about to exceed the limit',

@@ -162,4 +163,10 @@ recordingLength: 'Recording length %{recording_length}'

isSupported () {
return !!this.mediaDevices
hasCameraCheck () {
if (!this.mediaDevices) {
return Promise.resolve(false)
}
return this.mediaDevices.enumerateDevices().then(devices => {
return devices.some(device => device.kind === 'videoinput')
})
}

@@ -181,3 +188,3 @@

_start () {
if (!this.isSupported()) {
if (!this.supportsUserMedia) {
return Promise.reject(new Error('Webcam access not supported'))

@@ -187,19 +194,23 @@ }

this.webcamActive = true
const constraints = this.getConstraints()
// ask user for access to their camera
return this.mediaDevices.getUserMedia(constraints)
.then((stream) => {
this.stream = stream
// this.streamSrc = URL.createObjectURL(this.stream)
this.setPluginState({
cameraReady: true
})
this.hasCameraCheck().then(hasCamera => {
this.setPluginState({
hasCamera: hasCamera
})
.catch((err) => {
this.setPluginState({
cameraError: err
// ask user for access to their camera
return this.mediaDevices.getUserMedia(constraints)
.then((stream) => {
this.stream = stream
this.setPluginState({
cameraReady: true
})
})
})
.catch((err) => {
this.setPluginState({
cameraError: err
})
})
})
}

@@ -444,3 +455,3 @@

render (state) {
render () {
if (!this.webcamActive) {

@@ -452,5 +463,9 @@ this._start()

if (!webcamState.cameraReady) {
if (!webcamState.cameraReady || !webcamState.hasCamera) {
return (
<PermissionsScreen icon={CameraIcon} i18n={this.i18n} />
<PermissionsScreen
icon={CameraIcon}
i18n={this.i18n}
hasCamera={webcamState.hasCamera}
/>
)

@@ -457,0 +472,0 @@ }

@@ -7,6 +7,6 @@ const { h } = require('preact')

<div class="uppy-Webcam-permissonsIcon">{props.icon()}</div>
<h1 class="uppy-Webcam-title">{props.i18n('allowAccessTitle')}</h1>
<p>{props.i18n('allowAccessDescription')}</p>
<h1 class="uppy-Webcam-title">{props.hasCamera ? props.i18n('allowAccessTitle') : props.i18n('noCameraTitle')}</h1>
<p>{props.hasCamera ? props.i18n('allowAccessDescription') : props.i18n('noCameraDescription')}</p>
</div>
)
}

@@ -10,2 +10,4 @@ import Uppy = require('@uppy/core')

| 'allowAccessDescription'
| 'noCameraTitle'
| 'noCameraDescription'
| 'recordingStoppedMaxSize'

@@ -12,0 +14,0 @@ | 'recordingLength'

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