@mylasertools/kerfscript 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/LANGUAGE.md +200 -84
  3. package/README.md +4 -3
  4. package/dist/assembly.d.cts +4 -1
  5. package/dist/assembly.d.ts +4 -1
  6. package/dist/ast.d.cts +6 -0
  7. package/dist/ast.d.ts +6 -0
  8. package/dist/bores.d.cts +15 -0
  9. package/dist/bores.d.ts +15 -0
  10. package/dist/cli.js +8959 -6064
  11. package/dist/customizer.d.cts +4 -0
  12. package/dist/customizer.d.ts +4 -0
  13. package/dist/effects.d.cts +31 -0
  14. package/dist/effects.d.ts +31 -0
  15. package/dist/evaluator.d.cts +10 -0
  16. package/dist/evaluator.d.ts +10 -0
  17. package/dist/export/mesh.d.cts +53 -0
  18. package/dist/export/mesh.d.ts +53 -0
  19. package/dist/export/model.d.cts +12 -0
  20. package/dist/export/model.d.ts +12 -0
  21. package/dist/export/triangulate.d.cts +5 -0
  22. package/dist/export/triangulate.d.ts +5 -0
  23. package/dist/export/zip.d.cts +5 -0
  24. package/dist/export/zip.d.ts +5 -0
  25. package/dist/functions.d.cts +2 -0
  26. package/dist/functions.d.ts +2 -0
  27. package/dist/geometry.d.cts +7 -0
  28. package/dist/geometry.d.ts +7 -0
  29. package/dist/halving.d.cts +8 -0
  30. package/dist/halving.d.ts +8 -0
  31. package/dist/highlight.cjs +3 -2
  32. package/dist/highlight.js +3 -2
  33. package/dist/import/dbg.d.cts +1 -0
  34. package/dist/import/dbg.d.ts +1 -0
  35. package/dist/index.cjs +522 -56
  36. package/dist/index.d.cts +6 -2
  37. package/dist/index.d.ts +6 -2
  38. package/dist/index.js +522 -56
  39. package/dist/language.cjs +495 -36
  40. package/dist/language.js +495 -36
  41. package/dist/libraries.cjs +474 -16
  42. package/dist/libraries.js +474 -16
  43. package/dist/plot.d.cts +16 -0
  44. package/dist/plot.d.ts +16 -0
  45. package/dist/render.d.cts +3 -0
  46. package/dist/render.d.ts +3 -0
  47. package/dist/signatures.cjs +182 -5
  48. package/dist/signatures.js +182 -5
  49. package/dist/text.d.cts +6 -0
  50. package/dist/text.d.ts +6 -0
  51. package/docs/3d-files.md +72 -0
  52. package/docs/cli.md +27 -21
  53. package/docs/compatibility.md +0 -8
  54. package/docs/customizer.md +74 -0
  55. package/docs/javascript.md +46 -0
  56. package/docs/library.md +162 -1
  57. package/docs/openscad.md +15 -13
  58. package/docs/parts-and-sheets.md +57 -1
  59. package/docs/versions.md +2 -2
  60. package/package.json +1 -1
