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

gerber-to-svg

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gerber-to-svg - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

4

dist/gerber-to-svg.min.js
/* copyright 2015 by mike cousins and contributors; shared under the terms of the MIT license. Source code available at github.com/mcous/gerber-to-svg */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.gerberToSvg=t()}}(function(){return function t(r,e,i){function o(s,l){if(!e[s]){if(!r[s]){var a="function"==typeof require&&require;if(!l&&a)return a(s,!0);if(n)return n(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var u=e[s]={exports:{}};r[s][0].call(u.exports,function(t){var e=r[s][1][t];return o(e?e:t)},u,u.exports,t,r,e,i)}return e[s].exports}for(var n="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(t,r){(function(e){var i,o,n,s,l,a,h,u;h=t("./obj-to-xml"),a=t("./plotter"),n=t("./drill-reader"),o=t("./drill-parser"),l=t("./gerber-reader"),s=t("./gerber-parser"),u=t("./svg-coord").factor,i={drill:!1,pretty:!1,object:!1,warnArr:null,places:null,zero:null,notation:null,units:null},r.exports=function(t,r){var c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R;null==r&&(r={}),b={};for(d in i)k=i[d],b[d]=k;for(d in r)k=r[d],b[d]=k;if("object"==typeof t){if(null!=t.svg)return h(t,{pretty:b.pretty});throw new Error("non SVG object cannot be converted to an SVG string")}w=null,(null!=b.places||null!=b.zero)&&(w={places:b.places,zero:b.zero}),b.drill?(v=new n(t),g=new o(w)):(v=new l(t),g=new s(w)),y=null,(null!=b.notation||null!=b.units)&&(y={notation:b.notation,units:b.units}),m=new a(v,g,y),x=null,M=null,Array.isArray(b.warnArr)&&(M="undefined"!=typeof window&&null!==window?window:e,null==M.console&&(M.console={}),x=M.console.warn,M.console.warn=function(t){return b.warnArr.push(t.toString())});try{_=m.plot()}catch(T){throw f=T,new Error("Error at line "+m.reader.line+" - "+f.message)}finally{null!=x&&null!=M&&(M.console.warn=x)}m.bbox.xMin>=m.bbox.xMax?(m.bbox.xMin=0,m.bbox.xMax=0,E=0):E=m.bbox.xMax-m.bbox.xMin,m.bbox.yMin>=m.bbox.yMax?(m.bbox.yMin=0,m.bbox.yMax=0,p=0):p=m.bbox.yMax-m.bbox.yMin,q={svg:{xmlns:"http://www.w3.org/2000/svg",version:"1.1","xmlns:xlink":"http://www.w3.org/1999/xlink",width:""+E/u+m.units,height:""+p/u+m.units,viewBox:[m.bbox.xMin,m.bbox.yMin,E,p],_:[]}},R=m.attr;for(c in R)k=R[c],q.svg[c]=k;return m.defs.length&&q.svg._.push({defs:{_:m.defs}}),m.group.g._.length&&q.svg._.push(m.group),b.object?q:h(q,{pretty:b.pretty})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./drill-parser":3,"./drill-reader":4,"./gerber-parser":5,"./gerber-reader":6,"./obj-to-xml":9,"./plotter":12,"./svg-coord":14}],2:[function(t,r){var e;e=t("./svg-coord").get,r.exports=function(t,r){var i,o,n,s,l,a,h,u,c,f,p,d;if(null==t)return{};if(null==r.zero||null==r.places)throw new Error("format undefined");o={},n={},o.x=null!=(l=t.match(/X[+-]?[\d\.]+/))&&null!=(a=l[0])?a.slice(1):void 0,o.y=null!=(h=t.match(/Y[+-]?[\d\.]+/))&&null!=(u=h[0])?u.slice(1):void 0,o.i=null!=(c=t.match(/I[+-]?[\d\.]+/))&&null!=(f=c[0])?f.slice(1):void 0,o.j=null!=(p=t.match(/J[+-]?[\d\.]+/))&&null!=(d=p[0])?d.slice(1):void 0;for(i in o)s=o[i],null!=s&&(n[i]=e(s,r));return n}},{"./svg-coord":14}],3:[function(t,r){var e,i,o,n,s,l,a,h,u,c,f,p={}.hasOwnProperty,d=function(t,r){function e(){this.constructor=t}for(var i in r)p.call(r,i)&&(t[i]=r[i]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t};a=t("./parser"),c=t("./coord-parser"),u=t("./svg-coord").get,o={"FMAT,1":"M70","FMAT,2":"M72"},s="M71",e="G90",n="G91",f=/[XY]{1,2}/,h="L",l=[2,4],i=function(t){function r(){this.fmat="FMAT,2",r.__super__.constructor.call(this,arguments[0])}return d(r,t),r.prototype.parseCommand=function(t){var r,i,a,p,d,x,b,m,g,w,y,v;if(i={},";"===t[0])return i;if("FMAT,1"===t)this.fmat=t;else if("M30"===t||"M00"===t)i.set={done:!0};else if(t===o[this.fmat]||t.match(/INCH/))null==(x=this.format).places&&(x.places=[2,4]),i.set={units:"in"};else if(t===s||t.match(/METRIC/))null==(b=this.format).places&&(b.places=[3,3]),i.set={units:"mm"};else if(t===e)i.set={notation:"A"};else if(t===n)i.set={notation:"I"};else if(r=null!=(w=t.match(/T\d+/))?w[0]:void 0){for(;"0"===r[1];)r=r[0]+r.slice(2);(a=null!=(y=t.match(/C[\d\.]+(?=.*$)/))?y[0]:void 0)?(a=a.slice(1),i.tool={},i.tool[r]={dia:u(a,{places:this.format.places})}):i.set={currentTool:r}}if(t.match(/TZ/)?null==(m=this.format).zero&&(m.zero="L"):t.match(/LZ/)&&null==(g=this.format).zero&&(g.zero="T"),t.match(f)){i.op={"do":"flash"},null==this.format.zero&&(this.format.zero=h),null==this.format.places&&(this.format.places=l),v=c(t,this.format);for(p in v)d=v[p],i.op[p]=d}return i},r}(a),r.exports=i},{"./coord-parser":2,"./parser":11,"./svg-coord":14}],4:[function(t,r){var e;e=function(){function t(t){this.line=0,this.blocks=t.split(/\r?\n/)}return t.prototype.nextBlock=function(){return this.line<this.blocks.length?this.blocks[++this.line-1]:!1},t}(),r.exports=e},{}],5:[function(t,r){var e,i,o,n,s,l={}.hasOwnProperty,a=function(t,r){function e(){this.constructor=t}for(var i in r)l.call(r,i)&&(t[i]=r[i]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t};i=t("./parser"),n=t("./coord-parser"),o=t("./svg-coord").get,s=/([XYIJ][+-]?\d+){1,4}/g,e=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return a(r,t),r.prototype.parseFormat=function(t,r){var e,i,o,n,s;if(o="L"===t[2]||"T"===t[2]?t[2]:null,e="A"===t[3]||"I"===t[3]?t[3]:null,"X"===t[4]&&"Y"===t[7]&&t.slice(5,7)===t.slice(8,10)&&t[5]<8&&t[6]<8&&(i=[+t[5],+t[6]]),null==i||null==e||null==o)throw new Error("invalid format specification");return null==(n=this.format).zero&&(n.zero=o),null==(s=this.format).places&&(s.places=i),null==r.set&&(r.set={}),r.set.notation=e},r.prototype.parseToolDef=function(t,r){var e,i,n,s,l,a,h;for(null==r.tool&&(r.tool={}),e=null!=(a=t.match(/^ADD\d{2,}/))?a[0].slice(2):void 0,h=t.slice(2+e.length).split(","),l=h[0],s=h[1],s=null!=s?s.split("X"):void 0;"0"===e[1];)e=e[0]+e.slice(2);switch(l){case"C":if(s.length>2?i={width:o(s[1],{places:this.format.places}),height:o(s[2],{places:this.format.places})}:s.length>1&&(i={dia:o(s[1],{places:this.format.places})}),r.tool[e]={dia:o(s[0],{places:this.format.places})},null!=i)return r.tool[e].hole=i;break;case"R":case"O":if(s.length>3?i={width:o(s[2],{places:this.format.places}),height:o(s[3],{places:this.format.places})}:s.length>2&&(i={dia:o(s[2],{places:this.format.places})}),r.tool[e]={width:o(s[0],{places:this.format.places}),height:o(s[1],{places:this.format.places})},"O"===l&&(r.tool[e].obround=!0),null!=i)return r.tool[e].hole=i;break;case"P":if(s.length>4?i={width:o(s[3],{places:this.format.places}),height:o(s[4],{places:this.format.places})}:s.length>3&&(i={dia:o(s[3],{places:this.format.places})}),r.tool[e]={dia:o(s[0],{places:this.format.places}),verticies:+s[1]},s.length>2&&(r.tool[e].degrees=+s[2]),null!=i)return r.tool[e].hole=i;break;default:return s=function(){var t,r,e,i;for(e=null!=s?s:[],i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(+n);return i}(),r.tool[e]={macro:l,mods:s}}},r.prototype.parseCommand=function(t){var r,e,i,l,a,h,u,c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R,T,B,A;if(null==t&&(t={}),e={},p=t.param)for(w=0,y=p.length;y>w;w++)switch(f=p[w],i=f.slice(0,2)){case"FS":this.parseFormat(f,e);break;case"MO":if(x=f.slice(2,4),null==e.set&&(e.set={}),"IN"===x)e.set.units="in";else{if("MM"!==x)throw new Error(""+f+" is an invalid units setting");e.set.units="mm"}break;case"AD":this.parseToolDef(f,e);break;case"AM":return{macro:p};case"LP":if(null==e["new"]&&(e["new"]={}),("D"===f[2]||"C"===f[2])&&(e["new"].layer=f[2]),null==e["new"].layer)throw new Error("invalid level polarity");break;case"SR":if(null==e["new"]&&(e["new"]={}),m=null!=(v=null!=(M=f.match(/X[+-]?[\d\.]+/))?M[0].slice(1):void 0)?v:1,g=null!=(k=null!=(E=f.match(/Y[+-]?[\d\.]+/))?E[0].slice(1):void 0)?k:1,a=null!=(q=f.match(/I[+-]?[\d\.]+/))?q[0].slice(1):void 0,h=null!=(_=f.match(/J[+-]?[\d\.]+/))?_[0].slice(1):void 0,1>m||1>g||m>1&&(null==a||0>a)||g>1&&(null==h||0>h))throw new Error("invalid step repeat");e["new"].sr={x:+m,y:+g},null!=a&&(e["new"].sr.i=o(a,{places:this.format.places})),null!=h&&(e["new"].sr.j=o(h,{places:this.format.places}))}else if(t=t.block){if("M02"===t)return{set:{done:!0}};if("G"===t[0])switch(i=null!=(R=t.slice(1).match(/^\d{1,2}/))?R[0]:void 0){case"4":case"04":return{};case"1":case"01":case"2":case"02":case"3":case"03":i=i[i.length-1],u="1"===i?"i":"2"===i?"cw":"ccw",e.set={mode:u};break;case"36":case"37":e.set={region:"36"===i};break;case"70":case"71":e.set={backupUnits:"70"===i?"in":"mm"};break;case"74":case"75":e.set={quad:"74"===i?"s":"m"}}if(l=n(null!=(T=t.match(s))?T[0]:void 0,this.format),c=(null!=(B=t.match(/D0?[123]$/))?B[0]:void 0)||Object.keys(l).length){null!=c&&(c=c[c.length-1]),c=function(){switch(c){case"1":return"int";case"2":return"move";case"3":return"flash";default:return"last"}}(),e.op={"do":c};for(r in l)b=l[r],e.op[r]=b}else(d=null!=(A=t.match(/D\d+$/))?A[0]:void 0)&&(e.set={currentTool:d})}return e},r}(i),r.exports=e},{"./coord-parser":2,"./parser":11,"./svg-coord":14}],6:[function(t,r){var e;e=function(){function t(t){this.gerberFile=null!=t?t:"",this.line=0,this.charIndex=0,this.end=this.gerberFile.length}return t.prototype.nextBlock=function(){var t,r,e;if(this.index>=this.end)return!1;for(r="",e=!1,0===this.line&&this.line++;!(this.charIndex>=this.end);)if(t=this.gerberFile[this.charIndex++],"%"===t){if(e)return{param:e};e=[]}else if("*"===t){if(!e)return{block:r};e.push(r),r=""}else"\n"===t?this.line++:t>=" "&&"~">=t&&(r+=t);return!1},t.prototype.getLine=function(){return this.line},t}(),r.exports=e},{}],7:[function(t,r){var e,i,o,n,s,l;i=/[\+\-\/xX\(\)]/,e=/[\$\d\.]+/,o=new RegExp("("+i.source+")|("+e.source+")","g"),l=function(t){var r;return r=t.match(o)},n=function(t){return e.test(t)},s=function(t){var r,e,i,o,s,a,h;return h=l(t),e=0,a=function(){return h[e]},r=function(t){return t===a()?e++:void 0},s=function(){var t,e;if(e=a(),r(e),n(e))t={type:"n",val:e};else{if("("!==e)throw new Error(""+e+" is unexpected in an arithmetic string");if(t=i(),")"!==a())throw new Error("expected ')'");r(")")}return t},o=function(){var t,e,i;for(t=s(),i=a();"x"===i||"/"===i||"X"===i;)r(i),"X"===i&&(i="x"),e=s(),t={type:i,left:t,right:e},i=a();return t},(i=function(){var t,e,i;for(t=o(),i=a();"+"===i||"-"===i;)r(i),e=o(),t={type:i,left:t,right:e},i=a();return t})()},r.exports={tokenize:l,isNumber:n,parse:s}},{}],8:[function(t,r){var e,i,o,n,s;n=t("./pad-shapes"),i=t("./macro-calc"),s=t("./unique-id"),o=t("./svg-coord").get,e=function(){function t(t,r){this.modifiers={},this.name=t[0].slice(2),this.blocks=t.slice(1),this.shapes=[],this.masks=[],this.lastExposure=null,this.bbox=[null,null,null,null],this.format={places:r}}return t.prototype.run=function(t,r){var e,i,o,n,l,a,h,u,c,f,p,d,x,b,m,g,w,y,v;for(null==r&&(r=[]),this.lastExposure=null,this.shapes=[],this.masks=[],this.bbox=[null,null,null,null],this.modifiers={},o=c=0,x=r.length;x>c;o=++c)n=r[o],this.modifiers["$"+(o+1)]=n;for(w=this.blocks,f=0,b=w.length;b>f;f++)e=w[f],this.runBlock(e);for(a="tool-"+t+"-pad-"+s(),l=[],y=this.masks,p=0,m=y.length;m>p;p++)n=y[p],l.push(n);if(this.shapes.length>1){for(i={id:a,_:[]},v=this.shapes,d=0,g=v.length;g>d;d++)h=v[d],i._.push(h);l=[{g:i}]}else 1===this.shapes.length&&(u=Object.keys(this.shapes[0])[0],this.shapes[0][u].id=a,l.push(this.shapes[0]));return{pad:l,padId:a,bbox:this.bbox,trace:!1}},t.prototype.runBlock=function(t){var r,e,i,o,n,s,l,a;switch(t[0]){case"$":return o=null!=(a=t.match(/^\$\d+(?=\=)/))?a[0]:void 0,n=t.slice(1+o.length),this.modifiers[o]=this.getNumber(n);case"1":case"2":case"20":case"21":case"22":case"4":case"5":case"6":case"7":for(e=t.split(","),i=s=0,l=e.length;l>s;i=++s)r=e[i],e[i]=this.getNumber(r);return this.primitive(e);default:if("0"!==t[0])throw new Error("'"+t+"' unrecognized tool macro block")}},t.prototype.primitive=function(t){var r,e,i,l,a,h,u,c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R,T,B,A,D,L;switch(a=!1,f=!1,d=null,t[0]){case 1:d=n.circle({dia:o(t[2],this.format),cx:o(t[3],this.format),cy:o(t[4],this.format)}),0===t[1]?a=!0:this.addBbox(d.bbox);break;case 2:case 20:d=n.vector({width:o(t[2],this.format),x1:o(t[3],this.format),y1:o(t[4],this.format),x2:o(t[5],this.format),y2:o(t[6],this.format)}),t[7]&&(d.shape.line.transform="rotate("+t[7]+")"),0===t[1]?a=!0:this.addBbox(d.bbox,t[7]);break;case 21:d=n.rect({cx:o(t[4],this.format),cy:o(t[5],this.format),width:o(t[2],this.format),height:o(t[3],this.format)}),t[6]&&(d.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?a=!0:this.addBbox(d.bbox,t[6]);break;case 22:d=n.lowerLeftRect({x:o(t[4],this.format),y:o(t[5],this.format),width:o(t[2],this.format),height:o(t[3],this.format)}),t[6]&&(d.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?a=!0:this.addBbox(d.bbox,t[6]);break;case 4:for(u=[],e=x=3,_=3+2*t[2];_>=x;e=x+=2)u.push([o(t[e],this.format),o(t[e+1],this.format)]);d=n.outline({points:u}),(c=t[t.length-1])&&(d.shape.polygon.transform="rotate("+c+")"),0===t[1]?a=!0:this.addBbox(d.bbox,t[t.length-1]);break;case 5:if(0!==t[6]&&(0!==t[3]||0!==t[4]))throw new RangeError("polygon center must be 0,0 if rotated in macro");d=n.polygon({cx:o(t[3],this.format),cy:o(t[4],this.format),dia:o(t[5],this.format),verticies:t[2],degrees:t[6]}),0===t[1]?a=!0:this.addBbox(d.bbox);break;case 6:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("moiré center must be 0,0 if rotated in macro");if(d=n.moire({cx:o(t[1],this.format),cy:o(t[2],this.format),outerDia:o(t[3],this.format),ringThx:o(t[4],this.format),ringGap:o(t[5],this.format),maxRings:t[6],crossThx:o(t[7],this.format),crossLength:o(t[8],this.format)}),t[9])for(R=d.shape,b=0,w=R.length;w>b;b++)p=R[b],null!=p.line&&(p.line.transform="rotate("+t[9]+")");this.addBbox(d.bbox,t[9]);break;case 7:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("thermal center must be 0,0 if rotated in macro");if(d=n.thermal({cx:o(t[1],this.format),cy:o(t[2],this.format),outerDia:o(t[3],this.format),innerDia:o(t[4],this.format),gap:o(t[5],this.format)}),t[6])for(T=d.shape,m=0,y=T.length;y>m;m++)if(p=T[m],null!=p.mask)for(B=p.mask._,g=0,v=B.length;v>g;g++)l=B[g],null!=l.rect&&(l.rect.transform="rotate("+t[6]+")");this.addBbox(d.bbox,t[6]);break;default:throw new Error(""+t[0]+" is not a valid primitive code")}if(a){for(i in d.shape)d.shape[i].fill="#000";if(0!==this.lastExposure){if(this.lastExposure=0,h="macro-"+this.name+"-mask-"+s(),l={mask:{id:h}},l.mask._=[{rect:{x:this.bbox[0],y:this.bbox[1],width:this.bbox[2]-this.bbox[0],height:this.bbox[3]-this.bbox[1],fill:"#fff"}}],1===this.shapes.length)for(i in this.shapes[0])this.shapes[0][i].mask="url(#"+h+")";else if(this.shapes.length>1){for(r={mask:"url(#"+h+")",_:[]},A=this.shapes,E=0,M=A.length;M>E;E++)p=A[E],r._.push(p);this.shapes=[{g:r}]}this.masks.push(l)}return this.masks[this.masks.length-1].mask._.push(d.shape)}if(this.lastExposure=1,Array.isArray(d.shape)){for(D=d.shape,L=[],q=0,k=D.length;k>q;q++)p=D[q],L.push(null!=p.mask?this.masks.push(p):this.shapes.push(p));return L}return this.shapes.push(d.shape)},t.prototype.addBbox=function(t,r){var e,i,o,n,s,l,a,h,u;if(null==r&&(r=0),r){for(s=Math.sin(r*Math.PI/180),i=Math.cos(r*Math.PI/180),Math.abs(s)<1e-9&&(s=0),Math.abs(i)<1e-9&&(i=0),n=[[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]]],h=0,u=n.length;u>h;h++)o=n[h],l=o[0]*i-o[1]*s,a=o[0]*s+o[1]*i,(null===this.bbox[0]||l<this.bbox[0])&&(this.bbox[0]=l),(null===this.bbox[1]||a<this.bbox[1])&&(this.bbox[1]=a),(null===this.bbox[2]||l>this.bbox[2])&&(this.bbox[2]=l),(null===this.bbox[3]||a>this.bbox[3])&&(this.bbox[3]=a);return this.bbox=function(){var t,r,i,o;for(i=this.bbox,o=[],t=0,r=i.length;r>t;t++)e=i[t],o.push(e===-0?0:e);return o}.call(this)}return(null===this.bbox[0]||t[0]<this.bbox[0])&&(this.bbox[0]=t[0]),(null===this.bbox[1]||t[1]<this.bbox[1])&&(this.bbox[1]=t[1]),(null===this.bbox[2]||t[2]>this.bbox[2])&&(this.bbox[2]=t[2]),null===this.bbox[3]||t[3]>this.bbox[3]?this.bbox[3]=t[3]:void 0},t.prototype.getNumber=function(t){return t.match(/^[+-]?[\d.]+$/)?Number(t):t.match(/^\$\d+$/)?Number(this.modifiers[t]):this.evaluate(i.parse(t))},t.prototype.evaluate=function(t){switch(t.type){case"n":return this.getNumber(t.val);case"+":return this.evaluate(t.left)+this.evaluate(t.right);case"-":return this.evaluate(t.left)-this.evaluate(t.right);case"x":return this.evaluate(t.left)*this.evaluate(t.right);case"/":return this.evaluate(t.left)/this.evaluate(t.right)}},t}(),r.exports=e},{"./macro-calc":7,"./pad-shapes":10,"./svg-coord":14,"./unique-id":15}],9:[function(t,r){var e,i,o,n;n=function(t,r){var e;if(e="",0===r)return"";for(;r>1;)1&r&&(e+=t),r>>=1,t+=t;return e+t},e="_",i=" ",o=function(t,r){var s,l,a,h,u,c,f,p,d,x,b,m,g,w,y,v,M,k,E;if(null==r&&(r={}),x=r.pretty,c=null!=(M=r.indent)?M:0,l=null!=(k=r.maxDec)?k:!1,a=function(t){return"number"==typeof t?Number(t.toFixed(l)):t},p=x?"\n":"",b=p?"string"==typeof x?x:i:"",b=n(b,c),w="","function"==typeof t&&(t=t()),Array.isArray(t))for(u=y=0,v=t.length;v>y;u=++y)d=t[u],w+=(0!==u?p:"")+o(d,r);else if("object"==typeof t){if(s=!1,h=Object.keys(t)[0],null!=h){w=""+b+"<"+h,"function"==typeof t[h]&&(t[h]=t[h]()),E=t[h];for(f in E)g=E[f],"function"==typeof g&&(g=g()),f===e?s=g:(Array.isArray(g)&&(l&&(g=function(){var t,r,e;for(e=[],t=0,r=g.length;r>t;t++)m=g[t],e.push(a(m));return e}()),g=g.join(" ")),l&&(g=a(g)),w+=" "+f+'="'+g+'"');s&&(w+=">"+p+o(s,{pretty:x,indent:c+1})),w+=null!=t[h]._?""+p+b+"</"+h+">":"/>"}}else w+=""+t+" ";return w},r.exports=o},{}],10:[function(t,r){var e,i,o,n,s,l,a,h,u;h=t("./unique-id"),e=function(t){var r;if(null==t.dia)throw new Error("circle function requires diameter");if(null==t.cx)throw new Error("circle function requires x center");if(null==t.cy)throw new Error("circle function requires y center");return r=t.dia/2,{shape:{circle:{cx:t.cx,cy:t.cy,r:r}},bbox:[t.cx-r,t.cy-r,t.cx+r,t.cy+r]}},l=function(t){var r,e,i,o;if(null==t.width)throw new Error("rectangle requires width");if(null==t.height)throw new Error("rectangle requires height");if(null==t.cx)throw new Error("rectangle function requires x center");if(null==t.cy)throw new Error("rectangle function requires y center");return i=t.cx-t.width/2,o=t.cy-t.height/2,e={shape:{rect:{x:i,y:o,width:t.width,height:t.height}},bbox:[i,o,i+t.width,o+t.height]},t.obround&&(r=.5*Math.min(t.width,t.height),e.shape.rect.rx=r,e.shape.rect.ry=r),e},s=function(t){var r,e,i,o,n,s,l,a,h,u,c,f,p,d,x,b;if(null==t.dia)throw new Error("polygon requires diameter");if(null==t.verticies)throw new Error("polygon requires verticies");if(null==t.cx)throw new Error("polygon function requires x center");if(null==t.cy)throw new Error("polygon function requires y center");for(s=null!=t.degrees?t.degrees*Math.PI/180:0,l=2*Math.PI/t.verticies,i=t.dia/2,e="",c=null,d=null,u=null,p=null,r=x=0,b=t.verticies;b>=0?b>x:x>b;r=b>=0?++x:--x)a=s+r*l,o=i*Math.cos(a),n=i*Math.sin(a),Math.abs(o)<1e-9&&(o=0),Math.abs(n)<1e-9&&(n=0),h=t.cx+o,f=t.cy+n,(c>h||null===c)&&(c=h),(h>u||null===u)&&(u=h),(d>f||null===d)&&(d=f),(f>p||null===p)&&(p=f),e+=" "+h+","+f;return{shape:{polygon:{points:e.slice(1)}},bbox:[c,d,u,p]}},u=function(t){var r,e,i;if(null==t.x1)throw new Error("vector function requires start x");if(null==t.y1)throw new Error("vector function requires start y");if(null==t.x2)throw new Error("vector function requires end x");if(null==t.y2)throw new Error("vector function requires end y");if(null==t.width)throw new Error("vector function requires width");return r=Math.abs(Math.atan((t.y2-t.y1)/(t.x2-t.x1))),e=t.width/2*Math.sin(r),i=t.width/2*Math.cos(r),1e-7>e&&(e=0),1e-7>i&&(i=0),{shape:{line:{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,"stroke-width":t.width,"stroke-linecap":"butt"}},bbox:[Math.min(t.x1,t.x2)-e,Math.min(t.y1,t.y2)-i,Math.max(t.x1,t.x2)+e,Math.max(t.y1,t.y2)+i]}},i=function(t){if(null==t.width)throw new Error("lower left rect requires width");if(null==t.height)throw new Error("lower left rect requires height");if(null==t.x)throw new Error("lower left rectangle requires x");if(null==t.y)throw new Error("lower left rectangle requires y");return{shape:{rect:{x:t.x,y:t.y,width:t.width,height:t.height}},bbox:[t.x,t.y,t.x+t.width,t.y+t.height]}},n=function(t){var r,e,i,o,n,s,l,a,h,u,c,f,p;if(!(Array.isArray(t.points)&&t.points.length>1))throw new Error("outline function requires points array");for(s=null,u=null,n=null,h=null,e="",p=t.points,c=0,f=p.length;f>c;c++){if(r=p[c],!Array.isArray(r)||2!==r.length)throw new Error("outline function requires points array");i=r[0],l=r[1],(s>i||null===s)&&(s=i),(i>n||null===n)&&(n=i),(u>l||null===u)&&(u=l),(l>h||null===h)&&(h=l),e+=" "+i+","+l}if(o=t.points[t.points.length-1][0],a=t.points[t.points.length-1][1],o!==t.points[0][0]||a!==t.points[0][1])throw new RangeError("last point must match first point of outline");return{shape:{polygon:{points:e.slice(1)}},bbox:[s,u,n,h]}},o=function(t){var r,e,i;if(null==t.cx)throw new Error("moiré requires x center");if(null==t.cy)throw new Error("moiré requires y center");if(null==t.outerDia)throw new Error("moiré requires outer diameter");if(null==t.ringThx)throw new Error("moiré requires ring thickness");if(null==t.ringGap)throw new Error("moiré requires ring gap");if(null==t.maxRings)throw new Error("moiré requires max rings");if(null==t.crossLength)throw new Error("moiré requires crosshair length");if(null==t.crossThx)throw new Error("moiré requires crosshair thickness");for(i=[{line:{x1:t.cx-t.crossLength/2,y1:0,x2:t.cx+t.crossLength/2,y2:0,"stroke-width":t.crossThx,"stroke-linecap":"butt"}},{line:{x1:0,y1:t.cy-t.crossLength/2,x2:0,y2:t.cy+t.crossLength/2,"stroke-width":t.crossThx,"stroke-linecap":"butt"}}],r=(t.outerDia-t.ringThx)/2,e=0;r>=t.ringThx&&e<t.maxRings;)i.push({circle:{cx:t.cx,cy:t.cy,r:r,fill:"none","stroke-width":t.ringThx}}),e++,r-=t.ringThx+t.ringGap;return r+=.5*t.ringThx,r>0&&e<t.maxRings&&i.push({circle:{cx:t.cx,cy:t.cy,r:r}}),{shape:i,bbox:[Math.min(t.cx-t.crossLength/2,t.cx-t.outerDia/2),Math.min(t.cy-t.crossLength/2,t.cy-t.outerDia/2),Math.max(t.cx+t.crossLength/2,t.cx+t.outerDia/2),Math.max(t.cy+t.crossLength/2,t.cy+t.outerDia/2)]}},a=function(t){var r,e,i,o,n,s,l,a,u;if(null==t.cx)throw new Error("thermal requires x center");if(null==t.cy)throw new Error("thermal requires y center");if(null==t.outerDia)throw new Error("thermal requires outer diameter");if(null==t.innerDia)throw new Error("thermal requires inner diameter");if(null==t.gap)throw new Error("thermal requires gap");return e="thermal-mask-"+h(),n=(t.outerDia-t.innerDia)/2,i=t.outerDia/2,o=i-n/2,l=t.cx-i,s=t.cx+i,u=t.cy-i,a=t.cy+i,r=t.gap/2,{shape:[{mask:{id:e,_:[{circle:{cx:t.cx,cy:t.cy,r:i,fill:"#fff"}},{rect:{x:l,y:-r,width:t.outerDia,height:t.gap,fill:"#000"}},{rect:{x:-r,y:u,width:t.gap,height:t.outerDia,fill:"#000"}}]}},{circle:{cx:t.cx,cy:t.cy,r:o,fill:"none","stroke-width":n,mask:"url(#"+e+")"}}],bbox:[l,u,s,a]}},r.exports={circle:e,rect:l,polygon:s,vector:u,lowerLeftRect:i,outline:n,moire:o,thermal:a}},{"./unique-id":15}],11:[function(t,r){var e;e=function(){function t(t){var r,e;if(null==t&&(t={}),this.format={zero:null!=(r=t.zero)?r:null,places:null!=(e=t.places)?e:null},null!=this.format.places&&(!Array.isArray(this.format.places)||2!==this.format.places.length||"number"!=typeof this.format.places[0]||"number"!=typeof this.format.places[1]))throw new Error("parser places format must be an array of two numbers");if(null!=this.format.zero&&("string"!=typeof this.format.zero||"L"!==this.format.zero&&"T"!==this.format.zero))throw new Error("parser zero format must be either 'L' or 'T'")}return t}(),r.exports=e},{}],12:[function(t,r){var e,i,o,n,s,l,a,h,u;u=t("./unique-id"),o=t("./macro-tool"),h=t("./standard-tool"),a=t("./svg-coord").factor,i=Math.PI/2,s=3*i,l=2*Math.PI,e="in",n=function(){function t(t,r,e){var i,o;this.reader=t,this.parser=r,null==e&&(e={}),this.units=null!=(i=e.units)?i:null,this.notation=null!=(o=e.notation)?o:null,this.macros={},this.tools={},this.currentTool="",this.defs=[],this.group={g:{_:[]}},this.polarity="D",this.current=[],this.stepRepeat={x:1,y:1,i:0,j:0},this.srOverClear=!1,this.srOverCurrent=[],this.mode=null,this.quad=null,this.lastOp=null,this.region=!1,this.done=!1,this.pos={x:0,y:0},this.path=[],this.attr={"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":0,stroke:"#000"},this.bbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},this.layerBbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0}}return t.prototype.addTool=function(t,r){var e,i;if(null!=this.tools[t])throw new Error("cannot reassign tool "+t);return i=null!=r.macro?this.macros[r.macro].run(t,r.mods):h(t,r),this.tools[t]={trace:i.trace,pad:function(){var t,r,o,n;for(o=i.pad,n=[],t=0,r=o.length;r>t;t++)e=o[t],n.push(e);return n}(),flash:function(t,r){return{use:{x:t,y:r,"xlink:href":"#"+i.padId}}},bbox:function(t,r){return null==t&&(t=0),null==r&&(r=0),{xMin:t+i.bbox[0],yMin:r+i.bbox[1],xMax:t+i.bbox[2],yMax:r+i.bbox[3]}}},this.changeTool(t)},t.prototype.changeTool=function(t){var r;if(this.finishPath(),this.region)throw new Error("cannot change tool when in region mode");if(null!=this.tools[t])return this.currentTool=t;if(!(null!=(r=this.parser)?r.fmat:void 0))throw new Error("tool "+t+" is not defined")},t.prototype.command=function(t){var r,e,i,n,s,l,a;if(null!=t.macro)return e=new o(t.macro,this.parser.format.places),void(this.macros[e.name]=e);l=t.set;for(n in l)switch(s=l[n],"region"===n&&this.finishPath(),n){case"currentTool":this.changeTool(s);break;case"units":case"notation":null==this[n]&&(this[n]=s);break;default:this[n]=s}if(null!=t.tool){a=t.tool;for(r in a)i=a[r],this.addTool(r,i)}if(null!=t.op&&this.operate(t.op),null!=t["new"]){if(this.finishLayer(),null!=t["new"].layer)return this.polarity=t["new"].layer;if(null!=t["new"].sr)return this.finishSR(),this.stepRepeat=t["new"].sr}},t.prototype.plot=function(){for(var t,r;!this.done;){if(t=this.reader.nextBlock(),t===!1)throw new Error(null==(null!=(r=this.parser)?r.fmat:void 0)?"end of file encountered before required M02 command":"end of drill file encountered before M00/M30 command");this.command(this.parser.parseCommand(t))}return this.finish()},t.prototype.finish=function(){return this.finishPath(),this.finishLayer(),this.finishSR(),this.group.g.fill="currentColor",this.group.g.stroke="currentColor",this.group.g.transform="translate(0,"+(this.bbox.yMin+this.bbox.yMax)+") scale(1,-1)"},t.prototype.finishSR=function(){var t,r,e,i,o,n,s,l,a,h,c,f,p,d,x,b;if(this.srOverClear&&this.srOverCurrent){for(e="gerber-sr-mask_"+u(),r={mask:{color:"#000",id:e,_:[]}},r.mask._.push({rect:{fill:"#fff",x:this.bbox.xMin,y:this.bbox.yMin,width:this.bbox.xMax-this.bbox.xMin,height:this.bbox.yMax-this.bbox.yMin}}),o=s=0,c=this.stepRepeat.x*this.stepRepeat.i,f=this.stepRepeat.i;f>0?c>s:s>c;o=s+=f)for(n=l=0,p=this.stepRepeat.y*this.stepRepeat.j,d=this.stepRepeat.j;d>0?p>l:l>p;n=l+=d)for(x=this.srOverCurrent,a=0,h=x.length;h>a;a++)t=x[a],i={use:{}},0!==o&&(i.use.x=o),0!==n&&(i.use.y=n),i.use["xlink:href"]="#"+(null!=(b=t.C)?b:t.D),null!=t.D&&(i.use.fill="#fff"),r.mask._.push(i);return this.srOverClear=!1,this.srOverCurrent=[],this.defs.push(r),this.group.g.mask="url(#"+e+")"}},t.prototype.finishLayer=function(){var t,r,e,i,o,n,s,l,a,h,c,f,p,d,x,b;if(this.finishPath(),this.current.length){if(this.stepRepeat.x>1||this.stepRepeat.y>1){for(o="gerber-sr_"+u(),this.current=[{g:{id:o,_:this.current}}],(this.srOverClear||this.stepRepeat.i<this.layerBbox.xMax-this.layerBbox.xMin||this.stepRepeat.j<this.layerBbox.yMax-this.layerBbox.yMin)&&(i={},i[this.polarity]=o,this.srOverCurrent.push(i),"C"===this.polarity&&(this.srOverClear=!0,this.defs.push(this.current[0]))),l=h=0,d=this.stepRepeat.x;d>=0?d>h:h>d;l=d>=0?++h:--h)for(a=c=0,x=this.stepRepeat.y;x>=0?x>c:c>x;a=x>=0?++c:--c)(0!==l||0!==a)&&(n={use:{"xlink:href":"#"+o}},0!==l&&(n.use.x=l*this.stepRepeat.i),0!==a&&(n.use.y=a*this.stepRepeat.j),this.current.push(n));this.layerBbox.xMax+=(this.stepRepeat.x-1)*this.stepRepeat.i,this.layerBbox.yMax+=(this.stepRepeat.y-1)*this.stepRepeat.j}if(this.addBbox(this.layerBbox,this.bbox),this.layerBbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},"D"===this.polarity)if(null!=this.group.g.mask&&this.current.unshift(this.group),null==this.group.g.mask&&this.group.g._.length)for(b=this.current,f=0,p=b.length;p>f;f++)t=b[f],this.group.g._.push(t);else this.group={g:{_:this.current}};else"C"!==this.polarity||this.srOverClear||(e="gerber-mask_"+u(),s=this.bbox.xMax-this.bbox.xMin,r=this.bbox.yMax-this.bbox.yMin,this.current.unshift({rect:{x:this.bbox.xMin,y:this.bbox.yMin,width:s,height:r,fill:"#fff"}}),this.defs.push({mask:{id:e,color:"#000",_:this.current}}),this.group.g.mask="url(#"+e+")");return this.current=[]}},t.prototype.finishPath=function(){var t,r,e,i;if(this.path.length){if(r={path:{}},this.region)this.path.push("Z");else{i=this.tools[this.currentTool].trace;for(t in i)e=i[t],r.path[t]=e}return r.path.d=this.path,this.current.push(r),this.path=[]}},t.prototype.operate=function(t){var r,i,o,n,s,l,a,h,u,c,f,p,d,x,b,m,g;if("last"===t["do"]?t["do"]=this.lastOp:this.lastOp=t["do"],s=this.pos.x,l=this.pos.y,"I"===this.notation?(this.pos.x+=null!=(c=t.x)?c:0,this.pos.y+=null!=(f=t.y)?f:0):(this.pos.x=null!=(p=t.x)?p:this.pos.x,this.pos.y=null!=(d=t.y)?d:this.pos.y),i=this.pos.x,o=this.pos.y,a=this.tools[this.currentTool],null==this.units&&(this.units=null!=this.backupUnits?this.backupUnits:e),null==this.notation){if(null==(null!=(x=this.parser)?x.fmat:void 0))throw new Error("format has not been set");this.notation="A"}if("move"===t["do"]&&this.path.length)return this.path.push("M",i,o);if("flash"===t["do"]){if(this.finishPath(),this.region)throw new Error("cannot flash while in region mode");if(a.pad){for(b=a.pad,h=0,u=b.length;u>h;h++)n=b[h],this.defs.push(n);a.pad=!1}return this.current.push(a.flash(i,o)),this.addBbox(a.bbox(i,o),this.layerBbox)}if("int"===t["do"]){if(!this.region&&!a.trace)throw new Error(""+this.currentTool+" is not a strokable tool");return 0===this.path.length&&(this.path.push("M",s,l),r=this.region?{xMin:s,yMin:l,xMax:s,yMax:l}:a.bbox(s,l),this.addBbox(r,this.layerBbox)),null==this.mode&&(this.mode="i"),"i"===this.mode?this.drawLine(s,l,i,o):this.drawArc(s,l,i,o,null!=(m=t.i)?m:0,null!=(g=t.j)?g:0)}},t.prototype.drawLine=function(t,r,e,o){var n,s,l,a,h,u,c,f,p,d,x,b,m;return b=this.tools[this.currentTool],n=this.region?{xMin:e,yMin:o,xMax:e,yMax:o}:b.bbox(e,o),this.addBbox(n,this.layerBbox),this.region||b.trace["stroke-width"]>=0?this.path.push("L",e,o):(c=b.pad[0].rect.width/2,u=b.pad[0].rect.height/2,f=t-c,p=t+c,d=r-u,x=r+u,s=e-c,l=e+c,a=o-u,h=o+u,m=Math.atan2(o-r,e-t),m>=0&&i>m?this.path.push("M",f,d,p,d,l,a,l,h,s,h,f,x,"Z"):m>=i&&m<Math.PI?this.path.push("M",f,d,p,d,p,x,l,h,s,h,s,a,"Z"):-Math.PI<=m&&-i>m?this.path.push("M",p,d,p,x,f,x,s,h,s,a,l,a,"Z"):m>=-i&&0>m?this.path.push("M",f,d,s,a,l,a,l,h,p,x,f,x,"Z"):void 0)},t.prototype.drawArc=function(t,r,e,o,n,h){var u,c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R,T,B,A,D,L,I,O,z,C,j,P,N;if(u=1.5*a*Math.pow(10,-1*(null!=(j=null!=(P=this.parser)?P.format.places[1]:void 0)?j:7)),w=this.tools[this.currentTool],!this.region&&!w.trace["stroke-width"])throw Error("cannot stroke an arc with non-circular tool "+this.currentTool);if(null==this.quad)throw new Error("arc quadrant mode has not been set");for(b=Math.sqrt(Math.pow(n,2)+Math.pow(h,2)),g="cw"===this.mode?0:1,x=0,k=[],f=[[t+n,r+h]],"s"===this.quad&&f.push([t-n,r-h],[t-n,r+h],[t+n,r-h]),I=0,z=f.length;z>I;I++)c=f[I],d=Math.sqrt(Math.pow(c[0]-e,2)+Math.pow(c[1]-o,2)),Math.abs(b-d)<u&&k.push({x:c[0],y:c[1]});for(v=0,M=0,p=null,O=0,C=k.length;C>O&&(c=k[O],v=Math.atan2(o-c.y,e-c.x),0>v&&(v+=l),M=Math.atan2(r-c.y,t-c.x),0>M&&(M+=l),"cw"===this.mode&&v>M?M+=l:"ccw"===this.mode&&M>v&&(v+=l),y=Math.abs(v-M),"s"===this.quad&&i>=y?p=c:"m"===this.quad&&(y>=Math.PI&&(x=1),p={x:c.x,y:c.y}),null==p);O++);return null!=p?(m=this.region?0:w.bbox().xMax,"cw"===this.mode&&(N=[M,v],v=N[0],M=N[1]),R=M>0?l:0,D=i+(M>i?l:0),_=Math.PI+(M>Math.PI?l:0),A=s+(M>s?l:0),q=_>=M&&v>=_?p.x-b-m:Math.min(t,e)-m,E=R>=M&&v>=R?p.x+b+m:Math.max(t,e)+m,B=A>=M&&v>=A?p.y-b-m:Math.min(r,o)-m,T=D>=M&&v>=D?p.y+b+m:Math.max(r,o)+m,L=Math.abs(t-e)<u&&Math.abs(r-o)<u,"m"===this.quad&&L&&(this.path.push("A",b,b,0,0,g,e+2*n,o+2*h),q=p.x-b-m,B=p.y-b-m,E=p.x+b+m,T=p.y+b+m),this.path.push("A",b,b,0,x,g,e,o),"s"===this.quad&&L&&this.path.push("Z"),this.addBbox({xMin:q,yMin:B,xMax:E,yMax:T},this.layerBbox)):void 0
},t.prototype.addBbox=function(t,r){return t.xMin<r.xMin&&(r.xMin=t.xMin),t.yMin<r.yMin&&(r.yMin=t.yMin),t.xMax>r.xMax&&(r.xMax=t.xMax),t.yMax>r.yMax?r.yMax=t.yMax:void 0},t}(),r.exports=n},{"./macro-tool":8,"./standard-tool":13,"./svg-coord":14,"./unique-id":15}],13:[function(t,r){var e,i,o;o=t("./unique-id"),e=t("./pad-shapes"),i=function(t,r){var i,n,s,l,a,h,u;if(h={pad:[],trace:!1},r.cx=0,r.cy=0,n="tool-"+t+"-pad-"+o(),u="",null!=r.dia&&null==r.verticies){if(null!=r.obround||null!=r.width||null!=r.height||null!=r.degrees)throw new Error("incompatible parameters for tool "+t);if(r.dia<0)throw new RangeError(""+t+" circle diameter out of range ("+r.dia+"<0)");u="circle",null==r.hole&&(h.trace={"stroke-width":r.dia,fill:"none"})}else if(null!=r.width&&null!=r.height){if(null!=r.dia||null!=r.verticies||null!=r.degrees)throw new Error("incompatible parameters for tool "+t);if(r.width<0)throw new RangeError(""+t+" rect width out of range ("+r.width+"<0)");if(r.height<0)throw new RangeError(""+t+" rect height out of range ("+r.height+"<0)");u="rect",0!==r.width&&0!==r.height||r.obround||(u="circle",r.dia=0),null!=r.hole||r.obround||(h.trace={})}else{if(null==r.dia||null==r.verticies)throw new Error("unidentified standard tool shape");if(null!=r.obround||null!=r.width||null!=r.height)throw new Error("incompatible parameters for tool "+t);if(r.verticies<3||r.verticies>12)throw new RangeError(""+t+" polygon points out of range ("+r.verticies+"<3 or >12)]");u="polygon"}if(a=e[u](r),null!=r.hole){if(i=null,null!=r.hole.dia&&null==r.hole.width&&null==r.hole.height){if(!(r.hole.dia>=0))throw new RangeError(""+t+" hole diameter out of range ("+r.hole.dia+"<0)");i=e.circle({cx:r.cx,cy:r.cy,dia:r.hole.dia}),i=i.shape,i.circle.fill="#000"}else{if(null==r.hole.width||null==r.hole.height)throw new Error(""+t+" has invalid hole parameters");if(!(r.hole.width>=0))throw new RangeError(""+t+" hole width out of range ("+r.hole.width+"<0)");if(!(r.hole.height>=0))throw new RangeError(""+t+" hole height out of range ("+r.hole.height+"<0)");i=e.rect({cx:r.cx,cy:r.cy,width:r.hole.width,height:r.hole.height}),i=i.shape,i.rect.fill="#000"}l=n+"-mask",s={mask:{id:n+"-mask",_:[{rect:{x:a.bbox[0],y:a.bbox[1],width:a.bbox[2]-a.bbox[0],height:a.bbox[3]-a.bbox[1],fill:"#fff"}},i]}},a.shape[u].mask="url(#"+l+")",h.pad.push(s)}return n&&(a.shape[u].id=n),h.pad.push(a.shape),h.bbox=a.bbox,h.padId=n,h},r.exports=i},{"./pad-shapes":10,"./unique-id":15}],14:[function(t,r){var e,i,o=[].indexOf||function(t){for(var r=0,e=this.length;e>r;r++)if(r in this&&this[r]===t)return r;return-1};e=3,i=function(t,r){var i,n,s,l,a,h,u,c,f,p,d,x,b,m;if(null==t)return 0/0;if(t=""+t,n="",i="",a="+",("-"===t[0]||"+"===t[0])&&(a=t[0],t=t.slice(1)),o.call(t,".")>=0||null==r.zero){if(h=t.split("."),h.length>2)return 0/0;x=[h[0],null!=(d=h[1])?d:""],n=x[0],i=x[1]}else{if("number"!=typeof(null!=r&&null!=(b=r.places)?b[0]:void 0)||"number"!=typeof(null!=r&&null!=(m=r.places)?m[1]:void 0))return 0/0;if("T"===r.zero){for(l=u=0,f=t.length;f>u;l=++u)s=t[l],l<r.places[0]?n+=s:i+=s;for(;n.length<r.places[0];)n+="0"}else if("L"===r.zero){for(l=c=0,p=t.length;p>c;l=++c)s=t[l],t.length-l<=r.places[1]?i+=s:n+=s;for(;i.length<r.places[1];)i="0"+i}}for(;i.length<e;)i+="0";return n+=i.slice(0,e),i=i.length>e?"."+i.slice(e):"",Number(a+n+i)},r.exports={get:i,factor:Math.pow(10,e)}},{}],15:[function(t,r){var e,i;i=1e3,e=function(){return i++},r.exports=e},{}]},{},[1])(1)});
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.gerberToSvg=t()}}(function(){return function t(r,e,i){function o(s,l){if(!e[s]){if(!r[s]){var h="function"==typeof require&&require;if(!l&&h)return h(s,!0);if(n)return n(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var u=e[s]={exports:{}};r[s][0].call(u.exports,function(t){var e=r[s][1][t];return o(e?e:t)},u,u.exports,t,r,e,i)}return e[s].exports}for(var n="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(t,r){(function(e){var i,o,n,s,l,h,a,u;a=t("./obj-to-xml"),h=t("./plotter"),n=t("./drill-reader"),o=t("./drill-parser"),l=t("./gerber-reader"),s=t("./gerber-parser"),u=t("./svg-coord").factor,i={drill:!1,pretty:!1,object:!1,warnArr:null,places:null,zero:null,notation:null,units:null},r.exports=function(t,r){var c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R;null==r&&(r={}),b={};for(d in i)E=i[d],b[d]=E;for(d in r)E=r[d],b[d]=E;if("object"==typeof t){if(null!=t.svg)return a(t,{pretty:b.pretty});throw new Error("non SVG object cannot be converted to an SVG string")}w=null,(null!=b.places||null!=b.zero)&&(w={places:b.places,zero:b.zero}),b.drill?(v=new n(t),g=new o(w)):(v=new l(t),g=new s(w)),y=null,(null!=b.notation||null!=b.units)&&(y={notation:b.notation,units:b.units}),m=new h(v,g,y),x=null,k=null,Array.isArray(b.warnArr)&&(k="undefined"!=typeof window&&null!==window?window:e,null==k.console&&(k.console={}),x=k.console.warn,k.console.warn=function(t){return b.warnArr.push(t.toString())});try{R=m.plot()}catch(T){throw f=T,new Error("Error at line "+m.reader.line+" - "+f.message)}finally{null!=x&&null!=k&&(k.console.warn=x)}m.bbox.xMin>=m.bbox.xMax?(m.bbox.xMin=0,m.bbox.xMax=0,q=0):q=m.bbox.xMax-m.bbox.xMin,m.bbox.yMin>=m.bbox.yMax?(m.bbox.yMin=0,m.bbox.yMax=0,p=0):p=m.bbox.yMax-m.bbox.yMin,_={svg:{xmlns:"http://www.w3.org/2000/svg",version:"1.1","xmlns:xlink":"http://www.w3.org/1999/xlink",width:""+q/u+m.units,height:""+p/u+m.units,viewBox:[m.bbox.xMin,m.bbox.yMin,q,p],_:[]}},M=m.attr;for(c in M)E=M[c],_.svg[c]=E;return m.defs.length&&_.svg._.push({defs:{_:m.defs}}),m.group.g._.length&&_.svg._.push(m.group),b.object?_:a(_,{pretty:b.pretty})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./drill-parser":3,"./drill-reader":4,"./gerber-parser":5,"./gerber-reader":6,"./obj-to-xml":9,"./plotter":12,"./svg-coord":14}],2:[function(t,r){var e;e=t("./svg-coord").get,r.exports=function(t,r){var i,o,n,s,l,h,a,u,c,f,p,d;if(null==t)return{};if(null==r.zero||null==r.places)throw new Error("format undefined");o={},p={},o.x=null!=(n=t.match(/X[+-]?[\d\.]+/))&&null!=(s=n[0])?s.slice(1):void 0,o.y=null!=(l=t.match(/Y[+-]?[\d\.]+/))&&null!=(h=l[0])?h.slice(1):void 0,o.i=null!=(a=t.match(/I[+-]?[\d\.]+/))&&null!=(u=a[0])?u.slice(1):void 0,o.j=null!=(c=t.match(/J[+-]?[\d\.]+/))&&null!=(f=c[0])?f.slice(1):void 0;for(i in o)d=o[i],null!=d&&(p[i]=e(d,r));return p}},{"./svg-coord":14}],3:[function(t,r){var e,i,o,n,s,l,h,a,u,c,f,p=function(t,r){function e(){this.constructor=t}for(var i in r)d.call(r,i)&&(t[i]=r[i]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},d={}.hasOwnProperty;h=t("./parser"),c=t("./coord-parser"),u=t("./svg-coord").get,o={"FMAT,1":"M70","FMAT,2":"M72"},s="M71",e="G90",n="G91",f=/[XY]{1,2}/,a="L",l=[2,4],i=function(t){function r(){this.fmat="FMAT,2",r.__super__.constructor.call(this,arguments[0])}return p(r,t),r.prototype.parseCommand=function(t){var r,i,h,p,d,x,b,m,g,w,y,v;if(x={},";"===t[0])return x;if("FMAT,1"===t)this.fmat=t;else if("M30"===t||"M00"===t)x.set={done:!0};else if(t===o[this.fmat]||t.match(/INCH/))null==(r=this.format).places&&(r.places=[2,4]),x.set={units:"in"};else if(t===s||t.match(/METRIC/))null==(i=this.format).places&&(i.places=[3,3]),x.set={units:"mm"};else if(t===e)x.set={notation:"A"};else if(t===n)x.set={notation:"I"};else if(d=null!=(g=t.match(/T\d+/))?g[0]:void 0){for(;"0"===d[1];)d=d[0]+d.slice(2);(b=null!=(w=t.match(/C[\d\.]+(?=.*$)/))?w[0]:void 0)?(b=b.slice(1),x.tool={},x.tool[d]={dia:u(b,{places:this.format.places})}):x.set={currentTool:d}}if(t.match(/TZ/)?null==(h=this.format).zero&&(h.zero="L"):t.match(/LZ/)&&null==(p=this.format).zero&&(p.zero="T"),t.match(f)){x.op={"do":"flash"},null==this.format.zero&&(this.format.zero=a),null==this.format.places&&(this.format.places=l),y=c(t,this.format);for(m in y)v=y[m],x.op[m]=v}return x},r}(h),r.exports=i},{"./coord-parser":2,"./parser":11,"./svg-coord":14}],4:[function(t,r){var e;e=function(){function t(t){this.line=0,this.blocks=t.split(/\r?\n/)}return t.prototype.nextBlock=function(){return this.line<this.blocks.length?this.blocks[++this.line-1]:!1},t}(),r.exports=e},{}],5:[function(t,r){var e,i,o,n,s,l=function(t,r){function e(){this.constructor=t}for(var i in r)h.call(r,i)&&(t[i]=r[i]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},h={}.hasOwnProperty;i=t("./parser"),n=t("./coord-parser"),o=t("./svg-coord").get,s=/([XYIJ][+-]?\d+){1,4}/g,e=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return l(r,t),r.prototype.parseFormat=function(t,r){var e,i,o,n,s;if(s="L"===t[2]||"T"===t[2]?t[2]:null,o="A"===t[3]||"I"===t[3]?t[3]:null,"X"===t[4]&&"Y"===t[7]&&t.slice(5,7)===t.slice(8,10)&&t[5]<8&&t[6]<8&&(n=[+t[5],+t[6]]),null==n||null==o||null==s)throw new Error("invalid format specification");return null==(e=this.format).zero&&(e.zero=s),null==(i=this.format).places&&(i.places=n),null==r.set&&(r.set={}),r.set.notation=o},r.prototype.parseToolDef=function(t,r){var e,i,n,s,l,h,a;for(null==r.tool&&(r.tool={}),e=null!=(l=t.match(/^ADD\d{2,}/))?l[0].slice(2):void 0,h=t.slice(2+e.length).split(","),a=h[0],s=h[1],s=null!=s?s.split("X"):void 0;"0"===e[1];)e=e[0]+e.slice(2);switch(a){case"C":if(s.length>2?i={width:o(s[1],{places:this.format.places}),height:o(s[2],{places:this.format.places})}:s.length>1&&(i={dia:o(s[1],{places:this.format.places})}),r.tool[e]={dia:o(s[0],{places:this.format.places})},null!=i)return r.tool[e].hole=i;break;case"R":case"O":if(s.length>3?i={width:o(s[2],{places:this.format.places}),height:o(s[3],{places:this.format.places})}:s.length>2&&(i={dia:o(s[2],{places:this.format.places})}),r.tool[e]={width:o(s[0],{places:this.format.places}),height:o(s[1],{places:this.format.places})},"O"===a&&(r.tool[e].obround=!0),null!=i)return r.tool[e].hole=i;break;case"P":if(s.length>4?i={width:o(s[3],{places:this.format.places}),height:o(s[4],{places:this.format.places})}:s.length>3&&(i={dia:o(s[3],{places:this.format.places})}),r.tool[e]={dia:o(s[0],{places:this.format.places}),verticies:+s[1]},s.length>2&&(r.tool[e].degrees=+s[2]),null!=i)return r.tool[e].hole=i;break;default:return s=function(){var t,r,e,i;for(e=null!=s?s:[],i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(+n);return i}(),r.tool[e]={macro:a,mods:s}}},r.prototype.parseCommand=function(t){var r,e,i,l,h,a,u,c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R,T,B,A;if(null==t&&(t={}),e={},x=t.param)for(u=0,c=x.length;c>u;u++)switch(d=x[u],i=d.slice(0,2)){case"FS":this.parseFormat(d,e);break;case"MO":if(R=d.slice(2,4),null==e.set&&(e.set={}),"IN"===R)e.set.units="in";else{if("MM"!==R)throw new Error(d+" is an invalid units setting");e.set.units="mm"}break;case"AD":this.parseToolDef(d,e);break;case"AM":return{macro:x};case"LP":if(null==e["new"]&&(e["new"]={}),("D"===d[2]||"C"===d[2])&&(e["new"].layer=d[2]),null==e["new"].layer)throw new Error("invalid level polarity");break;case"SR":if(null==e["new"]&&(e["new"]={}),B=null!=(b=null!=(m=d.match(/X[+-]?[\d\.]+/))?m[0].slice(1):void 0)?b:1,A=null!=(g=null!=(w=d.match(/Y[+-]?[\d\.]+/))?w[0].slice(1):void 0)?g:1,h=null!=(y=d.match(/I[+-]?[\d\.]+/))?y[0].slice(1):void 0,a=null!=(v=d.match(/J[+-]?[\d\.]+/))?v[0].slice(1):void 0,1>B||1>A||B>1&&(null==h||0>h)||A>1&&(null==a||0>a))throw new Error("invalid step repeat");e["new"].sr={x:+B,y:+A},null!=h&&(e["new"].sr.i=o(h,{places:this.format.places})),null!=a&&(e["new"].sr.j=o(a,{places:this.format.places}))}else if(t=t.block){if("M02"===t)return{set:{done:!0}};if("G"===t[0])switch(i=null!=(M=t.slice(1).match(/^\d{1,2}/))?M[0]:void 0){case"4":case"04":return{};case"1":case"01":case"2":case"02":case"3":case"03":i=i[i.length-1],f="1"===i?"i":"2"===i?"cw":"ccw",e.set={mode:f};break;case"36":case"37":e.set={region:"36"===i};break;case"70":case"71":e.set={backupUnits:"70"===i?"in":"mm"};break;case"74":case"75":e.set={quad:"74"===i?"s":"m"}}if(l=n(null!=(k=t.match(s))?k[0]:void 0,this.format),p=(null!=(E=t.match(/D0?[123]$/))?E[0]:void 0)||Object.keys(l).length){null!=p&&(p=p[p.length-1]),p=function(){switch(p){case"1":return"int";case"2":return"move";case"3":return"flash";default:return"last"}}(),e.op={"do":p};for(r in l)T=l[r],e.op[r]=T}else(_=null!=(q=t.match(/D\d+$/))?q[0]:void 0)&&(e.set={currentTool:_})}return e},r}(i),r.exports=e},{"./coord-parser":2,"./parser":11,"./svg-coord":14}],6:[function(t,r){var e;e=function(){function t(t){this.gerberFile=null!=t?t:"",this.line=0,this.charIndex=0,this.end=this.gerberFile.length}return t.prototype.nextBlock=function(){var t,r,e;if(this.index>=this.end)return!1;for(r="",e=!1,0===this.line&&this.line++;!(this.charIndex>=this.end);)if(t=this.gerberFile[this.charIndex++],"%"===t){if(e)return{param:e};e=[]}else if("*"===t){if(!e)return{block:r};e.push(r),r=""}else"\n"===t?this.line++:t>=" "&&"~">=t&&(r+=t);return!1},t.prototype.getLine=function(){return this.line},t}(),r.exports=e},{}],7:[function(t,r){var e,i,o,n,s,l;i=/[\+\-\/xX\(\)]/,e=/[\$\d\.]+/,o=new RegExp("("+i.source+")|("+e.source+")","g"),l=function(t){var r;return r=t.match(o)},n=function(t){return e.test(t)},s=function(t){var r,e,i,o,s,h,a;return a=l(t),e=0,h=function(){return a[e]},r=function(t){return t===h()?e++:void 0},s=function(){var t,e;if(e=h(),r(e),n(e))t={type:"n",val:e};else{if("("!==e)throw new Error(e+" is unexpected in an arithmetic string");if(t=i(),")"!==h())throw new Error("expected ')'");r(")")}return t},o=function(){var t,e,i;for(t=s(),i=h();"x"===i||"/"===i||"X"===i;)r(i),"X"===i&&(i="x"),e=s(),t={type:i,left:t,right:e},i=h();return t},(i=function(){var t,e,i;for(t=o(),i=h();"+"===i||"-"===i;)r(i),e=o(),t={type:i,left:t,right:e},i=h();return t})()},r.exports={tokenize:l,isNumber:n,parse:s}},{}],8:[function(t,r){var e,i,o,n,s;n=t("./pad-shapes"),i=t("./macro-calc"),s=t("./unique-id"),o=t("./svg-coord").get,e=function(){function t(t,r){this.modifiers={},this.name=t[0].slice(2),this.blocks=t.slice(1),this.shapes=[],this.masks=[],this.lastExposure=null,this.bbox=[null,null,null,null],this.format={places:r}}return t.prototype.run=function(t,r){var e,i,o,n,l,h,a,u,c,f,p,d,x,b,m,g,w,y,v;for(null==r&&(r=[]),this.lastExposure=null,this.shapes=[],this.masks=[],this.bbox=[null,null,null,null],this.modifiers={},o=n=0,a=r.length;a>n;o=++n)p=r[o],this.modifiers["$"+(o+1)]=p;for(m=this.blocks,l=0,u=m.length;u>l;l++)e=m[l],this.runBlock(e);for(b="tool-"+t+"-pad-"+s(),x=[],g=this.masks,h=0,c=g.length;c>h;h++)p=g[h],x.push(p);if(this.shapes.length>1){for(i={id:b,_:[]},w=this.shapes,d=0,f=w.length;f>d;d++)y=w[d],i._.push(y);x=[{g:i}]}else 1===this.shapes.length&&(v=Object.keys(this.shapes[0])[0],this.shapes[0][v].id=b,x.push(this.shapes[0]));return{pad:x,padId:b,bbox:this.bbox,trace:!1}},t.prototype.runBlock=function(t){var r,e,i,o,n,s,l,h;switch(t[0]){case"$":return s=null!=(l=t.match(/^\$\d+(?=\=)/))?l[0]:void 0,h=t.slice(1+s.length),this.modifiers[s]=this.getNumber(h);case"1":case"2":case"20":case"21":case"22":case"4":case"5":case"6":case"7":for(e=t.split(","),i=o=0,n=e.length;n>o;i=++o)r=e[i],e[i]=this.getNumber(r);return this.primitive(e);default:if("0"!==t[0])throw new Error("'"+t+"' unrecognized tool macro block")}},t.prototype.primitive=function(t){var r,e,i,l,h,a,u,c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R,T,B,A,D,L;switch(b=!1,A=!1,L=null,t[0]){case 1:L=n.circle({dia:o(t[2],this.format),cx:o(t[3],this.format),cy:o(t[4],this.format)}),0===t[1]?b=!0:this.addBbox(L.bbox);break;case 2:case 20:L=n.vector({width:o(t[2],this.format),x1:o(t[3],this.format),y1:o(t[4],this.format),x2:o(t[5],this.format),y2:o(t[6],this.format)}),t[7]&&(L.shape.line.transform="rotate("+t[7]+")"),0===t[1]?b=!0:this.addBbox(L.bbox,t[7]);break;case 21:L=n.rect({cx:o(t[4],this.format),cy:o(t[5],this.format),width:o(t[2],this.format),height:o(t[3],this.format)}),t[6]&&(L.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?b=!0:this.addBbox(L.bbox,t[6]);break;case 22:L=n.lowerLeftRect({x:o(t[4],this.format),y:o(t[5],this.format),width:o(t[2],this.format),height:o(t[3],this.format)}),t[6]&&(L.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?b=!0:this.addBbox(L.bbox,t[6]);break;case 4:for(y=[],e=i=3,M=3+2*t[2];M>=i;e=i+=2)y.push([o(t[e],this.format),o(t[e+1],this.format)]);L=n.outline({points:y}),(B=t[t.length-1])&&(L.shape.polygon.transform="rotate("+B+")"),0===t[1]?b=!0:this.addBbox(L.bbox,t[t.length-1]);break;case 5:if(0!==t[6]&&(0!==t[3]||0!==t[4]))throw new RangeError("polygon center must be 0,0 if rotated in macro");L=n.polygon({cx:o(t[3],this.format),cy:o(t[4],this.format),dia:o(t[5],this.format),verticies:t[2],degrees:t[6]}),0===t[1]?b=!0:this.addBbox(L.bbox);break;case 6:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("moiré center must be 0,0 if rotated in macro");if(L=n.moire({cx:o(t[1],this.format),cy:o(t[2],this.format),outerDia:o(t[3],this.format),ringThx:o(t[4],this.format),ringGap:o(t[5],this.format),maxRings:t[6],crossThx:o(t[7],this.format),crossLength:o(t[8],this.format)}),t[9])for(k=L.shape,l=0,u=k.length;u>l;l++)D=k[l],null!=D.line&&(D.line.transform="rotate("+t[9]+")");this.addBbox(L.bbox,t[9]);break;case 7:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("thermal center must be 0,0 if rotated in macro");if(L=n.thermal({cx:o(t[1],this.format),cy:o(t[2],this.format),outerDia:o(t[3],this.format),innerDia:o(t[4],this.format),gap:o(t[5],this.format)}),t[6])for(E=L.shape,a=0,c=E.length;c>a;a++)if(D=E[a],null!=D.mask)for(q=D.mask._,g=0,f=q.length;f>g;g++)x=q[g],null!=x.rect&&(x.rect.transform="rotate("+t[6]+")");this.addBbox(L.bbox,t[6]);break;default:throw new Error(t[0]+" is not a valid primitive code")}if(b){for(h in L.shape)L.shape[h].fill="#000";if(0!==this.lastExposure){if(this.lastExposure=0,m="macro-"+this.name+"-mask-"+s(),x={mask:{id:m}},x.mask._=[{rect:{x:this.bbox[0],y:this.bbox[1],width:this.bbox[2]-this.bbox[0],height:this.bbox[3]-this.bbox[1],fill:"#fff"}}],1===this.shapes.length)for(h in this.shapes[0])this.shapes[0][h].mask="url(#"+m+")";else if(this.shapes.length>1){for(r={mask:"url(#"+m+")",_:[]},_=this.shapes,w=0,p=_.length;p>w;w++)D=_[w],r._.push(D);this.shapes=[{g:r}]}this.masks.push(x)}return this.masks[this.masks.length-1].mask._.push(L.shape)}if(this.lastExposure=1,Array.isArray(L.shape)){for(R=L.shape,T=[],v=0,d=R.length;d>v;v++)D=R[v],T.push(null!=D.mask?this.masks.push(D):this.shapes.push(D));return T}return this.shapes.push(L.shape)},t.prototype.addBbox=function(t,r){var e,i,o,n,s,l,h,a,u;if(null==r&&(r=0),r){for(h=Math.sin(r*Math.PI/180),i=Math.cos(r*Math.PI/180),Math.abs(h)<1e-9&&(h=0),Math.abs(i)<1e-9&&(i=0),l=[[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]]],o=0,n=l.length;n>o;o++)s=l[o],a=s[0]*i-s[1]*h,u=s[0]*h+s[1]*i,(null===this.bbox[0]||a<this.bbox[0])&&(this.bbox[0]=a),(null===this.bbox[1]||u<this.bbox[1])&&(this.bbox[1]=u),(null===this.bbox[2]||a>this.bbox[2])&&(this.bbox[2]=a),(null===this.bbox[3]||u>this.bbox[3])&&(this.bbox[3]=u);return this.bbox=function(){var t,r,i,o;for(i=this.bbox,o=[],t=0,r=i.length;r>t;t++)e=i[t],o.push(e===-0?0:e);return o}.call(this)}return(null===this.bbox[0]||t[0]<this.bbox[0])&&(this.bbox[0]=t[0]),(null===this.bbox[1]||t[1]<this.bbox[1])&&(this.bbox[1]=t[1]),(null===this.bbox[2]||t[2]>this.bbox[2])&&(this.bbox[2]=t[2]),null===this.bbox[3]||t[3]>this.bbox[3]?this.bbox[3]=t[3]:void 0},t.prototype.getNumber=function(t){return t.match(/^[+-]?[\d.]+$/)?Number(t):t.match(/^\$\d+$/)?Number(this.modifiers[t]):this.evaluate(i.parse(t))},t.prototype.evaluate=function(t){switch(t.type){case"n":return this.getNumber(t.val);case"+":return this.evaluate(t.left)+this.evaluate(t.right);case"-":return this.evaluate(t.left)-this.evaluate(t.right);case"x":return this.evaluate(t.left)*this.evaluate(t.right);case"/":return this.evaluate(t.left)/this.evaluate(t.right)}},t}(),r.exports=e},{"./macro-calc":7,"./pad-shapes":10,"./svg-coord":14,"./unique-id":15}],9:[function(t,r){var e,i,o,n;n=function(t,r){var e;if(e="",0===r)return"";for(;r>1;)1&r&&(e+=t),r>>=1,t+=t;return e+t},e="_",i=" ",o=function(t,r){var s,l,h,a,u,c,f,p,d,x,b,m,g,w,y,v,M,k,E;if(null==r&&(r={}),m=r.pretty,c=null!=(g=r.indent)?g:0,l=null!=(w=r.maxDec)?w:!1,h=function(t){return"number"==typeof t?Number(t.toFixed(l)):t},x=m?"\n":"",v=x?"string"==typeof m?m:i:"",v=n(v,c),E="","function"==typeof t&&(t=t()),Array.isArray(t))for(u=f=0,d=t.length;d>f;u=++f)b=t[u],E+=(0!==u?x:"")+o(b,r);else if("object"==typeof t){if(s=!1,a=Object.keys(t)[0],null!=a){E=v+"<"+a,"function"==typeof t[a]&&(t[a]=t[a]()),y=t[a];for(p in y)k=y[p],"function"==typeof k&&(k=k()),p===e?s=k:(Array.isArray(k)&&(l&&(k=function(){var t,r,e;for(e=[],t=0,r=k.length;r>t;t++)M=k[t],e.push(h(M));return e}()),k=k.join(" ")),l&&(k=h(k)),E+=" "+p+'="'+k+'"');s&&(E+=">"+x+o(s,{pretty:m,indent:c+1})),E+=null!=t[a]._?""+x+v+"</"+a+">":"/>"}}else E+=t+" ";return E},r.exports=o},{}],10:[function(t,r){var e,i,o,n,s,l,h,a,u;a=t("./unique-id"),e=function(t){var r;if(null==t.dia)throw new Error("circle function requires diameter");if(null==t.cx)throw new Error("circle function requires x center");if(null==t.cy)throw new Error("circle function requires y center");return r=t.dia/2,{shape:{circle:{cx:t.cx,cy:t.cy,r:r}},bbox:[t.cx-r,t.cy-r,t.cx+r,t.cy+r]}},l=function(t){var r,e,i,o;if(null==t.width)throw new Error("rectangle requires width");if(null==t.height)throw new Error("rectangle requires height");if(null==t.cx)throw new Error("rectangle function requires x center");if(null==t.cy)throw new Error("rectangle function requires y center");return i=t.cx-t.width/2,o=t.cy-t.height/2,e={shape:{rect:{x:i,y:o,width:t.width,height:t.height}},bbox:[i,o,i+t.width,o+t.height]},t.obround&&(r=.5*Math.min(t.width,t.height),e.shape.rect.rx=r,e.shape.rect.ry=r),e},s=function(t){var r,e,i,o,n,s,l,h,a,u,c,f,p,d,x,b;if(null==t.dia)throw new Error("polygon requires diameter");if(null==t.verticies)throw new Error("polygon requires verticies");if(null==t.cx)throw new Error("polygon function requires x center");if(null==t.cy)throw new Error("polygon function requires y center");for(h=null!=t.degrees?t.degrees*Math.PI/180:0,a=2*Math.PI/t.verticies,o=t.dia/2,i="",p=null,b=null,f=null,x=null,r=e=0,n=t.verticies;n>=0?n>e:e>n;r=n>=0?++e:--e)u=h+r*a,s=o*Math.cos(u),l=o*Math.sin(u),Math.abs(s)<1e-9&&(s=0),Math.abs(l)<1e-9&&(l=0),c=t.cx+s,d=t.cy+l,(p>c||null===p)&&(p=c),(c>f||null===f)&&(f=c),(b>d||null===b)&&(b=d),(d>x||null===x)&&(x=d),i+=" "+c+","+d;return{shape:{polygon:{points:i.slice(1)}},bbox:[p,b,f,x]}},u=function(t){var r,e,i;if(null==t.x1)throw new Error("vector function requires start x");if(null==t.y1)throw new Error("vector function requires start y");if(null==t.x2)throw new Error("vector function requires end x");if(null==t.y2)throw new Error("vector function requires end y");if(null==t.width)throw new Error("vector function requires width");return r=Math.abs(Math.atan((t.y2-t.y1)/(t.x2-t.x1))),e=t.width/2*Math.sin(r),i=t.width/2*Math.cos(r),1e-7>e&&(e=0),1e-7>i&&(i=0),{shape:{line:{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,"stroke-width":t.width,"stroke-linecap":"butt"}},bbox:[Math.min(t.x1,t.x2)-e,Math.min(t.y1,t.y2)-i,Math.max(t.x1,t.x2)+e,Math.max(t.y1,t.y2)+i]}},i=function(t){if(null==t.width)throw new Error("lower left rect requires width");if(null==t.height)throw new Error("lower left rect requires height");if(null==t.x)throw new Error("lower left rectangle requires x");if(null==t.y)throw new Error("lower left rectangle requires y");return{shape:{rect:{x:t.x,y:t.y,width:t.width,height:t.height}},bbox:[t.x,t.y,t.x+t.width,t.y+t.height]}},n=function(t){var r,e,i,o,n,s,l,h,a,u,c,f,p;if(!(Array.isArray(t.points)&&t.points.length>1))throw new Error("outline function requires points array");for(a=null,p=null,h=null,f=null,o="",n=t.points,r=0,e=n.length;e>r;r++){if(i=n[r],!Array.isArray(i)||2!==i.length)throw new Error("outline function requires points array");s=i[0],u=i[1],(a>s||null===a)&&(a=s),(s>h||null===h)&&(h=s),(p>u||null===p)&&(p=u),(u>f||null===f)&&(f=u),o+=" "+s+","+u}if(l=t.points[t.points.length-1][0],c=t.points[t.points.length-1][1],l!==t.points[0][0]||c!==t.points[0][1])throw new RangeError("last point must match first point of outline");return{shape:{polygon:{points:o.slice(1)}},bbox:[a,p,h,f]}},o=function(t){var r,e,i;if(null==t.cx)throw new Error("moiré requires x center");if(null==t.cy)throw new Error("moiré requires y center");if(null==t.outerDia)throw new Error("moiré requires outer diameter");if(null==t.ringThx)throw new Error("moiré requires ring thickness");if(null==t.ringGap)throw new Error("moiré requires ring gap");if(null==t.maxRings)throw new Error("moiré requires max rings");if(null==t.crossLength)throw new Error("moiré requires crosshair length");if(null==t.crossThx)throw new Error("moiré requires crosshair thickness");for(i=[{line:{x1:t.cx-t.crossLength/2,y1:0,x2:t.cx+t.crossLength/2,y2:0,"stroke-width":t.crossThx,"stroke-linecap":"butt"}},{line:{x1:0,y1:t.cy-t.crossLength/2,x2:0,y2:t.cy+t.crossLength/2,"stroke-width":t.crossThx,"stroke-linecap":"butt"}}],r=(t.outerDia-t.ringThx)/2,e=0;r>=t.ringThx&&e<t.maxRings;)i.push({circle:{cx:t.cx,cy:t.cy,r:r,fill:"none","stroke-width":t.ringThx}}),e++,r-=t.ringThx+t.ringGap;return r+=.5*t.ringThx,r>0&&e<t.maxRings&&i.push({circle:{cx:t.cx,cy:t.cy,r:r}}),{shape:i,bbox:[Math.min(t.cx-t.crossLength/2,t.cx-t.outerDia/2),Math.min(t.cy-t.crossLength/2,t.cy-t.outerDia/2),Math.max(t.cx+t.crossLength/2,t.cx+t.outerDia/2),Math.max(t.cy+t.crossLength/2,t.cy+t.outerDia/2)]}},h=function(t){var r,e,i,o,n,s,l,h,u;if(null==t.cx)throw new Error("thermal requires x center");if(null==t.cy)throw new Error("thermal requires y center");if(null==t.outerDia)throw new Error("thermal requires outer diameter");if(null==t.innerDia)throw new Error("thermal requires inner diameter");if(null==t.gap)throw new Error("thermal requires gap");return e="thermal-mask-"+a(),n=(t.outerDia-t.innerDia)/2,i=t.outerDia/2,o=i-n/2,l=t.cx-i,s=t.cx+i,u=t.cy-i,h=t.cy+i,r=t.gap/2,{shape:[{mask:{id:e,_:[{circle:{cx:t.cx,cy:t.cy,r:i,fill:"#fff"}},{rect:{x:l,y:-r,width:t.outerDia,height:t.gap,fill:"#000"}},{rect:{x:-r,y:u,width:t.gap,height:t.outerDia,fill:"#000"}}]}},{circle:{cx:t.cx,cy:t.cy,r:o,fill:"none","stroke-width":n,mask:"url(#"+e+")"}}],bbox:[l,u,s,h]}},r.exports={circle:e,rect:l,polygon:s,vector:u,lowerLeftRect:i,outline:n,moire:o,thermal:h}},{"./unique-id":15}],11:[function(t,r){var e;e=function(){function t(t){var r,e;if(null==t&&(t={}),this.format={zero:null!=(r=t.zero)?r:null,places:null!=(e=t.places)?e:null},null!=this.format.places&&(!Array.isArray(this.format.places)||2!==this.format.places.length||"number"!=typeof this.format.places[0]||"number"!=typeof this.format.places[1]))throw new Error("parser places format must be an array of two numbers");if(null!=this.format.zero&&("string"!=typeof this.format.zero||"L"!==this.format.zero&&"T"!==this.format.zero))throw new Error("parser zero format must be either 'L' or 'T'")}return t}(),r.exports=e},{}],12:[function(t,r){var e,i,o,n,s,l,h,a,u;u=t("./unique-id"),o=t("./macro-tool"),a=t("./standard-tool"),h=t("./svg-coord").factor,i=Math.PI/2,s=3*i,l=2*Math.PI,e="in",n=function(){function t(t,r,e){var i,o;this.reader=t,this.parser=r,null==e&&(e={}),this.units=null!=(i=e.units)?i:null,this.notation=null!=(o=e.notation)?o:null,this.macros={},this.tools={},this.currentTool="",this.defs=[],this.group={g:{_:[]}},this.polarity="D",this.current=[],this.stepRepeat={x:1,y:1,i:0,j:0},this.srOverClear=!1,this.srOverCurrent=[],this.mode=null,this.quad=null,this.lastOp=null,this.region=!1,this.done=!1,this.pos={x:0,y:0},this.path=[],this.attr={"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":0,stroke:"#000"},this.bbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},this.layerBbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0}}return t.prototype.addTool=function(t,r){var e,i;if(null!=this.tools[t])throw new Error("cannot reassign tool "+t);return i=null!=r.macro?this.macros[r.macro].run(t,r.mods):a(t,r),this.tools[t]={trace:i.trace,pad:function(){var t,r,o,n;for(o=i.pad,n=[],t=0,r=o.length;r>t;t++)e=o[t],n.push(e);return n}(),flash:function(t,r){return{use:{x:t,y:r,"xlink:href":"#"+i.padId}}},flashed:!1,bbox:function(t,r){return null==t&&(t=0),null==r&&(r=0),{xMin:t+i.bbox[0],yMin:r+i.bbox[1],xMax:t+i.bbox[2],yMax:r+i.bbox[3]}}},this.changeTool(t)},t.prototype.changeTool=function(t){var r;if(this.finishPath(),this.region)throw new Error("cannot change tool when in region mode");if(null!=this.tools[t])return this.currentTool=t;if(!(null!=(r=this.parser)?r.fmat:void 0))throw new Error("tool "+t+" is not defined")},t.prototype.command=function(t){var r,e,i,n,s,l,h;if(null!=t.macro)return e=new o(t.macro,this.parser.format.places),void(this.macros[e.name]=e);n=t.set;for(l in n)switch(h=n[l],"region"===l&&this.finishPath(),l){case"currentTool":this.changeTool(h);break;case"units":case"notation":null==this[l]&&(this[l]=h);break;default:this[l]=h}if(null!=t.tool){s=t.tool;for(r in s)i=s[r],this.addTool(r,i)}if(null!=t.op&&this.operate(t.op),null!=t["new"]){if(this.finishLayer(),null!=t["new"].layer)return this.polarity=t["new"].layer;if(null!=t["new"].sr)return this.finishSR(),this.stepRepeat=t["new"].sr}},t.prototype.plot=function(){for(var t,r;!this.done;){if(t=this.reader.nextBlock(),t===!1)throw new Error(null==(null!=(r=this.parser)?r.fmat:void 0)?"end of file encountered before required M02 command":"end of drill file encountered before M00/M30 command");this.command(this.parser.parseCommand(t))}return this.finish()},t.prototype.finish=function(){return this.finishPath(),this.finishLayer(),this.finishSR(),this.group.g.fill="currentColor",this.group.g.stroke="currentColor",this.group.g.transform="translate(0,"+(this.bbox.yMin+this.bbox.yMax)+") scale(1,-1)"},t.prototype.finishSR=function(){var t,r,e,i,o,n,s,l,h,a,c,f,p,d,x,b;if(this.srOverClear&&this.srOverCurrent){for(n="gerber-sr-mask_"+u(),o={mask:{color:"#000",id:n,_:[]}},o.mask._.push({rect:{fill:"#fff",x:this.bbox.xMin,y:this.bbox.yMin,width:this.bbox.xMax-this.bbox.xMin,height:this.bbox.yMax-this.bbox.yMin}}),x=t=0,l=this.stepRepeat.x*this.stepRepeat.i,h=this.stepRepeat.i;h>0?l>t:t>l;x=t+=h)for(b=r=0,a=this.stepRepeat.y*this.stepRepeat.j,c=this.stepRepeat.j;c>0?a>r:r>a;b=r+=c)for(f=this.srOverCurrent,s=0,i=f.length;i>s;s++)e=f[s],d={use:{}},0!==x&&(d.use.x=x),0!==b&&(d.use.y=b),d.use["xlink:href"]="#"+(null!=(p=e.C)?p:e.D),null!=e.D&&(d.use.fill="#fff"),o.mask._.push(d);return this.srOverClear=!1,this.srOverCurrent=[],this.defs.push(o),this.group.g.mask="url(#"+n+")"}},t.prototype.finishLayer=function(){var t,r,e,i,o,n,s,l,h,a,c,f,p,d,x,b;if(this.finishPath(),this.current.length){if(this.stepRepeat.x>1||this.stepRepeat.y>1){for(f="gerber-sr_"+u(),this.current=[{g:{id:f,_:this.current}}],(this.srOverClear||this.stepRepeat.i<this.layerBbox.xMax-this.layerBbox.xMin||this.stepRepeat.j<this.layerBbox.yMax-this.layerBbox.yMin)&&(l={},l[this.polarity]=f,this.srOverCurrent.push(l),"C"===this.polarity&&(this.srOverClear=!0,this.defs.push(this.current[0]))),x=i=0,h=this.stepRepeat.x;h>=0?h>i:i>h;x=h>=0?++i:--i)for(b=o=0,a=this.stepRepeat.y;a>=0?a>o:o>a;b=a>=0?++o:--o)(0!==x||0!==b)&&(p={use:{"xlink:href":"#"+f}},0!==x&&(p.use.x=x*this.stepRepeat.i),0!==b&&(p.use.y=b*this.stepRepeat.j),this.current.push(p));this.layerBbox.xMax+=(this.stepRepeat.x-1)*this.stepRepeat.i,this.layerBbox.yMax+=(this.stepRepeat.y-1)*this.stepRepeat.j}if(this.addBbox(this.layerBbox,this.bbox),this.layerBbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},"D"===this.polarity)if(null!=this.group.g.mask&&this.current.unshift(this.group),null==this.group.g.mask&&this.group.g._.length)for(c=this.current,s=0,n=c.length;n>s;s++)t=c[s],this.group.g._.push(t);else this.group={g:{_:this.current}};else"C"!==this.polarity||this.srOverClear||(e="gerber-mask_"+u(),d=this.bbox.xMax-this.bbox.xMin,r=this.bbox.yMax-this.bbox.yMin,this.current.unshift({rect:{x:this.bbox.xMin,y:this.bbox.yMin,width:d,height:r,fill:"#fff"}}),this.defs.push({mask:{id:e,color:"#000",_:this.current}}),this.group.g.mask="url(#"+e+")");return this.current=[]}},t.prototype.finishPath=function(){var t,r,e,i;if(this.path.length){if(r={path:{}},this.region)this.path.push("Z");else{e=this.tools[this.currentTool].trace;for(t in e)i=e[t],r.path[t]=i}return r.path.d=this.path,this.current.push(r),this.path=[]}},t.prototype.operate=function(t){var r,i,o,n,s,l,h,a,u,c,f,p,d,x,b,m,g;if("last"===t["do"]?t["do"]=this.lastOp:this.lastOp=t["do"],b=this.pos.x,m=this.pos.y,"I"===this.notation?(this.pos.x+=null!=(l=t.x)?l:0,this.pos.y+=null!=(h=t.y)?h:0):(this.pos.x=null!=(a=t.x)?a:this.pos.x,this.pos.y=null!=(u=t.y)?u:this.pos.y),i=this.pos.x,o=this.pos.y,g=this.tools[this.currentTool],null==this.units&&(this.units=null!=this.backupUnits?this.backupUnits:e),null==this.notation){if(null==(null!=(c=this.parser)?c.fmat:void 0))throw new Error("format has not been set");this.notation="A"}if("move"===t["do"]&&this.path.length)return this.path.push("M",i,o);if("flash"===t["do"]){if(this.finishPath(),this.region)throw new Error("cannot flash while in region mode");if(!g.flashed){for(f=g.pad,n=0,s=f.length;s>n;n++)x=f[n],this.defs.push(x);g.flashed=!0}return this.current.push(g.flash(i,o)),this.addBbox(g.bbox(i,o),this.layerBbox)}if("int"===t["do"]){if(!this.region&&!g.trace)throw new Error(this.currentTool+" is not a strokable tool");return 0===this.path.length&&(this.path.push("M",b,m),r=this.region?{xMin:b,yMin:m,xMax:b,yMax:m}:g.bbox(b,m),this.addBbox(r,this.layerBbox)),null==this.mode&&(this.mode="i"),"i"===this.mode?this.drawLine(b,m,i,o):this.drawArc(b,m,i,o,null!=(p=t.i)?p:0,null!=(d=t.j)?d:0)}},t.prototype.drawLine=function(t,r,e,o){var n,s,l,h,a,u,c,f,p,d,x,b,m;return b=this.tools[this.currentTool],n=this.region?{xMin:e,yMin:o,xMax:e,yMax:o}:b.bbox(e,o),this.addBbox(n,this.layerBbox),this.region||b.trace["stroke-width"]>=0?this.path.push("L",e,o):(c=b.pad[0].rect.width/2,u=b.pad[0].rect.height/2,f=t-c,p=t+c,d=r-u,x=r+u,s=e-c,l=e+c,h=o-u,a=o+u,m=Math.atan2(o-r,e-t),m>=0&&i>m?this.path.push("M",f,d,p,d,l,h,l,a,s,a,f,x,"Z"):m>=i&&m<=Math.PI?this.path.push("M",f,d,p,d,p,x,l,a,s,a,s,h,"Z"):-Math.PI<=m&&-i>m?this.path.push("M",p,d,p,x,f,x,s,a,s,h,l,h,"Z"):m>=-i&&0>m?this.path.push("M",f,d,s,h,l,h,l,a,p,x,f,x,"Z"):void 0)},t.prototype.drawArc=function(t,r,e,o,n,a){var u,c,f,p,d,x,b,m,g,w,y,v,M,k,E,q,_,R,T,B,A,D,L,I,O,z,C,j,P,N;if(u=1.5*h*Math.pow(10,-1*(null!=(M=null!=(k=this.parser)?k.format.places[1]:void 0)?M:7)),_=this.tools[this.currentTool],!this.region&&!_.trace["stroke-width"])throw Error("cannot stroke an arc with non-circular tool "+this.currentTool);if(null==this.quad)throw new Error("arc quadrant mode has not been set");for(y=Math.sqrt(Math.pow(n,2)+Math.pow(a,2)),q="cw"===this.mode?0:1,m=0,A=[],f=[[t+n,r+a]],"s"===this.quad&&f.push([t-n,r-a],[t-n,r+a],[t+n,r-a]),x=0,g=f.length;g>x;x++)c=f[x],d=Math.sqrt(Math.pow(c[0]-e,2)+Math.pow(c[1]-o,2)),Math.abs(y-d)<u&&A.push({x:c[0],y:c[1]});for(T=0,B=0,p=null,b=0,w=A.length;w>b&&(c=A[b],T=Math.atan2(o-c.y,e-c.x),0>T&&(T+=l),B=Math.atan2(r-c.y,t-c.x),0>B&&(B+=l),"cw"===this.mode&&T>B?B+=l:"ccw"===this.mode&&B>T&&(T+=l),R=Math.abs(T-B),"s"===this.quad&&i>=R?p=c:"m"===this.quad&&(R>=Math.PI&&(m=1),p={x:c.x,y:c.y}),null==p);b++);return null!=p?(v=this.region?0:_.bbox().xMax,"cw"===this.mode&&(E=[B,T],T=E[0],B=E[1]),O=B>0?l:0,P=i+(B>i?l:0),I=Math.PI+(B>Math.PI?l:0),j=s+(B>s?l:0),L=I>=B&&T>=I?p.x-y-v:Math.min(t,e)-v,D=O>=B&&T>=O?p.x+y+v:Math.max(t,e)+v,C=j>=B&&T>=j?p.y-y-v:Math.min(r,o)-v,z=P>=B&&T>=P?p.y+y+v:Math.max(r,o)+v,N=Math.abs(t-e)<u&&Math.abs(r-o)<u,"m"===this.quad&&N&&(this.path.push("A",y,y,0,0,q,e+2*n,o+2*a),L=p.x-y-v,C=p.y-y-v,D=p.x+y+v,z=p.y+y+v),this.path.push("A",y,y,0,m,q,e,o),"s"===this.quad&&N&&this.path.push("Z"),this.addBbox({xMin:L,yMin:C,xMax:D,yMax:z},this.layerBbox)):void 0
},t.prototype.addBbox=function(t,r){return t.xMin<r.xMin&&(r.xMin=t.xMin),t.yMin<r.yMin&&(r.yMin=t.yMin),t.xMax>r.xMax&&(r.xMax=t.xMax),t.yMax>r.yMax?r.yMax=t.yMax:void 0},t}(),r.exports=n},{"./macro-tool":8,"./standard-tool":13,"./svg-coord":14,"./unique-id":15}],13:[function(t,r){var e,i,o;o=t("./unique-id"),e=t("./pad-shapes"),i=function(t,r){var i,n,s,l,h,a,u;if(a={pad:[],trace:!1},r.cx=0,r.cy=0,n="tool-"+t+"-pad-"+o(),u="",null!=r.dia&&null==r.verticies){if(null!=r.obround||null!=r.width||null!=r.height||null!=r.degrees)throw new Error("incompatible parameters for tool "+t);if(r.dia<0)throw new RangeError(t+" circle diameter out of range ("+r.dia+"<0)");u="circle",null==r.hole&&(a.trace={"stroke-width":r.dia,fill:"none"})}else if(null!=r.width&&null!=r.height){if(null!=r.dia||null!=r.verticies||null!=r.degrees)throw new Error("incompatible parameters for tool "+t);if(r.width<0)throw new RangeError(t+" rect width out of range ("+r.width+"<0)");if(r.height<0)throw new RangeError(t+" rect height out of range ("+r.height+"<0)");u="rect",0!==r.width&&0!==r.height||r.obround||(u="circle",r.dia=0),null!=r.hole||r.obround||(a.trace={})}else{if(null==r.dia||null==r.verticies)throw new Error("unidentified standard tool shape");if(null!=r.obround||null!=r.width||null!=r.height)throw new Error("incompatible parameters for tool "+t);if(r.verticies<3||r.verticies>12)throw new RangeError(t+" polygon points out of range ("+r.verticies+"<3 or >12)]");u="polygon"}if(h=e[u](r),null!=r.hole){if(i=null,null!=r.hole.dia&&null==r.hole.width&&null==r.hole.height){if(!(r.hole.dia>=0))throw new RangeError(t+" hole diameter out of range ("+r.hole.dia+"<0)");i=e.circle({cx:r.cx,cy:r.cy,dia:r.hole.dia}),i=i.shape,i.circle.fill="#000"}else{if(null==r.hole.width||null==r.hole.height)throw new Error(t+" has invalid hole parameters");if(!(r.hole.width>=0))throw new RangeError(t+" hole width out of range ("+r.hole.width+"<0)");if(!(r.hole.height>=0))throw new RangeError(t+" hole height out of range ("+r.hole.height+"<0)");i=e.rect({cx:r.cx,cy:r.cy,width:r.hole.width,height:r.hole.height}),i=i.shape,i.rect.fill="#000"}l=n+"-mask",s={mask:{id:n+"-mask",_:[{rect:{x:h.bbox[0],y:h.bbox[1],width:h.bbox[2]-h.bbox[0],height:h.bbox[3]-h.bbox[1],fill:"#fff"}},i]}},h.shape[u].mask="url(#"+l+")",a.pad.push(s)}return n&&(h.shape[u].id=n),a.pad.push(h.shape),a.bbox=h.bbox,a.padId=n,a},r.exports=i},{"./pad-shapes":10,"./unique-id":15}],14:[function(t,r){var e,i,o=[].indexOf||function(t){for(var r=0,e=this.length;e>r;r++)if(r in this&&this[r]===t)return r;return-1};e=3,i=function(t,r){var i,n,s,l,h,a,u,c,f,p,d,x,b,m;if(null==t)return 0/0;if(t=""+t,n="",i="",b="+",("-"===t[0]||"+"===t[0])&&(b=t[0],t=t.slice(1)),o.call(t,".")>=0||null==r.zero){if(m=t.split("."),m.length>2)return 0/0;p=[m[0],null!=(f=m[1])?f:""],n=p[0],i=p[1]}else{if("number"!=typeof(null!=r&&null!=(d=r.places)?d[0]:void 0)||"number"!=typeof(null!=r&&null!=(x=r.places)?x[1]:void 0))return 0/0;if("T"===r.zero){for(l=h=0,u=t.length;u>h;l=++h)s=t[l],l<r.places[0]?n+=s:i+=s;for(;n.length<r.places[0];)n+="0"}else if("L"===r.zero){for(l=a=0,c=t.length;c>a;l=++a)s=t[l],t.length-l<=r.places[1]?i+=s:n+=s;for(;i.length<r.places[1];)i="0"+i}}for(;i.length<e;)i+="0";return n+=i.slice(0,e),i=i.length>e?"."+i.slice(e):"",Number(b+n+i)},r.exports={get:i,factor:Math.pow(10,e)}},{}],15:[function(t,r){var e,i;i=1e3,e=function(){return i++},r.exports=e},{}]},{},[1])(1)});
(function() {
var BANNER, BOOLEAN_OPTS, OPTIONS, STRING_OPTS, VERSION, chalk, fs, gerberToSvg, getOptions, help, parseArgs, path, printOptions, run, stderr, streamCapture, version,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
var BANNER, BOOLEAN_OPTS, OPTIONS, STRING_OPTS, VERSION, chalk, fs, gerberToSvg, getOptions, help, minimatch, parseArgs, path, printOptions, run, stderr, streamCapture, version;

@@ -13,2 +12,4 @@ fs = require('fs');

minimatch = require('minimatch');
gerberToSvg = require('./gerber-to-svg');

@@ -39,26 +40,26 @@

BANNER = 'Usage: gerber2svg [options] path/to/gerbers\nExamples:\n `$ gerber2svg path/to/gerber.gbr` will write the svg to stdout\n `$ gerber2svg -o some/dir path/to/gerb.gbr` will create some/dir/gerb.svg\n `$ gerber2svg -d drill.drl -o out gerb/*` will process drill.drl as a drill\n file, everything in gerb as a Gerber file, and output to out';
BANNER = 'Usage: gerber2svg [options] path/to/gerbers\nExamples:\n `$ gerber2svg path/to/gerber.gbr` will write the svg to stdout\n `$ gerber2svg -o some/dir path/to/gerb.gbr` will create some/dir/gerb.svg\n `$ gerber2svg -d **/*.drl -o out -- gerb/*` will process any files in gerb\n that end in \'.drl\' as a drill files, everything else as Gerber files,\n and output to out';
OPTIONS = [['o', 'out', ' specify an output directory'], ['q', 'quiet', ' do not print warnings and messages'], ['p', 'pretty', ' align SVG output prettily'], ['d', 'drill', ' process following file as an NC (Excellon) drill file'], ['f', 'format', " override coordinate format with '[n_int,n_dec]'"], ['z', 'zero', " override zero suppression with 'L' or 'T'"], ['u', 'units', " override (without converting) units with 'mm' or 'in'"], ['n', 'notation', " override absolute/incremental notation with 'A' or 'I'"], ['a', 'append-ext', ' append .svg rather than replace the extension'], ['j', 'json', ' output json rather than an xml string'], ['v', 'version', ' display version information'], ['h', 'help', ' display this help text']];
OPTIONS = [['o', 'out', ' specify an output directory'], ['q', 'quiet', ' do not print warnings and messages'], ['p', 'pretty', ' align SVG output prettily'], ['d', 'drill', ' process files mathing this glob as NC drill files'], ['f', 'format', " override coordinate format with '[n_int,n_dec]'"], ['z', 'zero', " override zero suppression with 'L' or 'T'"], ['u', 'units', " override (without converting) units with 'mm' or 'in'"], ['n', 'notation', " override absolute/incremental notation with 'A' or 'I'"], ['a', 'append-ext', ' append .svg rather than replace the extension'], ['j', 'json', ' output json rather than an xml string'], ['v', 'version', ' display version information'], ['h', 'help', ' display this help text']];
STRING_OPTS = ['out', 'drill', 'format', 'zero', 'units', 'notation'];
BOOLEAN_OPTS = ['quiet', 'pretty', 'append-ext', 'json', 'version', 'help'];
BOOLEAN_OPTS = ['quiet', 'pretty', 'json', 'append-ext', 'version', 'help'];
printOptions = function() {
var o, _i, _len, _results;
var i, len, o, results;
console.log('Options:');
_results = [];
for (_i = 0, _len = OPTIONS.length; _i < _len; _i++) {
o = OPTIONS[_i];
_results.push(console.log(" -" + o[0] + ", --" + o[1] + " " + o[2]));
results = [];
for (i = 0, len = OPTIONS.length; i < len; i++) {
o = OPTIONS[i];
results.push(console.log(" -" + o[0] + ", --" + o[1] + " " + o[2]));
}
return _results;
return results;
};
getOptions = function() {
var alias, o, _i, _len;
var alias, i, len, o;
alias = {};
for (_i = 0, _len = OPTIONS.length; _i < _len; _i++) {
o = OPTIONS[_i];
for (i = 0, len = OPTIONS.length; i < len; i++) {
o = OPTIONS[i];
alias[o[0]] = o[1];

@@ -80,3 +81,3 @@ }

run = function() {
var argv, e, err, file, fileList, places, print, warn, write, _i, _len, _ref, _results;
var argv, e, err, file, fileExt, fileList, i, len, places, print, results, warn, write;
argv = parseArgs(process.argv.slice(2), {

@@ -107,2 +108,3 @@ alias: getOptions(),

};
fileExt = argv.json ? '.json' : '.svg';
write = function(string, filename) {

@@ -121,6 +123,6 @@ var newName;

}
newName = path.join(argv.out, newName + '.svg');
newName = path.join(argv.out, newName + fileExt);
return fs.writeFile(newName, string, function(error) {
if (!error) {
return print("" + filename + " converted to " + newName);
return print(filename + " converted to " + newName);
} else {

@@ -157,11 +159,8 @@ return "Error writing to " + newName + ": " + error.code;

}
if ((argv.drill != null) && (_ref = argv.drill, __indexOf.call(fileList, _ref) < 0)) {
fileList.push(argv.drill);
}
_results = [];
for (_i = 0, _len = fileList.length; _i < _len; _i++) {
file = fileList[_i];
_results.push((function(file) {
results = [];
for (i = 0, len = fileList.length; i < len; i++) {
file = fileList[i];
results.push((function(file) {
return fs.readFile(file, 'utf-8', function(error, data) {
var hook, opts, warnings;
var hook, opts, ref, warnings;
if (!error) {

@@ -172,3 +171,3 @@ try {

pretty: argv.pretty,
drill: file === argv.drill,
drill: minimatch(file, (ref = argv.drill) != null ? ref : ''),
object: argv.json,

@@ -188,3 +187,3 @@ places: argv.format,

if (warnings) {
warn("" + file + " produced the following warnings:\n" + warnings);
warn(file + " produced the following warnings:\n" + warnings);
}

@@ -198,3 +197,3 @@ }

}
return _results;
return results;
};

@@ -201,0 +200,0 @@

@@ -7,3 +7,3 @@ (function() {

module.exports = function(coord, format) {
var key, parse, result, val, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
var key, parse, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, result, val;
if (coord == null) {

@@ -17,6 +17,6 @@ return {};

result = {};
parse.x = (_ref = coord.match(/X[+-]?[\d\.]+/)) != null ? (_ref1 = _ref[0]) != null ? _ref1.slice(1) : void 0 : void 0;
parse.y = (_ref2 = coord.match(/Y[+-]?[\d\.]+/)) != null ? (_ref3 = _ref2[0]) != null ? _ref3.slice(1) : void 0 : void 0;
parse.i = (_ref4 = coord.match(/I[+-]?[\d\.]+/)) != null ? (_ref5 = _ref4[0]) != null ? _ref5.slice(1) : void 0 : void 0;
parse.j = (_ref6 = coord.match(/J[+-]?[\d\.]+/)) != null ? (_ref7 = _ref6[0]) != null ? _ref7.slice(1) : void 0 : void 0;
parse.x = (ref = coord.match(/X[+-]?[\d\.]+/)) != null ? (ref1 = ref[0]) != null ? ref1.slice(1) : void 0 : void 0;
parse.y = (ref2 = coord.match(/Y[+-]?[\d\.]+/)) != null ? (ref3 = ref2[0]) != null ? ref3.slice(1) : void 0 : void 0;
parse.i = (ref4 = coord.match(/I[+-]?[\d\.]+/)) != null ? (ref5 = ref4[0]) != null ? ref5.slice(1) : void 0 : void 0;
parse.j = (ref6 = coord.match(/J[+-]?[\d\.]+/)) != null ? (ref7 = ref6[0]) != null ? ref7.slice(1) : void 0 : void 0;
for (key in parse) {

@@ -23,0 +23,0 @@ val = parse[key];

(function() {
var ABS_COMMAND, DrillParser, INCH_COMMAND, INC_COMMAND, METRIC_COMMAND, PLACES_BACKUP, Parser, ZERO_BACKUP, getSvgCoord, parseCoord, reCOORD,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -29,4 +29,4 @@ Parser = require('./parser');

DrillParser = (function(_super) {
__extends(DrillParser, _super);
DrillParser = (function(superClass) {
extend(DrillParser, superClass);

@@ -39,3 +39,3 @@ function DrillParser() {

DrillParser.prototype.parseCommand = function(block) {
var code, command, dia, k, v, _base, _base1, _base2, _base3, _ref, _ref1, _ref2;
var base, base1, base2, base3, code, command, dia, k, ref, ref1, ref2, v;
command = {};

@@ -52,4 +52,4 @@ if (block[0] === ';') {

} else if (block === INCH_COMMAND[this.fmat] || block.match(/INCH/)) {
if ((_base = this.format).places == null) {
_base.places = [2, 4];
if ((base = this.format).places == null) {
base.places = [2, 4];
}

@@ -60,4 +60,4 @@ command.set = {

} else if (block === METRIC_COMMAND || block.match(/METRIC/)) {
if ((_base1 = this.format).places == null) {
_base1.places = [3, 3];
if ((base1 = this.format).places == null) {
base1.places = [3, 3];
}

@@ -75,7 +75,7 @@ command.set = {

};
} else if ((code = (_ref = block.match(/T\d+/)) != null ? _ref[0] : void 0)) {
} else if ((code = (ref = block.match(/T\d+/)) != null ? ref[0] : void 0)) {
while (code[1] === '0') {
code = code[0] + code.slice(2);
}
if ((dia = (_ref1 = block.match(/C[\d\.]+(?=.*$)/)) != null ? _ref1[0] : void 0)) {
if ((dia = (ref1 = block.match(/C[\d\.]+(?=.*$)/)) != null ? ref1[0] : void 0)) {
dia = dia.slice(1);

@@ -95,8 +95,8 @@ command.tool = {};

if (block.match(/TZ/)) {
if ((_base2 = this.format).zero == null) {
_base2.zero = 'L';
if ((base2 = this.format).zero == null) {
base2.zero = 'L';
}
} else if (block.match(/LZ/)) {
if ((_base3 = this.format).zero == null) {
_base3.zero = 'T';
if ((base3 = this.format).zero == null) {
base3.zero = 'T';
}

@@ -116,5 +116,5 @@ }

}
_ref2 = parseCoord(block, this.format);
for (k in _ref2) {
v = _ref2[k];
ref2 = parseCoord(block, this.format);
for (k in ref2) {
v = ref2[k];
command.op[k] = v;

@@ -121,0 +121,0 @@ }

(function() {
var GerberParser, Parser, getSvgCoord, parseCoord, reCOORD,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -14,4 +14,4 @@ Parser = require('./parser');

GerberParser = (function(_super) {
__extends(GerberParser, _super);
GerberParser = (function(superClass) {
extend(GerberParser, superClass);

@@ -23,3 +23,3 @@ function GerberParser() {

GerberParser.prototype.parseFormat = function(p, c) {
var nota, places, zero, _base, _base1;
var base, base1, nota, places, zero;
zero = p[2] === 'L' || p[2] === 'T' ? p[2] : null;

@@ -33,7 +33,7 @@ nota = p[3] === 'A' || p[3] === 'I' ? p[3] : null;

}
if ((_base = this.format).zero == null) {
_base.zero = zero;
if ((base = this.format).zero == null) {
base.zero = zero;
}
if ((_base1 = this.format).places == null) {
_base1.places = places;
if ((base1 = this.format).places == null) {
base1.places = places;
}

@@ -47,8 +47,8 @@ if (c.set == null) {

GerberParser.prototype.parseToolDef = function(p, c) {
var code, hole, m, mods, shape, _ref, _ref1;
var code, hole, m, mods, ref, ref1, shape;
if (c.tool == null) {
c.tool = {};
}
code = (_ref = p.match(/^ADD\d{2,}/)) != null ? _ref[0].slice(2) : void 0;
_ref1 = p.slice(2 + code.length).split(','), shape = _ref1[0], mods = _ref1[1];
code = (ref = p.match(/^ADD\d{2,}/)) != null ? ref[0].slice(2) : void 0;
ref1 = p.slice(2 + code.length).split(','), shape = ref1[0], mods = ref1[1];
mods = mods != null ? mods.split('X') : void 0;

@@ -150,10 +150,10 @@ while (code[1] === '0') {

mods = (function() {
var _i, _len, _ref2, _results;
_ref2 = mods != null ? mods : [];
_results = [];
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
m = _ref2[_i];
_results.push(+m);
var k, len, ref2, results;
ref2 = mods != null ? mods : [];
results = [];
for (k = 0, len = ref2.length; k < len; k++) {
m = ref2[k];
results.push(+m);
}
return _results;
return results;
})();

@@ -168,3 +168,3 @@ return c.tool[code] = {

GerberParser.prototype.parseCommand = function(block) {
var axis, c, code, coord, i, j, m, op, p, param, tool, u, val, x, y, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
var axis, c, code, coord, i, j, k, len, m, op, p, param, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, tool, u, val, x, y;
if (block == null) {

@@ -175,4 +175,4 @@ block = {};

if (param = block.param) {
for (_i = 0, _len = param.length; _i < _len; _i++) {
p = param[_i];
for (k = 0, len = param.length; k < len; k++) {
p = param[k];
switch (code = p.slice(0, 2)) {

@@ -192,3 +192,3 @@ case 'FS':

} else {
throw new Error("" + p + " is an invalid units setting");
throw new Error(p + " is an invalid units setting");
}

@@ -218,6 +218,6 @@ break;

}
x = (_ref = (_ref1 = p.match(/X[+-]?[\d\.]+/)) != null ? _ref1[0].slice(1) : void 0) != null ? _ref : 1;
y = (_ref2 = (_ref3 = p.match(/Y[+-]?[\d\.]+/)) != null ? _ref3[0].slice(1) : void 0) != null ? _ref2 : 1;
i = (_ref4 = p.match(/I[+-]?[\d\.]+/)) != null ? _ref4[0].slice(1) : void 0;
j = (_ref5 = p.match(/J[+-]?[\d\.]+/)) != null ? _ref5[0].slice(1) : void 0;
x = (ref = (ref1 = p.match(/X[+-]?[\d\.]+/)) != null ? ref1[0].slice(1) : void 0) != null ? ref : 1;
y = (ref2 = (ref3 = p.match(/Y[+-]?[\d\.]+/)) != null ? ref3[0].slice(1) : void 0) != null ? ref2 : 1;
i = (ref4 = p.match(/I[+-]?[\d\.]+/)) != null ? ref4[0].slice(1) : void 0;
j = (ref5 = p.match(/J[+-]?[\d\.]+/)) != null ? ref5[0].slice(1) : void 0;
if ((x < 1 || y < 1) || (x > 1 && ((i == null) || i < 0)) || (y > 1 && ((j == null) || j < 0))) {

@@ -250,3 +250,3 @@ throw new Error('invalid step repeat');

} else if (block[0] === 'G') {
switch (code = (_ref6 = block.slice(1).match(/^\d{1,2}/)) != null ? _ref6[0] : void 0) {
switch (code = (ref6 = block.slice(1).match(/^\d{1,2}/)) != null ? ref6[0] : void 0) {
case '4':

@@ -286,4 +286,4 @@ case '04':

}
coord = parseCoord((_ref7 = block.match(reCOORD)) != null ? _ref7[0] : void 0, this.format);
if (op = ((_ref8 = block.match(/D0?[123]$/)) != null ? _ref8[0] : void 0) || Object.keys(coord).length) {
coord = parseCoord((ref7 = block.match(reCOORD)) != null ? ref7[0] : void 0, this.format);
if (op = ((ref8 = block.match(/D0?[123]$/)) != null ? ref8[0] : void 0) || Object.keys(coord).length) {
if (op != null) {

@@ -311,3 +311,3 @@ op = op[op.length - 1];

}
} else if (tool = (_ref9 = block.match(/D\d+$/)) != null ? _ref9[0] : void 0) {
} else if (tool = (ref9 = block.match(/D\d+$/)) != null ? ref9[0] : void 0) {
c.set = {

@@ -314,0 +314,0 @@ currentTool: tool

@@ -30,3 +30,3 @@ (function() {

module.exports = function(file, options) {
var a, error, height, key, oldWarn, opts, p, parser, parserOpts, plotterOpts, reader, root, val, width, xml, xmlObject, _ref;
var a, error, height, key, oldWarn, opts, p, parser, parserOpts, plotterOpts, reader, ref, root, val, width, xml, xmlObject;
if (options == null) {

@@ -122,5 +122,5 @@ options = {};

};
_ref = p.attr;
for (a in _ref) {
val = _ref[a];
ref = p.attr;
for (a in ref) {
val = ref[a];
xml.svg[a] = val;

@@ -127,0 +127,0 @@ }

@@ -48,3 +48,3 @@ (function() {

} else {
throw new Error("" + t + " is unexpected in an arithmetic string");
throw new Error(t + " is unexpected in an arithmetic string");
}

@@ -51,0 +51,0 @@ return exp;

@@ -27,3 +27,3 @@ (function() {

MacroTool.prototype.run = function(tool, modifiers) {
var b, group, i, m, pad, padId, s, shape, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2;
var b, group, i, j, k, l, len, len1, len2, len3, m, n, pad, padId, ref, ref1, ref2, s, shape;
if (modifiers == null) {

@@ -37,9 +37,9 @@ modifiers = [];

this.modifiers = {};
for (i = _i = 0, _len = modifiers.length; _i < _len; i = ++_i) {
for (i = j = 0, len = modifiers.length; j < len; i = ++j) {
m = modifiers[i];
this.modifiers["$" + (i + 1)] = m;
}
_ref = this.blocks;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
b = _ref[_j];
ref = this.blocks;
for (k = 0, len1 = ref.length; k < len1; k++) {
b = ref[k];
this.runBlock(b);

@@ -49,5 +49,5 @@ }

pad = [];
_ref1 = this.masks;
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
m = _ref1[_k];
ref1 = this.masks;
for (l = 0, len2 = ref1.length; l < len2; l++) {
m = ref1[l];
pad.push(m);

@@ -60,5 +60,5 @@ }

};
_ref2 = this.shapes;
for (_l = 0, _len3 = _ref2.length; _l < _len3; _l++) {
s = _ref2[_l];
ref2 = this.shapes;
for (n = 0, len3 = ref2.length; n < len3; n++) {
s = ref2[n];
group._.push(s);

@@ -85,6 +85,6 @@ }

MacroTool.prototype.runBlock = function(block) {
var a, args, i, mod, val, _i, _len, _ref;
var a, args, i, j, len, mod, ref, val;
switch (block[0]) {
case '$':
mod = (_ref = block.match(/^\$\d+(?=\=)/)) != null ? _ref[0] : void 0;
mod = (ref = block.match(/^\$\d+(?=\=)/)) != null ? ref[0] : void 0;
val = block.slice(1 + mod.length);

@@ -102,3 +102,3 @@ return this.modifiers[mod] = this.getNumber(val);

args = block.split(',');
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
for (i = j = 0, len = args.length; j < len; i = ++j) {
a = args[i];

@@ -116,3 +116,3 @@ args[i] = this.getNumber(a);

MacroTool.prototype.primitive = function(args) {
var group, i, key, m, mask, maskId, points, rot, rotation, s, shape, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _n, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
var group, i, j, k, key, l, len, len1, len2, len3, len4, m, mask, maskId, n, o, points, q, ref, ref1, ref2, ref3, ref4, ref5, results, rot, rotation, s, shape;
mask = false;

@@ -186,3 +186,3 @@ rotation = false;

points = [];
for (i = _i = 3, _ref = 3 + 2 * args[2]; _i <= _ref; i = _i += 2) {
for (i = j = 3, ref = 3 + 2 * args[2]; j <= ref; i = j += 2) {
points.push([getSvgCoord(args[i], this.format), getSvgCoord(args[i + 1], this.format)]);

@@ -234,5 +234,5 @@ }

if (args[9]) {
_ref1 = shape.shape;
for (_j = 0, _len = _ref1.length; _j < _len; _j++) {
s = _ref1[_j];
ref1 = shape.shape;
for (k = 0, len = ref1.length; k < len; k++) {
s = ref1[k];
if (s.line != null) {

@@ -257,9 +257,9 @@ s.line.transform = "rotate(" + args[9] + ")";

if (args[6]) {
_ref2 = shape.shape;
for (_k = 0, _len1 = _ref2.length; _k < _len1; _k++) {
s = _ref2[_k];
ref2 = shape.shape;
for (l = 0, len1 = ref2.length; l < len1; l++) {
s = ref2[l];
if (s.mask != null) {
_ref3 = s.mask._;
for (_l = 0, _len2 = _ref3.length; _l < _len2; _l++) {
m = _ref3[_l];
ref3 = s.mask._;
for (n = 0, len2 = ref3.length; n < len2; n++) {
m = ref3[n];
if (m.rect != null) {

@@ -275,3 +275,3 @@ m.rect.transform = "rotate(" + args[6] + ")";

default:
throw new Error("" + args[0] + " is not a valid primitive code");
throw new Error(args[0] + " is not a valid primitive code");
}

@@ -310,5 +310,5 @@ if (mask) {

};
_ref4 = this.shapes;
for (_m = 0, _len3 = _ref4.length; _m < _len3; _m++) {
s = _ref4[_m];
ref4 = this.shapes;
for (o = 0, len3 = ref4.length; o < len3; o++) {
s = ref4[o];
group._.push(s);

@@ -330,13 +330,13 @@ }

} else {
_ref5 = shape.shape;
_results = [];
for (_n = 0, _len4 = _ref5.length; _n < _len4; _n++) {
s = _ref5[_n];
ref5 = shape.shape;
results = [];
for (q = 0, len4 = ref5.length; q < len4; q++) {
s = ref5[q];
if (s.mask != null) {
_results.push(this.masks.push(s));
results.push(this.masks.push(s));
} else {
_results.push(this.shapes.push(s));
results.push(this.shapes.push(s));
}
}
return _results;
return results;
}

@@ -347,3 +347,3 @@ }

MacroTool.prototype.addBbox = function(bbox, rotation) {
var b, c, p, points, s, x, y, _i, _len;
var b, c, j, len, p, points, s, x, y;
if (rotation == null) {

@@ -375,4 +375,4 @@ rotation = 0;

points = [[bbox[0], bbox[1]], [bbox[2], bbox[1]], [bbox[2], bbox[3]], [bbox[0], bbox[3]]];
for (_i = 0, _len = points.length; _i < _len; _i++) {
p = points[_i];
for (j = 0, len = points.length; j < len; j++) {
p = points[j];
x = (p[0] * c) - (p[1] * s);

@@ -394,10 +394,10 @@ y = (p[0] * s) + (p[1] * c);

return this.bbox = (function() {
var _j, _len1, _ref, _results;
_ref = this.bbox;
_results = [];
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
b = _ref[_j];
_results.push(b === -0 ? 0 : b);
var k, len1, ref, results;
ref = this.bbox;
results = [];
for (k = 0, len1 = ref.length; k < len1; k++) {
b = ref[k];
results.push(b === -0 ? 0 : b);
}
return _results;
return results;
}).call(this);

@@ -404,0 +404,0 @@ }

@@ -25,3 +25,3 @@ (function() {

objToXml = function(obj, op) {
var children, dec, decimals, elem, i, ind, key, nl, o, pre, tb, v, val, xml, _i, _len, _ref, _ref1, _ref2;
var children, dec, decimals, elem, i, ind, j, key, len, nl, o, pre, ref, ref1, ref2, tb, v, val, xml;
if (op == null) {

@@ -31,4 +31,4 @@ op = {};

pre = op.pretty;
ind = (_ref = op.indent) != null ? _ref : 0;
dec = (_ref1 = op.maxDec) != null ? _ref1 : false;
ind = (ref = op.indent) != null ? ref : 0;
dec = (ref1 = op.maxDec) != null ? ref1 : false;
decimals = function(n) {

@@ -49,3 +49,3 @@ if (typeof n === 'number') {

if (Array.isArray(obj)) {
for (i = _i = 0, _len = obj.length; _i < _len; i = ++_i) {
for (i = j = 0, len = obj.length; j < len; i = ++j) {
o = obj[i];

@@ -58,9 +58,9 @@ xml += (i !== 0 ? nl : '') + (objToXml(o, op));

if (elem != null) {
xml = "" + tb + "<" + elem;
xml = tb + "<" + elem;
if (typeof obj[elem] === 'function') {
obj[elem] = obj[elem]();
}
_ref2 = obj[elem];
for (key in _ref2) {
val = _ref2[key];
ref2 = obj[elem];
for (key in ref2) {
val = ref2[key];
if (typeof val === 'function') {

@@ -75,9 +75,9 @@ val = val();

val = (function() {
var _j, _len1, _results;
_results = [];
for (_j = 0, _len1 = val.length; _j < _len1; _j++) {
v = val[_j];
_results.push(decimals(v));
var k, len1, results;
results = [];
for (k = 0, len1 = val.length; k < len1; k++) {
v = val[k];
results.push(decimals(v));
}
return _results;
return results;
})();

@@ -106,3 +106,3 @@ }

} else {
xml += "" + obj + " ";
xml += obj + " ";
}

@@ -109,0 +109,0 @@ return xml;

@@ -66,3 +66,3 @@ (function() {

polygon = function(p) {
var i, points, r, rx, ry, start, step, theta, x, xMax, xMin, y, yMax, yMin, _i, _ref;
var i, j, points, r, ref, rx, ry, start, step, theta, x, xMax, xMin, y, yMax, yMin;
if (p.dia == null) {

@@ -88,3 +88,3 @@ throw new Error('polygon requires diameter');

yMax = null;
for (i = _i = 0, _ref = p.verticies; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
for (i = j = 0, ref = p.verticies; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
theta = start + (i * step);

@@ -193,3 +193,3 @@ rx = r * Math.cos(theta);

outline = function(p) {
var point, pointString, x, xLast, xMax, xMin, y, yLast, yMax, yMin, _i, _len, _ref;
var j, len, point, pointString, ref, x, xLast, xMax, xMin, y, yLast, yMax, yMin;
if (!(Array.isArray(p.points) && p.points.length > 1)) {

@@ -203,5 +203,5 @@ throw new Error('outline function requires points array');

pointString = '';
_ref = p.points;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
point = _ref[_i];
ref = p.points;
for (j = 0, len = ref.length; j < len; j++) {
point = ref[j];
if (!(Array.isArray(point) && point.length === 2)) {

@@ -208,0 +208,0 @@ throw new Error('outline function requires points array');

@@ -6,3 +6,3 @@ (function() {

function Parser(formatOpts) {
var _ref, _ref1;
var ref, ref1;
if (formatOpts == null) {

@@ -12,4 +12,4 @@ formatOpts = {};

this.format = {
zero: (_ref = formatOpts.zero) != null ? _ref : null,
places: (_ref1 = formatOpts.places) != null ? _ref1 : null
zero: (ref = formatOpts.zero) != null ? ref : null,
places: (ref1 = formatOpts.places) != null ? ref1 : null
};

@@ -16,0 +16,0 @@ if (this.format.places != null) {

@@ -22,3 +22,3 @@ (function() {

function Plotter(reader, parser, opts) {
var _ref, _ref1;
var ref, ref1;
this.reader = reader;

@@ -29,4 +29,4 @@ this.parser = parser;

}
this.units = (_ref = opts.units) != null ? _ref : null;
this.notation = (_ref1 = opts.notation) != null ? _ref1 : null;
this.units = (ref = opts.units) != null ? ref : null;
this.notation = (ref1 = opts.notation) != null ? ref1 : null;
this.macros = {};

@@ -94,10 +94,10 @@ this.tools = {};

pad: (function() {
var _i, _len, _ref, _results;
_ref = t.pad;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
obj = _ref[_i];
_results.push(obj);
var k, len, ref, results;
ref = t.pad;
results = [];
for (k = 0, len = ref.length; k < len; k++) {
obj = ref[k];
results.push(obj);
}
return _results;
return results;
})(),

@@ -113,2 +113,3 @@ flash: function(x, y) {

},
flashed: false,
bbox: function(x, y) {

@@ -133,3 +134,3 @@ if (x == null) {

Plotter.prototype.changeTool = function(code) {
var _ref;
var ref;
this.finishPath();

@@ -140,3 +141,3 @@ if (this.region) {

if (this.tools[code] == null) {
if (!((_ref = this.parser) != null ? _ref.fmat : void 0)) {
if (!((ref = this.parser) != null ? ref.fmat : void 0)) {
throw new Error("tool " + code + " is not defined");

@@ -150,3 +151,3 @@ }

Plotter.prototype.command = function(c) {
var code, m, params, state, val, _ref, _ref1;
var code, m, params, ref, ref1, state, val;
if (c.macro != null) {

@@ -157,5 +158,5 @@ m = new Macro(c.macro, this.parser.format.places);

}
_ref = c.set;
for (state in _ref) {
val = _ref[state];
ref = c.set;
for (state in ref) {
val = ref[state];
if (state === 'region') {

@@ -179,5 +180,5 @@ this.finishPath();

if (c.tool != null) {
_ref1 = c.tool;
for (code in _ref1) {
params = _ref1[code];
ref1 = c.tool;
for (code in ref1) {
params = ref1[code];
this.addTool(code, params);

@@ -201,7 +202,7 @@ }

Plotter.prototype.plot = function() {
var block, _ref;
var block, ref;
while (!this.done) {
block = this.reader.nextBlock();
if (block === false) {
if (((_ref = this.parser) != null ? _ref.fmat : void 0) == null) {
if (((ref = this.parser) != null ? ref.fmat : void 0) == null) {
throw new Error('end of file encountered before required M02 command');

@@ -228,3 +229,3 @@ } else {

Plotter.prototype.finishSR = function() {
var layer, m, maskId, u, x, y, _i, _j, _k, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
var k, l, layer, len, m, maskId, n, ref, ref1, ref2, ref3, ref4, ref5, u, x, y;
if (this.srOverClear && this.srOverCurrent) {

@@ -248,7 +249,7 @@ maskId = "gerber-sr-mask_" + (unique());

});
for (x = _i = 0, _ref = this.stepRepeat.x * this.stepRepeat.i, _ref1 = this.stepRepeat.i; _ref1 > 0 ? _i < _ref : _i > _ref; x = _i += _ref1) {
for (y = _j = 0, _ref2 = this.stepRepeat.y * this.stepRepeat.j, _ref3 = this.stepRepeat.j; _ref3 > 0 ? _j < _ref2 : _j > _ref2; y = _j += _ref3) {
_ref4 = this.srOverCurrent;
for (_k = 0, _len = _ref4.length; _k < _len; _k++) {
layer = _ref4[_k];
for (x = k = 0, ref = this.stepRepeat.x * this.stepRepeat.i, ref1 = this.stepRepeat.i; ref1 > 0 ? k < ref : k > ref; x = k += ref1) {
for (y = l = 0, ref2 = this.stepRepeat.y * this.stepRepeat.j, ref3 = this.stepRepeat.j; ref3 > 0 ? l < ref2 : l > ref2; y = l += ref3) {
ref4 = this.srOverCurrent;
for (n = 0, len = ref4.length; n < len; n++) {
layer = ref4[n];
u = {

@@ -263,3 +264,3 @@ use: {}

}
u.use['xlink:href'] = '#' + ((_ref5 = layer.C) != null ? _ref5 : layer.D);
u.use['xlink:href'] = '#' + ((ref5 = layer.C) != null ? ref5 : layer.D);
if (layer.D != null) {

@@ -280,3 +281,3 @@ u.use.fill = '#fff';

Plotter.prototype.finishLayer = function() {
var c, h, id, obj, srId, u, w, x, y, _i, _j, _k, _len, _ref, _ref1, _ref2;
var c, h, id, k, l, len, n, obj, ref, ref1, ref2, srId, u, w, x, y;
this.finishPath();

@@ -305,4 +306,4 @@ if (!this.current.length) {

}
for (x = _i = 0, _ref = this.stepRepeat.x; 0 <= _ref ? _i < _ref : _i > _ref; x = 0 <= _ref ? ++_i : --_i) {
for (y = _j = 0, _ref1 = this.stepRepeat.y; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; y = 0 <= _ref1 ? ++_j : --_j) {
for (x = k = 0, ref = this.stepRepeat.x; 0 <= ref ? k < ref : k > ref; x = 0 <= ref ? ++k : --k) {
for (y = l = 0, ref1 = this.stepRepeat.y; 0 <= ref1 ? l < ref1 : l > ref1; y = 0 <= ref1 ? ++l : --l) {
if (!(x === 0 && y === 0)) {

@@ -339,5 +340,5 @@ u = {

if ((this.group.g.mask == null) && this.group.g._.length) {
_ref2 = this.current;
for (_k = 0, _len = _ref2.length; _k < _len; _k++) {
c = _ref2[_k];
ref2 = this.current;
for (n = 0, len = ref2.length; n < len; n++) {
c = ref2[n];
this.group.g._.push(c);

@@ -378,3 +379,3 @@ }

Plotter.prototype.finishPath = function() {
var key, p, val, _ref;
var key, p, ref, val;
if (this.path.length) {

@@ -387,5 +388,5 @@ p = {

} else {
_ref = this.tools[this.currentTool].trace;
for (key in _ref) {
val = _ref[key];
ref = this.tools[this.currentTool].trace;
for (key in ref) {
val = ref[key];
p.path[key] = val;

@@ -401,3 +402,3 @@ }

Plotter.prototype.operate = function(op) {
var bbox, ex, ey, shape, sx, sy, t, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
var bbox, ex, ey, k, len, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, shape, sx, sy, t;
if (op["do"] === 'last') {

@@ -412,7 +413,7 @@ op["do"] = this.lastOp;

if (this.notation === 'I') {
this.pos.x += (_ref = op.x) != null ? _ref : 0;
this.pos.y += (_ref1 = op.y) != null ? _ref1 : 0;
this.pos.x += (ref = op.x) != null ? ref : 0;
this.pos.y += (ref1 = op.y) != null ? ref1 : 0;
} else {
this.pos.x = (_ref2 = op.x) != null ? _ref2 : this.pos.x;
this.pos.y = (_ref3 = op.y) != null ? _ref3 : this.pos.y;
this.pos.x = (ref2 = op.x) != null ? ref2 : this.pos.x;
this.pos.y = (ref3 = op.y) != null ? ref3 : this.pos.y;
}

@@ -432,3 +433,3 @@ ex = this.pos.x;

if (this.notation == null) {
if (((_ref4 = this.parser) != null ? _ref4.fmat : void 0) != null) {
if (((ref4 = this.parser) != null ? ref4.fmat : void 0) != null) {
this.notation = 'A';

@@ -446,9 +447,9 @@ } else {

}
if (t.pad) {
_ref5 = t.pad;
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
shape = _ref5[_i];
if (!t.flashed) {
ref5 = t.pad;
for (k = 0, len = ref5.length; k < len; k++) {
shape = ref5[k];
this.defs.push(shape);
}
t.pad = false;
t.flashed = true;
}

@@ -459,3 +460,3 @@ this.current.push(t.flash(ex, ey));

if (!this.region && !t.trace) {
throw new Error("" + this.currentTool + " is not a strokable tool");
throw new Error(this.currentTool + " is not a strokable tool");
}

@@ -479,3 +480,3 @@ if (this.path.length === 0) {

} else {
return this.drawArc(sx, sy, ex, ey, (_ref6 = op.i) != null ? _ref6 : 0, (_ref7 = op.j) != null ? _ref7 : 0);
return this.drawArc(sx, sy, ex, ey, (ref6 = op.i) != null ? ref6 : 0, (ref7 = op.j) != null ? ref7 : 0);
}

@@ -511,3 +512,3 @@ }

return this.path.push('M', sxm, sym, sxp, sym, exp, eym, exp, eyp, exm, eyp, sxm, syp, 'Z');
} else if ((HALF_PI <= theta && theta < Math.PI)) {
} else if ((HALF_PI <= theta && theta <= Math.PI)) {
return this.path.push('M', sxm, sym, sxp, sym, sxp, syp, exp, eyp, exm, eyp, exm, eym, 'Z');

@@ -523,4 +524,4 @@ } else if ((-Math.PI <= theta && theta < -HALF_PI)) {

Plotter.prototype.drawArc = function(sx, sy, ex, ey, i, j) {
var arcEps, c, cand, cen, dist, large, r, rTool, sweep, t, theta, thetaE, thetaS, validCen, xMax, xMin, xn, xp, yMax, yMin, yn, yp, zeroLength, _i, _j, _len, _len1, _ref, _ref1, _ref2;
arcEps = 1.5 * coordFactor * Math.pow(10, -1 * ((_ref = (_ref1 = this.parser) != null ? _ref1.format.places[1] : void 0) != null ? _ref : 7));
var arcEps, c, cand, cen, dist, k, l, large, len, len1, r, rTool, ref, ref1, ref2, sweep, t, theta, thetaE, thetaS, validCen, xMax, xMin, xn, xp, yMax, yMin, yn, yp, zeroLength;
arcEps = 1.5 * coordFactor * Math.pow(10, -1 * ((ref = (ref1 = this.parser) != null ? ref1.format.places[1] : void 0) != null ? ref : 7));
t = this.tools[this.currentTool];

@@ -541,4 +542,4 @@ if (!this.region && !t.trace['stroke-width']) {

}
for (_i = 0, _len = cand.length; _i < _len; _i++) {
c = cand[_i];
for (k = 0, len = cand.length; k < len; k++) {
c = cand[k];
dist = Math.sqrt(Math.pow(c[0] - ex, 2) + Math.pow(c[1] - ey, 2));

@@ -555,4 +556,4 @@ if ((Math.abs(r - dist)) < arcEps) {

cen = null;
for (_j = 0, _len1 = validCen.length; _j < _len1; _j++) {
c = validCen[_j];
for (l = 0, len1 = validCen.length; l < len1; l++) {
c = validCen[l];
thetaE = Math.atan2(ey - c.y, ex - c.x);

@@ -593,3 +594,3 @@ if (thetaE < 0) {

if (this.mode === 'cw') {
_ref2 = [thetaS, thetaE], thetaE = _ref2[0], thetaS = _ref2[1];
ref2 = [thetaS, thetaE], thetaE = ref2[0], thetaS = ref2[1];
}

@@ -596,0 +597,0 @@ xp = thetaS > 0 ? TWO_PI : 0;

@@ -23,3 +23,3 @@ (function() {

if (p.dia < 0) {
throw new RangeError("" + tool + " circle diameter out of range (" + p.dia + "<0)");
throw new RangeError(tool + " circle diameter out of range (" + p.dia + "<0)");
}

@@ -38,6 +38,6 @@ shape = 'circle';

if (p.width < 0) {
throw new RangeError("" + tool + " rect width out of range (" + p.width + "<0)");
throw new RangeError(tool + " rect width out of range (" + p.width + "<0)");
}
if (p.height < 0) {
throw new RangeError("" + tool + " rect height out of range (" + p.height + "<0)");
throw new RangeError(tool + " rect height out of range (" + p.height + "<0)");
}

@@ -58,3 +58,3 @@ shape = 'rect';

if (p.verticies < 3 || p.verticies > 12) {
throw new RangeError("" + tool + " polygon points out of range (" + p.verticies + "<3 or >12)]");
throw new RangeError(tool + " polygon points out of range (" + p.verticies + "<3 or >12)]");
}

@@ -70,3 +70,3 @@ shape = 'polygon';

if (!(p.hole.dia >= 0)) {
throw new RangeError("" + tool + " hole diameter out of range (" + p.hole.dia + "<0)");
throw new RangeError(tool + " hole diameter out of range (" + p.hole.dia + "<0)");
}

@@ -82,6 +82,6 @@ hole = shapes.circle({

if (!(p.hole.width >= 0)) {
throw new RangeError("" + tool + " hole width out of range (" + p.hole.width + "<0)");
throw new RangeError(tool + " hole width out of range (" + p.hole.width + "<0)");
}
if (!(p.hole.height >= 0)) {
throw new RangeError("" + tool + " hole height out of range (" + p.hole.height + "<0)");
throw new RangeError(tool + " hole height out of range (" + p.hole.height + "<0)");
}

@@ -97,3 +97,3 @@ hole = shapes.rect({

} else {
throw new Error("" + tool + " has invalid hole parameters");
throw new Error(tool + " has invalid hole parameters");
}

@@ -100,0 +100,0 @@ maskId = id + '-mask';

(function() {
var SVG_COORD_E, getSvgCoord,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -8,3 +8,3 @@ SVG_COORD_E = 3;

getSvgCoord = function(numberString, format) {
var after, before, c, i, sign, subNumbers, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3;
var after, before, c, i, j, k, len, len1, ref, ref1, ref2, ref3, sign, subNumbers;
if (numberString != null) {

@@ -22,3 +22,3 @@ numberString = "" + numberString;

}
if ((__indexOf.call(numberString, '.') >= 0) || (format.zero == null)) {
if ((indexOf.call(numberString, '.') >= 0) || (format.zero == null)) {
subNumbers = numberString.split('.');

@@ -28,9 +28,9 @@ if (subNumbers.length > 2) {

}
_ref1 = [subNumbers[0], (_ref = subNumbers[1]) != null ? _ref : ''], before = _ref1[0], after = _ref1[1];
ref1 = [subNumbers[0], (ref = subNumbers[1]) != null ? ref : ''], before = ref1[0], after = ref1[1];
} else {
if (typeof (format != null ? (_ref2 = format.places) != null ? _ref2[0] : void 0 : void 0) !== 'number' || typeof (format != null ? (_ref3 = format.places) != null ? _ref3[1] : void 0 : void 0) !== 'number') {
if (typeof (format != null ? (ref2 = format.places) != null ? ref2[0] : void 0 : void 0) !== 'number' || typeof (format != null ? (ref3 = format.places) != null ? ref3[1] : void 0 : void 0) !== 'number') {
return NaN;
}
if (format.zero === 'T') {
for (i = _i = 0, _len = numberString.length; _i < _len; i = ++_i) {
for (i = j = 0, len = numberString.length; j < len; i = ++j) {
c = numberString[i];

@@ -47,3 +47,3 @@ if (i < format.places[0]) {

} else if (format.zero === 'L') {
for (i = _j = 0, _len1 = numberString.length; _j < _len1; i = ++_j) {
for (i = k = 0, len1 = numberString.length; k < len1; i = ++k) {
c = numberString[i];

@@ -50,0 +50,0 @@ if (numberString.length - i <= format.places[1]) {

{
"name": "gerber-to-svg",
"version": "0.3.2",
"version": "0.4.0",
"description": "Gerber and NC drill file to SVG converter",

@@ -32,10 +32,10 @@ "main": "lib/gerber-to-svg.js",

"brfs": "^1.2.0",
"browserify": "^8.0.1",
"chai": "^1.10.0",
"browserify": "9.0.3",
"chai": "2.2.0",
"coffee-script": "^1.7.1",
"coffeeify": "^1.0.0",
"glob": "^4.3.2",
"gulp": "^3.8.5",
"glob": "5.0.3",
"gulp": "^3.8.11",
"gulp-coffee": "^2.0.1",
"gulp-coffee-istanbul": "^0.6.0",
"gulp-coffee-istanbul": "0.7.0",
"gulp-coffeelint": "^0.4.0",

@@ -50,9 +50,11 @@ "gulp-coveralls": "^0.1.2",

"node-static": "^0.7.4",
"phantomjs": "^1.9.16",
"vinyl-source-stream": "^1.0.0",
"zuul": "^1.16.4"
"zuul": "2.1.1"
},
"dependencies": {
"chalk": "^0.5.1",
"chalk": "1.0.0",
"minimatch": "2.0.4",
"minimist": "^1.1.0"
}
}

@@ -24,3 +24,3 @@ # gerber-to-svg [![Build Status](http://img.shields.io/travis/mcous/gerber-to-svg.svg?style=flat-square)](https://travis-ci.org/mcous/gerber-to-svg) [![Coverage](http://img.shields.io/coveralls/mcous/gerber-to-svg.svg?style=flat-square)](https://coveralls.io/r/mcous/gerber-to-svg) [![Version](http://img.shields.io/npm/v/gerber-to-svg.svg?style=flat-square)](https://www.npmjs.org/package/gerber-to-svg) [![Dependencies](http://img.shields.io/david/mcous/gerber-to-svg.svg?style=flat-square)](https://david-dm.org/mcous/gerber-to-svg)

`-p, --pretty` | boolean | prettily align SVG output
`-d, --drill` | string | process following file as an NC (Excellon) drill
`-d, --drill` | glob | process input files matching this glob as NC (Excellon) drills
`-f, --format` | array | override coordinate format with '[n_int,n_dec]'

@@ -37,4 +37,4 @@ `-z, --zero` | string | override zero suppression with 'L' or 'T'

* `gerber2svg path/to/gerber.gbr` will write the SVG to stdout
* `gerber2svg -o some/dir path/to/gerber.gbr` will create some/dir/gerber.svg
* `gerber2svg -d drill.drl -o out gerb/*` will process drill.drl as a drill file, everything in gerb as a Gerber file, and output to out
* `gerber2svg -o some/dir -- path/to/gerber.gbr` will create some/dir/gerber.svg
* `gerber2svg -d **/*.drl -o out -- gerb/*` will process any files in gerb that end in '.drl' as a drill files, everything else as Gerber files, and output to out

@@ -134,3 +134,3 @@ ### api (node and browser)

drillObj = gerberToSvg drillFile, { object: true, drill: true}
# pull the origins from the viewBox
# pull the layer origin offsets from the viewBox
offsetFront = frontObj.svg.viewBox[0..1]

@@ -146,3 +146,3 @@ offsetBack = backObj.svg.viewBox[0..1]

## what you get
Since Gerber is just an image format, this library does not attempt to identify nor infer anything about what the file represents (e.g. a copper layer, a silkscreen layer, etc.) It just takes in a Gerber and spits out an SVG. This converter uses RS-274X and strives to be true to the [latest format specification](http://www.ucamco.com/files/downloads/file/81/the_gerber_file_format_specification.pdf?d69271f6602e26ab2474ad625fe40c97). All the Gerber image features should be there.
Since Gerber is just an image format, this library does not attempt to identify nor infer anything about what the file represents (e.g. a copper layer, a silkscreen layer, etc.) It just takes in a Gerber and spits out an SVG. This converter uses RS-274X and strives to be true to the [latest format specification](http://www.ucamco.com/downloads). All the Gerber image features should be there.

@@ -164,4 +164,3 @@ Everywhere that is "dark" or "exposed" in the Gerber (think a copper trace

If it messes up, open up an issue and attach your Gerber, if you can. I
appreciate files to test on.
If it messes up, open up an issue and attach your Gerber, if you can. I appreciate files to test on.

@@ -168,0 +167,0 @@ ### problems with drill files

Sorry, the diff of this file is too big to display

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