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

react-webcam

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-webcam - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

5

dist/react-webcam.js

@@ -286,4 +286,7 @@ (function webpackUniversalModuleDefinition(root, factory) {

var _canvas = document.createElement('canvas');
_canvas.height = video.clientHeight;
var aspectRatio = video.videoWidth / video.videoHeight;
_canvas.width = video.clientWidth;
_canvas.height = video.clientWidth / aspectRatio;
this.canvas = _canvas;

@@ -290,0 +293,0 @@ this.ctx = _canvas.getContext('2d');

2

dist/react-webcam.min.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.Webcam=t(require("react"),require("react-dom")):e.Webcam=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function n(){return!!(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia)}t.__esModule=!0;var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(1),c=o(u),d=r(2),p=function(e){function t(){i(this,t),e.call(this),this.state={hasUserMedia:!1}}return a(t,e),s(t,null,[{key:"defaultProps",value:{audio:!0,height:480,width:640,screenshotFormat:"image/webp",onUserMedia:function(){}},enumerable:!0},{key:"propTypes",value:{audio:u.PropTypes.bool,muted:u.PropTypes.bool,onUserMedia:u.PropTypes.func,height:u.PropTypes.oneOfType([u.PropTypes.number,u.PropTypes.string]),width:u.PropTypes.oneOfType([u.PropTypes.number,u.PropTypes.string]),screenshotFormat:u.PropTypes.oneOf(["image/webp","image/png","image/jpeg"]),className:u.PropTypes.string},enumerable:!0},{key:"mountedInstances",value:[],enumerable:!0},{key:"userMediaRequested",value:!1,enumerable:!0}]),t.prototype.componentDidMount=function(){n()&&(t.mountedInstances.push(this),this.state.hasUserMedia||t.userMediaRequested||this.requestUserMedia())},t.prototype.requestUserMedia=function(){var e=this;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var r=function(r,o){var i={video:{optional:[{sourceId:o}]}};e.props.audio&&(i.audio={optional:[{sourceId:r}]}),navigator.getUserMedia(i,function(e){t.mountedInstances.forEach(function(t){return t.handleUserMedia(null,e)})},function(e){t.mountedInstances.forEach(function(t){return t.handleUserMedia(e)})})};this.props.audioSource&&this.props.videoSource?r(this.props.audioSource,this.props.videoSource):"mediaDevices"in navigator?navigator.mediaDevices.enumerateDevices().then(function(e){var t=null,o=null;e.forEach(function(e){"audio"===e.kind?t=e.id:"video"===e.kind&&(o=e.id)}),r(t,o)}).catch(function(e){console.log(e.name+": "+e.message)}):MediaStreamTrack.getSources(function(e){var t=null,o=null;e.forEach(function(e){"audio"===e.kind?t=e.id:"video"===e.kind&&(o=e.id)}),r(t,o)}),t.userMediaRequested=!0},t.prototype.handleUserMedia=function(e,t){if(e)return void this.setState({hasUserMedia:!1});var r=window.URL.createObjectURL(t);this.stream=t,this.setState({hasUserMedia:!0,src:r}),this.props.onUserMedia()},t.prototype.componentWillUnmount=function(){var e=t.mountedInstances.indexOf(this);if(t.mountedInstances.splice(e,1),0===t.mountedInstances.length&&this.state.hasUserMedia){if(this.stream.stop)this.stream.stop();else{if(this.stream.getVideoTracks)for(var r=this.stream.getVideoTracks(),o=Array.isArray(r),i=0,r=o?r:r[Symbol.iterator]();;){var a;if(o){if(i>=r.length)break;a=r[i++]}else{if(i=r.next(),i.done)break;a=i.value}var n=a;n.stop()}if(this.stream.getAudioTracks)for(var s=this.stream.getAudioTracks(),u=Array.isArray(s),c=0,s=u?s:s[Symbol.iterator]();;){var d;if(u){if(c>=s.length)break;d=s[c++]}else{if(c=s.next(),c.done)break;d=c.value}var n=d;n.stop()}}t.userMediaRequested=!1,window.URL.revokeObjectURL(this.state.src)}},t.prototype.getScreenshot=function(){if(!this.state.hasUserMedia)return null;var e=this.getCanvas();return e.toDataURL(this.props.screenshotFormat)},t.prototype.getCanvas=function(){if(!this.state.hasUserMedia)return null;var e=d.findDOMNode(this);if(!this.ctx){var t=document.createElement("canvas");t.height=e.clientHeight,t.width=e.clientWidth,this.canvas=t,this.ctx=t.getContext("2d")}var r=this.ctx,o=this.canvas;return r.drawImage(e,0,0,o.width,o.height),o},t.prototype.render=function(){return c.default.createElement("video",{autoPlay:!0,width:this.props.width,height:this.props.height,src:this.state.src,muted:this.props.muted,className:this.props.className})},t}(u.Component);t.default=p,e.exports=t.default},function(t,r){t.exports=e},function(e,r){e.exports=t}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.Webcam=t(require("react"),require("react-dom")):e.Webcam=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function n(){return!!(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia)}t.__esModule=!0;var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(1),c=o(u),d=r(2),p=function(e){function t(){i(this,t),e.call(this),this.state={hasUserMedia:!1}}return a(t,e),s(t,null,[{key:"defaultProps",value:{audio:!0,height:480,width:640,screenshotFormat:"image/webp",onUserMedia:function(){}},enumerable:!0},{key:"propTypes",value:{audio:u.PropTypes.bool,muted:u.PropTypes.bool,onUserMedia:u.PropTypes.func,height:u.PropTypes.oneOfType([u.PropTypes.number,u.PropTypes.string]),width:u.PropTypes.oneOfType([u.PropTypes.number,u.PropTypes.string]),screenshotFormat:u.PropTypes.oneOf(["image/webp","image/png","image/jpeg"]),className:u.PropTypes.string},enumerable:!0},{key:"mountedInstances",value:[],enumerable:!0},{key:"userMediaRequested",value:!1,enumerable:!0}]),t.prototype.componentDidMount=function(){n()&&(t.mountedInstances.push(this),this.state.hasUserMedia||t.userMediaRequested||this.requestUserMedia())},t.prototype.requestUserMedia=function(){var e=this;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var r=function(r,o){var i={video:{optional:[{sourceId:o}]}};e.props.audio&&(i.audio={optional:[{sourceId:r}]}),navigator.getUserMedia(i,function(e){t.mountedInstances.forEach(function(t){return t.handleUserMedia(null,e)})},function(e){t.mountedInstances.forEach(function(t){return t.handleUserMedia(e)})})};this.props.audioSource&&this.props.videoSource?r(this.props.audioSource,this.props.videoSource):"mediaDevices"in navigator?navigator.mediaDevices.enumerateDevices().then(function(e){var t=null,o=null;e.forEach(function(e){"audio"===e.kind?t=e.id:"video"===e.kind&&(o=e.id)}),r(t,o)}).catch(function(e){console.log(e.name+": "+e.message)}):MediaStreamTrack.getSources(function(e){var t=null,o=null;e.forEach(function(e){"audio"===e.kind?t=e.id:"video"===e.kind&&(o=e.id)}),r(t,o)}),t.userMediaRequested=!0},t.prototype.handleUserMedia=function(e,t){if(e)return void this.setState({hasUserMedia:!1});var r=window.URL.createObjectURL(t);this.stream=t,this.setState({hasUserMedia:!0,src:r}),this.props.onUserMedia()},t.prototype.componentWillUnmount=function(){var e=t.mountedInstances.indexOf(this);if(t.mountedInstances.splice(e,1),0===t.mountedInstances.length&&this.state.hasUserMedia){if(this.stream.stop)this.stream.stop();else{if(this.stream.getVideoTracks)for(var r=this.stream.getVideoTracks(),o=Array.isArray(r),i=0,r=o?r:r[Symbol.iterator]();;){var a;if(o){if(i>=r.length)break;a=r[i++]}else{if(i=r.next(),i.done)break;a=i.value}var n=a;n.stop()}if(this.stream.getAudioTracks)for(var s=this.stream.getAudioTracks(),u=Array.isArray(s),c=0,s=u?s:s[Symbol.iterator]();;){var d;if(u){if(c>=s.length)break;d=s[c++]}else{if(c=s.next(),c.done)break;d=c.value}var n=d;n.stop()}}t.userMediaRequested=!1,window.URL.revokeObjectURL(this.state.src)}},t.prototype.getScreenshot=function(){if(!this.state.hasUserMedia)return null;var e=this.getCanvas();return e.toDataURL(this.props.screenshotFormat)},t.prototype.getCanvas=function(){if(!this.state.hasUserMedia)return null;var e=d.findDOMNode(this);if(!this.ctx){var t=document.createElement("canvas"),r=e.videoWidth/e.videoHeight;t.width=e.clientWidth,t.height=e.clientWidth/r,this.canvas=t,this.ctx=t.getContext("2d")}var o=this.ctx,i=this.canvas;return o.drawImage(e,0,0,i.width,i.height),i},t.prototype.render=function(){return c.default.createElement("video",{autoPlay:!0,width:this.props.width,height:this.props.height,src:this.state.src,muted:this.props.muted,className:this.props.className})},t}(u.Component);t.default=p,e.exports=t.default},function(t,r){t.exports=e},function(e,r){e.exports=t}])});
{
"name": "react-webcam",
"version": "0.0.13",
"version": "0.0.14",
"description": "React webcam component",

@@ -5,0 +5,0 @@ "main": "dist/react-webcam.js",

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