package/dist/libraries.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /*! @mylasertools/kerfscript | (c) MyLaserTools | AGPL-3.0-only or commercial licence, see COMMERCIAL-LICENSE.md. Includes Clipper2 (BSL-1.0), opentype.js, tiny-inflate and string.prototype.codepointat (MIT), see THIRD-PARTY-NOTICES.md. */
2
- import{createHash as b1}from"node:crypto";import{existsSync as I,mkdirSync as w1,readdirSync as Q,readFileSync as T,rmSync as J,statSync as m1,writeFileSync as _}from"node:fs";import{dirname as Y,isAbsolute as E,join as d,relative as L1,resolve as O,sep as A1}from"node:path";import{gunzipSync as y1,gzipSync as C1}from"node:zlib";var p1=(a,c=!0)=>`line ${a.line}${c?`, column ${a.col}`:""}${a.file?` in <${a.file}>`:""}`;var A=class extends Error{constructor(l,e){super(e?`${l} (${p1(e)})`:l);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=l,e&&(this.line=e.line,this.col=e.col,this.file=e.file)}addFrame(l,e,n){let t=this.trace.find(h=>h.name===e&&h.line===n.line&&h.col===n.col&&h.file===n.file);t?t.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:l,name:e,line:n.line,col:n.col,...n.file&&{file:n.file},count:1})}},g1=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function s1(a,c){let l=[],e=[],n=0,t=1,h=0,s=()=>({line:t,col:n-h+1,offset:n,...c&&{file:c}}),i=o=>{for(let m=0;m<o;m++)a[n]===`
3
- `&&(t++,h=n+1),n++};for(;n<a.length;){let o=a[n];if(o===" "||o===" "||o==="\r"||o===`
4
- `){i(1);continue}if(o==="/"&&a[n+1]==="/"){let r=a.indexOf(`
5
- `,n),v=r<0?a.length:r,p=/^[ \t]*$/.test(a.slice(a.lastIndexOf(`
6
- `,n-1)+1,n));e.push({text:a.slice(n+2,v).trim(),line:t,block:!1,own:p,start:n,end:v}),n=v;continue}if(o==="/"&&a[n+1]==="*"){let r=s(),v=a.indexOf("*/",n+2);if(v<0)throw new A("Unclosed block comment",r);e.push({text:a.slice(n+2,v).trim(),line:r.line,block:!0,own:!0,start:n,end:v+2}),i(v+2-n);continue}let m=s();if(/[0-9]/.test(o)||o==="."&&/[0-9]/.test(a[n+1]??"")){let r=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:(?:mm|cm|m|in|ft)(?![A-Za-z0-9_]))?/.exec(a.slice(n));l.push({type:"num",value:r[0],pos:m,end:n+r[0].length}),i(r[0].length);continue}if(/[A-Za-z_$]/.test(o)){let r=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(a.slice(n));l.push({type:"id",value:r[0],pos:m,end:n+r[0].length}),i(r[0].length);continue}if(o==='"'){let r="";for(i(1);n<a.length&&a[n]!=='"';){if(a[n]==="\\"){let v=a[n+1];if(v==="n")r+=`
7
- `;else if(v==="t")r+=" ";else if(v==="u"){let p=a.slice(n+2,n+6);if(!/^[0-9a-fA-F]{4}$/.test(p))throw new A("Bad \\u escape",s());r+=String.fromCharCode(parseInt(p,16)),i(4)}else r+=v;i(2);continue}if(a[n]===`
8
- `)throw new A("Unclosed string",m);r+=a[n],i(1)}if(n>=a.length)throw new A("Unclosed string",m);i(1),l.push({type:"str",value:r,pos:m,end:n});continue}if(o==="<"&&/^<[A-Za-z0-9_./-]+>/.test(a.slice(n))){let r=l[l.length-1];if(r&&r.type==="id"&&(r.value==="use"||r.value==="include")){let v=/^<([A-Za-z0-9_./-]+)>/.exec(a.slice(n));l.push({type:"str",value:v[1],pos:m,end:n+v[0].length}),i(v[0].length);continue}}let z=g1.find(r=>a.startsWith(r,n));if(!z)throw new A(`Unexpected character "${o}"`,m);l.push({type:"punct",value:z,pos:m,end:n+z.length}),i(z.length)}return l.push({type:"eof",value:"",pos:s(),end:n}),{tokens:l,comments:e}}var D=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function h1(a,c){let{tokens:l,comments:e}=s1(a,c),n=new N(l),t=[];for(;!n.at("eof");)t.push(...n.statement());return{program:{body:t},comments:e}}var N=class a{constructor(c){this.tokens=c;this.i=0}peek(c=0){return this.tokens[Math.min(this.i+c,this.tokens.length-1)]}at(c,l,e=0){let n=this.peek(e);return n.type===c&&(l===void 0||n.value===l)}isP(c,l=0){return this.at("punct",c,l)}isK(c,l=0){return this.at("id",c,l)}next(){return this.tokens[this.i++]}fail(c,l=this.peek()){let e=l.type==="eof"?"end of file":`"${l.value}"`;throw new A(`${c}, found ${e}`,l.pos)}expectP(c){return this.isP(c)||this.fail(`Expected "${c}"`),this.next()}separator(c){this.isP(c)||(this.isP(",")||this.fail(`Expected "," or "${c}"`),this.next())}ident(){let c=this.peek();return(c.type!=="id"||D.has(c.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let c=this.stmt();for(let l of c)l.end=this.last();return c}stmt(){let c=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let h=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),h.push(...this.statement());return this.next(),[{kind:"block",body:h,pos:c.pos}]}if(this.isK("module")){this.next();let h=this.ident(),s=this.params();return[{kind:"module",name:h.value,params:s,body:this.body(),pos:c.pos,namePos:h.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let h=this.ident(),s=this.params();this.expectP("=");let i=this.expr();return this.expectP(";"),[{kind:"function",name:h.value,params:s,body:i,pos:c.pos,namePos:h.pos}]}if(this.isK("use")||this.isK("include")){this.next();let h=this.peek();return h.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:h.value,include:c.value==="include",pos:c.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:c.pos}];if(this.isK("if")){this.next(),this.expectP("(");let h=this.expr();this.expectP(")");let s=this.body(),i=[];return this.isK("else")&&(this.next(),i=this.body()),[{kind:"if",cond:h,then:s,else:i,pos:c.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:c.pos}];if(c.type==="id"&&this.isP("=",1)){let h=this.ident().value;this.next();let s=this.peek().pos.offset,i=this.expr(),o=this.expectP(";").pos.offset;return[{kind:"assign",name:h,value:i,span:[s,o],pos:c.pos}]}let l=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(l=this.next().value);let e=this.peek();(e.type!=="id"||D.has(e.value))&&this.fail("Expected a statement"),this.next();let n=this.args(),t=this.body();return[{kind:"call",name:e.value,args:n,children:t,modifier:l,pos:e.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let c=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),c.push(...this.statement());return this.next(),c}return this.statement()}params(){this.expectP("(");let c=[];for(;!this.isP(")");){let l=this.ident(),e=null;this.isP("=")&&(this.next(),e=this.expr()),c.push({name:l.value,default:e,pos:l.pos}),this.separator(")")}return this.next(),c}args(){this.expectP("(");let c=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let l=this.next();this.next(),c.push({name:l.value,value:this.expr(),pos:l.pos})}else c.push({name:null,value:this.expr()});this.separator(")")}return this.next(),c}assigns(){this.expectP("(");let c=[];for(;!this.isP(")");){let l=this.ident();this.expectP("="),c.push({name:l.value,value:this.expr(),pos:l.pos}),this.separator(")")}return this.next(),c}expr(){let c=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let e=this.params(),n=this.expr();return{kind:"lambda",params:e,body:n,pos:c.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let e=this.assigns(),n=this.expr();return{kind:"let",assigns:e,body:n,pos:c.pos,end:this.last()}}let l=this.binary(0);if(this.isP("?")){this.next();let e=this.expr();this.expectP(":");let n=this.expr();return{kind:"ternary",cond:l,then:e,else:n,pos:c.pos}}return l}static{this.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]]}binary(c){if(c>=a.LEVELS.length)return this.unary();let l=this.binary(c+1);for(;this.at("punct")&&a.LEVELS[c].includes(this.peek().value);){let e=this.next(),n=this.binary(c+1);l={kind:"binary",op:e.value,left:l,right:n,pos:e.pos}}return l}unary(){if(this.isP("-")||this.isP("!")||this.isP("+")){let c=this.next();return{kind:"unary",op:c.value,arg:this.unary(),pos:c.pos}}return this.power()}power(){let c=this.postfix();if(this.isP("^")){let l=this.next();return{kind:"binary",op:"^",left:c,right:this.unary(),pos:l.pos}}return c}postfix(){let c=this.primary();for(;;){let l=this.peek();if(this.isP("("))c={kind:"call",callee:c,args:this.args(),pos:c.pos};else if(this.isP("[")){this.next();let e=this.expr();this.expectP("]"),c={kind:"index",target:c,index:e,pos:l.pos}}else if(this.isP("."))this.next(),c={kind:"member",target:c,name:this.ident().value,pos:l.pos};else return c}}primary(){let c=this.peek();if(c.type==="num"){this.next();let l=/(mm|cm|m|in|ft)$/.exec(c.value);return l?{kind:"num",value:Number(c.value.slice(0,-l[1].length)),unit:l[1],pos:c.pos}:{kind:"num",value:Number(c.value),pos:c.pos}}if(c.type==="str")return this.next(),{kind:"str",value:c.value,pos:c.pos};if(c.type==="id")return c.value==="true"||c.value==="false"?(this.next(),{kind:"bool",value:c.value==="true",pos:c.pos}):c.value==="undef"?(this.next(),{kind:"undef",pos:c.pos}):(D.has(c.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:c.value,pos:c.pos});if(this.isP("(")){this.next();let l=this.expr();return this.expectP(")"),l}if(this.isP("["))return this.list();if(this.isP("{"))return this.record();this.fail("Expected a value")}record(){let c=this.expectP("{"),l=[];for(;!this.isP("}");){let e=this.ident();if(l.some(n=>n.name===e.value))throw new A(`Field ${e.value} is given twice`,e.pos);if(this.expectP("="),l.push({name:e.value,value:this.expr(),pos:e.pos}),!this.isP(","))break;this.next()}return this.expectP("}"),{kind:"record",fields:l,pos:c.pos}}list(){let c=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:c.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let l=this.expr();if(this.isP(":")){this.next();let n=null,t=this.expr();return this.isP(":")&&(this.next(),n=t,t=this.expr()),this.expectP("]"),{kind:"range",start:l,step:n,end:t,pos:c.pos}}let e=[{kind:"item",expr:l}];return this.listRest(e,c.pos)}return this.listRest([],c.pos)}listRest(c,l){if(c.length){if(this.isP("]"))return this.next(),{kind:"list",items:c,pos:l};this.separator("]")}for(;!this.isP("]");)c.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:c,pos:l}}listItem(){let c=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let l=this.assigns(),e=this.listItem();return{kind:"for",assigns:l,body:e,pos:c.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let l=this.expr();this.expectP(")");let e=this.listItem(),n=null;return this.isK("else")&&(this.next(),n=this.listItem()),{kind:"if",cond:l,then:e,else:n}}if(this.isK("let")&&this.isP("(",1)){this.next();let l=this.assigns(),e=this.listItem();return{kind:"let",assigns:l,body:e,pos:c.pos,end:this.last()}}if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let l=this.listItem();return this.expectP(")"),l}return{kind:"item",expr:this.expr()}}};var i1={"kerf/box":`// kerf/box: finger-jointed boxes.
2
+ import{createHash as b1}from"node:crypto";import{existsSync as I,mkdirSync as w1,readdirSync as Y,readFileSync as T,rmSync as Q,statSync as v1,writeFileSync as _}from"node:fs";import{dirname as J,isAbsolute as Z,join as f,relative as L1,resolve as O,sep as y1}from"node:path";import{gunzipSync as A1,gzipSync as k1}from"node:zlib";var p1=(a,c=!0)=>`line ${a.line}${c?`, column ${a.col}`:""}${a.file?` in <${a.file}>`:""}`;var y=class extends Error{constructor(l,e){super(e?`${l} (${p1(e)})`:l);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=l,e&&(this.line=e.line,this.col=e.col,this.file=e.file)}addFrame(l,e,n){let t=this.trace.find(s=>s.name===e&&s.line===n.line&&s.col===n.col&&s.file===n.file);t?t.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:l,name:e,line:n.line,col:n.col,...n.file&&{file:n.file},count:1})}},g1=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function s1(a,c){let l=[],e=[],n=0,t=1,s=0,h=()=>({line:t,col:n-s+1,offset:n,...c&&{file:c}}),i=r=>{for(let v=0;v<r;v++)a[n]===`
3
+ `&&(t++,s=n+1),n++};for(;n<a.length;){let r=a[n];if(r===" "||r===" "||r==="\r"||r===`
4
+ `){i(1);continue}if(r==="/"&&a[n+1]==="/"){let o=a.indexOf(`
5
+ `,n),m=o<0?a.length:o,p=/^[ \t]*$/.test(a.slice(a.lastIndexOf(`
6
+ `,n-1)+1,n));e.push({text:a.slice(n+2,m).trim(),line:t,block:!1,own:p,start:n,end:m}),n=m;continue}if(r==="/"&&a[n+1]==="*"){let o=h(),m=a.indexOf("*/",n+2);if(m<0)throw new y("Unclosed block comment",o);e.push({text:a.slice(n+2,m).trim(),line:o.line,block:!0,own:!0,start:n,end:m+2}),i(m+2-n);continue}let v=h();if(/[0-9]/.test(r)||r==="."&&/[0-9]/.test(a[n+1]??"")){let o=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:(?:mm|cm|m|in|ft)(?![A-Za-z0-9_]))?/.exec(a.slice(n));l.push({type:"num",value:o[0],pos:v,end:n+o[0].length}),i(o[0].length);continue}if(/[A-Za-z_$]/.test(r)){let o=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(a.slice(n));l.push({type:"id",value:o[0],pos:v,end:n+o[0].length}),i(o[0].length);continue}if(r==='"'){let o="";for(i(1);n<a.length&&a[n]!=='"';){if(a[n]==="\\"){let m=a[n+1];if(m==="n")o+=`
7
+ `;else if(m==="t")o+=" ";else if(m==="u"){let p=a.slice(n+2,n+6);if(!/^[0-9a-fA-F]{4}$/.test(p))throw new y("Bad \\u escape",h());o+=String.fromCharCode(parseInt(p,16)),i(4)}else o+=m;i(2);continue}if(a[n]===`
8
+ `)throw new y("Unclosed string",v);o+=a[n],i(1)}if(n>=a.length)throw new y("Unclosed string",v);i(1),l.push({type:"str",value:o,pos:v,end:n});continue}if(r==="<"&&/^<[A-Za-z0-9_./\\: -]+>/.test(a.slice(n))){let o=l[l.length-1];if(o&&o.type==="id"&&(o.value==="use"||o.value==="include")){let m=/^<([A-Za-z0-9_./\\: -]+)>/.exec(a.slice(n));l.push({type:"str",value:m[1],pos:v,end:n+m[0].length}),i(m[0].length);continue}}let M=g1.find(o=>a.startsWith(o,n));if(!M)throw new y(`Unexpected character "${r}"`,v);l.push({type:"punct",value:M,pos:v,end:n+M.length}),i(M.length)}return l.push({type:"eof",value:"",pos:h(),end:n}),{tokens:l,comments:e}}var D=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function h1(a,c){let{tokens:l,comments:e}=s1(a,c),n=new N(l),t=[];for(;!n.at("eof");)t.push(...n.statement());return{program:{body:t},comments:e}}var N=class a{constructor(c){this.tokens=c;this.i=0}peek(c=0){return this.tokens[Math.min(this.i+c,this.tokens.length-1)]}at(c,l,e=0){let n=this.peek(e);return n.type===c&&(l===void 0||n.value===l)}isP(c,l=0){return this.at("punct",c,l)}isK(c,l=0){return this.at("id",c,l)}next(){return this.tokens[this.i++]}fail(c,l=this.peek()){let e=l.type==="eof"?"end of file":`"${l.value}"`;throw new y(`${c}, found ${e}`,l.pos)}expectP(c){return this.isP(c)||this.fail(`Expected "${c}"`),this.next()}separator(c){this.isP(c)||(this.isP(",")||this.fail(`Expected "," or "${c}"`),this.next())}ident(){let c=this.peek();return(c.type!=="id"||D.has(c.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let c=this.stmt();for(let l of c)l.end=this.last();return c}stmt(){let c=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let s=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),s.push(...this.statement());return this.next(),[{kind:"block",body:s,pos:c.pos}]}if(this.isK("module")){this.next();let s=this.ident(),h=this.params();return[{kind:"module",name:s.value,params:h,body:this.body(),pos:c.pos,namePos:s.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let s=this.ident(),h=this.params();this.expectP("=");let i=this.expr();return this.expectP(";"),[{kind:"function",name:s.value,params:h,body:i,pos:c.pos,namePos:s.pos}]}if(this.isK("use")||this.isK("include")){this.next();let s=this.peek();return s.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:s.value,include:c.value==="include",pos:c.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:c.pos}];if(this.isK("intersection_for")&&this.isP("(",1))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:c.pos,intersect:!0}];if(this.isK("if")){this.next(),this.expectP("(");let s=this.expr();this.expectP(")");let h=this.body(),i=[];return this.isK("else")&&(this.next(),i=this.body()),[{kind:"if",cond:s,then:h,else:i,pos:c.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:c.pos}];if(c.type==="id"&&this.isP("=",1)){let s=this.ident().value;this.next();let h=this.peek().pos.offset,i=this.expr(),r=this.expectP(";").pos.offset;return[{kind:"assign",name:s,value:i,span:[h,r],pos:c.pos}]}let l=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(l=this.next().value);let e=this.peek();(e.type!=="id"||D.has(e.value))&&this.fail("Expected a statement"),this.next();let n=this.args(),t=this.body();return[{kind:"call",name:e.value,args:n,children:t,modifier:l,pos:e.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let c=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),c.push(...this.statement());return this.next(),c}return this.statement()}params(){this.expectP("(");let c=[];for(;!this.isP(")");){let l=this.ident(),e=null;this.isP("=")&&(this.next(),e=this.expr()),c.push({name:l.value,default:e,pos:l.pos}),this.separator(")")}return this.next(),c}args(){this.expectP("(");let c=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let l=this.next();this.next(),c.push({name:l.value,value:this.expr(),pos:l.pos})}else c.push({name:null,value:this.expr()});this.separator(")")}return this.next(),c}assigns(){this.expectP("(");let c=[];for(;!this.isP(")");){let l=this.ident();this.expectP("="),c.push({name:l.value,value:this.expr(),pos:l.pos}),this.separator(")")}return this.next(),c}expr(){let c=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let e=this.params(),n=this.expr();return{kind:"lambda",params:e,body:n,pos:c.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let e=this.assigns(),n=this.expr();return{kind:"let",assigns:e,body:n,pos:c.pos,end:this.last()}}if(this.at("id")&&(c.value==="assert"||c.value==="echo")&&this.isP("(",1)){let e=this.i;this.next();let n={kind:"call",callee:{kind:"var",name:c.value,pos:c.pos},args:this.args(),pos:c.pos};if(this.startsValue())return{kind:"chain",check:n,body:this.expr(),pos:c.pos};this.i=e}let l=this.binary(0);if(this.isP("?")){this.next();let e=this.expr();this.expectP(":");let n=this.expr();return{kind:"ternary",cond:l,then:e,else:n,pos:c.pos}}return l}static{this.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]]}binary(c){if(c>=a.LEVELS.length)return this.unary();let l=this.binary(c+1);for(;this.at("punct")&&a.LEVELS[c].includes(this.peek().value);){let e=this.next(),n=this.binary(c+1);l={kind:"binary",op:e.value,left:l,right:n,pos:e.pos}}return l}startsValue(){let c=this.peek();return c.type==="num"||c.type==="str"||c.type==="id"?!0:this.isP("[")||this.isP("(")||this.isP("{")||this.isP("!")||this.isP("-")}unary(){if((this.isK("let")||this.isK("function"))&&this.isP("(",1))return this.expr();if(this.isP("-")||this.isP("!")||this.isP("+")){let c=this.next();return{kind:"unary",op:c.value,arg:this.unary(),pos:c.pos}}return this.power()}power(){let c=this.postfix();if(this.isP("^")){let l=this.next();return{kind:"binary",op:"^",left:c,right:this.unary(),pos:l.pos}}return c}postfix(){let c=this.primary();for(;;){let l=this.peek();if(this.isP("("))c={kind:"call",callee:c,args:this.args(),pos:c.pos};else if(this.isP("[")){this.next();let e=this.expr();this.expectP("]"),c={kind:"index",target:c,index:e,pos:l.pos}}else if(this.isP("."))this.next(),c={kind:"member",target:c,name:this.ident().value,pos:l.pos};else return c}}primary(){let c=this.peek();if(c.type==="num"){this.next();let l=/(mm|cm|m|in|ft)$/.exec(c.value);return l?{kind:"num",value:Number(c.value.slice(0,-l[1].length)),unit:l[1],pos:c.pos}:{kind:"num",value:Number(c.value),pos:c.pos}}if(c.type==="str")return this.next(),{kind:"str",value:c.value,pos:c.pos};if(c.type==="id")return c.value==="true"||c.value==="false"?(this.next(),{kind:"bool",value:c.value==="true",pos:c.pos}):c.value==="undef"?(this.next(),{kind:"undef",pos:c.pos}):(D.has(c.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:c.value,pos:c.pos});if(this.isP("(")){this.next();let l=this.expr();return this.expectP(")"),l}if(this.isP("["))return this.list();if(this.isP("{"))return this.record();this.fail("Expected a value")}record(){let c=this.expectP("{"),l=[];for(;!this.isP("}");){let e=this.ident();if(l.some(n=>n.name===e.value))throw new y(`Field ${e.value} is given twice`,e.pos);if(this.expectP("="),l.push({name:e.value,value:this.expr(),pos:e.pos}),!this.isP(","))break;this.next()}return this.expectP("}"),{kind:"record",fields:l,pos:c.pos}}list(){let c=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:c.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let l=this.expr();if(this.isP(":")){this.next();let n=null,t=this.expr();return this.isP(":")&&(this.next(),n=t,t=this.expr()),this.expectP("]"),{kind:"range",start:l,step:n,end:t,pos:c.pos}}let e=[{kind:"item",expr:l}];return this.listRest(e,c.pos)}return this.listRest([],c.pos)}listRest(c,l){if(c.length){if(this.isP("]"))return this.next(),{kind:"list",items:c,pos:l};this.separator("]")}for(;!this.isP("]");)c.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:c,pos:l}}listItem(){let c=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let l=this.assigns(),e=this.listItem();return{kind:"for",assigns:l,body:e,pos:c.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let l=this.expr();this.expectP(")");let e=this.listItem(),n=null;return this.isK("else")&&(this.next(),n=this.listItem()),{kind:"if",cond:l,then:e,else:n}}if(this.isK("let")&&this.isP("(",1)){this.next();let l=this.assigns(),e=this.listItem();return{kind:"let",assigns:l,body:e,pos:c.pos,end:this.last()}}if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let l=this.listItem();return this.expectP(")"),l}return{kind:"item",expr:this.expr()}}};var i1={"kerf/box":`// kerf/box: finger-jointed boxes.
9
9
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
10
10
 
11
11
  // Box from its outer size [width, depth, height] in the current material.
@@ -275,6 +275,70 @@ module vents(size, slot = 3, pitch = 6) {
275
275
  translate([0, ends]) circle(d = slot, $fn = 24);
276
276
  }
277
277
  }
