javascript-barcode-reader
Advanced tools
Comparing version 0.6.8 to 0.6.9
@@ -1,16 +0,16 @@ | ||
import{read as n}from"jimp"; | ||
import*as n from"jimp"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */function e(n,e,t,w){return new(t||(t=Promise))((function(o,r){function c(n){try{s(w.next(n))}catch(n){r(n)}}function i(n){try{s(w.throw(n))}catch(n){r(n)}}function s(n){n.done?o(n.value):new t((function(e){e(n.value)})).then(c,i)}s((w=w.apply(n,e||[])).next())}))}const t={nnnnnww:"0",nnnnwwn:"1",nnnwnnw:"2",wwnnnnn:"3",nnwnnwn:"4",wnnnnwn:"5",nwnnnnw:"6",nwnnwnn:"7",nwwnnnn:"8",wnnwnnn:"9",nnnwwnn:"-",nnwwnnn:"$",wnnnwnw:":",wnwnnnw:"/",wnwnwnn:".",nnwwwww:"+",nnwwnwn:"A",nnnwnww:"B",nwnwnnw:"C",nnnwwwn:"D"};function w(n){const e=[],w=Math.ceil(n.reduce((n,e)=>(n+e)/2,0));for(;n.length>0;){const o=n.splice(0,8).splice(0,7).map(n=>n<w?"n":"w").join("");e.push(t[o])}return e.join("")}const o=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232","233111","211133","2331112"],r=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","FS","GS","RS","US","FNC 3","FNC 2","Shift B","Code C","Code B","FNC 4","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],c=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL","FNC 3","FNC 2","Shift A","Code C","FNC 4","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],i=["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","Code B","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"];function s(n){const e=[];let t,w,s=c;const a=(n=>{const e=n.length-13,t=n.reduce((n,t,w)=>w>=e?n:n+t,0)/(11*Math.ceil(e/6));return n.map(n=>Math.round(n/t)||1)})(n);if(!a)return"";a.pop();for(let n=0;6*n<a.length-13;n+=1){t=a.slice(6*n,6*(n+1)).join("");const l=s[o.indexOf(t)];switch(l){case"Code A":s=r;break;case"Code B":s=c;break;case"Code C":s=i;break;case"FNC 4":break;default:l?("FNC 4"===w?e.push(l.charCodeAt(0)+128):e.push(l),w=l):e.push("?")}}return e.join("")}const a={nnnwwnwnn:"0",wnnwnnnnw:"1",nnwwnnnnw:"2",wnwwnnnnn:"3",nnnwwnnnw:"4",wnnwwnnnn:"5",nnwwwnnnn:"6",nnnwnnwnw:"7",wnnwnnwnn:"8",nnwwnnwnn:"9",wnnnnwnnw:"A",nnwnnwnnw:"B",wnwnnwnnn:"C",nnnnwwnnw:"D",wnnnwwnnn:"E",nnwnwwnnn:"F",nnnnnwwnw:"G",wnnnnwwnn:"H",nnwnnwwnn:"I",nnnnwwwnn:"J",wnnnnnnww:"K",nnwnnnnww:"L",wnwnnnnwn:"M",nnnnwnnww:"N",wnnnwnnwn:"O",nnwnwnnwn:"P",nnnnnnwww:"Q",wnnnnnwwn:"R",nnwnnnwwn:"S",nnnnwnwwn:"T",wwnnnnnnw:"U",nwwnnnnnw:"V",wwwnnnnnn:"W",nwnnwnnnw:"X",wwnnwnnnn:"Y",nwwnwnnnn:"Z",nwnnnnwnw:"-",wwnnnnwnn:".",nwwnnnwnn:" ",nwnwnwnnn:"$",nwnwnnnwn:"/",nwnnnwnwn:"+",nnnwnwnwn:"%",nwnnwnwnn:"*"};function l(n){const e=[],t=Math.ceil(n.reduce((n,e)=>n+e,0)/n.length);for(;n.length>0;){const w=n.splice(0,10).map(n=>n>t?"w":"n").slice(0,9).join("");e.push(a[w])}return"*"!==e.pop()||"*"!==e.shift()?"":e.join("")}const h=[{100010100:"0"},{101001e3:"1"},{101000100:"2"},{101000010:"3"},{100101e3:"4"},{100100100:"5"},{100100010:"6"},{10101e4:"7"},{100010010:"8"},{100001010:"9"},{110101e3:"A"},{110100100:"B"},{110100010:"C"},{110010100:"D"},{110010010:"E"},{110001010:"F"},{101101e3:"G"},{101100100:"H"},{101100010:"I"},{100110100:"J"},{100011010:"K"},{101011e3:"L"},{101001100:"M"},{101000110:"N"},{100101100:"O"},{100010110:"P"},{110110100:"Q"},{110110010:"R"},{110101100:"S"},{110100110:"T"},{110010110:"U"},{110011010:"V"},{101101100:"W"},{101100110:"X"},{100110110:"Y"},{100111010:"Z"},{100101110:"-"},{111010100:"."},{111010010:" "},{111001010:"$"},{101101110:"/"},{101110110:"+"},{110101110:"%"},{100100110:"($)"},{111011010:"(%)"},{111010110:"(/)"},{100110010:"(+)"},{101011110:"*"}];function f(n){const e=[],t=[];n.pop();const w=Math.ceil(n.reduce((n,e)=>n+e,0)/n.length),o=Math.ceil(n.reduce((n,e)=>e<w?(n+e)/2:n,0));for(let e=0;e<n.length;e+=1){let w=n[e];for(;w>0;)e%2==0?t.push(1):t.push(0),w-=o}for(let n=0;n<t.length;n+=9){const w=t.slice(n,n+9).join(""),o=h.filter(n=>Object.keys(n)[0]===w);e.push(o[0][w])}if("*"!==e.shift()||"*"!==e.pop())return"";const r=e.pop();let c,i,s=0;const a=n=>Object.values(n)[0]===c;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=h.indexOf(h.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);if(Object.values(h[s%47])[0]!==r)return"";const l=e.pop();s=0;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=h.indexOf(h.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);return Object.values(h[s%47])[0]!==l?"":e.join("")}const d=["nnwwn","wnnnw","nwnnw","wwnnn","nnwnw","wnwnn","nwwnn","nnnww","wnnwn","nwnwn"];function p(n,e){const t=[],w=Math.ceil(n.reduce((n,e)=>(n+e)/2,0));if("interleaved"===e){const e=n.splice(0,4).map(n=>n>w?"w":"n").join(""),o=n.splice(n.length-3,3).map(n=>n>w?"w":"n").join("");if("nnnn"!==e||"wnn"!==o)return"";for(;n.length>0;){const e=n.splice(0,10),o=e.filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join("");t.push(d.indexOf(o));const r=e.filter((n,e)=>e%2!=0).map(n=>n>w?"w":"n").join("");t.push(d.indexOf(r))}}else{const e=n.splice(0,6).filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join(""),o=n.splice(n.length-5,5).filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join("");if("wwn"!==e||"wnw"!==o)return"";for(;n.length>0;){const e=n.splice(0,10).filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join("");t.push(d.indexOf(e))}}return t.join("")}const u={3211:"0",2221:"1",2122:"2",1411:"3",1132:"4",1231:"5",1114:"6",1312:"7",1213:"8",3112:"9"};function C(n,e="13"){let t="";const w=(n[0]+n[1]+n[2])/3;n.shift(),n.shift(),n.shift(),n.pop(),n.pop(),n.pop(),"13"===e?n.splice(24,5):n.splice(16,5);for(let e=0;e<n.length;e+=4){const o=n.slice(e,e+4),r=[o[0]/w,o[1]/w,o[2]/w,o[3]/w].map(n=>1.5===n?1:Math.round(n)),c=u[r.join("")]||u[r.reverse().join("")];t+=c||"?"}return t}var g;function m(n,e){if(""===n||""===e)return e;const t=n.split("");return e.split("").forEach((n,e)=>{t[e]&&"?"!==t[e]||n&&"?"!==n&&(t[e]=n)}),t.join("")}function v(n){const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");const w=n.naturalWidth,o=n.naturalHeight;return e.width=w,e.height=o,t.drawImage(n,0,0),t.getImageData(0,0,w,o)}!function(n){n["code-128"]="code-128",n["code-2of5"]="code-2of5",n["code-39"]="code-39",n["code-93"]="code-93",n["ean-13"]="ean-13",n["ean-8"]="ean-8",n.codabar="codabar"}(g||(g={}));const E="object"==typeof process&&process.release&&"node"===process.release.name;function b(n,e,t){const w=[],o=n.length/(e*t);let r=0,c=0;for(let i=0;i<e;i+=1){let s=0,a=0;for(let w=0;w<t;w+=1){const t=(w*e+i)*o;s+=Math.sqrt((Math.pow(n[t],2)+Math.pow(n[t+1],2)+Math.pow(n[t+2],2))/3)}a=s/t>=127?255:0,255===a&&0===r||(a===c?r+=1:(w.push(r),c=a,r=1),i===e-1&&0===a&&w.push(r))}return w}let j;try{process&&"test"===process.env.NODE_ENV&&(j=!0)}catch(n){j=!1}export default function({image:t,barcode:o,barcodeType:r,options:c}){return e(this,void 0,void 0,(function*(){let i;switch(o){case g.codabar:i=w;break;case g["code-128"]:i=s;break;case g["code-39"]:i=l;break;case g["code-93"]:i=f;break;case g["code-2of5"]:i=p;break;case g["ean-13"]:i=C,r="13";break;case g["ean-8"]:i=C,r="8";break;default:throw new Error(`Invalid barcode specified. Available decoders: ${g}.`)}const a=j||c&&c.singlePass||!1,{data:h,width:d,height:u}=(M=t).data&&M.width&&M.height?t:yield function(t){return e(this,void 0,void 0,(function*(){return new Promise((e,w)=>{if("string"==typeof t)if(t.startsWith("#")){const n=document.getElementById(t.substr(1));if(n instanceof HTMLImageElement&&e(v(n)),n instanceof HTMLCanvasElement){const t=n.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");e(t.getImageData(0,0,n.width,n.height))}w(new Error("Invalid image source specified!"))}else if(!(o=t).startsWith("#")&&/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(o)){const n=new Image;n.onerror=w,n.onload=()=>e(v(n)),n.src=t}else E&&n(t,(n,t)=>{if(n)w(n);else{const{data:n,width:w,height:o}=t.bitmap;e({data:Uint8ClampedArray.from(n),width:w,height:o})}});else if(t instanceof HTMLImageElement)e(v(t));else if(t instanceof HTMLCanvasElement){const n=t.getContext("2d");if(!n)throw new Error("Cannot create canvas 2d context");e(n.getImageData(0,0,t.width,t.height))}var o})}))}(t);var M;const S=h.length/(d*u);let N="";c&&c.useAdaptiveThreshold&&function(n,e,t){const w=new Array(e*t).fill(0),o=n.length/(e*t),r=Math.floor(t),c=Math.floor(r/2);for(let r=0;r<e;r+=1){let c=0;for(let i=0;i<t;i+=1){const t=i*e+r,s=t*o,a=(n[s]+n[s+1]+n[s+2])/3;n[s]=a,n[s+1]=a,n[s+2]=a,c+=a,w[t]=0===r?c:w[t-1]+c}}for(let r=0;r<e;r+=1)for(let i=0;i<t;i+=1){const s=(i*e+r)*o;let a=r-c,l=r+c,h=i-c,f=i+c;a<0&&(a=0),l>=e&&(l=e-1),h<0&&(h=0),f>=t&&(f=t-1);const d=(l-a)*(f-h),p=w[f*e+l]-w[h*e+l]-w[f*e+a]+w[h*e+a];let u=255;n[s]*d<.85*p&&(u=0),n[s]=u,n[s+1]=u,n[s+2]=u}}(h,d,u);const A=[5,6,4,7,3,8,2,9,1],F=Math.round(u/A.length),O=Math.min(2,u);for(let n=0;n<A.length;n+=1){const e=S*d*Math.floor(F*A[n]),t=e+O*S*d,w=b(h.slice(e,t),d,O);if(0===w.length){if(a||n===A.length-1)throw new Error("Failed to detect lines in the image!");continue}const o=i(w,r);if(o){if(a||!o.includes("?"))return o;if(N=m(N,o),!N.includes("?"))return N}}return N}))} | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function e(n,e,t,w){return new(t||(t=Promise))((function(o,r){function c(n){try{s(w.next(n))}catch(n){r(n)}}function i(n){try{s(w.throw(n))}catch(n){r(n)}}function s(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(c,i)}s((w=w.apply(n,e||[])).next())}))}const t={nnnnnww:"0",nnnnwwn:"1",nnnwnnw:"2",wwnnnnn:"3",nnwnnwn:"4",wnnnnwn:"5",nwnnnnw:"6",nwnnwnn:"7",nwwnnnn:"8",wnnwnnn:"9",nnnwwnn:"-",nnwwnnn:"$",wnnnwnw:":",wnwnnnw:"/",wnwnwnn:".",nnwwwww:"+",nnwwnwn:"A",nnnwnww:"B",nwnwnnw:"C",nnnwwwn:"D"};function w(n){const e=[],w=Math.ceil(n.reduce(((n,e)=>(n+e)/2),0));for(;n.length>0;){const o=n.splice(0,8).splice(0,7).map((n=>n<w?"n":"w")).join("");e.push(t[o])}return e.join("")}const o=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232","233111","211133","2331112"],r=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","FS","GS","RS","US","FNC 3","FNC 2","Shift B","Code C","Code B","FNC 4","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],c=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL","FNC 3","FNC 2","Shift A","Code C","FNC 4","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],i=["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","Code B","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"];function s(n){const e=[];let t,w,s=c;const a=(n=>{const e=n.length-13,t=n.reduce(((n,t,w)=>w>=e?n:n+t),0)/(11*Math.ceil(e/6));return n.map((n=>Math.round(n/t)||1))})(n);if(!a)return"";a.pop();for(let n=0;6*n<a.length-13;n+=1){t=a.slice(6*n,6*(n+1)).join("");const l=s[o.indexOf(t)];switch(l){case"Code A":s=r;break;case"Code B":s=c;break;case"Code C":s=i;break;case"FNC 4":break;default:l?("FNC 4"===w?e.push(l.charCodeAt(0)+128):e.push(l),w=l):e.push("?")}}return e.join("")}const a={nnnwwnwnn:"0",wnnwnnnnw:"1",nnwwnnnnw:"2",wnwwnnnnn:"3",nnnwwnnnw:"4",wnnwwnnnn:"5",nnwwwnnnn:"6",nnnwnnwnw:"7",wnnwnnwnn:"8",nnwwnnwnn:"9",wnnnnwnnw:"A",nnwnnwnnw:"B",wnwnnwnnn:"C",nnnnwwnnw:"D",wnnnwwnnn:"E",nnwnwwnnn:"F",nnnnnwwnw:"G",wnnnnwwnn:"H",nnwnnwwnn:"I",nnnnwwwnn:"J",wnnnnnnww:"K",nnwnnnnww:"L",wnwnnnnwn:"M",nnnnwnnww:"N",wnnnwnnwn:"O",nnwnwnnwn:"P",nnnnnnwww:"Q",wnnnnnwwn:"R",nnwnnnwwn:"S",nnnnwnwwn:"T",wwnnnnnnw:"U",nwwnnnnnw:"V",wwwnnnnnn:"W",nwnnwnnnw:"X",wwnnwnnnn:"Y",nwwnwnnnn:"Z",nwnnnnwnw:"-",wwnnnnwnn:".",nwwnnnwnn:" ",nwnwnwnnn:"$",nwnwnnnwn:"/",nwnnnwnwn:"+",nnnwnwnwn:"%",nwnnwnwnn:"*"};function l(n){const e=[],t=Math.ceil(n.reduce(((n,e)=>n+e),0)/n.length);for(;n.length>0;){const w=n.splice(0,10).map((n=>n>t?"w":"n")).slice(0,9).join("");e.push(a[w])}return"*"!==e.pop()||"*"!==e.shift()?"":e.join("")}const h=[{100010100:"0"},{101001e3:"1"},{101000100:"2"},{101000010:"3"},{100101e3:"4"},{100100100:"5"},{100100010:"6"},{10101e4:"7"},{100010010:"8"},{100001010:"9"},{110101e3:"A"},{110100100:"B"},{110100010:"C"},{110010100:"D"},{110010010:"E"},{110001010:"F"},{101101e3:"G"},{101100100:"H"},{101100010:"I"},{100110100:"J"},{100011010:"K"},{101011e3:"L"},{101001100:"M"},{101000110:"N"},{100101100:"O"},{100010110:"P"},{110110100:"Q"},{110110010:"R"},{110101100:"S"},{110100110:"T"},{110010110:"U"},{110011010:"V"},{101101100:"W"},{101100110:"X"},{100110110:"Y"},{100111010:"Z"},{100101110:"-"},{111010100:"."},{111010010:" "},{111001010:"$"},{101101110:"/"},{101110110:"+"},{110101110:"%"},{100100110:"($)"},{111011010:"(%)"},{111010110:"(/)"},{100110010:"(+)"},{101011110:"*"}];function f(n){const e=[],t=[];n.pop();const w=Math.ceil(n.reduce(((n,e)=>n+e),0)/n.length),o=Math.ceil(n.reduce(((n,e)=>e<w?(n+e)/2:n),0));for(let e=0;e<n.length;e+=1){let w=n[e];for(;w>0;)e%2==0?t.push(1):t.push(0),w-=o}for(let n=0;n<t.length;n+=9){const w=t.slice(n,n+9).join(""),o=h.filter((n=>Object.keys(n)[0]===w));e.push(o[0][w])}if("*"!==e.shift()||"*"!==e.pop())return"";const r=e.pop();let c,i,s=0;const a=n=>Object.values(n)[0]===c;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=h.indexOf(h.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);if(Object.values(h[s%47])[0]!==r)return"";const l=e.pop();s=0;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=h.indexOf(h.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);return Object.values(h[s%47])[0]!==l?"":e.join("")}const d=["nnwwn","wnnnw","nwnnw","wwnnn","nnwnw","wnwnn","nwwnn","nnnww","wnnwn","nwnwn"];function p(n,e){const t=[],w=Math.ceil(n.reduce(((n,e)=>(n+e)/2),0));if("interleaved"===e){const e=n.splice(0,4).map((n=>n>w?"w":"n")).join(""),o=n.splice(n.length-3,3).map((n=>n>w?"w":"n")).join("");if("nnnn"!==e||"wnn"!==o)return"";for(;n.length>0;){const e=n.splice(0,10),o=e.filter(((n,e)=>e%2==0)).map((n=>n>w?"w":"n")).join("");t.push(d.indexOf(o));const r=e.filter(((n,e)=>e%2!=0)).map((n=>n>w?"w":"n")).join("");t.push(d.indexOf(r))}}else{const e=n.splice(0,6).filter(((n,e)=>e%2==0)).map((n=>n>w?"w":"n")).join(""),o=n.splice(n.length-5,5).filter(((n,e)=>e%2==0)).map((n=>n>w?"w":"n")).join("");if("wwn"!==e||"wnw"!==o)return"";for(;n.length>0;){const e=n.splice(0,10).filter(((n,e)=>e%2==0)).map((n=>n>w?"w":"n")).join("");t.push(d.indexOf(e))}}return t.join("")}const u={3211:"0",2221:"1",2122:"2",1411:"3",1132:"4",1231:"5",1114:"6",1312:"7",1213:"8",3112:"9"};function C(n,e="13"){let t="";const w=(n[0]+n[1]+n[2])/3;n.shift(),n.shift(),n.shift(),n.pop(),n.pop(),n.pop(),"13"===e?n.splice(24,5):n.splice(16,5);for(let e=0;e<n.length;e+=4){const o=n.slice(e,e+4),r=[o[0]/w,o[1]/w,o[2]/w,o[3]/w].map((n=>1.5===n?1:Math.round(n))),c=u[r.join("")]||u[r.reverse().join("")];t+=c||"?"}return t}var g;function m(n,e){if(""===n||""===e)return e;const t=n.split("");return e.split("").forEach(((n,e)=>{t[e]&&"?"!==t[e]||n&&"?"!==n&&(t[e]=n)})),t.join("")}function v(n){const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");const w=n.naturalWidth,o=n.naturalHeight;return e.width=w,e.height=o,t.drawImage(n,0,0),t.getImageData(0,0,w,o)}!function(n){n["code-128"]="code-128",n["code-2of5"]="code-2of5",n["code-39"]="code-39",n["code-93"]="code-93",n["ean-13"]="ean-13",n["ean-8"]="ean-8",n.codabar="codabar"}(g||(g={}));const E="object"==typeof process&&process.release&&"node"===process.release.name;function b(n,e,t){const w=[],o=n.length/(e*t);let r=0,c=0;for(let i=0;i<e;i+=1){let s=0,a=0;for(let w=0;w<t;w+=1){const t=(w*e+i)*o;s+=Math.sqrt((Math.pow(n[t],2)+Math.pow(n[t+1],2)+Math.pow(n[t+2],2))/3)}a=s/t>=127?255:0,255===a&&0===r||(a===c?r+=1:(w.push(r),c=a,r=1),i===e-1&&0===a&&w.push(r))}return w}let j;try{process&&"test"===process.env.NODE_ENV&&(j=!0)}catch(n){j=!1}function M({image:t,barcode:o,barcodeType:r,options:c}){return e(this,void 0,void 0,(function*(){let i;switch(o){case g.codabar:i=w;break;case g["code-128"]:i=s;break;case g["code-39"]:i=l;break;case g["code-93"]:i=f;break;case g["code-2of5"]:i=p;break;case g["ean-13"]:i=C,r="13";break;case g["ean-8"]:i=C,r="8";break;default:throw new Error(`Invalid barcode specified. Available decoders: ${g}.`)}const a=j||c&&c.singlePass||!1,{data:h,width:d,height:u}=(M=t).data&&M.width&&M.height?t:yield function(t){return e(this,void 0,void 0,(function*(){return new Promise(((e,w)=>{if("string"==typeof t)if(t.startsWith("#")){const n=document.getElementById(t.substr(1));if(n instanceof HTMLImageElement&&e(v(n)),n instanceof HTMLCanvasElement){const t=n.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");e(t.getImageData(0,0,n.width,n.height))}w(new Error("Invalid image source specified!"))}else if(!(o=t).startsWith("#")&&/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(o)){const n=new Image;n.onerror=w,n.onload=()=>e(v(n)),n.src=t}else E&&n.read(t,((n,t)=>{if(n)w(n);else{const{data:n,width:w,height:o}=t.bitmap;e({data:Uint8ClampedArray.from(n),width:w,height:o})}}));else if(t instanceof HTMLImageElement)e(v(t));else if(t instanceof HTMLCanvasElement){const n=t.getContext("2d");if(!n)throw new Error("Cannot create canvas 2d context");e(n.getImageData(0,0,t.width,t.height))}var o}))}))}(t);var M;const S=h.length/(d*u);let N="";c&&c.useAdaptiveThreshold&&function(n,e,t){const w=new Array(e*t).fill(0),o=n.length/(e*t),r=Math.floor(t),c=Math.floor(r/2);for(let r=0;r<e;r+=1){let c=0;for(let i=0;i<t;i+=1){const t=i*e+r,s=t*o,a=(n[s]+n[s+1]+n[s+2])/3;n[s]=a,n[s+1]=a,n[s+2]=a,c+=a,w[t]=0===r?c:w[t-1]+c}}for(let r=0;r<e;r+=1)for(let i=0;i<t;i+=1){const s=(i*e+r)*o;let a=r-c,l=r+c,h=i-c,f=i+c;a<0&&(a=0),l>=e&&(l=e-1),h<0&&(h=0),f>=t&&(f=t-1);const d=(l-a)*(f-h),p=w[f*e+l]-w[h*e+l]-w[f*e+a]+w[h*e+a];let u=255;n[s]*d<.85*p&&(u=0),n[s]=u,n[s+1]=u,n[s+2]=u}}(h,d,u);const A=[5,6,4,7,3,8,2,9,1],F=Math.round(u/A.length),O=Math.min(2,u);for(let n=0;n<A.length;n+=1){const e=S*d*Math.floor(F*A[n]),t=e+O*S*d,w=b(h.slice(e,t),d,O);if(0===w.length){if(a||n===A.length-1)throw new Error("Failed to detect lines in the image!");continue}const o=i(w,r);if(o){if(a||!o.includes("?"))return o;if(N=m(N,o),!N.includes("?"))return N}}return N}))}export default M; | ||
//# sourceMappingURL=javascript-barcode-reader.es5.min.js.map |
@@ -1,16 +0,16 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("jimp")):"function"==typeof define&&define.amd?define(["jimp"],e):(n=n||self).javascriptBarcodeReader=e(n.Jimp)}(this,(function(n){"use strict"; | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("jimp")):"function"==typeof define&&define.amd?define(["jimp"],e):(n="undefined"!=typeof globalThis?globalThis:n||self).javascriptBarcodeReader=e(n.Jimp)}(this,(function(n){"use strict";function e(n){if(n&&n.__esModule)return n;var e=Object.create(null);return n&&Object.keys(n).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:function(){return n[t]}})}})),e.default=n,Object.freeze(e)}var t=e(n); | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */function e(n,e,t,w){return new(t||(t=Promise))((function(o,r){function c(n){try{s(w.next(n))}catch(n){r(n)}}function i(n){try{s(w.throw(n))}catch(n){r(n)}}function s(n){n.done?o(n.value):new t((function(e){e(n.value)})).then(c,i)}s((w=w.apply(n,e||[])).next())}))}const t={nnnnnww:"0",nnnnwwn:"1",nnnwnnw:"2",wwnnnnn:"3",nnwnnwn:"4",wnnnnwn:"5",nwnnnnw:"6",nwnnwnn:"7",nwwnnnn:"8",wnnwnnn:"9",nnnwwnn:"-",nnwwnnn:"$",wnnnwnw:":",wnwnnnw:"/",wnwnwnn:".",nnwwwww:"+",nnwwnwn:"A",nnnwnww:"B",nwnwnnw:"C",nnnwwwn:"D"};function w(n){const e=[],w=Math.ceil(n.reduce((n,e)=>(n+e)/2,0));for(;n.length>0;){const o=n.splice(0,8).splice(0,7).map(n=>n<w?"n":"w").join("");e.push(t[o])}return e.join("")}const o=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232","233111","211133","2331112"],r=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","FS","GS","RS","US","FNC 3","FNC 2","Shift B","Code C","Code B","FNC 4","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],c=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL","FNC 3","FNC 2","Shift A","Code C","FNC 4","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],i=["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","Code B","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"];function s(n){const e=[];let t,w,s=c;const a=(n=>{const e=n.length-13,t=n.reduce((n,t,w)=>w>=e?n:n+t,0)/(11*Math.ceil(e/6));return n.map(n=>Math.round(n/t)||1)})(n);if(!a)return"";a.pop();for(let n=0;6*n<a.length-13;n+=1){t=a.slice(6*n,6*(n+1)).join("");const l=s[o.indexOf(t)];switch(l){case"Code A":s=r;break;case"Code B":s=c;break;case"Code C":s=i;break;case"FNC 4":break;default:l?("FNC 4"===w?e.push(l.charCodeAt(0)+128):e.push(l),w=l):e.push("?")}}return e.join("")}const a={nnnwwnwnn:"0",wnnwnnnnw:"1",nnwwnnnnw:"2",wnwwnnnnn:"3",nnnwwnnnw:"4",wnnwwnnnn:"5",nnwwwnnnn:"6",nnnwnnwnw:"7",wnnwnnwnn:"8",nnwwnnwnn:"9",wnnnnwnnw:"A",nnwnnwnnw:"B",wnwnnwnnn:"C",nnnnwwnnw:"D",wnnnwwnnn:"E",nnwnwwnnn:"F",nnnnnwwnw:"G",wnnnnwwnn:"H",nnwnnwwnn:"I",nnnnwwwnn:"J",wnnnnnnww:"K",nnwnnnnww:"L",wnwnnnnwn:"M",nnnnwnnww:"N",wnnnwnnwn:"O",nnwnwnnwn:"P",nnnnnnwww:"Q",wnnnnnwwn:"R",nnwnnnwwn:"S",nnnnwnwwn:"T",wwnnnnnnw:"U",nwwnnnnnw:"V",wwwnnnnnn:"W",nwnnwnnnw:"X",wwnnwnnnn:"Y",nwwnwnnnn:"Z",nwnnnnwnw:"-",wwnnnnwnn:".",nwwnnnwnn:" ",nwnwnwnnn:"$",nwnwnnnwn:"/",nwnnnwnwn:"+",nnnwnwnwn:"%",nwnnwnwnn:"*"};function l(n){const e=[],t=Math.ceil(n.reduce((n,e)=>n+e,0)/n.length);for(;n.length>0;){const w=n.splice(0,10).map(n=>n>t?"w":"n").slice(0,9).join("");e.push(a[w])}return"*"!==e.pop()||"*"!==e.shift()?"":e.join("")}const f=[{100010100:"0"},{101001e3:"1"},{101000100:"2"},{101000010:"3"},{100101e3:"4"},{100100100:"5"},{100100010:"6"},{10101e4:"7"},{100010010:"8"},{100001010:"9"},{110101e3:"A"},{110100100:"B"},{110100010:"C"},{110010100:"D"},{110010010:"E"},{110001010:"F"},{101101e3:"G"},{101100100:"H"},{101100010:"I"},{100110100:"J"},{100011010:"K"},{101011e3:"L"},{101001100:"M"},{101000110:"N"},{100101100:"O"},{100010110:"P"},{110110100:"Q"},{110110010:"R"},{110101100:"S"},{110100110:"T"},{110010110:"U"},{110011010:"V"},{101101100:"W"},{101100110:"X"},{100110110:"Y"},{100111010:"Z"},{100101110:"-"},{111010100:"."},{111010010:" "},{111001010:"$"},{101101110:"/"},{101110110:"+"},{110101110:"%"},{100100110:"($)"},{111011010:"(%)"},{111010110:"(/)"},{100110010:"(+)"},{101011110:"*"}];function d(n){const e=[],t=[];n.pop();const w=Math.ceil(n.reduce((n,e)=>n+e,0)/n.length),o=Math.ceil(n.reduce((n,e)=>e<w?(n+e)/2:n,0));for(let e=0;e<n.length;e+=1){let w=n[e];for(;w>0;)e%2==0?t.push(1):t.push(0),w-=o}for(let n=0;n<t.length;n+=9){const w=t.slice(n,n+9).join(""),o=f.filter(n=>Object.keys(n)[0]===w);e.push(o[0][w])}if("*"!==e.shift()||"*"!==e.pop())return"";const r=e.pop();let c,i,s=0;const a=n=>Object.values(n)[0]===c;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=f.indexOf(f.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);if(Object.values(f[s%47])[0]!==r)return"";const l=e.pop();s=0;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=f.indexOf(f.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);return Object.values(f[s%47])[0]!==l?"":e.join("")}const h=["nnwwn","wnnnw","nwnnw","wwnnn","nnwnw","wnwnn","nwwnn","nnnww","wnnwn","nwnwn"];function p(n,e){const t=[],w=Math.ceil(n.reduce((n,e)=>(n+e)/2,0));if("interleaved"===e){const e=n.splice(0,4).map(n=>n>w?"w":"n").join(""),o=n.splice(n.length-3,3).map(n=>n>w?"w":"n").join("");if("nnnn"!==e||"wnn"!==o)return"";for(;n.length>0;){const e=n.splice(0,10),o=e.filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join("");t.push(h.indexOf(o));const r=e.filter((n,e)=>e%2!=0).map(n=>n>w?"w":"n").join("");t.push(h.indexOf(r))}}else{const e=n.splice(0,6).filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join(""),o=n.splice(n.length-5,5).filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join("");if("wwn"!==e||"wnw"!==o)return"";for(;n.length>0;){const e=n.splice(0,10).filter((n,e)=>e%2==0).map(n=>n>w?"w":"n").join("");t.push(h.indexOf(e))}}return t.join("")}const u={3211:"0",2221:"1",2122:"2",1411:"3",1132:"4",1231:"5",1114:"6",1312:"7",1213:"8",3112:"9"};function C(n,e="13"){let t="";const w=(n[0]+n[1]+n[2])/3;n.shift(),n.shift(),n.shift(),n.pop(),n.pop(),n.pop(),"13"===e?n.splice(24,5):n.splice(16,5);for(let e=0;e<n.length;e+=4){const o=n.slice(e,e+4),r=[o[0]/w,o[1]/w,o[2]/w,o[3]/w].map(n=>1.5===n?1:Math.round(n)),c=u[r.join("")]||u[r.reverse().join("")];t+=c||"?"}return t}var g;function m(n,e){if(""===n||""===e)return e;const t=n.split("");return e.split("").forEach((n,e)=>{t[e]&&"?"!==t[e]||n&&"?"!==n&&(t[e]=n)}),t.join("")}function v(n){const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");const w=n.naturalWidth,o=n.naturalHeight;return e.width=w,e.height=o,t.drawImage(n,0,0),t.getImageData(0,0,w,o)}!function(n){n["code-128"]="code-128",n["code-2of5"]="code-2of5",n["code-39"]="code-39",n["code-93"]="code-93",n["ean-13"]="ean-13",n["ean-8"]="ean-8",n.codabar="codabar"}(g||(g={}));const j="object"==typeof process&&process.release&&"node"===process.release.name;function E(n,e,t){const w=[],o=n.length/(e*t);let r=0,c=0;for(let i=0;i<e;i+=1){let s=0,a=0;for(let w=0;w<t;w+=1){const t=(w*e+i)*o;s+=Math.sqrt((Math.pow(n[t],2)+Math.pow(n[t+1],2)+Math.pow(n[t+2],2))/3)}a=s/t>=127?255:0,255===a&&0===r||(a===c?r+=1:(w.push(r),c=a,r=1),i===e-1&&0===a&&w.push(r))}return w}let b;try{process&&"test"===process.env.NODE_ENV&&(b=!0)}catch(n){b=!1}return function({image:t,barcode:o,barcodeType:r,options:c}){return e(this,void 0,void 0,(function*(){let i;switch(o){case g.codabar:i=w;break;case g["code-128"]:i=s;break;case g["code-39"]:i=l;break;case g["code-93"]:i=d;break;case g["code-2of5"]:i=p;break;case g["ean-13"]:i=C,r="13";break;case g["ean-8"]:i=C,r="8";break;default:throw new Error(`Invalid barcode specified. Available decoders: ${g}.`)}const a=b||c&&c.singlePass||!1,{data:f,width:h,height:u}=(M=t).data&&M.width&&M.height?t:yield function(t){return e(this,void 0,void 0,(function*(){return new Promise((e,w)=>{if("string"==typeof t)if(t.startsWith("#")){const n=document.getElementById(t.substr(1));if(n instanceof HTMLImageElement&&e(v(n)),n instanceof HTMLCanvasElement){const t=n.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");e(t.getImageData(0,0,n.width,n.height))}w(new Error("Invalid image source specified!"))}else if(!(o=t).startsWith("#")&&/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(o)){const n=new Image;n.onerror=w,n.onload=()=>e(v(n)),n.src=t}else j&&n.read(t,(n,t)=>{if(n)w(n);else{const{data:n,width:w,height:o}=t.bitmap;e({data:Uint8ClampedArray.from(n),width:w,height:o})}});else if(t instanceof HTMLImageElement)e(v(t));else if(t instanceof HTMLCanvasElement){const n=t.getContext("2d");if(!n)throw new Error("Cannot create canvas 2d context");e(n.getImageData(0,0,t.width,t.height))}var o})}))}(t);var M;const S=f.length/(h*u);let N="";c&&c.useAdaptiveThreshold&&function(n,e,t){const w=new Array(e*t).fill(0),o=n.length/(e*t),r=Math.floor(t),c=Math.floor(r/2);for(let r=0;r<e;r+=1){let c=0;for(let i=0;i<t;i+=1){const t=i*e+r,s=t*o,a=(n[s]+n[s+1]+n[s+2])/3;n[s]=a,n[s+1]=a,n[s+2]=a,c+=a,w[t]=0===r?c:w[t-1]+c}}for(let r=0;r<e;r+=1)for(let i=0;i<t;i+=1){const s=(i*e+r)*o;let a=r-c,l=r+c,f=i-c,d=i+c;a<0&&(a=0),l>=e&&(l=e-1),f<0&&(f=0),d>=t&&(d=t-1);const h=(l-a)*(d-f),p=w[d*e+l]-w[f*e+l]-w[d*e+a]+w[f*e+a];let u=255;n[s]*h<.85*p&&(u=0),n[s]=u,n[s+1]=u,n[s+2]=u}}(f,h,u);const A=[5,6,4,7,3,8,2,9,1],F=Math.round(u/A.length),B=Math.min(2,u);for(let n=0;n<A.length;n+=1){const e=S*h*Math.floor(F*A[n]),t=e+B*S*h,w=E(f.slice(e,t),h,B);if(0===w.length){if(a||n===A.length-1)throw new Error("Failed to detect lines in the image!");continue}const o=i(w,r);if(o){if(a||!o.includes("?"))return o;if(N=m(N,o),!N.includes("?"))return N}}return N}))}})); | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function o(n,e,t,o){return new(t||(t=Promise))((function(w,r){function c(n){try{s(o.next(n))}catch(n){r(n)}}function i(n){try{s(o.throw(n))}catch(n){r(n)}}function s(n){var e;n.done?w(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(c,i)}s((o=o.apply(n,e||[])).next())}))}const w={nnnnnww:"0",nnnnwwn:"1",nnnwnnw:"2",wwnnnnn:"3",nnwnnwn:"4",wnnnnwn:"5",nwnnnnw:"6",nwnnwnn:"7",nwwnnnn:"8",wnnwnnn:"9",nnnwwnn:"-",nnwwnnn:"$",wnnnwnw:":",wnwnnnw:"/",wnwnwnn:".",nnwwwww:"+",nnwwnwn:"A",nnnwnww:"B",nwnwnnw:"C",nnnwwwn:"D"};function r(n){const e=[],t=Math.ceil(n.reduce(((n,e)=>(n+e)/2),0));for(;n.length>0;){const o=n.splice(0,8).splice(0,7).map((n=>n<t?"n":"w")).join("");e.push(w[o])}return e.join("")}const c=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232","233111","211133","2331112"],i=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","FS","GS","RS","US","FNC 3","FNC 2","Shift B","Code C","Code B","FNC 4","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],s=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL","FNC 3","FNC 2","Shift A","Code C","FNC 4","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"],a=["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","Code B","Code A","FNC 1","Code A","Code B","Code C","Stop","Reverse Stop"];function l(n){const e=[];let t,o,w=s;const r=(n=>{const e=n.length-13,t=n.reduce(((n,t,o)=>o>=e?n:n+t),0)/(11*Math.ceil(e/6));return n.map((n=>Math.round(n/t)||1))})(n);if(!r)return"";r.pop();for(let n=0;6*n<r.length-13;n+=1){t=r.slice(6*n,6*(n+1)).join("");const l=w[c.indexOf(t)];switch(l){case"Code A":w=i;break;case"Code B":w=s;break;case"Code C":w=a;break;case"FNC 4":break;default:l?("FNC 4"===o?e.push(l.charCodeAt(0)+128):e.push(l),o=l):e.push("?")}}return e.join("")}const f={nnnwwnwnn:"0",wnnwnnnnw:"1",nnwwnnnnw:"2",wnwwnnnnn:"3",nnnwwnnnw:"4",wnnwwnnnn:"5",nnwwwnnnn:"6",nnnwnnwnw:"7",wnnwnnwnn:"8",nnwwnnwnn:"9",wnnnnwnnw:"A",nnwnnwnnw:"B",wnwnnwnnn:"C",nnnnwwnnw:"D",wnnnwwnnn:"E",nnwnwwnnn:"F",nnnnnwwnw:"G",wnnnnwwnn:"H",nnwnnwwnn:"I",nnnnwwwnn:"J",wnnnnnnww:"K",nnwnnnnww:"L",wnwnnnnwn:"M",nnnnwnnww:"N",wnnnwnnwn:"O",nnwnwnnwn:"P",nnnnnnwww:"Q",wnnnnnwwn:"R",nnwnnnwwn:"S",nnnnwnwwn:"T",wwnnnnnnw:"U",nwwnnnnnw:"V",wwwnnnnnn:"W",nwnnwnnnw:"X",wwnnwnnnn:"Y",nwwnwnnnn:"Z",nwnnnnwnw:"-",wwnnnnwnn:".",nwwnnnwnn:" ",nwnwnwnnn:"$",nwnwnnnwn:"/",nwnnnwnwn:"+",nnnwnwnwn:"%",nwnnwnwnn:"*"};function d(n){const e=[],t=Math.ceil(n.reduce(((n,e)=>n+e),0)/n.length);for(;n.length>0;){const o=n.splice(0,10).map((n=>n>t?"w":"n")).slice(0,9).join("");e.push(f[o])}return"*"!==e.pop()||"*"!==e.shift()?"":e.join("")}const h=[{100010100:"0"},{101001e3:"1"},{101000100:"2"},{101000010:"3"},{100101e3:"4"},{100100100:"5"},{100100010:"6"},{10101e4:"7"},{100010010:"8"},{100001010:"9"},{110101e3:"A"},{110100100:"B"},{110100010:"C"},{110010100:"D"},{110010010:"E"},{110001010:"F"},{101101e3:"G"},{101100100:"H"},{101100010:"I"},{100110100:"J"},{100011010:"K"},{101011e3:"L"},{101001100:"M"},{101000110:"N"},{100101100:"O"},{100010110:"P"},{110110100:"Q"},{110110010:"R"},{110101100:"S"},{110100110:"T"},{110010110:"U"},{110011010:"V"},{101101100:"W"},{101100110:"X"},{100110110:"Y"},{100111010:"Z"},{100101110:"-"},{111010100:"."},{111010010:" "},{111001010:"$"},{101101110:"/"},{101110110:"+"},{110101110:"%"},{100100110:"($)"},{111011010:"(%)"},{111010110:"(/)"},{100110010:"(+)"},{101011110:"*"}];function u(n){const e=[],t=[];n.pop();const o=Math.ceil(n.reduce(((n,e)=>n+e),0)/n.length),w=Math.ceil(n.reduce(((n,e)=>e<o?(n+e)/2:n),0));for(let e=0;e<n.length;e+=1){let o=n[e];for(;o>0;)e%2==0?t.push(1):t.push(0),o-=w}for(let n=0;n<t.length;n+=9){const o=t.slice(n,n+9).join(""),w=h.filter((n=>Object.keys(n)[0]===o));e.push(w[0][o])}if("*"!==e.shift()||"*"!==e.pop())return"";const r=e.pop();let c,i,s=0;const a=n=>Object.values(n)[0]===c;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=h.indexOf(h.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);if(Object.values(h[s%47])[0]!==r)return"";const l=e.pop();s=0;for(let n=e.length-1;n>=0;n-=1)c=e[n],i=h.indexOf(h.filter(a)[0]),s+=i*(1+(e.length-(n+1))%20);return Object.values(h[s%47])[0]!==l?"":e.join("")}const p=["nnwwn","wnnnw","nwnnw","wwnnn","nnwnw","wnwnn","nwwnn","nnnww","wnnwn","nwnwn"];function C(n,e){const t=[],o=Math.ceil(n.reduce(((n,e)=>(n+e)/2),0));if("interleaved"===e){const e=n.splice(0,4).map((n=>n>o?"w":"n")).join(""),w=n.splice(n.length-3,3).map((n=>n>o?"w":"n")).join("");if("nnnn"!==e||"wnn"!==w)return"";for(;n.length>0;){const e=n.splice(0,10),w=e.filter(((n,e)=>e%2==0)).map((n=>n>o?"w":"n")).join("");t.push(p.indexOf(w));const r=e.filter(((n,e)=>e%2!=0)).map((n=>n>o?"w":"n")).join("");t.push(p.indexOf(r))}}else{const e=n.splice(0,6).filter(((n,e)=>e%2==0)).map((n=>n>o?"w":"n")).join(""),w=n.splice(n.length-5,5).filter(((n,e)=>e%2==0)).map((n=>n>o?"w":"n")).join("");if("wwn"!==e||"wnw"!==w)return"";for(;n.length>0;){const e=n.splice(0,10).filter(((n,e)=>e%2==0)).map((n=>n>o?"w":"n")).join("");t.push(p.indexOf(e))}}return t.join("")}const g={3211:"0",2221:"1",2122:"2",1411:"3",1132:"4",1231:"5",1114:"6",1312:"7",1213:"8",3112:"9"};function m(n,e="13"){let t="";const o=(n[0]+n[1]+n[2])/3;n.shift(),n.shift(),n.shift(),n.pop(),n.pop(),n.pop(),"13"===e?n.splice(24,5):n.splice(16,5);for(let e=0;e<n.length;e+=4){const w=n.slice(e,e+4),r=[w[0]/o,w[1]/o,w[2]/o,w[3]/o].map((n=>1.5===n?1:Math.round(n))),c=g[r.join("")]||g[r.reverse().join("")];t+=c||"?"}return t}var b;function j(n,e){if(""===n||""===e)return e;const t=n.split("");return e.split("").forEach(((n,e)=>{t[e]&&"?"!==t[e]||n&&"?"!==n&&(t[e]=n)})),t.join("")}function v(n){const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");const o=n.naturalWidth,w=n.naturalHeight;return e.width=o,e.height=w,t.drawImage(n,0,0),t.getImageData(0,0,o,w)}!function(n){n["code-128"]="code-128",n["code-2of5"]="code-2of5",n["code-39"]="code-39",n["code-93"]="code-93",n["ean-13"]="ean-13",n["ean-8"]="ean-8",n.codabar="codabar"}(b||(b={}));const E="object"==typeof process&&process.release&&"node"===process.release.name;function M(n,e,t){const o=[],w=n.length/(e*t);let r=0,c=0;for(let i=0;i<e;i+=1){let s=0,a=0;for(let o=0;o<t;o+=1){const t=(o*e+i)*w;s+=Math.sqrt((Math.pow(n[t],2)+Math.pow(n[t+1],2)+Math.pow(n[t+2],2))/3)}a=s/t>=127?255:0,255===a&&0===r||(a===c?r+=1:(o.push(r),c=a,r=1),i===e-1&&0===a&&o.push(r))}return o}let S;try{process&&"test"===process.env.NODE_ENV&&(S=!0)}catch(n){S=!1}return function({image:n,barcode:e,barcodeType:w,options:c}){return o(this,void 0,void 0,(function*(){let i;switch(e){case b.codabar:i=r;break;case b["code-128"]:i=l;break;case b["code-39"]:i=d;break;case b["code-93"]:i=u;break;case b["code-2of5"]:i=C;break;case b["ean-13"]:i=m,w="13";break;case b["ean-8"]:i=m,w="8";break;default:throw new Error(`Invalid barcode specified. Available decoders: ${b}.`)}const s=S||c&&c.singlePass||!1,{data:a,width:f,height:h}=(p=n).data&&p.width&&p.height?n:yield function(n){return o(this,void 0,void 0,(function*(){return new Promise(((e,o)=>{if("string"==typeof n)if(n.startsWith("#")){const t=document.getElementById(n.substr(1));if(t instanceof HTMLImageElement&&e(v(t)),t instanceof HTMLCanvasElement){const n=t.getContext("2d");if(!n)throw new Error("Cannot create canvas 2d context");e(n.getImageData(0,0,t.width,t.height))}o(new Error("Invalid image source specified!"))}else if(!(w=n).startsWith("#")&&/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/.test(w)){const t=new Image;t.onerror=o,t.onload=()=>e(v(t)),t.src=n}else E&&t.read(n,((n,t)=>{if(n)o(n);else{const{data:n,width:o,height:w}=t.bitmap;e({data:Uint8ClampedArray.from(n),width:o,height:w})}}));else if(n instanceof HTMLImageElement)e(v(n));else if(n instanceof HTMLCanvasElement){const t=n.getContext("2d");if(!t)throw new Error("Cannot create canvas 2d context");e(t.getImageData(0,0,n.width,n.height))}var w}))}))}(n);var p;const g=a.length/(f*h);let O="";c&&c.useAdaptiveThreshold&&function(n,e,t){const o=new Array(e*t).fill(0),w=n.length/(e*t),r=Math.floor(t),c=Math.floor(r/2);for(let r=0;r<e;r+=1){let c=0;for(let i=0;i<t;i+=1){const t=i*e+r,s=t*w,a=(n[s]+n[s+1]+n[s+2])/3;n[s]=a,n[s+1]=a,n[s+2]=a,c+=a,o[t]=0===r?c:o[t-1]+c}}for(let r=0;r<e;r+=1)for(let i=0;i<t;i+=1){const s=(i*e+r)*w;let a=r-c,l=r+c,f=i-c,d=i+c;a<0&&(a=0),l>=e&&(l=e-1),f<0&&(f=0),d>=t&&(d=t-1);const h=(l-a)*(d-f),u=o[d*e+l]-o[f*e+l]-o[d*e+a]+o[f*e+a];let p=255;n[s]*h<.85*u&&(p=0),n[s]=p,n[s+1]=p,n[s+2]=p}}(a,f,h);const N=[5,6,4,7,3,8,2,9,1],y=Math.round(h/N.length),A=Math.min(2,h);for(let n=0;n<N.length;n+=1){const e=g*f*Math.floor(y*N[n]),t=e+A*g*f,o=M(a.slice(e,t),f,A);if(0===o.length){if(s||n===N.length-1)throw new Error("Failed to detect lines in the image!");continue}const r=i(o,w);if(r){if(s||!r.includes("?"))return r;if(O=j(O,r),!O.includes("?"))return O}}return O}))}})); | ||
//# sourceMappingURL=javascript-barcode-reader.umd.min.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decoder = void 0; | ||
const CHAR_SET = { | ||
@@ -4,0 +5,0 @@ nnnnnww: '0', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decoder = void 0; | ||
const WIDTH_TBL = [ | ||
@@ -4,0 +5,0 @@ '212222', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decoder = void 0; | ||
const CHAR_SET = { | ||
@@ -4,0 +5,0 @@ nnnwwnwnn: '0', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decoder = void 0; | ||
const CHAR_SET = [ | ||
@@ -4,0 +5,0 @@ { '100010100': '0' }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decoder = void 0; | ||
const CHAR_SET = [ | ||
@@ -4,0 +5,0 @@ 'nnwwn', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decoder = void 0; | ||
const UPC_SET = { | ||
@@ -4,0 +5,0 @@ '3211': '0', |
@@ -0,0 +0,0 @@ "use strict"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.applyAdaptiveThreshold = void 0; | ||
function applyAdaptiveThreshold(data, width, height) { | ||
@@ -4,0 +5,0 @@ const integralImage = new Array(width * height).fill(0); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BARCODE_DECODERS = void 0; | ||
var BARCODE_DECODERS; | ||
@@ -4,0 +5,0 @@ (function (BARCODE_DECODERS) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.combineAllPossible = void 0; | ||
function combineAllPossible(finalResult, result) { | ||
@@ -4,0 +5,0 @@ if (finalResult === '' || result === '') { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createImageData = void 0; | ||
function createImageData(image) { | ||
@@ -4,0 +5,0 @@ const canvas = document.createElement('canvas'); |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getImageDataFromSource = void 0; | ||
const Jimp = require("jimp"); | ||
@@ -14,0 +15,0 @@ const createImageData_1 = require("./createImageData"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLines = void 0; | ||
function getLines(data, width, height) { | ||
@@ -4,0 +5,0 @@ const lines = []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=ImageDataLike.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isUrl = void 0; | ||
function isUrl(s) { | ||
@@ -4,0 +5,0 @@ const regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -14,53 +14,55 @@ { | ||
"dependencies": { | ||
"jimp": "^0.9.3" | ||
"jimp": "^0.16.1" | ||
}, | ||
"description": "Simple & Fast Barcode decoder for Browser and Node.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.8.6", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
"@babel/preset-env": "^7.8.6", | ||
"@commitlint/cli": "^8.3.5", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@types/babel__core": "^7.1.6", | ||
"@types/eslint": "^6.1.8", | ||
"@types/eslint-plugin-prettier": "^2.2.0", | ||
"@types/jest": "^25.1.3", | ||
"@types/node": "^13.7.7", | ||
"@types/nodemon": "^1.19.0", | ||
"@types/prettier": "^1.19.0", | ||
"@babel/core": "^7.14.6", | ||
"@babel/plugin-proposal-class-properties": "^7.14.5", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.14.7", | ||
"@babel/preset-env": "^7.14.7", | ||
"@commitlint/cli": "^12.1.4", | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@rollup/plugin-commonjs": "^19.0.0", | ||
"@types/babel__core": "^7.1.15", | ||
"@types/babel__preset-env": "^7.9.2", | ||
"@types/core-js": "2.5.4", | ||
"@types/eslint": "^7.2.14", | ||
"@types/eslint-plugin-prettier": "^3.1.0", | ||
"@types/jest": "^26.0.24", | ||
"@types/node": "^16.0.1", | ||
"@types/nodemon": "^1.19.1", | ||
"@types/prettier": "^2.3.2", | ||
"@types/rollup-plugin-json": "^3.0.2", | ||
"@types/semantic-release": "^15.13.1", | ||
"@typescript-eslint/eslint-plugin": "^2.21.0", | ||
"@typescript-eslint/parser": "^2.21.0", | ||
"canvas": "^2.6.1", | ||
"commitizen": "^4.0.3", | ||
"core-js": "3.6.4", | ||
"coveralls": "^3.0.9", | ||
"cross-env": "^7.0.0", | ||
"cz-conventional-changelog": "^3.1.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-jest": "^23.8.1", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"husky": "^4.2.3", | ||
"jest": "^25.1.0", | ||
"jest-config": "^25.1.0", | ||
"jest-environment-jsdom": "^25.1.0", | ||
"lint-staged": "^10.0.8", | ||
"nodemon": "^2.0.2", | ||
"prettier": "^1.19.1", | ||
"rollup": "^1.32.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"@types/semantic-release": "^17.2.1", | ||
"@typescript-eslint/eslint-plugin": "^4.28.2", | ||
"@typescript-eslint/parser": "^4.28.2", | ||
"canvas": "^2.8.0", | ||
"commitizen": "^4.2.4", | ||
"core-js": "3.15.2", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^7.30.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"husky": "^7.0.1", | ||
"jest": "^27.0.6", | ||
"jest-config": "^27.0.6", | ||
"jest-environment-jsdom": "^27.0.6", | ||
"lint-staged": "^11.0.0", | ||
"nodemon": "^2.0.9", | ||
"prettier": "^2.3.2", | ||
"rollup": "^2.52.8", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-json": "^4.0.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-sourcemaps": "^0.5.0", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"rollup-plugin-typescript2": "^0.26.0", | ||
"semantic-release": "^17.0.4", | ||
"ts-jest": "^25.2.1", | ||
"ts-node": "^8.6.2", | ||
"typedoc": "^0.16.11", | ||
"typescript": "^3.8.3" | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"semantic-release": "^17.4.4", | ||
"ts-jest": "^27.0.3", | ||
"ts-node": "^10.0.0", | ||
"typedoc": "^0.21.2", | ||
"typescript": "^4.3.5" | ||
}, | ||
@@ -97,3 +99,3 @@ "engines": { | ||
"scripts": { | ||
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", | ||
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --options typedoc.json", | ||
"commit": "git-cz", | ||
@@ -112,4 +114,4 @@ "deploy-docs": "ts-node tools/gh-pages-publish", | ||
}, | ||
"typings": "dist/types/javascript-barcode-reader.d.ts", | ||
"version": "0.6.8" | ||
"typings": "dist/types/src/index.d.ts", | ||
"version": "0.6.9" | ||
} |
@@ -9,2 +9,3 @@ # Javascript-Barcode-Reader | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) | ||
[![Rate on Openbase](https://badges.openbase.com/js/rating/javascript-barcode-reader.svg)](https://openbase.com/js/javascript-barcode-reader?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge) | ||
@@ -19,3 +20,3 @@ [![NPM](https://nodei.co/npm/javascript-barcode-reader.png)](https://nodei.co/npm/javascript-barcode-reader/) | ||
https://stackblitz.com/edit/javascript-barcode-reader?file=index.ts | ||
https://codesandbox.io/s/javascript-barcode-reader-liium | ||
@@ -57,3 +58,3 @@ ## Available decoders | ||
```ts | ||
import { javascriptBarcodeReader } from 'javascript-barcode-reader' | ||
import javascriptBarcodeReader from 'javascript-barcode-reader' | ||
@@ -65,4 +66,4 @@ javascriptBarcodeReader({ | ||
// barcodeType: 'industrial', | ||
options: { | ||
// useAdaptiveThreshold: true | ||
options: { | ||
// useAdaptiveThreshold: true // for images with sahded portions | ||
// singlePass: true | ||
@@ -90,3 +91,3 @@ } | ||
options: { | ||
// useAdaptiveThreshold: true | ||
// useAdaptiveThreshold: true // for images with sahded portions | ||
// singlePass: true | ||
@@ -93,0 +94,0 @@ } |
@@ -0,0 +0,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
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2804
120
254727
49
6
+ Added@jimp/bmp@0.16.13(transitive)
+ Added@jimp/core@0.16.13(transitive)
+ Added@jimp/custom@0.16.13(transitive)
+ Added@jimp/gif@0.16.13(transitive)
+ Added@jimp/jpeg@0.16.13(transitive)
+ Added@jimp/plugin-blit@0.16.13(transitive)
+ Added@jimp/plugin-blur@0.16.13(transitive)
+ Added@jimp/plugin-circle@0.16.13(transitive)
+ Added@jimp/plugin-color@0.16.13(transitive)
+ Added@jimp/plugin-contain@0.16.13(transitive)
+ Added@jimp/plugin-cover@0.16.13(transitive)
+ Added@jimp/plugin-crop@0.16.13(transitive)
+ Added@jimp/plugin-displace@0.16.13(transitive)
+ Added@jimp/plugin-dither@0.16.13(transitive)
+ Added@jimp/plugin-fisheye@0.16.13(transitive)
+ Added@jimp/plugin-flip@0.16.13(transitive)
+ Added@jimp/plugin-gaussian@0.16.13(transitive)
+ Added@jimp/plugin-invert@0.16.13(transitive)
+ Added@jimp/plugin-mask@0.16.13(transitive)
+ Added@jimp/plugin-normalize@0.16.13(transitive)
+ Added@jimp/plugin-print@0.16.13(transitive)
+ Added@jimp/plugin-resize@0.16.13(transitive)
+ Added@jimp/plugin-rotate@0.16.13(transitive)
+ Added@jimp/plugin-scale@0.16.13(transitive)
+ Added@jimp/plugin-shadow@0.16.13(transitive)
+ Added@jimp/plugin-threshold@0.16.13(transitive)
+ Added@jimp/plugins@0.16.13(transitive)
+ Added@jimp/png@0.16.13(transitive)
+ Added@jimp/tiff@0.16.13(transitive)
+ Added@jimp/types@0.16.13(transitive)
+ Added@jimp/utils@0.16.13(transitive)
+ Added@tokenizer/token@0.3.0(transitive)
+ Added@types/node@16.9.1(transitive)
+ Addedfile-type@16.5.4(transitive)
+ Addedgifwrap@0.9.4(transitive)
+ Addedimage-q@4.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjimp@0.16.13(transitive)
+ Addedjpeg-js@0.4.4(transitive)
+ Addedpeek-readable@4.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedreadable-web-to-node-stream@3.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrtok3@6.3.0(transitive)
+ Addedtoken-types@4.2.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removed@jimp/bmp@0.9.8(transitive)
- Removed@jimp/core@0.9.8(transitive)
- Removed@jimp/custom@0.9.8(transitive)
- Removed@jimp/gif@0.9.8(transitive)
- Removed@jimp/jpeg@0.9.8(transitive)
- Removed@jimp/plugin-blit@0.9.8(transitive)
- Removed@jimp/plugin-blur@0.9.8(transitive)
- Removed@jimp/plugin-circle@0.9.8(transitive)
- Removed@jimp/plugin-color@0.9.8(transitive)
- Removed@jimp/plugin-contain@0.9.8(transitive)
- Removed@jimp/plugin-cover@0.9.8(transitive)
- Removed@jimp/plugin-crop@0.9.8(transitive)
- Removed@jimp/plugin-displace@0.9.8(transitive)
- Removed@jimp/plugin-dither@0.9.8(transitive)
- Removed@jimp/plugin-fisheye@0.9.8(transitive)
- Removed@jimp/plugin-flip@0.9.8(transitive)
- Removed@jimp/plugin-gaussian@0.9.8(transitive)
- Removed@jimp/plugin-invert@0.9.8(transitive)
- Removed@jimp/plugin-mask@0.9.8(transitive)
- Removed@jimp/plugin-normalize@0.9.8(transitive)
- Removed@jimp/plugin-print@0.9.8(transitive)
- Removed@jimp/plugin-resize@0.9.8(transitive)
- Removed@jimp/plugin-rotate@0.9.8(transitive)
- Removed@jimp/plugin-scale@0.9.8(transitive)
- Removed@jimp/plugin-shadow@0.9.8(transitive)
- Removed@jimp/plugin-threshold@0.9.8(transitive)
- Removed@jimp/plugins@0.9.8(transitive)
- Removed@jimp/png@0.9.8(transitive)
- Removed@jimp/tiff@0.9.8(transitive)
- Removed@jimp/types@0.9.8(transitive)
- Removed@jimp/utils@0.9.8(transitive)
- Removedcore-js@3.37.0(transitive)
- Removedfile-type@9.0.0(transitive)
- Removedjimp@0.9.8(transitive)
- Removedjpeg-js@0.3.7(transitive)
Updatedjimp@^0.16.1