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

instacam

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instacam - npm Package Compare versions

Comparing version 1.11.2 to 1.11.3

2

dist/instacam.umd.js
/*!
instacam – Instant canvas video
Xavier Foucrier @xavierfoucrier 2019 MIT
1.11.2
1.11.3
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Instacam",[],e):"object"==typeof exports?exports.Instacam=e():t.Instacam=e()}(window,(function(){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"h",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.h)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(s,r,function(e){return t[e]}.bind(null,r));return s},i.n=function(t){var e=t&&t.h?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);var s={width:400,height:300,autostart:!0,camera:!0,mode:"front",framerate:30,ratio:4/3,sound:!1,volume:100,mirror:!1,opacity:1,brightness:1,contrast:1,saturation:1,hue:0,invert:0,grayscale:0,sepia:0,blur:0,url:"",blend:{},filter:null,done:null,fail:null,unsupported:null},r="requestAnimationFrame"in window&&"mediaDevices"in navigator&&"Promise"in window;i.d(e,"default",(function(){return n}));class n{constructor(t,e){if(this.u=Object.assign({},s,e),r){if("string"==typeof t&&(t=document.querySelector(t)),null==t||"canvas"!==t.nodeName.toLowerCase())throw new Error("Invalid viewport, you need to pass a valid selector or HTML5 canvas element");this.viewport=t,this.viewport.setAttribute("data-instacam-viewport",""),this.viewport.width=this.u.width,this.viewport.height=this.u.height,this.v=document.createElement("video"),this.v.setAttribute("data-instacam-stream",""),this.v.style.display="none",this.viewport.parentNode.insertBefore(this.v,this.viewport.nextSibling),this.g=document.createElement("div"),this.g.setAttribute("data-instacam",""),this.g.style="position:relative;overflow:hidden;vertical-align:bottom;",this.viewport.parentNode.insertBefore(this.g,this.viewport),this.g.appendChild(this.viewport),this.g.appendChild(this.v),this.mirror=this.u.mirror,!0===this.u.autostart&&(this.I(),this.j())}else"function"==typeof this.u.unsupported&&this.u.unsupported()}j(){try{navigator.mediaDevices.getUserMedia({audio:this.u.sound,video:(()=>!1!==this.u.camera&&{width:this.u.width,height:this.u.height,frameRate:this.u.framerate,aspectRatio:this.u.ratio,facingMode:"front"===this.u.mode?"user":"environment"})()}).then(t=>{this.$=t,this.v.srcObject=t,this.O=this.v.play();let e=this.$.getAudioTracks().filter(t=>"live"===t.readyState)[0],i=this.$.getVideoTracks().filter(t=>"live"===t.readyState)[0];if(this.k={audio:void 0===e?null:{id:e.id,name:e.label,track:e},video:void 0===i?null:{id:i.id,name:i.label,track:i,width:i.getSettings().width,height:i.getSettings().height}},this.viewport.width=null!==this.k.video?this.k.video.width:0,this.viewport.height=null!==this.k.video?this.k.video.height:0,this.volume=this.u.volume,this.u.camera){const t=()=>{"function"!=typeof this.u.filter?this.viewport.getContext("2d").drawImage(this.v,0,0,this.viewport.width,this.viewport.height):(void 0===this._&&(this._=document.createElement("canvas"),this._.setAttribute("data-instacam-buffer",""),this._.style.display="none",this._.width=this.viewport.width,this._.height=this.viewport.height,this.viewport.parentNode.insertBefore(this._,this.viewport.nextSibling)),this._.getContext("2d").drawImage(this.v,0,0,this.viewport.width,this.viewport.height),this.viewport.getContext("2d").putImageData(this.M(this._.getContext("2d").getImageData(0,0,this.viewport.width,this.viewport.height)),0,0)),requestAnimationFrame(t)};requestAnimationFrame(t)}"function"==typeof this.u.done&&this.u.done()}).catch(t=>{"function"==typeof this.u.fail&&this.u.fail(t)})}catch(t){"function"==typeof this.u.fail&&this.u.fail(t)}}I(){this.S=this.u.opacity!==s.opacity?`opacity(${this.u.opacity}) `:"",this.S+=this.u.brightness!==s.brightness?`brightness(${this.u.brightness}) `:"",this.S+=this.u.contrast!==s.contrast?`contrast(${this.u.contrast}) `:"",this.S+=this.u.saturation!==s.saturation?`saturate(${this.u.saturation}) `:"",this.S+=this.u.hue!==s.hue?`hue-rotate(${this.u.hue}deg) `:"",this.S+=this.u.invert!==s.invert?`invert(${this.u.invert}) `:"",this.S+=this.u.grayscale!==s.grayscale?`grayscale(${this.u.grayscale}) `:"",this.S+=this.u.sepia!==s.sepia?`sepia(${this.u.sepia}) `:"",this.S+=this.u.blur!==s.blur?`blur(${this.u.blur}px) `:"",this.S+=this.u.url!==s.url?`url(${this.u.url}) `:"",this.viewport.style.filter=this.S,0!==Object.keys(this.u.blend).length?(void 0===this.q&&(this.q=document.createElement("div"),this.q.setAttribute("data-instacam-blend",""),this.viewport.parentNode.insertBefore(this.q,this.viewport)),this.q.style=`position:absolute;z-index:1;width:100%;height:100%;mix-blend-mode:${this.u.blend.mode};background:${this.u.blend.color};pointer-events:none;`):void 0!==this.q&&(this.q.parentNode.removeChild(this.q),delete this.q)}M(t){let e=t.data;try{for(let t=0;t<this.u.height;t++)for(let i=0;i<this.u.width;i++){const s=4*(this.u.width*t+i),r=this.u.filter({offset:s,x:i,y:t,red:e[s],green:e[s+1],blue:e[s+2],alpha:e[s+3]});e[s]=r[0],e[s+1]=r[1],e[s+2]=r[2],e[s+3]=r[3]}return t}catch(t){throw new Error("Invalid filter, you need to return a valid [red, green, blue, alpha] pixel array")}}start(){this.I(),this.j()}stop(){void 0!==this.$&&(this.$.getTracks().forEach((function(t){t.stop()})),this.v.srcObject=null)}pause(){void 0!==this.$&&this.O.then(()=>{this.v.pause(),this.u.paused=!0})}resume(){this.v.play(),this.u.paused=!1}mute(){this.u.muted=this.v.muted=!0}unmute(){this.u.muted=this.v.muted=!1}snap(t=0,e=0,i=this.u.width,s=this.u.height){if(i<=0||s<=0)throw new Error("Invalid snap area, you need to specify a positive width and height for your image capture");return this.viewport.getContext("2d").getImageData(t,e,i,s)}save(t="png",e=1){return this.viewport.toDataURL("image/"+t,e)}get mode(){return this.u.mode}set mode(t){if("string"!=typeof t||"front"!==t&&"back"!==t)throw new Error("Invalid facing mode, you need to give a valid string front|back");this.u.mode=t,this.$.getVideoTracks().forEach((function(t){t.stop()})),this.j()}get paused(){return this.v.paused}get muted(){return this.v.muted}get volume(){return this.u.volume}set volume(t){if("number"!=typeof t||t<0||t>100)throw new Error("Invalid volume, you need to give a number between 0 and 100");this.v.volume=this.u.volume=t/100}get mirror(){return this.u.mirror}set mirror(t){if("boolean"!=typeof t)throw new Error("Invalid mirror mode, you need to give a boolean to enable or disable the mirror mode");let e=getComputedStyle(this.viewport).getPropertyValue("transform");e="none"!==e?e:"",this.viewport.style.transform=!0===t?`${e} scale(-1, 1)`:"",this.u.mirror=t}get opacity(){return this.u.opacity}set opacity(t){if("number"!=typeof t||t<0||t>1)throw new Error("Invalid opacity, you need to give a number between 0 and 1");this.u.opacity=t,this.I()}get brightness(){return this.u.brightness}set brightness(t){if("number"!=typeof t||t<0)throw new Error("Invalid brightness, you need to give a number above 0");this.u.brightness=t,this.I()}get contrast(){return this.u.contrast}set contrast(t){if("number"!=typeof t||t<0)throw new Error("Invalid contrast, you need to give a number above 0");this.u.contrast=t,this.I()}get saturation(){return this.u.saturation}set saturation(t){if("number"!=typeof t||t<0)throw new Error("Invalid saturation, you need to give a number above 0");this.u.saturation=t,this.I()}get hue(){return this.u.hue}set hue(t){if("number"!=typeof t||t<0||t>360)throw new Error("Invalid hue, you need to give a number between 0 and 360");this.u.hue=t,this.I()}get invert(){return this.u.invert}set invert(t){if("number"!=typeof t||t<0||t>1)throw new Error("Invalid invert, you need to give a number between 0 and 1");this.u.invert=t,this.I()}get grayscale(){return this.u.grayscale}set grayscale(t){if("number"!=typeof t||t<0||t>1)throw new Error("Invalid grayscale, you need to give a number between 0 and 1");this.u.grayscale=t,this.I()}get sepia(){return this.u.sepia}set sepia(t){if("number"!=typeof t||t<0||t>1)throw new Error("Invalid sepia, you need to give a number between 0 and 1");this.u.sepia=t,this.I()}get blur(){return this.u.blur}set blur(t){if("number"!=typeof t||t<0)throw new Error("Invalid blur, you need to give a number above 0");this.u.blur=t,this.I()}get url(){return this.u.url}set url(t){if("string"!=typeof t)throw new Error("Invalid url, you need to give a string");this.u.url=t,this.I()}get blend(){return this.u.blend}set blend(t){if("object"!=typeof t)throw new Error("Invalid blend, you need to give a valid object with {mode|color} or an empty object to disable blending");this.u.blend=t,this.I()}get filter(){return this.u.filter}set filter(t){if(null!==t&&"function"!=typeof t)throw new Error("Invalid filter, you need to give a function or null to disable the custom filtering");this.u.filter=t}get style(){return 0!==this.S.length?this.S.trim().split(" "):[]}get hardware(){return void 0===this.$?null:this.k}}}]).default}));
{
"name": "instacam",
"year": "2019",
"version": "1.11.2",
"version": "1.11.3",
"description": "Instant canvas video",

@@ -39,4 +39,4 @@ "main": "dist/instacam.umd.js",

"devDependencies": {
"terser-webpack-plugin": "^2.2.2",
"webpack": "^4.41.2",
"terser-webpack-plugin": "^2.3.1",
"webpack": "^4.41.4",
"webpack-command": "^0.5.0",

@@ -43,0 +43,0 @@ "webpack-merge": "^4.2.2"

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