278
+ `,"kerf/fit":`// kerf/fit: drawings scaled to a size and placed by a point of their box.
279
+ // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
280
+ //
281
+ // For any drawing whose size you don't know beforehand: an imported SVG
282
+ // path, a silhouette, a symbol, a line of text. Each measures its children
283
+ // and moves or scales them, keeping their layers, so cut, score and
284
+ // engrave stay together. They are for drawings, not for parts: scaling a
285
+ // part would scale its joints and leave its thickness.
286
+
287
+ // The fractions of a box an anchor names, [0, 0] the bottom left and
288
+ // [1, 1] the top right: "center", "left", "right", "top", "bottom",
289
+ // "top-left", "top-right", "bottom-left", "bottom-right", or [fx, fy]
290
+ function anchor_point(anchor) =
291
+ is_list(anchor) ? anchor
292
+ : let (
293
+ a = lower(anchor),
294
+ fx = contains(a, "left") ? 0 : contains(a, "right") ? 1 : 0.5,
295
+ fy = contains(a, "bottom") ? 0 : contains(a, "top") ? 1 : 0.5
296
+ )
297
+ assert(
298
+ len([for (w = split(a, "-")) if (w != "center" && w != "left" && w != "right" && w != "top" && w != "bottom") w]) == 0,
299
+ str("Unknown anchor \\"", anchor, "\\": use center, left, right, top, bottom or a corner such as top-left")
300
+ )
301
+ [fx, fy];
302
+
303
+ // The children moved so the point of their box that \`anchor\` names is at
304
+ // the origin: align("bottom-left") puts their box's corner there, and
305
+ // align() centres them.
306
+ module align(anchor = "center") {
307
+ f = anchor_point(anchor);
308
+ measure() {
309
+ children();
310
+ if (!is_undef($bounds))
311
+ translate([-($bounds[0] + f[0] * ($bounds[2] - $bounds[0])), -($bounds[1] + f[1] * ($bounds[3] - $bounds[1]))])
312
+ children();
313
+ }
314
+ }
315
+
316
+ // The children scaled to \`size\` = [w, h] (or one number for a square):
317
+ // mode = "contain" keeps their proportions and fits them inside, "stretch"
318
+ // fills the size exactly. A drawing with no width or no height (a line)
319
+ // is scaled by the other side. They are then placed by \`anchor\` as
320
+ // align() does, the box's bottom left at the origin by default.
321
+ module fit(size, mode = "contain", anchor = "bottom-left") {
322
+ s = is_list(size) ? size : [size, size];
323
+ assert(s[0] > 0 && s[1] > 0, "fit(): size must be more than 0");
324
+ assert(mode == "contain" || mode == "stretch", "fit(): mode is \\"contain\\" or \\"stretch\\"");
325
+ f = anchor_point(anchor);
326
+ measure() {
327
+ children();
328
+ if (!is_undef($bounds)) {
329
+ w = $bounds[2] - $bounds[0];
330
+ h = $bounds[3] - $bounds[1];
331
+ kx = w > 0 ? s[0] / w : undef;
332
+ ky = h > 0 ? s[1] / h : undef;
333
+ k = mode == "stretch"
334
+ ? [is_undef(kx) ? 1 : kx, is_undef(ky) ? 1 : ky]
335
+ : let (one = is_undef(kx) ? ky : is_undef(ky) ? kx : min(kx, ky)) [one, one];
336
+ if (!is_undef(k[0]))
337
+ translate([-f[0] * w * k[0], -f[1] * h * k[1]])
338
+ scale(k) translate([-$bounds[0], -$bounds[1]]) children();
339
+ }
340
+ }
341
+ }
278
342
  `,"kerf/gears":`// kerf/gears: gears, racks, lantern gears and cams for moving models.
279
343
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
280
344
  //
@@ -1478,6 +1542,330 @@ module ring_stack(diameters, hole, name = "ring", count = undef, feet = true, cl
1478
1542
  translate([-(t + clearance) / 2, -t - 1]) rect([t + clearance, h / 2 + t + 1]);
1479
1543
  }
1480
1544
  }
