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

quikpik

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quikpik - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

2

dist/quikpik.js

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

var quikpik=(()=>{var V=Object.defineProperty;var h=Object.assign;var $=(t,o)=>{for(var e in o)V(t,e,{get:o[e],enumerable:!0})};var ae={};$(ae,{default:()=>R});function U(){let t=!1,o,e,r=(s,a)=>{t||(t=!0,s(a))},n=new Promise((s,a)=>{o=s,e=a});return n.resolve=s=>r(o,s),n.reject=s=>r(e,s),n}function G(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof NodeList)&&!(t instanceof Node)&&!(t.el instanceof Node)}function J(t){return!!t.forEach}function j(t,o,e,r){return t.addEventListener(o,e,r),()=>t.removeEventListener(o,e,r)}function g(t){return c("div",{innerHTML:t}).firstChild}function c(t,...o){let[e,...r]=t.split("."),n=e==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(e||"div");e==="svg"&&n.setAttribute("xmlns","http://www.w3.org/2000/svg");let s=o[0],a=G(s)&&s;return r.length&&(n.className=r.join(" ")),K(a,n),Q(a?o.slice(1):o,n),n}function K(t,o){return o&&t&&Object.keys(t).forEach(e=>{let r=t[e];if(e==="class"||e==="className"){let n=r&&r.split(" ");n&&n.length&&o.classList.add(...n)}else e==="innerHTML"||e==="textContent"||typeof r=="function"||e.startsWith("$")?o[e]=r:r!==!1&&r!==void 0&&r!==null&&o.setAttribute(e,r)}),o}function Q(t,o){return o.appendChild(W(t)),o}function W(t,o){return o||(o=document.createDocumentFragment()),t instanceof Node||typeof t=="string"?Z(t,o):(J(t)&&Array.from(t).forEach(e=>e&&W(e,o)),o)}function Z(t,o){if(!t)return o;let e=typeof t=="string"?document.createTextNode(t):t;return o instanceof Range?(o.insertNode(e),o.collapse()):o instanceof Node&&o.appendChild(e),o}var P=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>');(function(){if(window.ImageCapture)return;let o=document.createElement("script");o.src="https://unpkg.com/browse/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(o)})();function N(){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:t,takeaudio:t}}function A(t){let o=t.video?["video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav"],[e]=o.filter(r=>MediaRecorder.isTypeSupported(r));if(!e)throw new Error("No supported mime type found.");return e}function z(t){return t.name=`your${t.type.replace("/",".")}`,t}function F(t){let o=[],e,r;function n(i){i.data.size>0?o.push(i.data):console.error("No data",i)}function s(){return e}function a(){let i=e.getVideoTracks()[0];return new ImageCapture(i).takePhoto().then(z)}function m(){o=[],r=new MediaRecorder(e,{mimeType:A(t)}),r.ondataavailable=n,r.start()}function l(){return new Promise((i,u)=>{r.onstop=()=>{try{let d=new Blob(o,{type:A(t)});i(z(d))}catch(d){u(d)}},r.stop()})}return navigator.mediaDevices.getUserMedia(t).then(i=>(e=i,{liveSrc:s,capturePhoto:a,beginMediaCapture:m,endMediaCapture:l}))}function b({onPickFile:t,accept:o,sources:e,onTakePhoto:r}){let n=N().takephoto&&e.includes("takephoto"),s=c("label.quik-drop-target.quik-content",{ondragover(a){a.preventDefault(),s.classList.add("quik-drop-target-active")},ondragleave(){s.classList.remove("quik-drop-target-active")},ondrop(a){a.preventDefault(),a.stopPropagation(),t(a.dataTransfer.files&&a.dataTransfer.files[0])}},c("input.quik-file-input",{type:"file",accept:o,onchange(a){t(a.target.files[0])}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),n&&c("button.quik-footer-btn",{onclick(a){a.preventDefault(),r()}},P(),"Take Photo"))));return s}function S({close:t,onPickFile:o,accept:e,onTakePhoto:r,sources:n}){return c(".quikpik",{onclick:t,ontouchend:t},c("div.quik-body",{onclick(a){a.stopPropagation()},ontouchend(a){a.stopPropagation()}},b({onPickFile:o,accept:e,onTakePhoto:r,sources:n})))}function k(t,o){t.querySelector(".quik-body").firstChild.replaceWith(o)}function B(t){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading ",t.name||""),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function O(t,o){let e=t.querySelector(".quik-progress-bar");t.querySelector(".quik-percent").textContent=Math.round(o)+"%",e.style.width=o+"%",o>=100&&e.classList.add("quik-done-bar")}function X(t,o,e,r){let n=0,s=!1,a=new Image;function m(){let i=e.width;e.width=e.height,e.height=i}function l(i,u,d){if(!u||!s)return;let p=u.getContext("2d");p.translate(u.width/2,u.height/2),p.rotate(d*Math.PI/180),p.drawImage(i,-i.width/2,-i.height/2),p.rotate(-d*Math.PI/180),p.translate(-u.width/2,-u.height/2)}return a.addEventListener("load",()=>{s=!0,e.width=a.width,e.height=a.height,l(a,e,n),r()}),a.addEventListener("error",()=>alert("Failed to load image.")),a.src=t,{save(i="image/png",u=void 0){return n?new Promise(d=>e.toBlob(p=>{p.name=o&&o.name,d(p)},i,u)):Promise.resolve(o)},rotate(){n=(n+90)%360,m(),l(a,e,n)}}}var _=32,ee=32;function te(t){let o=t.parentElement,e=c(".quik-crop");return o.appendChild(e),e}var T=({e:t,bounds:o,parentBounds:e})=>({left:t.clientX-e.x,width:o.right-t.clientX}),y=({e:t,bounds:o,newSize:e,aspectRatio:r})=>({width:r&&e?e.height*(1/r):t.clientX-o.x}),D=({e:t,bounds:o,parentBounds:e,newSize:r,aspectRatio:n})=>{if(n&&r){let s=r.width*n;return{top:o.bottom-s-e.y,height:s}}return{top:t.clientY-e.y,height:o.bottom-t.clientY}},q=({e:t,bounds:o,newSize:e,aspectRatio:r})=>({height:r&&e?r*e.width:t.clientY-o.y}),oe=({e:t,parentBounds:o,offsetY:e,offsetX:r})=>({top:t.clientY-o.y-e,left:t.clientX-o.x-r}),E=()=>{};function re({image:t,cropBounds:o,scale:e}){let r=c("canvas");return r.width=o.width*e,r.height=o.height*e,r.getContext("2d").drawImage(t,o.left*e,o.top*e,o.width*e,o.height*e,0,0,r.width,r.height),new Promise(s=>{r.toBlob(a=>{a.name=t.name,s(a)},"image/png")})}function I(t,o){let e=te(t),r=i=>u=>{let d=e.offsetParent,p=e.getBoundingClientRect(),w=d.getBoundingClientRect(),{offsetY:f,offsetX:M}=u;function C(x){let L=i({e:x,offsetY:f,offsetX:M,bounds:p,parentBounds:w,aspectRatio:o});Object.keys(L).forEach(v=>e.style[v]=L[v]+"px")}d.addEventListener("mousemove",C),document.addEventListener("mouseup",function x(L){d.removeEventListener("mousemove",C),document.removeEventListener("mouseup",x)})},n=(i,u)=>r(d=>{let p=i(d);return Object.assign(p,u(h(h({},d),{newSize:p}))),p.width<ee||p.height<_?{}:p}),s={se:n(y,q),sw:n(T,q),ne:n(y,D),nw:n(T,D),s:n(q,o?y:E),e:n(y,o?q:E),n:n(D,o?y:E),w:n(T,o?q:E),move:r(oe)},a=s.move;return e.addEventListener("mousemove",i=>{let u=e.getBoundingClientRect(),d=Math.max(10,Math.floor(u.width/5)),p=Math.max(10,Math.floor(u.height/5)),w=i.clientX<u.left+p,f=i.clientX>u.right-d,M=i.clientY<u.top+p,C=i.clientY>u.bottom-p,v=(M?"n":C?"s":"")+(f?"e":w?"w":"");v?(e.style.cursor=v+"-resize",a=s[v]):(e.style.cursor="grabbing",a=s.move)}),e.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),a(i)}),{el:e,dispose:()=>{e.remove()},apply:i=>re({image:i,cropBounds:{top:e.offsetTop-t.offsetTop,left:e.offsetLeft-t.offsetLeft,width:e.offsetWidth,height:e.offsetHeight},scale:i.naturalWidth/t.offsetWidth})}}function ne(t,o){let e=new Image;return new Promise(r=>{e.onload=()=>{r(o(e)),URL.revokeObjectURL(e.src)},e.src=URL.createObjectURL(t)})}function Y({url:t,file:o,cancelText:e,confirmText:r,onCancel:n,onConfirm:s,requireCrop:a,cropRatio:m}){let l,i=c(".quik-content-wrapper",c(".quik-text","Loading...")),u=c("canvas.quik-confirm-item"),d=c(".quik-content",u),p=X(t,o,u,()=>{l=a?I(u,m):void 0,i.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:n},e),!a&&c("button.quik-footer-btn",{onclick(){l?(l.dispose(),l=void 0):l=I(u,m)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:p.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(w){w.target.disabled=!0,p.save().then(f=>l?ne(f,l.apply):f).then(f=>{f.name=o.name,s(f)})}},r))),i.firstChild.replaceWith(d)});return i}function ie({recorder:t,onPickFile:o,onError:e}){let r=c("video.quik-vid.quik-content");return r.srcObject=t.liveSrc(),r.muted=!0,r.controls=!1,r.play(),r}function H({onPickFile:t,onCancel:o}){let e=c(".quik-media",c("p.quik-info.quik-content","Waiting for your camera..."),c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:o},"Cancel"))),r=n=>{e.firstChild.replaceWith(c("p.quik-error",n.toString()))};return F({video:!0,audio:!1}).then(n=>{e.firstChild.replaceWith(ie({recorder:n,onPickFile:t,onError:r})),e.lastChild.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(){n.capturePhoto().then(t).catch(r)}},P(),"Take photo"))}).catch(r),e}function ce(t){t=h({sources:["filepicker","takephoto"]},t);let o,e=U(),r=[j(window,"keydown",i=>{(i.key==="Escape"||i.code==="Escape")&&s()}),j(document.body,"paste",i=>{i.clipboardData&&i.clipboardData.files&&i.clipboardData.files.length&&(i.preventDefault(),a(i.clipboardData.files[0]))})],n=h(h({},t),{close:s,uploadFile:l,onPickFile:a,onTakePhoto:m,promise:e,root:void 0,uploader:void 0});n.root=S(n);function s(){e.resolve(o),n.root.remove(),r.forEach(i=>i()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function a(i){if(i.type!=="image/gif"&&!i.type.startsWith("image/svg")&&i.type.startsWith("image/")){let u=URL.createObjectURL(i);r.push(()=>URL.revokeObjectURL(u)),k(n.root,Y(h(h({},t),{url:u,file:i,cancelText:"Cancel",confirmText:"Accept & upload",onCancel(){k(n.root,b({onPickFile:a,onTakePhoto:m,accept:n.accept,sources}))},onConfirm(d){l(d)}})));return}l(i)}function m(){k(n.root,H({onPickFile:a,onCancel(){k(n.root,b({onPickFile:a,onTakePhoto:m,accept:n.accept,sources}))}}))}function l(i){if(t.customProgress)n.root.remove(),n.uploader=t.upload({file:i,onProgress(){}}),n.uploader.promise.then(u=>e.resolve(u)).catch(e.reject);else{let u=B(i);k(n.root,u),n.uploader=t.upload({file:i,onProgress(d){O(u,d)}}),n.uploader.promise.then(d=>{o=d,setTimeout(s,250)}).catch(e.reject)}return n.uploader}return e.cancel=s,n}function R(t={}){let o=ce(t);return document.body.appendChild(o.root),o.promise}return ae;})();
var R=Object.defineProperty;var h=Object.assign,$=e=>R(e,"__esModule",{value:!0});var G=(e,o)=>{for(var t in o)R(e,t,{get:o[t],enumerable:!0})};$(exports);G(exports,{default:()=>V});function U(){let e=!1,o,t,r=(s,a)=>{e||(e=!0,s(a))},n=new Promise((s,a)=>{o=s,t=a});return n.resolve=s=>r(o,s),n.reject=s=>r(t,s),n}function J(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function K(e){return!!e.forEach}function j(e,o,t,r){return e.addEventListener(o,t,r),()=>e.removeEventListener(o,t,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...o){let[t,...r]=e.split("."),n=t==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(t||"div");t==="svg"&&n.setAttribute("xmlns","http://www.w3.org/2000/svg");let s=o[0],a=J(s)&&s;return r.length&&(n.className=r.join(" ")),Q(a,n),Z(a?o.slice(1):o,n),n}function Q(e,o){return o&&e&&Object.keys(e).forEach(t=>{let r=e[t];if(t==="class"||t==="className"){let n=r&&r.split(" ");n&&n.length&&o.classList.add(...n)}else t==="innerHTML"||t==="textContent"||typeof r=="function"||t.startsWith("$")?o[t]=r:r!==!1&&r!==void 0&&r!==null&&o.setAttribute(t,r)}),o}function Z(e,o){return o.appendChild(W(e)),o}function W(e,o){return o||(o=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?_(e,o):(K(e)&&Array.from(e).forEach(t=>t&&W(t,o)),o)}function _(e,o){if(!e)return o;let t=typeof e=="string"?document.createTextNode(e):e;return o instanceof Range?(o.insertNode(t),o.collapse()):o instanceof Node&&o.appendChild(t),o}var P=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>');(function(){if(window.ImageCapture)return;let o=document.createElement("script");o.src="https://unpkg.com/browse/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(o)})();function N(){let e=!!window.MediaRecorder;return{filepicker:!0,takephoto:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e,takeaudio:e}}function A(e){let o=e.video?["video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav"],[t]=o.filter(r=>MediaRecorder.isTypeSupported(r));if(!t)throw new Error("No supported mime type found.");return t}function z(e){return e.name=`your${e.type.replace("/",".")}`,e}function F(e){let o=[],t,r;function n(i){i.data.size>0?o.push(i.data):console.error("No data",i)}function s(){return t}function a(){let i=t.getVideoTracks()[0];return new ImageCapture(i).takePhoto().then(z)}function m(){o=[],r=new MediaRecorder(t,{mimeType:A(e)}),r.ondataavailable=n,r.start()}function l(){return new Promise((i,u)=>{r.onstop=()=>{try{let d=new Blob(o,{type:A(e)});i(z(d))}catch(d){u(d)}},r.stop()})}return navigator.mediaDevices.getUserMedia(e).then(i=>(t=i,{liveSrc:s,capturePhoto:a,beginMediaCapture:m,endMediaCapture:l}))}function b({onPickFile:e,accept:o,sources:t,onTakePhoto:r}){let n=N().takephoto&&t.includes("takephoto"),s=c("label.quik-drop-target.quik-content",{ondragover(a){a.preventDefault(),s.classList.add("quik-drop-target-active")},ondragleave(){s.classList.remove("quik-drop-target-active")},ondrop(a){a.preventDefault(),a.stopPropagation(),e(a.dataTransfer.files&&a.dataTransfer.files[0])}},c("input.quik-file-input",{type:"file",accept:o,onchange(a){e(a.target.files[0])}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),n&&c("button.quik-footer-btn",{onclick(a){a.preventDefault(),r()}},P(),"Take Photo"))));return s}function S({close:e,onPickFile:o,accept:t,onTakePhoto:r,sources:n}){return c(".quikpik",{onclick:e,ontouchend:e},c("div.quik-body",{onclick(a){a.stopPropagation()},ontouchend(a){a.stopPropagation()}},b({onPickFile:o,accept:t,onTakePhoto:r,sources:n})))}function k(e,o){e.querySelector(".quik-body").firstChild.replaceWith(o)}function B(e){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading ",e.name||""),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function O(e,o){let t=e.querySelector(".quik-progress-bar");e.querySelector(".quik-percent").textContent=Math.round(o)+"%",t.style.width=o+"%",o>=100&&t.classList.add("quik-done-bar")}function X(e,o,t,r){let n=0,s=!1,a=new Image;function m(){let i=t.width;t.width=t.height,t.height=i}function l(i,u,d){if(!u||!s)return;let p=u.getContext("2d");p.translate(u.width/2,u.height/2),p.rotate(d*Math.PI/180),p.drawImage(i,-i.width/2,-i.height/2),p.rotate(-d*Math.PI/180),p.translate(-u.width/2,-u.height/2)}return a.addEventListener("load",()=>{s=!0,t.width=a.width,t.height=a.height,l(a,t,n),r()}),a.addEventListener("error",()=>alert("Failed to load image.")),a.src=e,{save(i="image/png",u=void 0){return n?new Promise(d=>t.toBlob(p=>{p.name=o&&o.name,d(p)},i,u)):Promise.resolve(o)},rotate(){n=(n+90)%360,m(),l(a,t,n)}}}var ee=32,te=32;function oe(e){let o=e.parentElement,t=c(".quik-crop");return o.appendChild(t),t}var T=({e,bounds:o,parentBounds:t})=>({left:e.clientX-t.x,width:o.right-e.clientX}),y=({e,bounds:o,newSize:t,aspectRatio:r})=>({width:r&&t?t.height*(1/r):e.clientX-o.x}),D=({e,bounds:o,parentBounds:t,newSize:r,aspectRatio:n})=>{if(n&&r){let s=r.width*n;return{top:o.bottom-s-t.y,height:s}}return{top:e.clientY-t.y,height:o.bottom-e.clientY}},q=({e,bounds:o,newSize:t,aspectRatio:r})=>({height:r&&t?r*t.width:e.clientY-o.y}),re=({e,parentBounds:o,offsetY:t,offsetX:r})=>({top:e.clientY-o.y-t,left:e.clientX-o.x-r}),E=()=>{};function ne({image:e,cropBounds:o,scale:t}){let r=c("canvas");return r.width=o.width*t,r.height=o.height*t,r.getContext("2d").drawImage(e,o.left*t,o.top*t,o.width*t,o.height*t,0,0,r.width,r.height),new Promise(s=>{r.toBlob(a=>{a.name=e.name,s(a)},"image/png")})}function I(e,o){let t=oe(e),r=i=>u=>{let d=t.offsetParent,p=t.getBoundingClientRect(),w=d.getBoundingClientRect(),{offsetY:f,offsetX:M}=u;function C(x){let L=i({e:x,offsetY:f,offsetX:M,bounds:p,parentBounds:w,aspectRatio:o});Object.keys(L).forEach(v=>t.style[v]=L[v]+"px")}d.addEventListener("mousemove",C),document.addEventListener("mouseup",function x(L){d.removeEventListener("mousemove",C),document.removeEventListener("mouseup",x)})},n=(i,u)=>r(d=>{let p=i(d);return Object.assign(p,u(h(h({},d),{newSize:p}))),p.width<te||p.height<ee?{}:p}),s={se:n(y,q),sw:n(T,q),ne:n(y,D),nw:n(T,D),s:n(q,o?y:E),e:n(y,o?q:E),n:n(D,o?y:E),w:n(T,o?q:E),move:r(re)},a=s.move;return t.addEventListener("mousemove",i=>{let u=t.getBoundingClientRect(),d=Math.max(10,Math.floor(u.width/5)),p=Math.max(10,Math.floor(u.height/5)),w=i.clientX<u.left+p,f=i.clientX>u.right-d,M=i.clientY<u.top+p,C=i.clientY>u.bottom-p,v=(M?"n":C?"s":"")+(f?"e":w?"w":"");v?(t.style.cursor=v+"-resize",a=s[v]):(t.style.cursor="grabbing",a=s.move)}),t.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),a(i)}),{el:t,dispose:()=>{t.remove()},apply:i=>ne({image:i,cropBounds:{top:t.offsetTop-e.offsetTop,left:t.offsetLeft-e.offsetLeft,width:t.offsetWidth,height:t.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}function ie(e,o){let t=new Image;return new Promise(r=>{t.onload=()=>{r(o(t)),URL.revokeObjectURL(t.src)},t.src=URL.createObjectURL(e)})}function Y({url:e,file:o,cancelText:t,confirmText:r,onCancel:n,onConfirm:s,requireCrop:a,cropRatio:m}){let l,i=c(".quik-content-wrapper",c(".quik-text","Loading...")),u=c("canvas.quik-confirm-item"),d=c(".quik-content",u),p=X(e,o,u,()=>{l=a?I(u,m):void 0,i.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:n},t),!a&&c("button.quik-footer-btn",{onclick(){l?(l.dispose(),l=void 0):l=I(u,m)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:p.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(w){w.target.disabled=!0,p.save().then(f=>l?ie(f,l.apply):f).then(f=>{f.name=o.name,s(f)})}},r))),i.firstChild.replaceWith(d)});return i}function ae({recorder:e,onPickFile:o,onError:t}){let r=c("video.quik-vid.quik-content");return r.srcObject=e.liveSrc(),r.muted=!0,r.controls=!1,r.play(),r}function H({onPickFile:e,onCancel:o}){let t=c(".quik-media",c("p.quik-info.quik-content","Waiting for your camera..."),c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:o},"Cancel"))),r=n=>{t.firstChild.replaceWith(c("p.quik-error",n.toString()))};return F({video:!0,audio:!1}).then(n=>{t.firstChild.replaceWith(ae({recorder:n,onPickFile:e,onError:r})),t.lastChild.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(){n.capturePhoto().then(e).catch(r)}},P(),"Take photo"))}).catch(r),t}function ce(e){e=h({sources:["filepicker","takephoto"]},e);let o,t=U(),r=[j(window,"keydown",i=>{(i.key==="Escape"||i.code==="Escape")&&s()}),j(document.body,"paste",i=>{i.clipboardData&&i.clipboardData.files&&i.clipboardData.files.length&&(i.preventDefault(),a(i.clipboardData.files[0]))})],n=h(h({},e),{close:s,uploadFile:l,onPickFile:a,onTakePhoto:m,promise:t,root:void 0,uploader:void 0});n.root=S(n);function s(){t.resolve(o),n.root.remove(),r.forEach(i=>i()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function a(i){if(i.type!=="image/gif"&&!i.type.startsWith("image/svg")&&i.type.startsWith("image/")){let u=URL.createObjectURL(i);r.push(()=>URL.revokeObjectURL(u)),k(n.root,Y(h(h({},e),{url:u,file:i,cancelText:"Cancel",confirmText:"Accept & upload",onCancel(){k(n.root,b({onPickFile:a,onTakePhoto:m,accept:n.accept,sources}))},onConfirm(d){l(d)}})));return}l(i)}function m(){k(n.root,H({onPickFile:a,onCancel(){k(n.root,b({onPickFile:a,onTakePhoto:m,accept:n.accept,sources}))}}))}function l(i){if(e.customProgress)n.root.remove(),n.uploader=e.upload({file:i,onProgress(){}}),n.uploader.promise.then(u=>t.resolve(u)).catch(t.reject);else{let u=B(i);k(n.root,u),n.uploader=e.upload({file:i,onProgress(d){O(u,d)}}),n.uploader.promise.then(d=>{o=d,setTimeout(s,250)}).catch(t.reject)}return n.uploader}return t.cancel=s,n}function V(e={}){let o=ce(e);return document.body.appendChild(o.root),o.promise}
{
"name": "quikpik",
"version": "0.0.15",
"version": "0.0.16",
"main": "./dist/quikpik.js",

@@ -8,3 +8,3 @@ "types": "./types.d.ts",

"prepublishOnly": "npm run build",
"build": "NODE_ENV=production esbuild src/index.js --global-name=quikpik --bundle --outfile=dist/quikpik.js --sourcemap=external --minify --target=es6 --define:process.env.NODE_ENV=\"'production'\"",
"build": "NODE_ENV=production esbuild src/index.js --global-name=quikpik --bundle --outfile=dist/quikpik.js --sourcemap=external --minify --format=cjs --target=es6 --define:process.env.NODE_ENV=\"'production'\"",
"start": "esbuild public/main.js --outfile=public/build/bundle.js --bundle --servedir=public",

@@ -11,0 +11,0 @@ "test": ""

@@ -24,4 +24,4 @@ # quikpik

```
<script src="https://unpkg.com/quikpik@0.0.15/dist/quikpik.js"></script>
<link rel="stylesheet" href="https://unpkg.com/quikpik@0.0.15/dist/quikpik.css"></script>
<script src="https://unpkg.com/quikpik@0.0.16/dist/quikpik.js"></script>
<link rel="stylesheet" href="https://unpkg.com/quikpik@0.0.16/dist/quikpik.css"></script>
```

@@ -28,0 +28,0 @@

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