1545
+ `,"kerf/shapes":`// kerf/shapes: basic shapes by name, sized to a box.
1546
+ // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
1547
+ //
1548
+ // Hearts, teardrops, clouds, shields, banners, arrows and the other shapes
1549
+ // that signs, tags, ornaments and boxes are made of. Each takes its size as
1550
+ // [w, h] (or one number for both) and is centred on the origin, as circle()
1551
+ // and ellipse() are; arrows and chevrons point along x, the others stand
1552
+ // upright. A shape with one outline also has a _points() function giving
1553
+ // that outline, counter-clockwise, for offset_path(), flex_strip() and
1554
+ // anything else that works on points. Curves follow $fn when it is set,
1555
+ // and otherwise take about a point per millimetre.
1556
+
1557
+ use <kerf/fit>
1558
+
1559
+ // [w, h] from a number or a pair, checked
1560
+ function shape_size(size, what) =
1561
+ let (s = is_list(size) ? size : [size, size])
1562
+ assert(
1563
+ len(s) == 2 && is_num(s[0]) && is_num(s[1]) && s[0] > 0 && s[1] > 0,
1564
+ str(what, "(): size must be more than 0, as a number or [w, h]")
1565
+ )
1566
+ s;
1567
+
1568
+ // How many points a curve about \`length\` mm long is drawn with
1569
+ function shape_steps(length) = $fn > 0 ? max(3, $fn) : clamp(ceil(length), 32, 200);
1570
+
1571
+ // The points scaled to fill the box [w, h], centred on the origin
1572
+ function shape_fill(points, s) =
1573
+ let (b = bounds(points), c = [(b[0] + b[2]) / 2, (b[1] + b[3]) / 2], kx = s[0] / (b[2] - b[0]), ky = s[1] / (b[3] - b[1]))
1574
+ [for (p = points) [(p[0] - c[0]) * kx, (p[1] - c[1]) * ky]];
1575
+
1576
+ // The points moved so their box is centred on the origin
1577
+ function shape_centre(points) =
1578
+ let (b = bounds(points), c = [(b[0] + b[2]) / 2, (b[1] + b[3]) / 2])
1579
+ [for (p = points) p - c];
1580
+
1581
+ // Points along an arc round \`c\` of radius r, from angle a0 to a1, the first
1582
+ // and last included
1583
+ function shape_arc(c, r, a0, a1, n) = [for (i = [0:n]) let (a = a0 + (a1 - a0) * i / n) c + r * [cos(a), sin(a)]];
1584
+
1585
+ // A heart: two round lobes meeting in a dip, and a point at the bottom
1586
+ module heart(size = 20) polygon(heart_points(size));
1587
+
1588
+ // The outline of heart(), as points
1589
+ function heart_points(size = 20) =
1590
+ let (s = shape_size(size, "heart"), n = shape_steps(1.7 * (s[0] + s[1])))
1591
+ shape_fill([for (i = [0:n - 1]) let (a = -360 * i / n) [16 * pow(sin(a), 3), 13 * cos(a) - 5 * cos(2 * a) - 2 * cos(3 * a) - cos(4 * a)]], s);
1592
+
1593
+ // A drop: round at the bottom, coming to a point at the top. It must be
1594
+ // taller than it is wide.
1595
+ module teardrop(size = [14, 20]) polygon(teardrop_points(size));
1596
+
1597
+ // The outline of teardrop(), as points
1598
+ function teardrop_points(size = [14, 20]) =
1599
+ let (
1600
+ s = shape_size(size, "teardrop"),
1601
+ r = s[0] / 2,
1602
+ d = s[1] - r
1603
+ )
1604
+ assert(s[1] > s[0], "teardrop(): make it taller than it is wide")
1605
+ let (
1606
+ t = acos(r / d),
1607
+ n = shape_steps(PI * s[0])
1608
+ )
1609
+ [for (p = concat([[0, s[1]]], shape_arc([0, r], r, 90 + t, 450 - t, n))) p - [0, s[1] / 2]];
1610
+
1611
+ // An egg standing on its broad end; \`taper\` is how much narrower the top
1612
+ // is, 0 for an ellipse
1613
+ module egg(size = [16, 20], taper = 0.2) polygon(egg_points(size, taper));
1614
+
1615
+ // The outline of egg(), as points
1616
+ function egg_points(size = [16, 20], taper = 0.2) =
1617
+ let (s = shape_size(size, "egg"), n = shape_steps(1.6 * (s[0] + s[1])))
1618
+ assert(taper >= 0 && taper < 1, "egg(): taper is from 0 up to 1")
1619
+ shape_fill([for (i = [0:n - 1]) let (a = 360 * i / n) [cos(a) * (1 - taper * sin(a)), sin(a)]], s);
1620
+
1621
+ // A lens (a leaf, a petal, an eye): two arcs meeting in a point at each
1622
+ // end of its longer side, the top and bottom of a tall one, the left and
1623
+ // right of a wide one
1624
+ module lens(size = [10, 20]) polygon(lens_points(size));
1625
+
1626
+ // The outline of lens(), as points
1627
+ function lens_points(size = [10, 20]) =
1628
+ let (s = shape_size(size, "lens"))
1629
+ // A wide lens is a tall one turned a quarter turn, so its arcs stay less
1630
+ // than half circles and its ends pointed
1631
+ s[0] > s[1] ? [for (p = shape_tall_lens([s[1], s[0]])) [p[1], -p[0]]] : shape_tall_lens(s);
1632
+
1633
+ // A lens with its points at the top and the bottom, no wider than tall
1634
+ function shape_tall_lens(s) =
1635
+ let (
1636
+ g = s[0] / 2,
1637
+ R = g / 2 + s[1] * s[1] / (8 * g),
1638
+ t = asin(min(1, s[1] / 2 / R)),
1639
+ // even, so a point falls on the widest place
1640
+ n = 2 * max(2, ceil(shape_steps(PI * (s[0] + s[1]) / 2) / 4))
1641
+ )
1642
+ concat(shape_arc([g - R, 0], R, -t, t, n), [for (p = shape_arc([R - g, 0], R, 180 - t, 180 + t, n)) if (abs(p[1]) < s[1] / 2 - 1e-9) p]);
1643
+
1644
+ // A crescent moon \`d\` across, open to the right, \`thickness\` at its widest
1645
+ module crescent(d = 20, thickness) polygon(crescent_points(d, thickness));
1646
+
1647
+ // The outline of crescent(), as points
1648
+ function crescent_points(d = 20, thickness) =
1649
+ let (
1650
+ R = d / 2,
1651
+ t = is_undef(thickness) ? d / 4 : thickness
1652
+ )
1653
+ assert(is_num(d) && d > 0, "crescent(): d must be more than 0")
1654
+ assert(t > 0 && t < d, "crescent(): thickness must be more than 0 and less than d")
1655
+ let (
1656
+ Y = sqrt(R * R - t * t / 4),
1657
+ a = atan2(Y, t / 2),
1658
+ b = atan2(Y, -t / 2),
1659
+ n = shape_steps(PI * d)
1660
+ )
1661
+ shape_centre(concat(
1662
+ shape_arc([0, 0], R, a, 360 - a, n),
1663
+ [for (i = [1:n - 1]) let (q = 360 - b - (360 - 2 * b) * i / n) [t, 0] + R * [cos(q), sin(q)]]
1664
+ ));
1665
+
1666
+ // A rectangle with round ends (a stadium, a pill)
1667
+ module capsule(size = [30, 10]) polygon(capsule_points(size));
1668
+
1669
+ // The outline of capsule(), as points
1670
+ function capsule_points(size = [30, 10]) =
1671
+ let (
1672
+ s = shape_size(size, "capsule"),
1673
+ r = min(s) / 2,
1674
+ c = s[0] >= s[1] ? [s[0] / 2 - r, 0] : [0, s[1] / 2 - r],
1675
+ a = s[0] >= s[1] ? -90 : 0,
1676
+ n = ceil(shape_steps(PI * r * 2) / 2)
1677
+ )
1678
+ concat(shape_arc(c, r, a, a + 180, n), shape_arc(-c, r, a + 180, a + 360, n));
1679
+
1680
+ // A diamond (a rhombus) touching the middle of each side of its box
1681
+ module diamond(size = [14, 20]) polygon(diamond_points(size));
1682
+
1683
+ // The outline of diamond(), as points
1684
+ function diamond_points(size = [14, 20]) =
1685
+ let (s = shape_size(size, "diamond") / 2) [[0, -s[1]], [s[0], 0], [0, s[1]], [-s[0], 0]];
1686
+
1687
+ // A regular polygon with \`n\` corners \`r\` from its centre, as
1688
+ // regular_polygon(n, r), each rounded with radius \`round\`
1689
+ module rounded_polygon(n = 6, r = 10, round = 2) polygon(rounded_polygon_points(n, r, round));
1690
+
1691
+ // The outline of rounded_polygon(), as points
1692
+ function rounded_polygon_points(n = 6, r = 10, round = 2) =
1693
+ assert(is_num(n) && n >= 3, "rounded_polygon(): n must be 3 or more")
1694
+ assert(r > 0, "rounded_polygon(): r must be more than 0")
1695
+ assert(round >= 0 && round < r * cos(180 / n), "rounded_polygon(): round must be less than the distance to a side")
1696
+ let (
1697
+ k = floor(n),
1698
+ c = r - round / cos(180 / k),
1699
+ m = round > 0 ? max(2, ceil(shape_steps(2 * PI * round) / k)) : 0
1700
+ )
1701
+ [for (i = [0:k - 1]) let (a = 360 * i / k)
1702
+ each (round > 0 ? shape_arc(c * [cos(a), sin(a)], round, a - 180 / k, a + 180 / k, m) : [r * [cos(a), sin(a)]])];
1703
+
1704
+ // A shield: a flat top, straight sides, curving in to a point at the
1705
+ // bottom. \`point\` is how much of the height the curved part takes.
1706
+ module shield(size = [16, 20], point = 0.55) polygon(shield_points(size, point));
1707
+
1708
+ // The outline of shield(), as points
1709
+ function shield_points(size = [16, 20], point = 0.55) =
1710
+ let (s = shape_size(size, "shield"), w = s[0] / 2, top = s[1] / 2)
1711
+ assert(point > 0 && point <= 1, "shield(): point is more than 0, up to 1")
1712
+ let (
1713
+ yk = top - s[1] * (1 - point),
1714
+ n = shape_steps(s[1] * point),
1715
+ side = function(u) [w * (1 - u * u), yk - (yk + top) * u]
1716
+ )
1717
+ concat(
1718
+ [[-w, top]],
1719
+ [for (i = [0:n]) let (p = side(i / n)) [-p[0], p[1]]],
1720
+ [for (i = [n - 1:-1:0]) side(i / n)],
1721
+ [[w, top]]
1722
+ );
1723
+
1724
+ // An arrow pointing along x: \`size\` is its length and the head's width,
1725
+ // \`shaft\` the shaft's width and \`head\` the head's length
1726
+ module arrow(size = [30, 14], shaft, head) polygon(arrow_points(size, shaft, head));
1727
+
1728
+ // The outline of arrow(), as points
1729
+ function arrow_points(size = [30, 14], shaft, head) =
1730
+ let (
1731
+ s = shape_size(size, "arrow"),
1732
+ L = s[0] / 2,
1733
+ W = s[1] / 2,
1734
+ sw = is_undef(shaft) ? s[1] / 3 : shaft,
1735
+ hl = is_undef(head) ? min(s[0] / 2, s[1]) : head
1736
+ )
1737
+ assert(sw > 0 && sw <= s[1], "arrow(): shaft must be more than 0 and no wider than the head")
1738
+ assert(hl > 0 && hl <= s[0], "arrow(): head must be more than 0 and no longer than the arrow")
1739
+ [[-L, -sw / 2], [L - hl, -sw / 2], [L - hl, -W], [L, 0], [L - hl, W], [L - hl, sw / 2], [-L, sw / 2]];
1740
+
1741
+ // A chevron (>) pointing along x, \`thickness\` across each arm along x
1742
+ module chevron(size = [12, 20], thickness) polygon(chevron_points(size, thickness));
1743
+
1744
+ // The outline of chevron(), as points
1745
+ function chevron_points(size = [12, 20], thickness) =
1746
+ let (
1747
+ s = shape_size(size, "chevron"),
1748
+ w = s[0] / 2,
1749
+ h = s[1] / 2,
1750
+ t = is_undef(thickness) ? s[0] / 2 : thickness
1751
+ )
1752
+ assert(t > 0 && t < s[0], "chevron(): thickness must be more than 0 and less than the width")
1753
+ [[-w, -h], [-w + t, -h], [w, 0], [-w + t, h], [-w, h], [w - t, 0]];
1754
+
1755
+ // A banner with a V cut \`notch\` deep into each end
1756
+ module banner(size = [60, 16], notch) polygon(banner_points(size, notch));
1757
+
1758
+ // The outline of banner(), as points
1759
+ function banner_points(size = [60, 16], notch) =
1760
+ let (
1761
+ s = shape_size(size, "banner"),
1762
+ w = s[0] / 2,
1763
+ h = s[1] / 2,
1764
+ v = is_undef(notch) ? s[1] / 3 : notch
1765
+ )
1766
+ assert(v >= 0 && v < s[0] / 2, "banner(): notch must be less than half the width")
1767
+ [[-w, -h], [w, -h], [w - v, 0], [w, h], [-w, h], [-w + v, 0]];
1768
+
1769
+ // A house: walls and a pitched roof \`roof\` tall
1770
+ module house(size = [20, 24], roof) polygon(house_points(size, roof));
1771
+
1772
+ // The outline of house(), as points
1773
+ function house_points(size = [20, 24], roof) =
1774
+ let (
1775
+ s = shape_size(size, "house"),
1776
+ w = s[0] / 2,
1777
+ h = s[1] / 2,
1778
+ rf = is_undef(roof) ? s[0] / 2 : roof
1779
+ )
1780
+ assert(rf > 0 && rf < s[1], "house(): roof must be more than 0 and less than the height")
1781
+ [[-w, -h], [w, -h], [w, h - rf], [0, h], [-w, h - rf]];
1782
+
1783
+ // A gift or luggage tag: its left end's corners cut off by \`cut\`, with a
1784
+ // hole \`hole\` across near that end (0 for none)
1785
+ module tag(size = [50, 25], cut, hole) {
1786
+ s = shape_size(size, "tag");
1787
+ hd = is_undef(hole) ? s[1] / 4 : hole;
1788
+ difference() {
1789
+ polygon(tag_points(size, cut));
1790
+ if (hd > 0) translate([-s[0] / 2 + s[1] / 3, 0]) circle(d = hd);
1791
+ }
1792
+ }
1793
+
1794
+ // The outline of tag(), without its hole, as points
1795
+ function tag_points(size = [50, 25], cut) =
1796
+ let (
1797
+ s = shape_size(size, "tag"),
1798
+ w = s[0] / 2,
1799
+ h = s[1] / 2,
1800
+ c = is_undef(cut) ? s[1] / 4 : cut
1801
+ )
1802
+ assert(c >= 0 && c < min(s[0], s[1] / 2), "tag(): cut must be less than half the height")
1803
+ [[-w + c, -h], [w, -h], [w, h], [-w + c, h], [-w, h - c], [-w, -h + c]];
1804
+
1805
+ // A ring \`d\` across, its band \`width\` wide
1806
+ module ring(d = 20, width = 3) {
1807
+ assert(is_num(d) && d > 0, "ring(): d must be more than 0");
1808
+ assert(width > 0 && width < d / 2, "ring(): width must be more than 0 and less than half of d");
1809
+ difference() {
1810
+ circle(d = d);
1811
+ circle(d = d - 2 * width);
1812
+ }
1813
+ }
1814
+
1815
+ // A circle \`d\` across with \`n\` round scallops round its edge
1816
+ module scalloped(d = 30, n = 16) {
1817
+ assert(is_num(d) && d > 0, "scalloped(): d must be more than 0");
1818
+ assert(n >= 3, "scalloped(): n must be 3 or more");
1819
+ k = sin(180 / n);
1820
+ rb = d / 2 / (1 + k);
1821
+ union() {
1822
+ circle(r = rb);
1823
+ for (i = [0:n - 1]) rotate(360 * i / n) translate([rb, 0]) circle(r = rb * k);
1824
+ }
1825
+ }
1826
+
1827
+ // A flower \`d\` across with \`petals\` petals round a round middle \`center\`
1828
+ // of d across
1829
+ module flower(d = 30, petals = 6, center = 0.35) {
1830
+ assert(is_num(d) && d > 0, "flower(): d must be more than 0");
1831
+ assert(petals >= 3, "flower(): petals must be 3 or more");
1832
+ assert(center > 0 && center < 1, "flower(): center is a part of d, more than 0 and less than 1");
1833
+ pl = d / 2 * (1 - center / 3);
1834
+ rc = d / 2 - pl / 2;
1835
+ pw = min(pl, 2.2 * rc * sin(180 / petals));
1836
+ union() {
1837
+ circle(d = d * center);
1838
+ for (i = [0:petals - 1]) rotate(90 + 360 * i / petals) translate([rc, 0]) ellipse(d = [pl, pw]);
1839
+ }
1840
+ }
1841
+
1842
+ // A cloud: a flat bottom with \`puffs\` round puffs along the top
1843
+ module cloud(size = [40, 24], puffs = 3) {
1844
+ s = shape_size(size, "cloud");
1845
+ assert(puffs >= 1, "cloud(): puffs must be 1 or more");
1846
+ fit(s, mode = "stretch", anchor = "center") union() {
1847
+ translate([0.08, 0]) rect([0.84, 0.3], r = 0.15);
1848
+ for (i = [0:puffs - 1]) let (f = (i + 0.5) / puffs, rise = sin(180 * f), r = (0.3 + 0.2 * rise) / max(1, puffs / 2.2))
1849
+ translate([0.12 + 0.76 * f, 0.18 + 0.32 * rise]) circle(r = r, $fn = shape_steps(150));
1850
+ translate([0.12, 0.17]) circle(r = 0.12, $fn = shape_steps(80));
1851
+ translate([0.88, 0.17]) circle(r = 0.12, $fn = shape_steps(80));
1852
+ }
1853
+ }
1854
+
1855
+ // A speech bubble: a rounded box with a tail \`tail\` long at its bottom
1856
+ // left (mirror() it for the right). The tail is part of \`size\`.
1857
+ module speech_bubble(size = [40, 30], r, tail) {
1858
+ s = shape_size(size, "speech_bubble");
1859
+ th = is_undef(tail) ? s[1] / 4 : tail;
1860
+ assert(th > 0 && th < s[1] / 2, "speech_bubble(): tail must be more than 0 and less than half the height");
1861
+ rr = is_undef(r) ? min(s[0], s[1] - th) / 5 : r;
1862
+ bh = s[1] - th;
1863
+ yb = -s[1] / 2 + th;
1864
+ union() {
1865
+ translate([-s[0] / 2, yb]) rect([s[0], bh], r = rr);
1866
+ polygon([[-s[0] * 0.3, yb + min(bh / 2, rr + 1)], [-s[0] * 0.3 + s[0] / 5, yb + min(bh / 2, rr + 1)], [-s[0] * 0.38, -s[1] / 2]]);
1867
+ }
1868
+ }
1481
1869
  `,"kerf/sizes":`// kerf/sizes: paper, card and photo sizes, in millimetres, for holders,
1482
1870
  // folders, frames and boxes made to fit them.
1483
1871
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
@@ -1556,6 +1944,61 @@ function lookup_alias(name, aliases) = let (k = lower(name), hit = [for (e = ali
1556
1944
  len(hit) ? hit[0] : name;
1557
1945
  // The names in a table, for messages
1558
1946
  function size_names(table) = join([for (e = table) e[0]], ", ");
1947
+ `,"kerf/stand":`// kerf/stand: a sign, a photo or a calendar standing in a base.
1948
+ // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
1949
+ //
1950
+ // The panel has tabs along its bottom edge that go through slots in a
1951
+ // base, upright or leaning back. stand() makes both parts and puts them
1952
+ // together; stand_tabs() and stand_slots() are the two halves of the joint
1953
+ // for a base of your own, and match whenever they are given the same
1954
+ // width, count, tab and lean. The base is $thickness thick, as the panel.
1955
+
1956
+ use <kerf/tabs>
1957
+
1958
+ // The panel \`width\` wide drawn by the children, its bottom edge on y = 0
1959
+ // from x = 0, standing in a base \`depth\` deep and \`margin\` wider than it
1960
+ // on each side, leaning back by \`lean\` degrees. Its back face meets the
1961
+ // base \`back\` from the front, half way by default. The parts are \`name\`
1962
+ // and "\`name\` stand".
1963
+ module stand(width, depth = 40, count = undef, tab = undef, lean = 0, margin = 10, back = undef, r = 3, clearance = 0.1, name = "Sign") {
1964
+ t = $thickness;
1965
+ assert(width > 0, "stand(): width must be more than 0");
1966
+ assert(lean >= 0 && lean < 45, "stand(): lean is from 0 up to 45 degrees");
1967
+ ys = is_undef(back) ? depth / 2 : back;
1968
+ assert(ys > 0 && ys < depth, "stand(): back must be inside the base's depth");
1969
+ part(name, at = [0, ys, t], rotate = [90 - lean, 0, 0]) {
1970
+ children();
1971
+ stand_tabs(width, count, tab, lean);
1972
+ }
1973
+ part(str(name, " stand"), at = [0, 0, 0]) difference() {
1974
+ translate([-margin, 0]) rect([width + 2 * margin, depth], r = r);
1975
+ translate([0, ys]) stand_slots(width, count, tab, lean, clearance);
1976
+ }
1977
+ }
1978
+
1979
+ // Tabs for the bottom edge of a panel \`width\` wide, x from 0 to \`width\`,
1980
+ // hanging below y = 0 far enough to go through a base $thickness thick
1981
+ // when the panel leans back by \`lean\` degrees. Each is \`tab\` wide, half
1982
+ // the space between tabs by default; \`count\` is one for every 50 mm.
1983
+ module stand_tabs(width, count = undef, tab = undef, lean = 0) {
1984
+ at = tab_positions(width, count);
1985
+ w = is_undef(tab) ? width / (2 * len(at)) : tab;
1986
+ d = $thickness / cos(lean);
1987
+ for (x = at) translate([x - w / 2, -d]) rect([w, d + 0.01]);
1988
+ }
1989
+
1990
+ // The slots in a base for stand_tabs() with the same width, count, tab
1991
+ // and lean, x from 0 to \`width\`, for a panel whose back face meets the top
1992
+ // of the base on y = 0, standing towards -y and leaning back towards +y.
1993
+ // \`clearance\` is added to each slot's width and depth.
1994
+ module stand_slots(width, count = undef, tab = undef, lean = 0, clearance = 0.1) {
1995
+ at = tab_positions(width, count);
1996
+ w = is_undef(tab) ? width / (2 * len(at)) : tab;
1997
+ t = $thickness;
1998
+ // from the back face at the top to the tab's front corner at its end
1999
+ across = t * cos(lean) + t * tan(lean);
2000
+ for (x = at) translate([x, -across / 2]) rect([w + clearance, across + clearance], center = true);
2001
+ }
1559
2002
  `,"kerf/symbols":`// kerf/symbols: 867 pictograms by name, for engraving and cutting.
1560
2003
  // The library code: Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or
1561
2004
  // MyLaserTools commercial licence. The symbols come from open icon sets,
@@ -1568,14 +2011,29 @@ function size_names(table) = join([for (e = table) e[0]], ", ");
1568
2011
  // symbol_names() lists them: "heart", "star", "paw", "tree" and the like.
1569
2012
  // box = "grid" sizes and places it by its icon set's grid (24 x 24 for
1570
2013
  // Material Design Icons) instead, so icons of one set line up as drawn.
1571
- module symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn") {
2014
+ // solid = true cuts it as one silhouette, gaps narrower than 2 * close
2015
+ // closed and its holes filled, with the drawing's detail engraved on it:
2016
+ // a pictogram drawn as separate strokes (a moon and stars, yarn) cut out
2017
+ // in one piece. bridge = w also joins pieces too far apart to close, by
2018
+ // strips w wide.
2019
+ module symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close = undef, bridge = undef) {
1572
2020
  assert(box == "drawn" || box == "grid", "box is \\"drawn\\" or \\"grid\\"");
1573
2021
  s = symbol_entry(name);
1574
2022
  vb = box == "grid" ? s[5] : s[2];
1575
2023
  k = size / max(vb[2], vb[3]);
1576
- translate(center ? [0, 0] : [vb[2] * k / 2, vb[3] * k / 2])
2024
+ module drawn() translate(center ? [0, 0] : [vb[2] * k / 2, vb[3] * k / 2])
1577
2025
  scale([k, -k]) translate([-vb[0] - vb[2] / 2, -vb[1] - vb[3] / 2])
1578
2026
  path(s[4], fill = fill, close = true);
2027
+ r = is_undef(close) ? size / 30 : close;
2028
+ module silhouette() if (is_undef(bridge)) fill_holes() close(r) drawn();
2029
+ else join_islands(bridge) fill_holes() close(r) drawn();
2030
+ if (solid) {
2031
+ silhouette();
2032
+ engrave() difference() {
2033
+ silhouette();
2034
+ drawn();
2035
+ }
2036
+ } else drawn();
1579
2037
  }
1580
2038
 
1581
2039
  // [width, height] of what a symbol draws when it is \`size\` across its
@@ -2556,10 +3014,10 @@ module tab_rect(size, edges = true, count = undef, width = undef) {
2556
3014
  if (e[2]) translate([w, h]) rotate(180) tabs(w, count, width);
2557
3015
  if (e[3]) translate([0, h]) rotate(270) tabs(h, count, width);
2558
3016
  }
2559
- `};var P="0.3";var u="kerf.json",C="kerf.lock",y="kerf_libraries",x=20<<20,R=2e3,X=/^[a-z0-9][a-z0-9_-]{0,63}$/,H1=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/,k1=/^(readme|licen[cs]e|copying|notice|changelog)(\.[a-z]+)?$/i,W=class extends Error{},c1=a=>{try{return m1(a).isFile()}catch{return!1}},H=a=>{try{return m1(a).isDirectory()}catch{return!1}},S=(a,c)=>a&&Object.prototype.hasOwnProperty.call(a,c)?a[c]:void 0,M=a=>{throw new W(a)};function r1(a,c){return(typeof a!="string"||!X.test(a))&&M(`${c} "${a}" is not a library name: use lowercase letters, digits, - and _`),a==="kerf"&&M(`${c}: "kerf" is the standard library's name`),a}function l1(a,c){(!a||typeof a!="object"||Array.isArray(a))&&M(`${c} must hold a JSON object`);let l=a;for(let n of["name","version","description","license","language"])l[n]!==void 0&&typeof l[n]!="string"&&M(`${c}: "${n}" must be a string`);l.name!==void 0&&r1(l.name,`${c}: name`),l.version!==void 0&&!H1.test(l.version)&&M(`${c}: "version" must look like 1.2.0, not "${l.version}"`),l.language!==void 0&&!/^\d+\.\d+$/.test(l.language)&&M(`${c}: "language" must look like ${P}, not "${l.language}"`),l.sheet!==void 0&&!(Array.isArray(l.sheet)&&l.sheet.length===2&&l.sheet.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0))&&M(`${c}: "sheet" must be [width, height] in mm, like [600, 400]`);let e=l.libraries??{};(!e||typeof e!="object"||Array.isArray(e))&&M(`${c}: "libraries" must be an object of name: source`);for(let[n,t]of Object.entries(e))r1(n,`${c}: library`),typeof t!="string"&&M(`${c}: the source of ${n} must be a string`);return{...l,libraries:{...e}}}function a1(a,c){let l;try{l=T(a,"utf8")}catch{return M(`${c} was not found`)}try{return JSON.parse(l)}catch(e){return M(`${c} is not valid JSON: ${e.message}`)}}function k(a,c=u){return l1(a1(d(a,u),c),c)}function M1(a){if(!I(d(a,C)))return;let c=a1(d(a,C),C);(c?.lockVersion!==1||!c.libraries||typeof c.libraries!="object")&&M(`${C} is not a kerf.lock this kerf can read. Delete it and run kerf install.`);for(let[l,e]of Object.entries(c.libraries))(!e||["source","resolved","integrity"].some(n=>typeof e[n]!="string"))&&M(`${C}: the entry for ${l} is damaged. Remove it and run kerf install.`);return c}function d1(a){for(let c=O(a);;){if(c1(d(c,u)))return c;let l=Y(c);if(l===c)return;c=l}}function n1(a){try{return k(a).name}catch{return}}function V1(a,c,l=c1){let e=(h,s)=>[d(h,s),d(h,s+".kerf")].find(i=>l(i));if(E(c))return[c,c+".kerf"].find(h=>l(h));let n=c.indexOf("/"),t=n>0?d1(a):void 0;if(t){let h=c.slice(0,n);if(h===n1(t))return e(t,c.slice(n+1));if(H(d(t,y,h)))return e(d(t,y),c)}return e(a,c)}function Q1(a){let c=Y(O(a));return l=>{let e=V1(c,l);return e===void 0?void 0:T(e,"utf8")}}function J1(a,c=200){let l=d1(a);if(!l)return[];let e=[],n=(s,i)=>{for(let o of[...z1(s,3)].sort()){if(e.length>=c)return;o.endsWith(".kerf")&&e.push(i+o.slice(0,-5))}},t=n1(l);t&&n(l,t+"/");let h=d(l,y);if(H(h))for(let s of Q(h).sort())X.test(s)&&H(d(h,s))&&n(d(h,s),s+"/");return e}function z1(a,c=1/0){let l=[],e=(n,t,h)=>{let s;try{s=Q(n,{withFileTypes:!0})}catch{return}for(let i of s){if(i.name.startsWith(".")||i.name==="node_modules"||i.name===y)continue;let o=t?`${t}/${i.name}`:i.name;i.isDirectory()?h<c&&e(d(n,i.name),o,h+1):i.isFile()&&(l.push(o),l.length>R&&M(`${a} has more than ${R} files`))}};return e(a,"",0),l}function G(a,c=()=>!0){let l=new Map;for(let e of z1(a))c(e)&&l.set(e,T(d(a,...e.split("/"))));return l}var e1=a=>a===u||a.endsWith(".kerf")||!a.includes("/")&&k1.test(a);function F(a){let c=b1("sha256");for(let l of[...a.keys()].sort()){let e=Buffer.from(a.get(l).toString("utf8").replace(/\r\n/g,`
2560
- `));c.update(`${l}\0${e.length}\0`),c.update(e)}return"sha256-"+c.digest("base64")}function o1(a){return a.kind==="folder"?"folder:"+(process.platform==="win32"?a.path.toLowerCase():a.path):a.kind==="github"?`github:${a.owner}/${a.repo}`.toLowerCase()+`@${a.ref}`:a.url}function Z(a,c){let l=/^github:([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@(\S+))?$/.exec(a);if(l)return{kind:"github",owner:l[1],repo:l[2],ref:l[3]??"HEAD"};if(/^https?:\/\//i.test(a)){let n;try{n=new URL(a)}catch{return M(`${a} is not a link`)}return n.protocol==="http:"&&!["localhost","127.0.0.1","[::1]"].includes(n.hostname)&&M(`Use https:// to download ${a}`),{kind:"url",url:a}}let e=a.startsWith("file:")?a.slice(5):a;return e.startsWith("./")||e.startsWith("../")||E(e)?{kind:"folder",path:O(c,e)}:M(`"${a}" is not a library source. Use github:owner/repo@tag, an https:// link to a .tar.gz, or a folder like ./my-library`)}async function q1(a,c){let l;try{l=await c(a)}catch(s){let i=s;return M(`Could not download ${a}: ${i.cause?.message??i.message}`)}l.ok||M(`Could not download ${a}: HTTP ${l.status}`+(l.status===404?". Check the name and the tag, and that it is public.":""));let e=()=>M(`${a} is larger than ${x>>20} MB`);if(Number(l.headers?.get("content-length"))>x&&e(),!l.body){let s=Buffer.from(await l.arrayBuffer());return s.length>x?e():s}let n=l.body.getReader(),t=[],h=0;for(;;){let{done:s,value:i}=await n.read();if(s||!i)break;h+=i.length,h>x&&(await n.cancel().catch(()=>{}),e()),t.push(i)}return Buffer.concat(t)}function x1(a,c){let l;try{l=y1(a,{maxOutputLength:5*x})}catch{return M(`${c} is not a .tar.gz file`)}let e=new Map,n,t={},h;for(let s=0;s+512<=l.length;){let i=l.subarray(s,s+512);if(i.every(g=>g===0))break;let o=(g,L)=>{let w=i.subarray(g,g+L),V=w.indexOf(0);return w.subarray(0,V<0?L:V).toString("utf8")},m=parseInt(o(124,12).trim()||"0",8);m>=0||M(`${c} is damaged`);let z=o(156,1)||"0",r=l.subarray(s+512,s+512+m);if(s+=512+Math.ceil(m/512)*512,z==="x"||z==="g"){let g=_1(r);z==="g"?n=g.comment??n:t=g;continue}if(z==="L"){h=r.toString("utf8").replace(/\0+$/,"");continue}let v=o(345,155),p=t.path??h??(v?v+"/":"")+o(0,100);t={},h=void 0,(z==="0"||z==="7")&&e.set(p,Buffer.from(r)),e.size>R&&M(`${c} has more than ${R} files`)}return{files:e,commit:n}}function _1(a){let c={};for(let l=0;l<a.length;){let e=a.indexOf(32,l),n=parseInt(a.subarray(l,e).toString(),10);if(!(n>0)||e<0)break;let t=a.subarray(e+1,l+n-1).toString("utf8"),h=t.indexOf("=");h>0&&(c[t.slice(0,h)]=t.slice(h+1)),l+=n}return c}function v1(a,c){let l=new Map;for(let[t,h]of a){let s=t.replace(/^\.\//,""),i=s.split("/");(E(s)||s.includes("\\")||s.includes(":")||i.some(o=>o===".."||o===""))&&M(`${c} holds a file outside its folder: ${t}`),l.set(s,h)}let e="";if(!l.has(u)){let t=new Set([...l.keys()].map(h=>h.split("/")[0]));t.size===1&&(e=[...t][0]+"/")}let n=new Map;for(let[t,h]of l){if(!t.startsWith(e))continue;let s=t.slice(e.length);s.split("/").some(i=>i.startsWith(".")||i===y||i==="node_modules")||e1(s)&&n.set(s,h)}return n.has(u)||M(`${c} has no kerf.json at its top. Is it a KerfScript library?`),n}var S1=(a,c)=>{let[l,e]=a.split(".").map(Number),[n,t]=c.split(".").map(Number);return l>n||l===n&&e>t};async function f1(a,c,l,e,n){let t=Z(a,c),h,s;if(t.kind==="folder")c1(d(t.path,u))||M(`${a}: no kerf.json in ${t.path}. Is it a KerfScript library?`),h=v1(G(t.path,e1),a),s=L1(l,t.path).split(A1).join("/")||".",!s.startsWith(".")&&!E(s)&&(s="./"+s);else{let o=t.kind==="github"?`https://github.com/${t.owner}/${t.repo}/archive/${t.ref}.tar.gz`:t.url,m=n.get(o)??await q1(o,e);n.set(o,m);let z=x1(m,a);h=v1(z.files,a),s=t.kind==="github"&&/^[0-9a-f]{40}$/.test(z.commit??"")?`https://github.com/${t.owner}/${t.repo}/archive/${z.commit}.tar.gz`:o}let i=l1(JSON.parse(h.get(u).toString("utf8")),`the kerf.json of ${a}`);return i.name||M(`${a}: its kerf.json has no "name", so it is not a library`),i.language&&S1(i.language,P)&&M(`${i.name} needs KerfScript language ${i.language} or later, and this kerf has ${P}. Update kerf.`),{manifest:i,files:h,resolved:s,integrity:F(h)}}function T1(a,c){J(a,{recursive:!0,force:!0});for(let[l,e]of c){let n=d(a,...l.split("/"));w1(Y(n),{recursive:!0}),_(n,e)}}var j1=a=>{let c=[...a].sort(([l],[e])=>l<e?-1:1);return JSON.stringify({lockVersion:1,libraries:Object.fromEntries(c)},null,2)+`
2561
- `};async function $1(a,c={}){let l=c.fetch??globalThis.fetch,e=c.log??(()=>{}),n=c.cache??new Map,t=k(a),h=M1(a),s=new Map,i=Object.entries(t.libraries).map(([r,v])=>({name:r,source:v,base:a,from:u})),o=d(a,y);for(;i.length;){let{name:r,source:v,base:p,from:g}=i.shift(),L=Z(v,p),w=L.kind==="folder",V=w?`${v} (${L.path})`:v,j=s.get(r);if(j){j.at!==o1(L)&&!S(t.libraries,r)&&M(`${g} uses ${r} from ${V}, and ${j.from} uses it from ${j.shown}. Add ${r} to kerf.json with the source to use.`);continue}let B=S(h?.libraries,r),b=B?.source===v&&(!w||O(a,B.resolved)===L.path)?B:void 0;c.frozen&&!b&&M(`kerf.lock does not pin ${r} from ${v}. Run kerf install without --frozen.`);let $=d(o,r),q;if(b&&!w&&H($)&&F(G($))===b.integrity)q=b;else{let f=await f1(b&&!w?b.resolved:v,w?p:a,a,l,n);f.manifest.name!==r&&M(`${v} is the library "${f.manifest.name}", so ${g} must call it ${f.manifest.name}, not ${r}`),b&&f.integrity!==b.integrity&&(!w||c.frozen)&&M(w?`${r} in ${v} changed since kerf.lock pinned it. Run kerf install without --frozen.`:`${r} from ${b.resolved} no longer matches kerf.lock. If you trust the change, remove ${r} from kerf.lock and run kerf install again.`),T1($,f.files),q={source:v,...f.manifest.version?{version:f.manifest.version}:{},resolved:f.resolved,integrity:f.integrity},(!b||b.integrity!==f.integrity||!w)&&e(`${b?"Restored":"Installed"} ${r}${q.version?" "+q.version:""} from ${v}`)}s.set(r,{entry:q,at:o1(L),shown:V,from:g});let t1=L.kind==="folder"?L.path:void 0;for(let[f,K]of Object.entries(k($,`${y}/${r}/${u}`).libraries))Z(K,a).kind==="folder"&&!t1&&M(`${r} uses ${f} from the folder ${K}: a published library needs github: or https: sources`),i.push({name:f,source:K,base:t1??a,from:r})}let m=j1(new Map([...s].map(([r,v])=>[r,v.entry]))),z=I(d(a,C))?T(d(a,C),"utf8"):"";if(c.frozen&&m!==z.replace(/\r\n/g,`
2562
- `)&&M("kerf.lock is out of date. Run kerf install without --frozen."),H(o))for(let r of Q(o,{withFileTypes:!0}))r.isDirectory()&&X.test(r.name)&&!s.has(r.name)&&(J(d(o,r.name),{recursive:!0,force:!0}),e(`Removed ${r.name}`));return m!==z.replace(/\r\n/g,`
2563
- `)&&_(d(a,C),m),JSON.parse(m)}function Y1(a){let c=k(a),l=M1(a),e=Object.keys(c.libraries);if(!l)return e.length?["kerf.lock is missing. Run kerf install."]:[];let n=[],t=new Set,h=[...e];for(;h.length;){let s=h.shift();if(t.has(s))continue;t.add(s);let i=S(l.libraries,s);if(!i){n.push(`${s} is not in kerf.lock. Run kerf install.`);continue}e.includes(s)&&i.source!==c.libraries[s]&&n.push(`kerf.json takes ${s} from ${c.libraries[s]}, and kerf.lock from ${i.source}. Run kerf install.`);let o=d(a,y,s);if(!H(o)){n.push(`${s} is not in ${y}. Run kerf install.`);continue}F(G(o))!==i.integrity&&n.push(`The files in ${y}/${s} differ from kerf.lock. Run kerf install.`);try{h.push(...Object.keys(k(o).libraries))}catch(m){n.push(m.message)}}for(let s of Object.keys(l.libraries))t.has(s)||n.push(`kerf.lock pins ${s}, which nothing uses any more.`);return n}function P1(a,c){let l=d(a,u),e=I(l)?a1(l,u):{};l1(e,u);let n={...e.libraries??{}};return c(n),e.libraries=n,{file:l,before:I(l)?T(l,"utf8"):void 0,raw:e}}async function u1(a,c,l){let{file:e,before:n,raw:t}=P1(a,c);_(e,JSON.stringify(t,null,2)+`
2564
- `);try{return await $1(a,l)}catch(h){throw n===void 0?J(e,{force:!0}):_(e,n),h}}async function X1(a,c,l={}){let e=new Map,t=(await f1(c,a,a,l.fetch??globalThis.fetch,e)).manifest.name;t===n1(a)&&M(`This project is the library ${t}; it cannot use itself`);let h=await u1(a,s=>void(s[t]=c),{...l,cache:e});return{name:t,lock:h}}async function c0(a,c,l={}){return u1(a,e=>{S(e,c)===void 0&&M(`kerf.json has no library named ${c}`),delete e[c]},l)}function U(a,c=[]){if(Array.isArray(a))for(let l of a)U(l,c);else if(a&&typeof a=="object"){let l=a;if(l.kind==="use"&&typeof l.path=="string")c.push({path:l.path,line:l.pos.line});else for(let e of Object.values(l))U(e,c)}return c}function I1(a){let c=[];for(let[l,e]of a){let n=Buffer.alloc(512),t=l,h="";if(Buffer.byteLength(t)>100){let i=l.lastIndexOf("/",155);(i<0||Buffer.byteLength(l.slice(i+1))>100)&&M(`${l}: the path is too long to pack`),h=l.slice(0,i),t=l.slice(i+1)}n.write(t,0,100),n.write("0000644\0",100),n.write("0000000\0",108),n.write("0000000\0",116),n.write(e.length.toString(8).padStart(11,"0")+"\0",124),n.write("00000000000\0",136),n.fill(32,148,156),n.write("0",156),n.write("ustar\0",257),n.write("00",263),n.write(h,345,155);let s=0;for(let i of n)s+=i;n.write(s.toString(8).padStart(6,"0")+"\0 ",148),c.push(n,e,Buffer.alloc((512-e.length%512)%512))}return c.push(Buffer.alloc(1024)),C1(Buffer.concat(c),{level:9})}function l0(a,c){let l=k(a),e=l.name??M('kerf.json needs a "name" to pack a library'),n=l.version??M('kerf.json needs a "version", like 1.0.0'),t=G(a,e1),h=[];for(let[m,z]of Object.entries(l.libraries))Z(z,a).kind==="folder"&&h.push(`kerf.json: ${m} comes from a folder; a published library needs github: or https: sources`);let s=m=>t.has(m)||t.has(m+".kerf");for(let[m,z]of t){if(!m.endsWith(".kerf"))continue;let r;try{r=h1(z.toString("utf8"),`${e}/${m}`).program}catch(v){h.push(`${m}: ${v.message}`);continue}for(let v of U(r)){let p=v.path.split("/")[0];Object.prototype.hasOwnProperty.call(i1,v.path)||p===e&&s(v.path.slice(e.length+1))||v.path.includes("/")&&S(l.libraries,p)!==void 0||h.push(`${m}, line ${v.line}: <${v.path}> will not be found once the library is installed`+(s(v.path)?`. Write <${e}/${v.path}> for the library's own file.`:"."))}}[...t.keys()].some(m=>m.endsWith(".kerf"))||h.push("There are no .kerf files to pack"),h.length&&M(h.join(`
2565
- `));let i=[...t.keys()].sort().map(m=>[`${e}/${m}`,t.get(m)]),o=c??d(a,`${e}-${n}.tar.gz`);return _(o,I1(i)),{file:o,name:e,version:n,files:t.size,integrity:F(t)}}export{y as FOLDER,C as LOCK,W as LibraryError,u as MANIFEST,X1 as add,Y1 as check,d1 as findProject,$1 as install,J1 as installedPaths,F as integrity,V1 as libraryFile,l0 as pack,M1 as readLock,k as readManifest,c0 as remove,Q1 as resolver};
3017
+ `};var P="0.3";var u="kerf.json",k="kerf.lock",A="kerf_libraries",x=20<<20,R=2e3,X=/^[a-z0-9][a-z0-9_-]{0,63}$/,C1=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/,H1=/^(readme|licen[cs]e|copying|notice|changelog)(\.[a-z]+)?$/i,W=class extends Error{},c1=a=>{try{return v1(a).isFile()}catch{return!1}},C=a=>{try{return v1(a).isDirectory()}catch{return!1}},S=(a,c)=>a&&Object.prototype.hasOwnProperty.call(a,c)?a[c]:void 0,d=a=>{throw new W(a)};function o1(a,c){return(typeof a!="string"||!X.test(a))&&d(`${c} "${a}" is not a library name: use lowercase letters, digits, - and _`),a==="kerf"&&d(`${c}: "kerf" is the standard library's name`),a}function l1(a,c){(!a||typeof a!="object"||Array.isArray(a))&&d(`${c} must hold a JSON object`);let l=a;for(let n of["name","version","description","license","language"])l[n]!==void 0&&typeof l[n]!="string"&&d(`${c}: "${n}" must be a string`);l.name!==void 0&&o1(l.name,`${c}: name`),l.version!==void 0&&!C1.test(l.version)&&d(`${c}: "version" must look like 1.2.0, not "${l.version}"`),l.language!==void 0&&!/^\d+\.\d+$/.test(l.language)&&d(`${c}: "language" must look like ${P}, not "${l.language}"`),l.sheet!==void 0&&!(Array.isArray(l.sheet)&&l.sheet.length===2&&l.sheet.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0))&&d(`${c}: "sheet" must be [width, height] in mm, like [600, 400]`);let e=l.libraries??{};(!e||typeof e!="object"||Array.isArray(e))&&d(`${c}: "libraries" must be an object of name: source`);for(let[n,t]of Object.entries(e))o1(n,`${c}: library`),typeof t!="string"&&d(`${c}: the source of ${n} must be a string`);return{...l,libraries:{...e}}}function a1(a,c){let l;try{l=T(a,"utf8")}catch{return d(`${c} was not found`)}try{return JSON.parse(l)}catch(e){return d(`${c} is not valid JSON: ${e.message}`)}}function H(a,c=u){return l1(a1(f(a,u),c),c)}function d1(a){if(!I(f(a,k)))return;let c=a1(f(a,k),k);(c?.lockVersion!==1||!c.libraries||typeof c.libraries!="object")&&d(`${k} is not a kerf.lock this kerf can read. Delete it and run kerf install.`);for(let[l,e]of Object.entries(c.libraries))(!e||["source","resolved","integrity"].some(n=>typeof e[n]!="string"))&&d(`${k}: the entry for ${l} is damaged. Remove it and run kerf install.`);return c}function f1(a){for(let c=O(a);;){if(c1(f(c,u)))return c;let l=J(c);if(l===c)return;c=l}}function n1(a){try{return H(a).name}catch{return}}function V1(a,c,l=c1){let e=(s,h)=>[f(s,h),f(s,h+".kerf")].find(i=>l(i));if(Z(c))return[c,c+".kerf"].find(s=>l(s));let n=c.indexOf("/"),t=n>0?f1(a):void 0;if(t){let s=c.slice(0,n);if(s===n1(t))return e(t,c.slice(n+1));if(C(f(t,A,s)))return e(f(t,A),c)}return e(a,c)}function Y1(a){let c=J(O(a));return l=>{let e=V1(c,l);return e===void 0?void 0:T(e,"utf8")}}function Q1(a,c=200){let l=f1(a);if(!l)return[];let e=[],n=(h,i)=>{for(let r of[...M1(h,3)].sort()){if(e.length>=c)return;r.endsWith(".kerf")&&e.push(i+r.slice(0,-5))}},t=n1(l);t&&n(l,t+"/");let s=f(l,A);if(C(s))for(let h of Y(s).sort())X.test(h)&&C(f(s,h))&&n(f(s,h),h+"/");return e}function M1(a,c=1/0){let l=[],e=(n,t,s)=>{let h;try{h=Y(n,{withFileTypes:!0})}catch{return}for(let i of h){if(i.name.startsWith(".")||i.name==="node_modules"||i.name===A)continue;let r=t?`${t}/${i.name}`:i.name;i.isDirectory()?s<c&&e(f(n,i.name),r,s+1):i.isFile()&&(l.push(r),l.length>R&&d(`${a} has more than ${R} files`))}};return e(a,"",0),l}function G(a,c=()=>!0){let l=new Map;for(let e of M1(a))c(e)&&l.set(e,T(f(a,...e.split("/"))));return l}var e1=a=>a===u||a.endsWith(".kerf")||!a.includes("/")&&H1.test(a);function F(a){let c=b1("sha256");for(let l of[...a.keys()].sort()){let e=Buffer.from(a.get(l).toString("utf8").replace(/\r\n/g,`
3018
+ `));c.update(`${l}\0${e.length}\0`),c.update(e)}return"sha256-"+c.digest("base64")}function r1(a){return a.kind==="folder"?"folder:"+(process.platform==="win32"?a.path.toLowerCase():a.path):a.kind==="github"?`github:${a.owner}/${a.repo}`.toLowerCase()+`@${a.ref}`:a.url}function E(a,c){let l=/^github:([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@(\S+))?$/.exec(a);if(l)return{kind:"github",owner:l[1],repo:l[2],ref:l[3]??"HEAD"};if(/^https?:\/\//i.test(a)){let n;try{n=new URL(a)}catch{return d(`${a} is not a link`)}return n.protocol==="http:"&&!["localhost","127.0.0.1","[::1]"].includes(n.hostname)&&d(`Use https:// to download ${a}`),{kind:"url",url:a}}let e=a.startsWith("file:")?a.slice(5):a;return e.startsWith("./")||e.startsWith("../")||Z(e)?{kind:"folder",path:O(c,e)}:d(`"${a}" is not a library source. Use github:owner/repo@tag, an https:// link to a .tar.gz, or a folder like ./my-library`)}async function q1(a,c){let l;try{l=await c(a)}catch(h){let i=h;return d(`Could not download ${a}: ${i.cause?.message??i.message}`)}l.ok||d(`Could not download ${a}: HTTP ${l.status}`+(l.status===404?". Check the name and the tag, and that it is public.":""));let e=()=>d(`${a} is larger than ${x>>20} MB`);if(Number(l.headers?.get("content-length"))>x&&e(),!l.body){let h=Buffer.from(await l.arrayBuffer());return h.length>x?e():h}let n=l.body.getReader(),t=[],s=0;for(;;){let{done:h,value:i}=await n.read();if(h||!i)break;s+=i.length,s>x&&(await n.cancel().catch(()=>{}),e()),t.push(i)}return Buffer.concat(t)}function x1(a,c){let l;try{l=A1(a,{maxOutputLength:5*x})}catch{return d(`${c} is not a .tar.gz file`)}let e=new Map,n,t={},s;for(let h=0;h+512<=l.length;){let i=l.subarray(h,h+512);if(i.every(g=>g===0))break;let r=(g,L)=>{let w=i.subarray(g,g+L),V=w.indexOf(0);return w.subarray(0,V<0?L:V).toString("utf8")},v=parseInt(r(124,12).trim()||"0",8);v>=0||d(`${c} is damaged`);let M=r(156,1)||"0",o=l.subarray(h+512,h+512+v);if(h+=512+Math.ceil(v/512)*512,M==="x"||M==="g"){let g=_1(o);M==="g"?n=g.comment??n:t=g;continue}if(M==="L"){s=o.toString("utf8").replace(/\0+$/,"");continue}let m=r(345,155),p=t.path??s??(m?m+"/":"")+r(0,100);t={},s=void 0,(M==="0"||M==="7")&&e.set(p,Buffer.from(o)),e.size>R&&d(`${c} has more than ${R} files`)}return{files:e,commit:n}}function _1(a){let c={};for(let l=0;l<a.length;){let e=a.indexOf(32,l),n=parseInt(a.subarray(l,e).toString(),10);if(!(n>0)||e<0)break;let t=a.subarray(e+1,l+n-1).toString("utf8"),s=t.indexOf("=");s>0&&(c[t.slice(0,s)]=t.slice(s+1)),l+=n}return c}function m1(a,c){let l=new Map;for(let[t,s]of a){let h=t.replace(/^\.\//,""),i=h.split("/");(Z(h)||h.includes("\\")||h.includes(":")||i.some(r=>r===".."||r===""))&&d(`${c} holds a file outside its folder: ${t}`),l.set(h,s)}let e="";if(!l.has(u)){let t=new Set([...l.keys()].map(s=>s.split("/")[0]));t.size===1&&(e=[...t][0]+"/")}let n=new Map;for(let[t,s]of l){if(!t.startsWith(e))continue;let h=t.slice(e.length);h.split("/").some(i=>i.startsWith(".")||i===A||i==="node_modules")||e1(h)&&n.set(h,s)}return n.has(u)||d(`${c} has no kerf.json at its top. Is it a KerfScript library?`),n}var S1=(a,c)=>{let[l,e]=a.split(".").map(Number),[n,t]=c.split(".").map(Number);return l>n||l===n&&e>t};async function z1(a,c,l,e,n){let t=E(a,c),s,h;if(t.kind==="folder")c1(f(t.path,u))||d(`${a}: no kerf.json in ${t.path}. Is it a KerfScript library?`),s=m1(G(t.path,e1),a),h=L1(l,t.path).split(y1).join("/")||".",!h.startsWith(".")&&!Z(h)&&(h="./"+h);else{let r=t.kind==="github"?`https://github.com/${t.owner}/${t.repo}/archive/${t.ref}.tar.gz`:t.url,v=n.get(r)??await q1(r,e);n.set(r,v);let M=x1(v,a);s=m1(M.files,a),h=t.kind==="github"&&/^[0-9a-f]{40}$/.test(M.commit??"")?`https://github.com/${t.owner}/${t.repo}/archive/${M.commit}.tar.gz`:r}let i=l1(JSON.parse(s.get(u).toString("utf8")),`the kerf.json of ${a}`);return i.name||d(`${a}: its kerf.json has no "name", so it is not a library`),i.language&&S1(i.language,P)&&d(`${i.name} needs KerfScript language ${i.language} or later, and this kerf has ${P}. Update kerf.`),{manifest:i,files:s,resolved:h,integrity:F(s)}}function T1(a,c){Q(a,{recursive:!0,force:!0});for(let[l,e]of c){let n=f(a,...l.split("/"));w1(J(n),{recursive:!0}),_(n,e)}}var $1=a=>{let c=[...a].sort(([l],[e])=>l<e?-1:1);return JSON.stringify({lockVersion:1,libraries:Object.fromEntries(c)},null,2)+`
3019
+ `};async function j1(a,c={}){let l=c.fetch??globalThis.fetch,e=c.log??(()=>{}),n=c.cache??new Map,t=H(a),s=d1(a),h=new Map,i=Object.entries(t.libraries).map(([o,m])=>({name:o,source:m,base:a,from:u})),r=f(a,A);for(;i.length;){let{name:o,source:m,base:p,from:g}=i.shift(),L=E(m,p),w=L.kind==="folder",V=w?`${m} (${L.path})`:m,$=h.get(o);if($){$.at!==r1(L)&&!S(t.libraries,o)&&d(`${g} uses ${o} from ${V}, and ${$.from} uses it from ${$.shown}. Add ${o} to kerf.json with the source to use.`);continue}let B=S(s?.libraries,o),b=B?.source===m&&(!w||O(a,B.resolved)===L.path)?B:void 0;c.frozen&&!b&&d(`kerf.lock does not pin ${o} from ${m}. Run kerf install without --frozen.`);let j=f(r,o),q;if(b&&!w&&C(j)&&F(G(j))===b.integrity)q=b;else{let z=await z1(b&&!w?b.resolved:m,w?p:a,a,l,n);z.manifest.name!==o&&d(`${m} is the library "${z.manifest.name}", so ${g} must call it ${z.manifest.name}, not ${o}`),b&&z.integrity!==b.integrity&&(!w||c.frozen)&&d(w?`${o} in ${m} changed since kerf.lock pinned it. Run kerf install without --frozen.`:`${o} from ${b.resolved} no longer matches kerf.lock. If you trust the change, remove ${o} from kerf.lock and run kerf install again.`),T1(j,z.files),q={source:m,...z.manifest.version?{version:z.manifest.version}:{},resolved:z.resolved,integrity:z.integrity},(!b||b.integrity!==z.integrity||!w)&&e(`${b?"Restored":"Installed"} ${o}${q.version?" "+q.version:""} from ${m}`)}h.set(o,{entry:q,at:r1(L),shown:V,from:g});let t1=L.kind==="folder"?L.path:void 0;for(let[z,K]of Object.entries(H(j,`${A}/${o}/${u}`).libraries))E(K,a).kind==="folder"&&!t1&&d(`${o} uses ${z} from the folder ${K}: a published library needs github: or https: sources`),i.push({name:z,source:K,base:t1??a,from:o})}let v=$1(new Map([...h].map(([o,m])=>[o,m.entry]))),M=I(f(a,k))?T(f(a,k),"utf8"):"";if(c.frozen&&v!==M.replace(/\r\n/g,`
3020
+ `)&&d("kerf.lock is out of date. Run kerf install without --frozen."),C(r))for(let o of Y(r,{withFileTypes:!0}))o.isDirectory()&&X.test(o.name)&&!h.has(o.name)&&(Q(f(r,o.name),{recursive:!0,force:!0}),e(`Removed ${o.name}`));return v!==M.replace(/\r\n/g,`
3021
+ `)&&_(f(a,k),v),JSON.parse(v)}function J1(a){let c=H(a),l=d1(a),e=Object.keys(c.libraries);if(!l)return e.length?["kerf.lock is missing. Run kerf install."]:[];let n=[],t=new Set,s=[...e];for(;s.length;){let h=s.shift();if(t.has(h))continue;t.add(h);let i=S(l.libraries,h);if(!i){n.push(`${h} is not in kerf.lock. Run kerf install.`);continue}e.includes(h)&&i.source!==c.libraries[h]&&n.push(`kerf.json takes ${h} from ${c.libraries[h]}, and kerf.lock from ${i.source}. Run kerf install.`);let r=f(a,A,h);if(!C(r)){n.push(`${h} is not in ${A}. Run kerf install.`);continue}F(G(r))!==i.integrity&&n.push(`The files in ${A}/${h} differ from kerf.lock. Run kerf install.`);try{s.push(...Object.keys(H(r).libraries))}catch(v){n.push(v.message)}}for(let h of Object.keys(l.libraries))t.has(h)||n.push(`kerf.lock pins ${h}, which nothing uses any more.`);return n}function P1(a,c){let l=f(a,u),e=I(l)?a1(l,u):{};l1(e,u);let n={...e.libraries??{}};return c(n),e.libraries=n,{file:l,before:I(l)?T(l,"utf8"):void 0,raw:e}}async function u1(a,c,l){let{file:e,before:n,raw:t}=P1(a,c);_(e,JSON.stringify(t,null,2)+`
3022
+ `);try{return await j1(a,l)}catch(s){throw n===void 0?Q(e,{force:!0}):_(e,n),s}}async function X1(a,c,l={}){let e=new Map,t=(await z1(c,a,a,l.fetch??globalThis.fetch,e)).manifest.name;t===n1(a)&&d(`This project is the library ${t}; it cannot use itself`);let s=await u1(a,h=>void(h[t]=c),{...l,cache:e});return{name:t,lock:s}}async function c0(a,c,l={}){return u1(a,e=>{S(e,c)===void 0&&d(`kerf.json has no library named ${c}`),delete e[c]},l)}function U(a,c=[]){if(Array.isArray(a))for(let l of a)U(l,c);else if(a&&typeof a=="object"){let l=a;if(l.kind==="use"&&typeof l.path=="string")c.push({path:l.path,line:l.pos.line});else for(let e of Object.values(l))U(e,c)}return c}function I1(a){let c=[];for(let[l,e]of a){let n=Buffer.alloc(512),t=l,s="";if(Buffer.byteLength(t)>100){let i=l.lastIndexOf("/",155);(i<0||Buffer.byteLength(l.slice(i+1))>100)&&d(`${l}: the path is too long to pack`),s=l.slice(0,i),t=l.slice(i+1)}n.write(t,0,100),n.write("0000644\0",100),n.write("0000000\0",108),n.write("0000000\0",116),n.write(e.length.toString(8).padStart(11,"0")+"\0",124),n.write("00000000000\0",136),n.fill(32,148,156),n.write("0",156),n.write("ustar\0",257),n.write("00",263),n.write(s,345,155);let h=0;for(let i of n)h+=i;n.write(h.toString(8).padStart(6,"0")+"\0 ",148),c.push(n,e,Buffer.alloc((512-e.length%512)%512))}return c.push(Buffer.alloc(1024)),k1(Buffer.concat(c),{level:9})}function l0(a,c){let l=H(a),e=l.name??d('kerf.json needs a "name" to pack a library'),n=l.version??d('kerf.json needs a "version", like 1.0.0'),t=G(a,e1),s=[];for(let[v,M]of Object.entries(l.libraries))E(M,a).kind==="folder"&&s.push(`kerf.json: ${v} comes from a folder; a published library needs github: or https: sources`);let h=v=>t.has(v)||t.has(v+".kerf");for(let[v,M]of t){if(!v.endsWith(".kerf"))continue;let o;try{o=h1(M.toString("utf8"),`${e}/${v}`).program}catch(m){s.push(`${v}: ${m.message}`);continue}for(let m of U(o)){let p=m.path.split("/")[0];Object.prototype.hasOwnProperty.call(i1,m.path)||p===e&&h(m.path.slice(e.length+1))||m.path.includes("/")&&S(l.libraries,p)!==void 0||s.push(`${v}, line ${m.line}: <${m.path}> will not be found once the library is installed`+(h(m.path)?`. Write <${e}/${m.path}> for the library's own file.`:"."))}}[...t.keys()].some(v=>v.endsWith(".kerf"))||s.push("There are no .kerf files to pack"),s.length&&d(s.join(`
3023
+ `));let i=[...t.keys()].sort().map(v=>[`${e}/${v}`,t.get(v)]),r=c??f(a,`${e}-${n}.tar.gz`);return _(r,I1(i)),{file:r,name:e,version:n,files:t.size,integrity:F(t)}}export{A as FOLDER,k as LOCK,W as LibraryError,u as MANIFEST,X1 as add,J1 as check,f1 as findProject,j1 as install,Q1 as installedPaths,F as integrity,V1 as libraryFile,l0 as pack,d1 as readLock,H as readManifest,c0 as remove,Y1 as resolver};