@orval/query 6.19.1 → 6.21.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.
- package/dist/index.js +2608 -78
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,116 +1,2589 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var Qn=Object.create;var Ce=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var wn=Object.getOwnPropertyNames;var In=Object.getPrototypeOf,xn=Object.prototype.hasOwnProperty;var Pe=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(n,r)=>(typeof require!="undefined"?require:n)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var P=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Mn=(e,n,r,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of wn(n))!xn.call(e,s)&&s!==r&&Ce(e,s,{get:()=>n[s],enumerable:!(t=Rn(n,s))||t.enumerable});return e};var Sn=(e,n,r)=>(r=e!=null?Qn(In(e)):{},Mn(n||!e||!e.__esModule?Ce(r,"default",{value:e,enumerable:!0}):r,e));var qe=P((Vt,Fe)=>{"use strict";Fe.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var ge=P((jt,ke)=>{var ne=qe(),Ue={};for(let e of Object.keys(ne))Ue[ne[e]]=e;var c={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};ke.exports=c;for(let e of Object.keys(c)){if(!("channels"in c[e]))throw new Error("missing channels property: "+e);if(!("labels"in c[e]))throw new Error("missing channel labels property: "+e);if(c[e].labels.length!==c[e].channels)throw new Error("channel and label counts mismatch: "+e);let{channels:n,labels:r}=c[e];delete c[e].channels,delete c[e].labels,Object.defineProperty(c[e],"channels",{value:n}),Object.defineProperty(c[e],"labels",{value:r})}c.rgb.hsl=function(e){let n=e[0]/255,r=e[1]/255,t=e[2]/255,s=Math.min(n,r,t),o=Math.max(n,r,t),i=o-s,u,l;o===s?u=0:n===o?u=(r-t)/i:r===o?u=2+(t-n)/i:t===o&&(u=4+(n-r)/i),u=Math.min(u*60,360),u<0&&(u+=360);let y=(s+o)/2;return o===s?l=0:y<=.5?l=i/(o+s):l=i/(2-o-s),[u,l*100,y*100]};c.rgb.hsv=function(e){let n,r,t,s,o,i=e[0]/255,u=e[1]/255,l=e[2]/255,y=Math.max(i,u,l),d=y-Math.min(i,u,l),f=function(g){return(y-g)/6/d+1/2};return d===0?(s=0,o=0):(o=d/y,n=f(i),r=f(u),t=f(l),i===y?s=t-r:u===y?s=1/3+n-t:l===y&&(s=2/3+r-n),s<0?s+=1:s>1&&(s-=1)),[s*360,o*100,y*100]};c.rgb.hwb=function(e){let n=e[0],r=e[1],t=e[2],s=c.rgb.hsl(e)[0],o=1/255*Math.min(n,Math.min(r,t));return t=1-1/255*Math.max(n,Math.max(r,t)),[s,o*100,t*100]};c.rgb.cmyk=function(e){let n=e[0]/255,r=e[1]/255,t=e[2]/255,s=Math.min(1-n,1-r,1-t),o=(1-n-s)/(1-s)||0,i=(1-r-s)/(1-s)||0,u=(1-t-s)/(1-s)||0;return[o*100,i*100,u*100,s*100]};function An(e,n){return(e[0]-n[0])**2+(e[1]-n[1])**2+(e[2]-n[2])**2}c.rgb.keyword=function(e){let n=Ue[e];if(n)return n;let r=1/0,t;for(let s of Object.keys(ne)){let o=ne[s],i=An(e,o);i<r&&(r=i,t=s)}return t};c.keyword.rgb=function(e){return ne[e]};c.rgb.xyz=function(e){let n=e[0]/255,r=e[1]/255,t=e[2]/255;n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,t=t>.04045?((t+.055)/1.055)**2.4:t/12.92;let s=n*.4124+r*.3576+t*.1805,o=n*.2126+r*.7152+t*.0722,i=n*.0193+r*.1192+t*.9505;return[s*100,o*100,i*100]};c.rgb.lab=function(e){let n=c.rgb.xyz(e),r=n[0],t=n[1],s=n[2];r/=95.047,t/=100,s/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,t=t>.008856?t**(1/3):7.787*t+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let o=116*t-16,i=500*(r-t),u=200*(t-s);return[o,i,u]};c.hsl.rgb=function(e){let n=e[0]/360,r=e[1]/100,t=e[2]/100,s,o,i;if(r===0)return i=t*255,[i,i,i];t<.5?s=t*(1+r):s=t+r-t*r;let u=2*t-s,l=[0,0,0];for(let y=0;y<3;y++)o=n+1/3*-(y-1),o<0&&o++,o>1&&o--,6*o<1?i=u+(s-u)*6*o:2*o<1?i=s:3*o<2?i=u+(s-u)*(2/3-o)*6:i=u,l[y]=i*255;return l};c.hsl.hsv=function(e){let n=e[0],r=e[1]/100,t=e[2]/100,s=r,o=Math.max(t,.01);t*=2,r*=t<=1?t:2-t,s*=o<=1?o:2-o;let i=(t+r)/2,u=t===0?2*s/(o+s):2*r/(t+r);return[n,u*100,i*100]};c.hsv.rgb=function(e){let n=e[0]/60,r=e[1]/100,t=e[2]/100,s=Math.floor(n)%6,o=n-Math.floor(n),i=255*t*(1-r),u=255*t*(1-r*o),l=255*t*(1-r*(1-o));switch(t*=255,s){case 0:return[t,l,i];case 1:return[u,t,i];case 2:return[i,t,l];case 3:return[i,u,t];case 4:return[l,i,t];case 5:return[t,i,u]}};c.hsv.hsl=function(e){let n=e[0],r=e[1]/100,t=e[2]/100,s=Math.max(t,.01),o,i;i=(2-r)*t;let u=(2-r)*s;return o=r*s,o/=u<=1?u:2-u,o=o||0,i/=2,[n,o*100,i*100]};c.hwb.rgb=function(e){let n=e[0]/360,r=e[1]/100,t=e[2]/100,s=r+t,o;s>1&&(r/=s,t/=s);let i=Math.floor(6*n),u=1-t;o=6*n-i,(i&1)!==0&&(o=1-o);let l=r+o*(u-r),y,d,f;switch(i){default:case 6:case 0:y=u,d=l,f=r;break;case 1:y=l,d=u,f=r;break;case 2:y=r,d=u,f=l;break;case 3:y=r,d=l,f=u;break;case 4:y=l,d=r,f=u;break;case 5:y=u,d=r,f=l;break}return[y*255,d*255,f*255]};c.cmyk.rgb=function(e){let n=e[0]/100,r=e[1]/100,t=e[2]/100,s=e[3]/100,o=1-Math.min(1,n*(1-s)+s),i=1-Math.min(1,r*(1-s)+s),u=1-Math.min(1,t*(1-s)+s);return[o*255,i*255,u*255]};c.xyz.rgb=function(e){let n=e[0]/100,r=e[1]/100,t=e[2]/100,s,o,i;return s=n*3.2406+r*-1.5372+t*-.4986,o=n*-.9689+r*1.8758+t*.0415,i=n*.0557+r*-.204+t*1.057,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,i=i>.0031308?1.055*i**(1/2.4)-.055:i*12.92,s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),[s*255,o*255,i*255]};c.xyz.lab=function(e){let n=e[0],r=e[1],t=e[2];n/=95.047,r/=100,t/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,t=t>.008856?t**(1/3):7.787*t+16/116;let s=116*r-16,o=500*(n-r),i=200*(r-t);return[s,o,i]};c.lab.xyz=function(e){let n=e[0],r=e[1],t=e[2],s,o,i;o=(n+16)/116,s=r/500+o,i=o-t/200;let u=o**3,l=s**3,y=i**3;return o=u>.008856?u:(o-16/116)/7.787,s=l>.008856?l:(s-16/116)/7.787,i=y>.008856?y:(i-16/116)/7.787,s*=95.047,o*=100,i*=108.883,[s,o,i]};c.lab.lch=function(e){let n=e[0],r=e[1],t=e[2],s;s=Math.atan2(t,r)*360/2/Math.PI,s<0&&(s+=360);let i=Math.sqrt(r*r+t*t);return[n,i,s]};c.lch.lab=function(e){let n=e[0],r=e[1],s=e[2]/360*2*Math.PI,o=r*Math.cos(s),i=r*Math.sin(s);return[n,o,i]};c.rgb.ansi16=function(e,n=null){let[r,t,s]=e,o=n===null?c.rgb.hsv(e)[2]:n;if(o=Math.round(o/50),o===0)return 30;let i=30+(Math.round(s/255)<<2|Math.round(t/255)<<1|Math.round(r/255));return o===2&&(i+=60),i};c.hsv.ansi16=function(e){return c.rgb.ansi16(c.hsv.rgb(e),e[2])};c.rgb.ansi256=function(e){let n=e[0],r=e[1],t=e[2];return n===r&&r===t?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(t/255*5)};c.ansi16.rgb=function(e){let n=e%10;if(n===0||n===7)return e>50&&(n+=3.5),n=n/10.5*255,[n,n,n];let r=(~~(e>50)+1)*.5,t=(n&1)*r*255,s=(n>>1&1)*r*255,o=(n>>2&1)*r*255;return[t,s,o]};c.ansi256.rgb=function(e){if(e>=232){let o=(e-232)*10+8;return[o,o,o]}e-=16;let n,r=Math.floor(e/36)/5*255,t=Math.floor((n=e%36)/6)/5*255,s=n%6/5*255;return[r,t,s]};c.rgb.hex=function(e){let r=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".substring(r.length)+r};c.hex.rgb=function(e){let n=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];let r=n[0];n[0].length===3&&(r=r.split("").map(u=>u+u).join(""));let t=parseInt(r,16),s=t>>16&255,o=t>>8&255,i=t&255;return[s,o,i]};c.rgb.hcg=function(e){let n=e[0]/255,r=e[1]/255,t=e[2]/255,s=Math.max(Math.max(n,r),t),o=Math.min(Math.min(n,r),t),i=s-o,u,l;return i<1?u=o/(1-i):u=0,i<=0?l=0:s===n?l=(r-t)/i%6:s===r?l=2+(t-n)/i:l=4+(n-r)/i,l/=6,l%=1,[l*360,i*100,u*100]};c.hsl.hcg=function(e){let n=e[1]/100,r=e[2]/100,t=r<.5?2*n*r:2*n*(1-r),s=0;return t<1&&(s=(r-.5*t)/(1-t)),[e[0],t*100,s*100]};c.hsv.hcg=function(e){let n=e[1]/100,r=e[2]/100,t=n*r,s=0;return t<1&&(s=(r-t)/(1-t)),[e[0],t*100,s*100]};c.hcg.rgb=function(e){let n=e[0]/360,r=e[1]/100,t=e[2]/100;if(r===0)return[t*255,t*255,t*255];let s=[0,0,0],o=n%1*6,i=o%1,u=1-i,l=0;switch(Math.floor(o)){case 0:s[0]=1,s[1]=i,s[2]=0;break;case 1:s[0]=u,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=i;break;case 3:s[0]=0,s[1]=u,s[2]=1;break;case 4:s[0]=i,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=u}return l=(1-r)*t,[(r*s[0]+l)*255,(r*s[1]+l)*255,(r*s[2]+l)*255]};c.hcg.hsv=function(e){let n=e[1]/100,r=e[2]/100,t=n+r*(1-n),s=0;return t>0&&(s=n/t),[e[0],s*100,t*100]};c.hcg.hsl=function(e){let n=e[1]/100,t=e[2]/100*(1-n)+.5*n,s=0;return t>0&&t<.5?s=n/(2*t):t>=.5&&t<1&&(s=n/(2*(1-t))),[e[0],s*100,t*100]};c.hcg.hwb=function(e){let n=e[1]/100,r=e[2]/100,t=n+r*(1-n);return[e[0],(t-n)*100,(1-t)*100]};c.hwb.hcg=function(e){let n=e[1]/100,r=e[2]/100,t=1-r,s=t-n,o=0;return s<1&&(o=(t-s)/(1-s)),[e[0],s*100,o*100]};c.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};c.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};c.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};c.gray.hsl=function(e){return[0,0,e[0]]};c.gray.hsv=c.gray.hsl;c.gray.hwb=function(e){return[0,100,e[0]]};c.gray.cmyk=function(e){return[0,0,0,e[0]]};c.gray.lab=function(e){return[e[0],0,0]};c.gray.hex=function(e){let n=Math.round(e[0]/100*255)&255,t=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(t.length)+t};c.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}});var _e=P((Kt,De)=>{var ce=ge();function Cn(){let e={},n=Object.keys(ce);for(let r=n.length,t=0;t<r;t++)e[n[t]]={distance:-1,parent:null};return e}function Pn(e){let n=Cn(),r=[e];for(n[e].distance=0;r.length;){let t=r.pop(),s=Object.keys(ce[t]);for(let o=s.length,i=0;i<o;i++){let u=s[i],l=n[u];l.distance===-1&&(l.distance=n[t].distance+1,l.parent=t,r.unshift(u))}}return n}function Fn(e,n){return function(r){return n(e(r))}}function qn(e,n){let r=[n[e].parent,e],t=ce[n[e].parent][e],s=n[e].parent;for(;n[s].parent;)r.unshift(n[s].parent),t=Fn(ce[n[s].parent][s],t),s=n[s].parent;return t.conversion=r,t}De.exports=function(e){let n=Pn(e),r={},t=Object.keys(n);for(let s=t.length,o=0;o<s;o++){let i=t[o];n[i].parent!==null&&(r[i]=qn(i,n))}return r}});var Ne=P((Ht,Be)=>{var me=ge(),Un=_e(),X={},kn=Object.keys(me);function Dn(e){let n=function(...r){let t=r[0];return t==null?t:(t.length>1&&(r=t),e(r))};return"conversion"in e&&(n.conversion=e.conversion),n}function _n(e){let n=function(...r){let t=r[0];if(t==null)return t;t.length>1&&(r=t);let s=e(r);if(typeof s=="object")for(let o=s.length,i=0;i<o;i++)s[i]=Math.round(s[i]);return s};return"conversion"in e&&(n.conversion=e.conversion),n}kn.forEach(e=>{X[e]={},Object.defineProperty(X[e],"channels",{value:me[e].channels}),Object.defineProperty(X[e],"labels",{value:me[e].labels});let n=Un(e);Object.keys(n).forEach(t=>{let s=n[t];X[e][t]=_n(s),X[e][t].raw=Dn(s)})});Be.exports=X});var Ye=P((Yt,He)=>{"use strict";var Ge=(e,n)=>(...r)=>`\x1B[${e(...r)+n}m`,Ve=(e,n)=>(...r)=>{let t=e(...r);return`\x1B[${38+n};5;${t}m`},je=(e,n)=>(...r)=>{let t=e(...r);return`\x1B[${38+n};2;${t[0]};${t[1]};${t[2]}m`},ae=e=>e,Ke=(e,n,r)=>[e,n,r],Z=(e,n,r)=>{Object.defineProperty(e,n,{get:()=>{let t=r();return Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0}),t},enumerable:!0,configurable:!0})},$e,J=(e,n,r,t)=>{$e===void 0&&($e=Ne());let s=t?10:0,o={};for(let[i,u]of Object.entries($e)){let l=i==="ansi16"?"ansi":i;i===n?o[l]=e(r,s):typeof u=="object"&&(o[l]=e(u[n],s))}return o};function Bn(){let e=new Map,n={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};n.color.gray=n.color.blackBright,n.bgColor.bgGray=n.bgColor.bgBlackBright,n.color.grey=n.color.blackBright,n.bgColor.bgGrey=n.bgColor.bgBlackBright;for(let[r,t]of Object.entries(n)){for(let[s,o]of Object.entries(t))n[s]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},t[s]=n[s],e.set(o[0],o[1]);Object.defineProperty(n,r,{value:t,enumerable:!1})}return Object.defineProperty(n,"codes",{value:e,enumerable:!1}),n.color.close="\x1B[39m",n.bgColor.close="\x1B[49m",Z(n.color,"ansi",()=>J(Ge,"ansi16",ae,!1)),Z(n.color,"ansi256",()=>J(Ve,"ansi256",ae,!1)),Z(n.color,"ansi16m",()=>J(je,"rgb",Ke,!1)),Z(n.bgColor,"ansi",()=>J(Ge,"ansi16",ae,!0)),Z(n.bgColor,"ansi256",()=>J(Ve,"ansi256",ae,!0)),Z(n.bgColor,"ansi16m",()=>J(je,"rgb",Ke,!0)),n}Object.defineProperty(He,"exports",{enumerable:!0,get:Bn})});var ze=P((Lt,Le)=>{"use strict";Le.exports=(e,n=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",t=n.indexOf(r+e),s=n.indexOf("--");return t!==-1&&(s===-1||t<s)}});var Ze=P((zt,Xe)=>{"use strict";var Nn=Pe("os"),We=Pe("tty"),w=ze(),{env:$}=process,j;w("no-color")||w("no-colors")||w("color=false")||w("color=never")?j=0:(w("color")||w("colors")||w("color=true")||w("color=always"))&&(j=1);"FORCE_COLOR"in $&&($.FORCE_COLOR==="true"?j=1:$.FORCE_COLOR==="false"?j=0:j=$.FORCE_COLOR.length===0?1:Math.min(parseInt($.FORCE_COLOR,10),3));function Ee(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Te(e,n){if(j===0)return 0;if(w("color=16m")||w("color=full")||w("color=truecolor"))return 3;if(w("color=256"))return 2;if(e&&!n&&j===void 0)return 0;let r=j||0;if($.TERM==="dumb")return r;if(process.platform==="win32"){let t=Nn.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in $)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in $)||$.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in $)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test($.TEAMCITY_VERSION)?1:0;if($.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in $){let t=parseInt(($.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch($.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test($.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test($.TERM)||"COLORTERM"in $?1:r}function Gn(e){let n=Te(e,e&&e.isTTY);return Ee(n)}Xe.exports={supportsColor:Gn,stdout:Ee(Te(!0,We.isatty(1))),stderr:Ee(Te(!0,We.isatty(2)))}});var en=P((Wt,Je)=>{"use strict";var Vn=(e,n,r)=>{let t=e.indexOf(n);if(t===-1)return e;let s=n.length,o=0,i="";do i+=e.substr(o,t-o)+n+r,o=t+s,t=e.indexOf(n,o);while(t!==-1);return i+=e.substr(o),i},jn=(e,n,r,t)=>{let s=0,o="";do{let i=e[t-1]==="\r";o+=e.substr(s,(i?t-1:t)-s)+n+(i?`\r
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/color-name/index.js
|
|
34
|
+
var require_color_name = __commonJS({
|
|
35
|
+
"../../node_modules/color-name/index.js"(exports, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
module2.exports = {
|
|
38
|
+
"aliceblue": [240, 248, 255],
|
|
39
|
+
"antiquewhite": [250, 235, 215],
|
|
40
|
+
"aqua": [0, 255, 255],
|
|
41
|
+
"aquamarine": [127, 255, 212],
|
|
42
|
+
"azure": [240, 255, 255],
|
|
43
|
+
"beige": [245, 245, 220],
|
|
44
|
+
"bisque": [255, 228, 196],
|
|
45
|
+
"black": [0, 0, 0],
|
|
46
|
+
"blanchedalmond": [255, 235, 205],
|
|
47
|
+
"blue": [0, 0, 255],
|
|
48
|
+
"blueviolet": [138, 43, 226],
|
|
49
|
+
"brown": [165, 42, 42],
|
|
50
|
+
"burlywood": [222, 184, 135],
|
|
51
|
+
"cadetblue": [95, 158, 160],
|
|
52
|
+
"chartreuse": [127, 255, 0],
|
|
53
|
+
"chocolate": [210, 105, 30],
|
|
54
|
+
"coral": [255, 127, 80],
|
|
55
|
+
"cornflowerblue": [100, 149, 237],
|
|
56
|
+
"cornsilk": [255, 248, 220],
|
|
57
|
+
"crimson": [220, 20, 60],
|
|
58
|
+
"cyan": [0, 255, 255],
|
|
59
|
+
"darkblue": [0, 0, 139],
|
|
60
|
+
"darkcyan": [0, 139, 139],
|
|
61
|
+
"darkgoldenrod": [184, 134, 11],
|
|
62
|
+
"darkgray": [169, 169, 169],
|
|
63
|
+
"darkgreen": [0, 100, 0],
|
|
64
|
+
"darkgrey": [169, 169, 169],
|
|
65
|
+
"darkkhaki": [189, 183, 107],
|
|
66
|
+
"darkmagenta": [139, 0, 139],
|
|
67
|
+
"darkolivegreen": [85, 107, 47],
|
|
68
|
+
"darkorange": [255, 140, 0],
|
|
69
|
+
"darkorchid": [153, 50, 204],
|
|
70
|
+
"darkred": [139, 0, 0],
|
|
71
|
+
"darksalmon": [233, 150, 122],
|
|
72
|
+
"darkseagreen": [143, 188, 143],
|
|
73
|
+
"darkslateblue": [72, 61, 139],
|
|
74
|
+
"darkslategray": [47, 79, 79],
|
|
75
|
+
"darkslategrey": [47, 79, 79],
|
|
76
|
+
"darkturquoise": [0, 206, 209],
|
|
77
|
+
"darkviolet": [148, 0, 211],
|
|
78
|
+
"deeppink": [255, 20, 147],
|
|
79
|
+
"deepskyblue": [0, 191, 255],
|
|
80
|
+
"dimgray": [105, 105, 105],
|
|
81
|
+
"dimgrey": [105, 105, 105],
|
|
82
|
+
"dodgerblue": [30, 144, 255],
|
|
83
|
+
"firebrick": [178, 34, 34],
|
|
84
|
+
"floralwhite": [255, 250, 240],
|
|
85
|
+
"forestgreen": [34, 139, 34],
|
|
86
|
+
"fuchsia": [255, 0, 255],
|
|
87
|
+
"gainsboro": [220, 220, 220],
|
|
88
|
+
"ghostwhite": [248, 248, 255],
|
|
89
|
+
"gold": [255, 215, 0],
|
|
90
|
+
"goldenrod": [218, 165, 32],
|
|
91
|
+
"gray": [128, 128, 128],
|
|
92
|
+
"green": [0, 128, 0],
|
|
93
|
+
"greenyellow": [173, 255, 47],
|
|
94
|
+
"grey": [128, 128, 128],
|
|
95
|
+
"honeydew": [240, 255, 240],
|
|
96
|
+
"hotpink": [255, 105, 180],
|
|
97
|
+
"indianred": [205, 92, 92],
|
|
98
|
+
"indigo": [75, 0, 130],
|
|
99
|
+
"ivory": [255, 255, 240],
|
|
100
|
+
"khaki": [240, 230, 140],
|
|
101
|
+
"lavender": [230, 230, 250],
|
|
102
|
+
"lavenderblush": [255, 240, 245],
|
|
103
|
+
"lawngreen": [124, 252, 0],
|
|
104
|
+
"lemonchiffon": [255, 250, 205],
|
|
105
|
+
"lightblue": [173, 216, 230],
|
|
106
|
+
"lightcoral": [240, 128, 128],
|
|
107
|
+
"lightcyan": [224, 255, 255],
|
|
108
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
109
|
+
"lightgray": [211, 211, 211],
|
|
110
|
+
"lightgreen": [144, 238, 144],
|
|
111
|
+
"lightgrey": [211, 211, 211],
|
|
112
|
+
"lightpink": [255, 182, 193],
|
|
113
|
+
"lightsalmon": [255, 160, 122],
|
|
114
|
+
"lightseagreen": [32, 178, 170],
|
|
115
|
+
"lightskyblue": [135, 206, 250],
|
|
116
|
+
"lightslategray": [119, 136, 153],
|
|
117
|
+
"lightslategrey": [119, 136, 153],
|
|
118
|
+
"lightsteelblue": [176, 196, 222],
|
|
119
|
+
"lightyellow": [255, 255, 224],
|
|
120
|
+
"lime": [0, 255, 0],
|
|
121
|
+
"limegreen": [50, 205, 50],
|
|
122
|
+
"linen": [250, 240, 230],
|
|
123
|
+
"magenta": [255, 0, 255],
|
|
124
|
+
"maroon": [128, 0, 0],
|
|
125
|
+
"mediumaquamarine": [102, 205, 170],
|
|
126
|
+
"mediumblue": [0, 0, 205],
|
|
127
|
+
"mediumorchid": [186, 85, 211],
|
|
128
|
+
"mediumpurple": [147, 112, 219],
|
|
129
|
+
"mediumseagreen": [60, 179, 113],
|
|
130
|
+
"mediumslateblue": [123, 104, 238],
|
|
131
|
+
"mediumspringgreen": [0, 250, 154],
|
|
132
|
+
"mediumturquoise": [72, 209, 204],
|
|
133
|
+
"mediumvioletred": [199, 21, 133],
|
|
134
|
+
"midnightblue": [25, 25, 112],
|
|
135
|
+
"mintcream": [245, 255, 250],
|
|
136
|
+
"mistyrose": [255, 228, 225],
|
|
137
|
+
"moccasin": [255, 228, 181],
|
|
138
|
+
"navajowhite": [255, 222, 173],
|
|
139
|
+
"navy": [0, 0, 128],
|
|
140
|
+
"oldlace": [253, 245, 230],
|
|
141
|
+
"olive": [128, 128, 0],
|
|
142
|
+
"olivedrab": [107, 142, 35],
|
|
143
|
+
"orange": [255, 165, 0],
|
|
144
|
+
"orangered": [255, 69, 0],
|
|
145
|
+
"orchid": [218, 112, 214],
|
|
146
|
+
"palegoldenrod": [238, 232, 170],
|
|
147
|
+
"palegreen": [152, 251, 152],
|
|
148
|
+
"paleturquoise": [175, 238, 238],
|
|
149
|
+
"palevioletred": [219, 112, 147],
|
|
150
|
+
"papayawhip": [255, 239, 213],
|
|
151
|
+
"peachpuff": [255, 218, 185],
|
|
152
|
+
"peru": [205, 133, 63],
|
|
153
|
+
"pink": [255, 192, 203],
|
|
154
|
+
"plum": [221, 160, 221],
|
|
155
|
+
"powderblue": [176, 224, 230],
|
|
156
|
+
"purple": [128, 0, 128],
|
|
157
|
+
"rebeccapurple": [102, 51, 153],
|
|
158
|
+
"red": [255, 0, 0],
|
|
159
|
+
"rosybrown": [188, 143, 143],
|
|
160
|
+
"royalblue": [65, 105, 225],
|
|
161
|
+
"saddlebrown": [139, 69, 19],
|
|
162
|
+
"salmon": [250, 128, 114],
|
|
163
|
+
"sandybrown": [244, 164, 96],
|
|
164
|
+
"seagreen": [46, 139, 87],
|
|
165
|
+
"seashell": [255, 245, 238],
|
|
166
|
+
"sienna": [160, 82, 45],
|
|
167
|
+
"silver": [192, 192, 192],
|
|
168
|
+
"skyblue": [135, 206, 235],
|
|
169
|
+
"slateblue": [106, 90, 205],
|
|
170
|
+
"slategray": [112, 128, 144],
|
|
171
|
+
"slategrey": [112, 128, 144],
|
|
172
|
+
"snow": [255, 250, 250],
|
|
173
|
+
"springgreen": [0, 255, 127],
|
|
174
|
+
"steelblue": [70, 130, 180],
|
|
175
|
+
"tan": [210, 180, 140],
|
|
176
|
+
"teal": [0, 128, 128],
|
|
177
|
+
"thistle": [216, 191, 216],
|
|
178
|
+
"tomato": [255, 99, 71],
|
|
179
|
+
"turquoise": [64, 224, 208],
|
|
180
|
+
"violet": [238, 130, 238],
|
|
181
|
+
"wheat": [245, 222, 179],
|
|
182
|
+
"white": [255, 255, 255],
|
|
183
|
+
"whitesmoke": [245, 245, 245],
|
|
184
|
+
"yellow": [255, 255, 0],
|
|
185
|
+
"yellowgreen": [154, 205, 50]
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// ../../node_modules/color-convert/conversions.js
|
|
191
|
+
var require_conversions = __commonJS({
|
|
192
|
+
"../../node_modules/color-convert/conversions.js"(exports, module2) {
|
|
193
|
+
"use strict";
|
|
194
|
+
var cssKeywords = require_color_name();
|
|
195
|
+
var reverseKeywords = {};
|
|
196
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
197
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
198
|
+
}
|
|
199
|
+
var convert = {
|
|
200
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
201
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
202
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
203
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
204
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
205
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
206
|
+
lab: { channels: 3, labels: "lab" },
|
|
207
|
+
lch: { channels: 3, labels: "lch" },
|
|
208
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
209
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
210
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
211
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
212
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
213
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
214
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
215
|
+
};
|
|
216
|
+
module2.exports = convert;
|
|
217
|
+
for (const model of Object.keys(convert)) {
|
|
218
|
+
if (!("channels" in convert[model])) {
|
|
219
|
+
throw new Error("missing channels property: " + model);
|
|
220
|
+
}
|
|
221
|
+
if (!("labels" in convert[model])) {
|
|
222
|
+
throw new Error("missing channel labels property: " + model);
|
|
223
|
+
}
|
|
224
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
225
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
226
|
+
}
|
|
227
|
+
const { channels, labels } = convert[model];
|
|
228
|
+
delete convert[model].channels;
|
|
229
|
+
delete convert[model].labels;
|
|
230
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
231
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
232
|
+
}
|
|
233
|
+
convert.rgb.hsl = function(rgb) {
|
|
234
|
+
const r = rgb[0] / 255;
|
|
235
|
+
const g = rgb[1] / 255;
|
|
236
|
+
const b = rgb[2] / 255;
|
|
237
|
+
const min = Math.min(r, g, b);
|
|
238
|
+
const max = Math.max(r, g, b);
|
|
239
|
+
const delta = max - min;
|
|
240
|
+
let h;
|
|
241
|
+
let s;
|
|
242
|
+
if (max === min) {
|
|
243
|
+
h = 0;
|
|
244
|
+
} else if (r === max) {
|
|
245
|
+
h = (g - b) / delta;
|
|
246
|
+
} else if (g === max) {
|
|
247
|
+
h = 2 + (b - r) / delta;
|
|
248
|
+
} else if (b === max) {
|
|
249
|
+
h = 4 + (r - g) / delta;
|
|
250
|
+
}
|
|
251
|
+
h = Math.min(h * 60, 360);
|
|
252
|
+
if (h < 0) {
|
|
253
|
+
h += 360;
|
|
254
|
+
}
|
|
255
|
+
const l = (min + max) / 2;
|
|
256
|
+
if (max === min) {
|
|
257
|
+
s = 0;
|
|
258
|
+
} else if (l <= 0.5) {
|
|
259
|
+
s = delta / (max + min);
|
|
260
|
+
} else {
|
|
261
|
+
s = delta / (2 - max - min);
|
|
262
|
+
}
|
|
263
|
+
return [h, s * 100, l * 100];
|
|
264
|
+
};
|
|
265
|
+
convert.rgb.hsv = function(rgb) {
|
|
266
|
+
let rdif;
|
|
267
|
+
let gdif;
|
|
268
|
+
let bdif;
|
|
269
|
+
let h;
|
|
270
|
+
let s;
|
|
271
|
+
const r = rgb[0] / 255;
|
|
272
|
+
const g = rgb[1] / 255;
|
|
273
|
+
const b = rgb[2] / 255;
|
|
274
|
+
const v = Math.max(r, g, b);
|
|
275
|
+
const diff = v - Math.min(r, g, b);
|
|
276
|
+
const diffc = function(c) {
|
|
277
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
278
|
+
};
|
|
279
|
+
if (diff === 0) {
|
|
280
|
+
h = 0;
|
|
281
|
+
s = 0;
|
|
282
|
+
} else {
|
|
283
|
+
s = diff / v;
|
|
284
|
+
rdif = diffc(r);
|
|
285
|
+
gdif = diffc(g);
|
|
286
|
+
bdif = diffc(b);
|
|
287
|
+
if (r === v) {
|
|
288
|
+
h = bdif - gdif;
|
|
289
|
+
} else if (g === v) {
|
|
290
|
+
h = 1 / 3 + rdif - bdif;
|
|
291
|
+
} else if (b === v) {
|
|
292
|
+
h = 2 / 3 + gdif - rdif;
|
|
293
|
+
}
|
|
294
|
+
if (h < 0) {
|
|
295
|
+
h += 1;
|
|
296
|
+
} else if (h > 1) {
|
|
297
|
+
h -= 1;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return [
|
|
301
|
+
h * 360,
|
|
302
|
+
s * 100,
|
|
303
|
+
v * 100
|
|
304
|
+
];
|
|
305
|
+
};
|
|
306
|
+
convert.rgb.hwb = function(rgb) {
|
|
307
|
+
const r = rgb[0];
|
|
308
|
+
const g = rgb[1];
|
|
309
|
+
let b = rgb[2];
|
|
310
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
311
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
312
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
313
|
+
return [h, w * 100, b * 100];
|
|
314
|
+
};
|
|
315
|
+
convert.rgb.cmyk = function(rgb) {
|
|
316
|
+
const r = rgb[0] / 255;
|
|
317
|
+
const g = rgb[1] / 255;
|
|
318
|
+
const b = rgb[2] / 255;
|
|
319
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
320
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
321
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
322
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
323
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
324
|
+
};
|
|
325
|
+
function comparativeDistance(x, y) {
|
|
326
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
327
|
+
}
|
|
328
|
+
convert.rgb.keyword = function(rgb) {
|
|
329
|
+
const reversed = reverseKeywords[rgb];
|
|
330
|
+
if (reversed) {
|
|
331
|
+
return reversed;
|
|
332
|
+
}
|
|
333
|
+
let currentClosestDistance = Infinity;
|
|
334
|
+
let currentClosestKeyword;
|
|
335
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
336
|
+
const value = cssKeywords[keyword];
|
|
337
|
+
const distance = comparativeDistance(rgb, value);
|
|
338
|
+
if (distance < currentClosestDistance) {
|
|
339
|
+
currentClosestDistance = distance;
|
|
340
|
+
currentClosestKeyword = keyword;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return currentClosestKeyword;
|
|
344
|
+
};
|
|
345
|
+
convert.keyword.rgb = function(keyword) {
|
|
346
|
+
return cssKeywords[keyword];
|
|
347
|
+
};
|
|
348
|
+
convert.rgb.xyz = function(rgb) {
|
|
349
|
+
let r = rgb[0] / 255;
|
|
350
|
+
let g = rgb[1] / 255;
|
|
351
|
+
let b = rgb[2] / 255;
|
|
352
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
353
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
354
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
355
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
356
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
357
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
358
|
+
return [x * 100, y * 100, z * 100];
|
|
359
|
+
};
|
|
360
|
+
convert.rgb.lab = function(rgb) {
|
|
361
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
362
|
+
let x = xyz[0];
|
|
363
|
+
let y = xyz[1];
|
|
364
|
+
let z = xyz[2];
|
|
365
|
+
x /= 95.047;
|
|
366
|
+
y /= 100;
|
|
367
|
+
z /= 108.883;
|
|
368
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
369
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
370
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
371
|
+
const l = 116 * y - 16;
|
|
372
|
+
const a = 500 * (x - y);
|
|
373
|
+
const b = 200 * (y - z);
|
|
374
|
+
return [l, a, b];
|
|
375
|
+
};
|
|
376
|
+
convert.hsl.rgb = function(hsl) {
|
|
377
|
+
const h = hsl[0] / 360;
|
|
378
|
+
const s = hsl[1] / 100;
|
|
379
|
+
const l = hsl[2] / 100;
|
|
380
|
+
let t2;
|
|
381
|
+
let t3;
|
|
382
|
+
let val;
|
|
383
|
+
if (s === 0) {
|
|
384
|
+
val = l * 255;
|
|
385
|
+
return [val, val, val];
|
|
386
|
+
}
|
|
387
|
+
if (l < 0.5) {
|
|
388
|
+
t2 = l * (1 + s);
|
|
389
|
+
} else {
|
|
390
|
+
t2 = l + s - l * s;
|
|
391
|
+
}
|
|
392
|
+
const t1 = 2 * l - t2;
|
|
393
|
+
const rgb = [0, 0, 0];
|
|
394
|
+
for (let i = 0; i < 3; i++) {
|
|
395
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
396
|
+
if (t3 < 0) {
|
|
397
|
+
t3++;
|
|
398
|
+
}
|
|
399
|
+
if (t3 > 1) {
|
|
400
|
+
t3--;
|
|
401
|
+
}
|
|
402
|
+
if (6 * t3 < 1) {
|
|
403
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
404
|
+
} else if (2 * t3 < 1) {
|
|
405
|
+
val = t2;
|
|
406
|
+
} else if (3 * t3 < 2) {
|
|
407
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
408
|
+
} else {
|
|
409
|
+
val = t1;
|
|
410
|
+
}
|
|
411
|
+
rgb[i] = val * 255;
|
|
412
|
+
}
|
|
413
|
+
return rgb;
|
|
414
|
+
};
|
|
415
|
+
convert.hsl.hsv = function(hsl) {
|
|
416
|
+
const h = hsl[0];
|
|
417
|
+
let s = hsl[1] / 100;
|
|
418
|
+
let l = hsl[2] / 100;
|
|
419
|
+
let smin = s;
|
|
420
|
+
const lmin = Math.max(l, 0.01);
|
|
421
|
+
l *= 2;
|
|
422
|
+
s *= l <= 1 ? l : 2 - l;
|
|
423
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
424
|
+
const v = (l + s) / 2;
|
|
425
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
426
|
+
return [h, sv * 100, v * 100];
|
|
427
|
+
};
|
|
428
|
+
convert.hsv.rgb = function(hsv) {
|
|
429
|
+
const h = hsv[0] / 60;
|
|
430
|
+
const s = hsv[1] / 100;
|
|
431
|
+
let v = hsv[2] / 100;
|
|
432
|
+
const hi = Math.floor(h) % 6;
|
|
433
|
+
const f = h - Math.floor(h);
|
|
434
|
+
const p = 255 * v * (1 - s);
|
|
435
|
+
const q = 255 * v * (1 - s * f);
|
|
436
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
437
|
+
v *= 255;
|
|
438
|
+
switch (hi) {
|
|
439
|
+
case 0:
|
|
440
|
+
return [v, t, p];
|
|
441
|
+
case 1:
|
|
442
|
+
return [q, v, p];
|
|
443
|
+
case 2:
|
|
444
|
+
return [p, v, t];
|
|
445
|
+
case 3:
|
|
446
|
+
return [p, q, v];
|
|
447
|
+
case 4:
|
|
448
|
+
return [t, p, v];
|
|
449
|
+
case 5:
|
|
450
|
+
return [v, p, q];
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
convert.hsv.hsl = function(hsv) {
|
|
454
|
+
const h = hsv[0];
|
|
455
|
+
const s = hsv[1] / 100;
|
|
456
|
+
const v = hsv[2] / 100;
|
|
457
|
+
const vmin = Math.max(v, 0.01);
|
|
458
|
+
let sl;
|
|
459
|
+
let l;
|
|
460
|
+
l = (2 - s) * v;
|
|
461
|
+
const lmin = (2 - s) * vmin;
|
|
462
|
+
sl = s * vmin;
|
|
463
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
464
|
+
sl = sl || 0;
|
|
465
|
+
l /= 2;
|
|
466
|
+
return [h, sl * 100, l * 100];
|
|
467
|
+
};
|
|
468
|
+
convert.hwb.rgb = function(hwb) {
|
|
469
|
+
const h = hwb[0] / 360;
|
|
470
|
+
let wh = hwb[1] / 100;
|
|
471
|
+
let bl = hwb[2] / 100;
|
|
472
|
+
const ratio = wh + bl;
|
|
473
|
+
let f;
|
|
474
|
+
if (ratio > 1) {
|
|
475
|
+
wh /= ratio;
|
|
476
|
+
bl /= ratio;
|
|
477
|
+
}
|
|
478
|
+
const i = Math.floor(6 * h);
|
|
479
|
+
const v = 1 - bl;
|
|
480
|
+
f = 6 * h - i;
|
|
481
|
+
if ((i & 1) !== 0) {
|
|
482
|
+
f = 1 - f;
|
|
483
|
+
}
|
|
484
|
+
const n = wh + f * (v - wh);
|
|
485
|
+
let r;
|
|
486
|
+
let g;
|
|
487
|
+
let b;
|
|
488
|
+
switch (i) {
|
|
489
|
+
default:
|
|
490
|
+
case 6:
|
|
491
|
+
case 0:
|
|
492
|
+
r = v;
|
|
493
|
+
g = n;
|
|
494
|
+
b = wh;
|
|
495
|
+
break;
|
|
496
|
+
case 1:
|
|
497
|
+
r = n;
|
|
498
|
+
g = v;
|
|
499
|
+
b = wh;
|
|
500
|
+
break;
|
|
501
|
+
case 2:
|
|
502
|
+
r = wh;
|
|
503
|
+
g = v;
|
|
504
|
+
b = n;
|
|
505
|
+
break;
|
|
506
|
+
case 3:
|
|
507
|
+
r = wh;
|
|
508
|
+
g = n;
|
|
509
|
+
b = v;
|
|
510
|
+
break;
|
|
511
|
+
case 4:
|
|
512
|
+
r = n;
|
|
513
|
+
g = wh;
|
|
514
|
+
b = v;
|
|
515
|
+
break;
|
|
516
|
+
case 5:
|
|
517
|
+
r = v;
|
|
518
|
+
g = wh;
|
|
519
|
+
b = n;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
return [r * 255, g * 255, b * 255];
|
|
523
|
+
};
|
|
524
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
525
|
+
const c = cmyk[0] / 100;
|
|
526
|
+
const m = cmyk[1] / 100;
|
|
527
|
+
const y = cmyk[2] / 100;
|
|
528
|
+
const k = cmyk[3] / 100;
|
|
529
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
530
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
531
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
532
|
+
return [r * 255, g * 255, b * 255];
|
|
533
|
+
};
|
|
534
|
+
convert.xyz.rgb = function(xyz) {
|
|
535
|
+
const x = xyz[0] / 100;
|
|
536
|
+
const y = xyz[1] / 100;
|
|
537
|
+
const z = xyz[2] / 100;
|
|
538
|
+
let r;
|
|
539
|
+
let g;
|
|
540
|
+
let b;
|
|
541
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
542
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
543
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
544
|
+
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
545
|
+
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
546
|
+
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
547
|
+
r = Math.min(Math.max(0, r), 1);
|
|
548
|
+
g = Math.min(Math.max(0, g), 1);
|
|
549
|
+
b = Math.min(Math.max(0, b), 1);
|
|
550
|
+
return [r * 255, g * 255, b * 255];
|
|
551
|
+
};
|
|
552
|
+
convert.xyz.lab = function(xyz) {
|
|
553
|
+
let x = xyz[0];
|
|
554
|
+
let y = xyz[1];
|
|
555
|
+
let z = xyz[2];
|
|
556
|
+
x /= 95.047;
|
|
557
|
+
y /= 100;
|
|
558
|
+
z /= 108.883;
|
|
559
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
560
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
561
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
562
|
+
const l = 116 * y - 16;
|
|
563
|
+
const a = 500 * (x - y);
|
|
564
|
+
const b = 200 * (y - z);
|
|
565
|
+
return [l, a, b];
|
|
566
|
+
};
|
|
567
|
+
convert.lab.xyz = function(lab) {
|
|
568
|
+
const l = lab[0];
|
|
569
|
+
const a = lab[1];
|
|
570
|
+
const b = lab[2];
|
|
571
|
+
let x;
|
|
572
|
+
let y;
|
|
573
|
+
let z;
|
|
574
|
+
y = (l + 16) / 116;
|
|
575
|
+
x = a / 500 + y;
|
|
576
|
+
z = y - b / 200;
|
|
577
|
+
const y2 = y ** 3;
|
|
578
|
+
const x2 = x ** 3;
|
|
579
|
+
const z2 = z ** 3;
|
|
580
|
+
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
581
|
+
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
582
|
+
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
583
|
+
x *= 95.047;
|
|
584
|
+
y *= 100;
|
|
585
|
+
z *= 108.883;
|
|
586
|
+
return [x, y, z];
|
|
587
|
+
};
|
|
588
|
+
convert.lab.lch = function(lab) {
|
|
589
|
+
const l = lab[0];
|
|
590
|
+
const a = lab[1];
|
|
591
|
+
const b = lab[2];
|
|
592
|
+
let h;
|
|
593
|
+
const hr = Math.atan2(b, a);
|
|
594
|
+
h = hr * 360 / 2 / Math.PI;
|
|
595
|
+
if (h < 0) {
|
|
596
|
+
h += 360;
|
|
597
|
+
}
|
|
598
|
+
const c = Math.sqrt(a * a + b * b);
|
|
599
|
+
return [l, c, h];
|
|
600
|
+
};
|
|
601
|
+
convert.lch.lab = function(lch) {
|
|
602
|
+
const l = lch[0];
|
|
603
|
+
const c = lch[1];
|
|
604
|
+
const h = lch[2];
|
|
605
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
606
|
+
const a = c * Math.cos(hr);
|
|
607
|
+
const b = c * Math.sin(hr);
|
|
608
|
+
return [l, a, b];
|
|
609
|
+
};
|
|
610
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
611
|
+
const [r, g, b] = args;
|
|
612
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
613
|
+
value = Math.round(value / 50);
|
|
614
|
+
if (value === 0) {
|
|
615
|
+
return 30;
|
|
616
|
+
}
|
|
617
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
618
|
+
if (value === 2) {
|
|
619
|
+
ansi += 60;
|
|
620
|
+
}
|
|
621
|
+
return ansi;
|
|
622
|
+
};
|
|
623
|
+
convert.hsv.ansi16 = function(args) {
|
|
624
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
625
|
+
};
|
|
626
|
+
convert.rgb.ansi256 = function(args) {
|
|
627
|
+
const r = args[0];
|
|
628
|
+
const g = args[1];
|
|
629
|
+
const b = args[2];
|
|
630
|
+
if (r === g && g === b) {
|
|
631
|
+
if (r < 8) {
|
|
632
|
+
return 16;
|
|
633
|
+
}
|
|
634
|
+
if (r > 248) {
|
|
635
|
+
return 231;
|
|
636
|
+
}
|
|
637
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
638
|
+
}
|
|
639
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
640
|
+
return ansi;
|
|
641
|
+
};
|
|
642
|
+
convert.ansi16.rgb = function(args) {
|
|
643
|
+
let color = args % 10;
|
|
644
|
+
if (color === 0 || color === 7) {
|
|
645
|
+
if (args > 50) {
|
|
646
|
+
color += 3.5;
|
|
647
|
+
}
|
|
648
|
+
color = color / 10.5 * 255;
|
|
649
|
+
return [color, color, color];
|
|
650
|
+
}
|
|
651
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
652
|
+
const r = (color & 1) * mult * 255;
|
|
653
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
654
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
655
|
+
return [r, g, b];
|
|
656
|
+
};
|
|
657
|
+
convert.ansi256.rgb = function(args) {
|
|
658
|
+
if (args >= 232) {
|
|
659
|
+
const c = (args - 232) * 10 + 8;
|
|
660
|
+
return [c, c, c];
|
|
661
|
+
}
|
|
662
|
+
args -= 16;
|
|
663
|
+
let rem;
|
|
664
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
665
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
666
|
+
const b = rem % 6 / 5 * 255;
|
|
667
|
+
return [r, g, b];
|
|
668
|
+
};
|
|
669
|
+
convert.rgb.hex = function(args) {
|
|
670
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
671
|
+
const string = integer.toString(16).toUpperCase();
|
|
672
|
+
return "000000".substring(string.length) + string;
|
|
673
|
+
};
|
|
674
|
+
convert.hex.rgb = function(args) {
|
|
675
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
676
|
+
if (!match) {
|
|
677
|
+
return [0, 0, 0];
|
|
678
|
+
}
|
|
679
|
+
let colorString = match[0];
|
|
680
|
+
if (match[0].length === 3) {
|
|
681
|
+
colorString = colorString.split("").map((char) => {
|
|
682
|
+
return char + char;
|
|
683
|
+
}).join("");
|
|
684
|
+
}
|
|
685
|
+
const integer = parseInt(colorString, 16);
|
|
686
|
+
const r = integer >> 16 & 255;
|
|
687
|
+
const g = integer >> 8 & 255;
|
|
688
|
+
const b = integer & 255;
|
|
689
|
+
return [r, g, b];
|
|
690
|
+
};
|
|
691
|
+
convert.rgb.hcg = function(rgb) {
|
|
692
|
+
const r = rgb[0] / 255;
|
|
693
|
+
const g = rgb[1] / 255;
|
|
694
|
+
const b = rgb[2] / 255;
|
|
695
|
+
const max = Math.max(Math.max(r, g), b);
|
|
696
|
+
const min = Math.min(Math.min(r, g), b);
|
|
697
|
+
const chroma = max - min;
|
|
698
|
+
let grayscale;
|
|
699
|
+
let hue;
|
|
700
|
+
if (chroma < 1) {
|
|
701
|
+
grayscale = min / (1 - chroma);
|
|
702
|
+
} else {
|
|
703
|
+
grayscale = 0;
|
|
704
|
+
}
|
|
705
|
+
if (chroma <= 0) {
|
|
706
|
+
hue = 0;
|
|
707
|
+
} else if (max === r) {
|
|
708
|
+
hue = (g - b) / chroma % 6;
|
|
709
|
+
} else if (max === g) {
|
|
710
|
+
hue = 2 + (b - r) / chroma;
|
|
711
|
+
} else {
|
|
712
|
+
hue = 4 + (r - g) / chroma;
|
|
713
|
+
}
|
|
714
|
+
hue /= 6;
|
|
715
|
+
hue %= 1;
|
|
716
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
717
|
+
};
|
|
718
|
+
convert.hsl.hcg = function(hsl) {
|
|
719
|
+
const s = hsl[1] / 100;
|
|
720
|
+
const l = hsl[2] / 100;
|
|
721
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
722
|
+
let f = 0;
|
|
723
|
+
if (c < 1) {
|
|
724
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
725
|
+
}
|
|
726
|
+
return [hsl[0], c * 100, f * 100];
|
|
727
|
+
};
|
|
728
|
+
convert.hsv.hcg = function(hsv) {
|
|
729
|
+
const s = hsv[1] / 100;
|
|
730
|
+
const v = hsv[2] / 100;
|
|
731
|
+
const c = s * v;
|
|
732
|
+
let f = 0;
|
|
733
|
+
if (c < 1) {
|
|
734
|
+
f = (v - c) / (1 - c);
|
|
735
|
+
}
|
|
736
|
+
return [hsv[0], c * 100, f * 100];
|
|
737
|
+
};
|
|
738
|
+
convert.hcg.rgb = function(hcg) {
|
|
739
|
+
const h = hcg[0] / 360;
|
|
740
|
+
const c = hcg[1] / 100;
|
|
741
|
+
const g = hcg[2] / 100;
|
|
742
|
+
if (c === 0) {
|
|
743
|
+
return [g * 255, g * 255, g * 255];
|
|
744
|
+
}
|
|
745
|
+
const pure = [0, 0, 0];
|
|
746
|
+
const hi = h % 1 * 6;
|
|
747
|
+
const v = hi % 1;
|
|
748
|
+
const w = 1 - v;
|
|
749
|
+
let mg = 0;
|
|
750
|
+
switch (Math.floor(hi)) {
|
|
751
|
+
case 0:
|
|
752
|
+
pure[0] = 1;
|
|
753
|
+
pure[1] = v;
|
|
754
|
+
pure[2] = 0;
|
|
755
|
+
break;
|
|
756
|
+
case 1:
|
|
757
|
+
pure[0] = w;
|
|
758
|
+
pure[1] = 1;
|
|
759
|
+
pure[2] = 0;
|
|
760
|
+
break;
|
|
761
|
+
case 2:
|
|
762
|
+
pure[0] = 0;
|
|
763
|
+
pure[1] = 1;
|
|
764
|
+
pure[2] = v;
|
|
765
|
+
break;
|
|
766
|
+
case 3:
|
|
767
|
+
pure[0] = 0;
|
|
768
|
+
pure[1] = w;
|
|
769
|
+
pure[2] = 1;
|
|
770
|
+
break;
|
|
771
|
+
case 4:
|
|
772
|
+
pure[0] = v;
|
|
773
|
+
pure[1] = 0;
|
|
774
|
+
pure[2] = 1;
|
|
775
|
+
break;
|
|
776
|
+
default:
|
|
777
|
+
pure[0] = 1;
|
|
778
|
+
pure[1] = 0;
|
|
779
|
+
pure[2] = w;
|
|
780
|
+
}
|
|
781
|
+
mg = (1 - c) * g;
|
|
782
|
+
return [
|
|
783
|
+
(c * pure[0] + mg) * 255,
|
|
784
|
+
(c * pure[1] + mg) * 255,
|
|
785
|
+
(c * pure[2] + mg) * 255
|
|
786
|
+
];
|
|
787
|
+
};
|
|
788
|
+
convert.hcg.hsv = function(hcg) {
|
|
789
|
+
const c = hcg[1] / 100;
|
|
790
|
+
const g = hcg[2] / 100;
|
|
791
|
+
const v = c + g * (1 - c);
|
|
792
|
+
let f = 0;
|
|
793
|
+
if (v > 0) {
|
|
794
|
+
f = c / v;
|
|
795
|
+
}
|
|
796
|
+
return [hcg[0], f * 100, v * 100];
|
|
797
|
+
};
|
|
798
|
+
convert.hcg.hsl = function(hcg) {
|
|
799
|
+
const c = hcg[1] / 100;
|
|
800
|
+
const g = hcg[2] / 100;
|
|
801
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
802
|
+
let s = 0;
|
|
803
|
+
if (l > 0 && l < 0.5) {
|
|
804
|
+
s = c / (2 * l);
|
|
805
|
+
} else if (l >= 0.5 && l < 1) {
|
|
806
|
+
s = c / (2 * (1 - l));
|
|
807
|
+
}
|
|
808
|
+
return [hcg[0], s * 100, l * 100];
|
|
809
|
+
};
|
|
810
|
+
convert.hcg.hwb = function(hcg) {
|
|
811
|
+
const c = hcg[1] / 100;
|
|
812
|
+
const g = hcg[2] / 100;
|
|
813
|
+
const v = c + g * (1 - c);
|
|
814
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
815
|
+
};
|
|
816
|
+
convert.hwb.hcg = function(hwb) {
|
|
817
|
+
const w = hwb[1] / 100;
|
|
818
|
+
const b = hwb[2] / 100;
|
|
819
|
+
const v = 1 - b;
|
|
820
|
+
const c = v - w;
|
|
821
|
+
let g = 0;
|
|
822
|
+
if (c < 1) {
|
|
823
|
+
g = (v - c) / (1 - c);
|
|
824
|
+
}
|
|
825
|
+
return [hwb[0], c * 100, g * 100];
|
|
826
|
+
};
|
|
827
|
+
convert.apple.rgb = function(apple) {
|
|
828
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
829
|
+
};
|
|
830
|
+
convert.rgb.apple = function(rgb) {
|
|
831
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
832
|
+
};
|
|
833
|
+
convert.gray.rgb = function(args) {
|
|
834
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
835
|
+
};
|
|
836
|
+
convert.gray.hsl = function(args) {
|
|
837
|
+
return [0, 0, args[0]];
|
|
838
|
+
};
|
|
839
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
840
|
+
convert.gray.hwb = function(gray) {
|
|
841
|
+
return [0, 100, gray[0]];
|
|
842
|
+
};
|
|
843
|
+
convert.gray.cmyk = function(gray) {
|
|
844
|
+
return [0, 0, 0, gray[0]];
|
|
845
|
+
};
|
|
846
|
+
convert.gray.lab = function(gray) {
|
|
847
|
+
return [gray[0], 0, 0];
|
|
848
|
+
};
|
|
849
|
+
convert.gray.hex = function(gray) {
|
|
850
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
851
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
852
|
+
const string = integer.toString(16).toUpperCase();
|
|
853
|
+
return "000000".substring(string.length) + string;
|
|
854
|
+
};
|
|
855
|
+
convert.rgb.gray = function(rgb) {
|
|
856
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
857
|
+
return [val / 255 * 100];
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// ../../node_modules/color-convert/route.js
|
|
863
|
+
var require_route = __commonJS({
|
|
864
|
+
"../../node_modules/color-convert/route.js"(exports, module2) {
|
|
865
|
+
"use strict";
|
|
866
|
+
var conversions = require_conversions();
|
|
867
|
+
function buildGraph() {
|
|
868
|
+
const graph = {};
|
|
869
|
+
const models = Object.keys(conversions);
|
|
870
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
871
|
+
graph[models[i]] = {
|
|
872
|
+
// http://jsperf.com/1-vs-infinity
|
|
873
|
+
// micro-opt, but this is simple.
|
|
874
|
+
distance: -1,
|
|
875
|
+
parent: null
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
return graph;
|
|
879
|
+
}
|
|
880
|
+
function deriveBFS(fromModel) {
|
|
881
|
+
const graph = buildGraph();
|
|
882
|
+
const queue = [fromModel];
|
|
883
|
+
graph[fromModel].distance = 0;
|
|
884
|
+
while (queue.length) {
|
|
885
|
+
const current = queue.pop();
|
|
886
|
+
const adjacents = Object.keys(conversions[current]);
|
|
887
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
888
|
+
const adjacent = adjacents[i];
|
|
889
|
+
const node = graph[adjacent];
|
|
890
|
+
if (node.distance === -1) {
|
|
891
|
+
node.distance = graph[current].distance + 1;
|
|
892
|
+
node.parent = current;
|
|
893
|
+
queue.unshift(adjacent);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return graph;
|
|
898
|
+
}
|
|
899
|
+
function link(from, to) {
|
|
900
|
+
return function(args) {
|
|
901
|
+
return to(from(args));
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
function wrapConversion(toModel, graph) {
|
|
905
|
+
const path = [graph[toModel].parent, toModel];
|
|
906
|
+
let fn = conversions[graph[toModel].parent][toModel];
|
|
907
|
+
let cur = graph[toModel].parent;
|
|
908
|
+
while (graph[cur].parent) {
|
|
909
|
+
path.unshift(graph[cur].parent);
|
|
910
|
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
911
|
+
cur = graph[cur].parent;
|
|
912
|
+
}
|
|
913
|
+
fn.conversion = path;
|
|
914
|
+
return fn;
|
|
915
|
+
}
|
|
916
|
+
module2.exports = function(fromModel) {
|
|
917
|
+
const graph = deriveBFS(fromModel);
|
|
918
|
+
const conversion = {};
|
|
919
|
+
const models = Object.keys(graph);
|
|
920
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
921
|
+
const toModel = models[i];
|
|
922
|
+
const node = graph[toModel];
|
|
923
|
+
if (node.parent === null) {
|
|
924
|
+
continue;
|
|
925
|
+
}
|
|
926
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
927
|
+
}
|
|
928
|
+
return conversion;
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
// ../../node_modules/color-convert/index.js
|
|
934
|
+
var require_color_convert = __commonJS({
|
|
935
|
+
"../../node_modules/color-convert/index.js"(exports, module2) {
|
|
936
|
+
"use strict";
|
|
937
|
+
var conversions = require_conversions();
|
|
938
|
+
var route = require_route();
|
|
939
|
+
var convert = {};
|
|
940
|
+
var models = Object.keys(conversions);
|
|
941
|
+
function wrapRaw(fn) {
|
|
942
|
+
const wrappedFn = function(...args) {
|
|
943
|
+
const arg0 = args[0];
|
|
944
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
945
|
+
return arg0;
|
|
946
|
+
}
|
|
947
|
+
if (arg0.length > 1) {
|
|
948
|
+
args = arg0;
|
|
949
|
+
}
|
|
950
|
+
return fn(args);
|
|
951
|
+
};
|
|
952
|
+
if ("conversion" in fn) {
|
|
953
|
+
wrappedFn.conversion = fn.conversion;
|
|
954
|
+
}
|
|
955
|
+
return wrappedFn;
|
|
956
|
+
}
|
|
957
|
+
function wrapRounded(fn) {
|
|
958
|
+
const wrappedFn = function(...args) {
|
|
959
|
+
const arg0 = args[0];
|
|
960
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
961
|
+
return arg0;
|
|
962
|
+
}
|
|
963
|
+
if (arg0.length > 1) {
|
|
964
|
+
args = arg0;
|
|
965
|
+
}
|
|
966
|
+
const result = fn(args);
|
|
967
|
+
if (typeof result === "object") {
|
|
968
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
969
|
+
result[i] = Math.round(result[i]);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
return result;
|
|
973
|
+
};
|
|
974
|
+
if ("conversion" in fn) {
|
|
975
|
+
wrappedFn.conversion = fn.conversion;
|
|
976
|
+
}
|
|
977
|
+
return wrappedFn;
|
|
978
|
+
}
|
|
979
|
+
models.forEach((fromModel) => {
|
|
980
|
+
convert[fromModel] = {};
|
|
981
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
982
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
983
|
+
const routes = route(fromModel);
|
|
984
|
+
const routeModels = Object.keys(routes);
|
|
985
|
+
routeModels.forEach((toModel) => {
|
|
986
|
+
const fn = routes[toModel];
|
|
987
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
988
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
module2.exports = convert;
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
|
|
995
|
+
// ../../node_modules/ansi-styles/index.js
|
|
996
|
+
var require_ansi_styles = __commonJS({
|
|
997
|
+
"../../node_modules/ansi-styles/index.js"(exports, module2) {
|
|
998
|
+
"use strict";
|
|
999
|
+
var wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1000
|
+
const code = fn(...args);
|
|
1001
|
+
return `\x1B[${code + offset}m`;
|
|
1002
|
+
};
|
|
1003
|
+
var wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1004
|
+
const code = fn(...args);
|
|
1005
|
+
return `\x1B[${38 + offset};5;${code}m`;
|
|
1006
|
+
};
|
|
1007
|
+
var wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1008
|
+
const rgb = fn(...args);
|
|
1009
|
+
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1010
|
+
};
|
|
1011
|
+
var ansi2ansi = (n) => n;
|
|
1012
|
+
var rgb2rgb = (r, g, b) => [r, g, b];
|
|
1013
|
+
var setLazyProperty = (object, property, get) => {
|
|
1014
|
+
Object.defineProperty(object, property, {
|
|
1015
|
+
get: () => {
|
|
1016
|
+
const value = get();
|
|
1017
|
+
Object.defineProperty(object, property, {
|
|
1018
|
+
value,
|
|
1019
|
+
enumerable: true,
|
|
1020
|
+
configurable: true
|
|
1021
|
+
});
|
|
1022
|
+
return value;
|
|
1023
|
+
},
|
|
1024
|
+
enumerable: true,
|
|
1025
|
+
configurable: true
|
|
1026
|
+
});
|
|
1027
|
+
};
|
|
1028
|
+
var colorConvert;
|
|
1029
|
+
var makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1030
|
+
if (colorConvert === void 0) {
|
|
1031
|
+
colorConvert = require_color_convert();
|
|
1032
|
+
}
|
|
1033
|
+
const offset = isBackground ? 10 : 0;
|
|
1034
|
+
const styles = {};
|
|
1035
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
|
1036
|
+
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1037
|
+
if (sourceSpace === targetSpace) {
|
|
1038
|
+
styles[name] = wrap(identity, offset);
|
|
1039
|
+
} else if (typeof suite === "object") {
|
|
1040
|
+
styles[name] = wrap(suite[targetSpace], offset);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return styles;
|
|
1044
|
+
};
|
|
1045
|
+
function assembleStyles() {
|
|
1046
|
+
const codes = /* @__PURE__ */ new Map();
|
|
1047
|
+
const styles = {
|
|
1048
|
+
modifier: {
|
|
1049
|
+
reset: [0, 0],
|
|
1050
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
1051
|
+
bold: [1, 22],
|
|
1052
|
+
dim: [2, 22],
|
|
1053
|
+
italic: [3, 23],
|
|
1054
|
+
underline: [4, 24],
|
|
1055
|
+
inverse: [7, 27],
|
|
1056
|
+
hidden: [8, 28],
|
|
1057
|
+
strikethrough: [9, 29]
|
|
1058
|
+
},
|
|
1059
|
+
color: {
|
|
1060
|
+
black: [30, 39],
|
|
1061
|
+
red: [31, 39],
|
|
1062
|
+
green: [32, 39],
|
|
1063
|
+
yellow: [33, 39],
|
|
1064
|
+
blue: [34, 39],
|
|
1065
|
+
magenta: [35, 39],
|
|
1066
|
+
cyan: [36, 39],
|
|
1067
|
+
white: [37, 39],
|
|
1068
|
+
// Bright color
|
|
1069
|
+
blackBright: [90, 39],
|
|
1070
|
+
redBright: [91, 39],
|
|
1071
|
+
greenBright: [92, 39],
|
|
1072
|
+
yellowBright: [93, 39],
|
|
1073
|
+
blueBright: [94, 39],
|
|
1074
|
+
magentaBright: [95, 39],
|
|
1075
|
+
cyanBright: [96, 39],
|
|
1076
|
+
whiteBright: [97, 39]
|
|
1077
|
+
},
|
|
1078
|
+
bgColor: {
|
|
1079
|
+
bgBlack: [40, 49],
|
|
1080
|
+
bgRed: [41, 49],
|
|
1081
|
+
bgGreen: [42, 49],
|
|
1082
|
+
bgYellow: [43, 49],
|
|
1083
|
+
bgBlue: [44, 49],
|
|
1084
|
+
bgMagenta: [45, 49],
|
|
1085
|
+
bgCyan: [46, 49],
|
|
1086
|
+
bgWhite: [47, 49],
|
|
1087
|
+
// Bright color
|
|
1088
|
+
bgBlackBright: [100, 49],
|
|
1089
|
+
bgRedBright: [101, 49],
|
|
1090
|
+
bgGreenBright: [102, 49],
|
|
1091
|
+
bgYellowBright: [103, 49],
|
|
1092
|
+
bgBlueBright: [104, 49],
|
|
1093
|
+
bgMagentaBright: [105, 49],
|
|
1094
|
+
bgCyanBright: [106, 49],
|
|
1095
|
+
bgWhiteBright: [107, 49]
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
styles.color.gray = styles.color.blackBright;
|
|
1099
|
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
1100
|
+
styles.color.grey = styles.color.blackBright;
|
|
1101
|
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
1102
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
1103
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
1104
|
+
styles[styleName] = {
|
|
1105
|
+
open: `\x1B[${style[0]}m`,
|
|
1106
|
+
close: `\x1B[${style[1]}m`
|
|
1107
|
+
};
|
|
1108
|
+
group[styleName] = styles[styleName];
|
|
1109
|
+
codes.set(style[0], style[1]);
|
|
1110
|
+
}
|
|
1111
|
+
Object.defineProperty(styles, groupName, {
|
|
1112
|
+
value: group,
|
|
1113
|
+
enumerable: false
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
Object.defineProperty(styles, "codes", {
|
|
1117
|
+
value: codes,
|
|
1118
|
+
enumerable: false
|
|
1119
|
+
});
|
|
1120
|
+
styles.color.close = "\x1B[39m";
|
|
1121
|
+
styles.bgColor.close = "\x1B[49m";
|
|
1122
|
+
setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1123
|
+
setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1124
|
+
setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1125
|
+
setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1126
|
+
setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1127
|
+
setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1128
|
+
return styles;
|
|
1129
|
+
}
|
|
1130
|
+
Object.defineProperty(module2, "exports", {
|
|
1131
|
+
enumerable: true,
|
|
1132
|
+
get: assembleStyles
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
// ../../node_modules/has-flag/index.js
|
|
1138
|
+
var require_has_flag = __commonJS({
|
|
1139
|
+
"../../node_modules/has-flag/index.js"(exports, module2) {
|
|
1140
|
+
"use strict";
|
|
1141
|
+
module2.exports = (flag, argv = process.argv) => {
|
|
1142
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
1143
|
+
const position = argv.indexOf(prefix + flag);
|
|
1144
|
+
const terminatorPosition = argv.indexOf("--");
|
|
1145
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// ../../node_modules/supports-color/index.js
|
|
1151
|
+
var require_supports_color = __commonJS({
|
|
1152
|
+
"../../node_modules/supports-color/index.js"(exports, module2) {
|
|
1153
|
+
"use strict";
|
|
1154
|
+
var os = require("os");
|
|
1155
|
+
var tty = require("tty");
|
|
1156
|
+
var hasFlag = require_has_flag();
|
|
1157
|
+
var { env } = process;
|
|
1158
|
+
var forceColor;
|
|
1159
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
1160
|
+
forceColor = 0;
|
|
1161
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
1162
|
+
forceColor = 1;
|
|
1163
|
+
}
|
|
1164
|
+
if ("FORCE_COLOR" in env) {
|
|
1165
|
+
if (env.FORCE_COLOR === "true") {
|
|
1166
|
+
forceColor = 1;
|
|
1167
|
+
} else if (env.FORCE_COLOR === "false") {
|
|
1168
|
+
forceColor = 0;
|
|
1169
|
+
} else {
|
|
1170
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
function translateLevel(level) {
|
|
1174
|
+
if (level === 0) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
level,
|
|
1179
|
+
hasBasic: true,
|
|
1180
|
+
has256: level >= 2,
|
|
1181
|
+
has16m: level >= 3
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
1185
|
+
if (forceColor === 0) {
|
|
1186
|
+
return 0;
|
|
1187
|
+
}
|
|
1188
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
1189
|
+
return 3;
|
|
1190
|
+
}
|
|
1191
|
+
if (hasFlag("color=256")) {
|
|
1192
|
+
return 2;
|
|
1193
|
+
}
|
|
1194
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
1195
|
+
return 0;
|
|
1196
|
+
}
|
|
1197
|
+
const min = forceColor || 0;
|
|
1198
|
+
if (env.TERM === "dumb") {
|
|
1199
|
+
return min;
|
|
1200
|
+
}
|
|
1201
|
+
if (process.platform === "win32") {
|
|
1202
|
+
const osRelease = os.release().split(".");
|
|
1203
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
1204
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
1205
|
+
}
|
|
1206
|
+
return 1;
|
|
1207
|
+
}
|
|
1208
|
+
if ("CI" in env) {
|
|
1209
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
1210
|
+
return 1;
|
|
1211
|
+
}
|
|
1212
|
+
return min;
|
|
1213
|
+
}
|
|
1214
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
1215
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
1216
|
+
}
|
|
1217
|
+
if (env.COLORTERM === "truecolor") {
|
|
1218
|
+
return 3;
|
|
1219
|
+
}
|
|
1220
|
+
if ("TERM_PROGRAM" in env) {
|
|
1221
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1222
|
+
switch (env.TERM_PROGRAM) {
|
|
1223
|
+
case "iTerm.app":
|
|
1224
|
+
return version >= 3 ? 3 : 2;
|
|
1225
|
+
case "Apple_Terminal":
|
|
1226
|
+
return 2;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
1230
|
+
return 2;
|
|
1231
|
+
}
|
|
1232
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
1233
|
+
return 1;
|
|
1234
|
+
}
|
|
1235
|
+
if ("COLORTERM" in env) {
|
|
1236
|
+
return 1;
|
|
1237
|
+
}
|
|
1238
|
+
return min;
|
|
1239
|
+
}
|
|
1240
|
+
function getSupportLevel(stream) {
|
|
1241
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
1242
|
+
return translateLevel(level);
|
|
1243
|
+
}
|
|
1244
|
+
module2.exports = {
|
|
1245
|
+
supportsColor: getSupportLevel,
|
|
1246
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
1247
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
// ../../node_modules/chalk/source/util.js
|
|
1253
|
+
var require_util = __commonJS({
|
|
1254
|
+
"../../node_modules/chalk/source/util.js"(exports, module2) {
|
|
1255
|
+
"use strict";
|
|
1256
|
+
var stringReplaceAll = (string, substring, replacer) => {
|
|
1257
|
+
let index = string.indexOf(substring);
|
|
1258
|
+
if (index === -1) {
|
|
1259
|
+
return string;
|
|
1260
|
+
}
|
|
1261
|
+
const substringLength = substring.length;
|
|
1262
|
+
let endIndex = 0;
|
|
1263
|
+
let returnValue = "";
|
|
1264
|
+
do {
|
|
1265
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1266
|
+
endIndex = index + substringLength;
|
|
1267
|
+
index = string.indexOf(substring, endIndex);
|
|
1268
|
+
} while (index !== -1);
|
|
1269
|
+
returnValue += string.substr(endIndex);
|
|
1270
|
+
return returnValue;
|
|
1271
|
+
};
|
|
1272
|
+
var stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
|
1273
|
+
let endIndex = 0;
|
|
1274
|
+
let returnValue = "";
|
|
1275
|
+
do {
|
|
1276
|
+
const gotCR = string[index - 1] === "\r";
|
|
1277
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1278
|
+
endIndex = index + 1;
|
|
1279
|
+
index = string.indexOf("\n", endIndex);
|
|
1280
|
+
} while (index !== -1);
|
|
1281
|
+
returnValue += string.substr(endIndex);
|
|
1282
|
+
return returnValue;
|
|
1283
|
+
};
|
|
1284
|
+
module2.exports = {
|
|
1285
|
+
stringReplaceAll,
|
|
1286
|
+
stringEncaseCRLFWithFirstIndex
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
// ../../node_modules/chalk/source/templates.js
|
|
1292
|
+
var require_templates = __commonJS({
|
|
1293
|
+
"../../node_modules/chalk/source/templates.js"(exports, module2) {
|
|
1294
|
+
"use strict";
|
|
1295
|
+
var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
1296
|
+
var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1297
|
+
var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1298
|
+
var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1299
|
+
var ESCAPES = /* @__PURE__ */ new Map([
|
|
1300
|
+
["n", "\n"],
|
|
1301
|
+
["r", "\r"],
|
|
1302
|
+
["t", " "],
|
|
1303
|
+
["b", "\b"],
|
|
1304
|
+
["f", "\f"],
|
|
1305
|
+
["v", "\v"],
|
|
1306
|
+
["0", "\0"],
|
|
1307
|
+
["\\", "\\"],
|
|
1308
|
+
["e", "\x1B"],
|
|
1309
|
+
["a", "\x07"]
|
|
1310
|
+
]);
|
|
1311
|
+
function unescape(c) {
|
|
1312
|
+
const u = c[0] === "u";
|
|
1313
|
+
const bracket = c[1] === "{";
|
|
1314
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1315
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1316
|
+
}
|
|
1317
|
+
if (u && bracket) {
|
|
1318
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1319
|
+
}
|
|
1320
|
+
return ESCAPES.get(c) || c;
|
|
1321
|
+
}
|
|
1322
|
+
function parseArguments(name, arguments_) {
|
|
1323
|
+
const results = [];
|
|
1324
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1325
|
+
let matches;
|
|
1326
|
+
for (const chunk of chunks) {
|
|
1327
|
+
const number = Number(chunk);
|
|
1328
|
+
if (!Number.isNaN(number)) {
|
|
1329
|
+
results.push(number);
|
|
1330
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1331
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
1332
|
+
} else {
|
|
1333
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
return results;
|
|
1337
|
+
}
|
|
1338
|
+
function parseStyle(style) {
|
|
1339
|
+
STYLE_REGEX.lastIndex = 0;
|
|
1340
|
+
const results = [];
|
|
1341
|
+
let matches;
|
|
1342
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1343
|
+
const name = matches[1];
|
|
1344
|
+
if (matches[2]) {
|
|
1345
|
+
const args = parseArguments(name, matches[2]);
|
|
1346
|
+
results.push([name].concat(args));
|
|
1347
|
+
} else {
|
|
1348
|
+
results.push([name]);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
return results;
|
|
1352
|
+
}
|
|
1353
|
+
function buildStyle(chalk2, styles) {
|
|
1354
|
+
const enabled = {};
|
|
1355
|
+
for (const layer of styles) {
|
|
1356
|
+
for (const style of layer.styles) {
|
|
1357
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
let current = chalk2;
|
|
1361
|
+
for (const [styleName, styles2] of Object.entries(enabled)) {
|
|
1362
|
+
if (!Array.isArray(styles2)) {
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
if (!(styleName in current)) {
|
|
1366
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1367
|
+
}
|
|
1368
|
+
current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
|
|
1369
|
+
}
|
|
1370
|
+
return current;
|
|
1371
|
+
}
|
|
1372
|
+
module2.exports = (chalk2, temporary) => {
|
|
1373
|
+
const styles = [];
|
|
1374
|
+
const chunks = [];
|
|
1375
|
+
let chunk = [];
|
|
1376
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1377
|
+
if (escapeCharacter) {
|
|
1378
|
+
chunk.push(unescape(escapeCharacter));
|
|
1379
|
+
} else if (style) {
|
|
1380
|
+
const string = chunk.join("");
|
|
1381
|
+
chunk = [];
|
|
1382
|
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk2, styles)(string));
|
|
1383
|
+
styles.push({ inverse, styles: parseStyle(style) });
|
|
1384
|
+
} else if (close) {
|
|
1385
|
+
if (styles.length === 0) {
|
|
1386
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
1387
|
+
}
|
|
1388
|
+
chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
|
|
1389
|
+
chunk = [];
|
|
1390
|
+
styles.pop();
|
|
1391
|
+
} else {
|
|
1392
|
+
chunk.push(character);
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
chunks.push(chunk.join(""));
|
|
1396
|
+
if (styles.length > 0) {
|
|
1397
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1398
|
+
throw new Error(errMessage);
|
|
1399
|
+
}
|
|
1400
|
+
return chunks.join("");
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
// ../../node_modules/chalk/source/index.js
|
|
1406
|
+
var require_source = __commonJS({
|
|
1407
|
+
"../../node_modules/chalk/source/index.js"(exports, module2) {
|
|
1408
|
+
"use strict";
|
|
1409
|
+
var ansiStyles = require_ansi_styles();
|
|
1410
|
+
var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
|
|
1411
|
+
var {
|
|
1412
|
+
stringReplaceAll,
|
|
1413
|
+
stringEncaseCRLFWithFirstIndex
|
|
1414
|
+
} = require_util();
|
|
1415
|
+
var { isArray } = Array;
|
|
1416
|
+
var levelMapping = [
|
|
1417
|
+
"ansi",
|
|
1418
|
+
"ansi",
|
|
1419
|
+
"ansi256",
|
|
1420
|
+
"ansi16m"
|
|
1421
|
+
];
|
|
1422
|
+
var styles = /* @__PURE__ */ Object.create(null);
|
|
1423
|
+
var applyOptions = (object, options = {}) => {
|
|
1424
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1425
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1426
|
+
}
|
|
1427
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1428
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1429
|
+
};
|
|
1430
|
+
var ChalkClass = class {
|
|
1431
|
+
constructor(options) {
|
|
1432
|
+
return chalkFactory(options);
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
var chalkFactory = (options) => {
|
|
1436
|
+
const chalk3 = {};
|
|
1437
|
+
applyOptions(chalk3, options);
|
|
1438
|
+
chalk3.template = (...arguments_) => chalkTag(chalk3.template, ...arguments_);
|
|
1439
|
+
Object.setPrototypeOf(chalk3, Chalk.prototype);
|
|
1440
|
+
Object.setPrototypeOf(chalk3.template, chalk3);
|
|
1441
|
+
chalk3.template.constructor = () => {
|
|
1442
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1443
|
+
};
|
|
1444
|
+
chalk3.template.Instance = ChalkClass;
|
|
1445
|
+
return chalk3.template;
|
|
1446
|
+
};
|
|
1447
|
+
function Chalk(options) {
|
|
1448
|
+
return chalkFactory(options);
|
|
1449
|
+
}
|
|
1450
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
1451
|
+
styles[styleName] = {
|
|
1452
|
+
get() {
|
|
1453
|
+
const builder2 = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
1454
|
+
Object.defineProperty(this, styleName, { value: builder2 });
|
|
1455
|
+
return builder2;
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
styles.visible = {
|
|
1460
|
+
get() {
|
|
1461
|
+
const builder2 = createBuilder(this, this._styler, true);
|
|
1462
|
+
Object.defineProperty(this, "visible", { value: builder2 });
|
|
1463
|
+
return builder2;
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1467
|
+
for (const model of usedModels) {
|
|
1468
|
+
styles[model] = {
|
|
1469
|
+
get() {
|
|
1470
|
+
const { level } = this;
|
|
1471
|
+
return function(...arguments_) {
|
|
1472
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
1473
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
for (const model of usedModels) {
|
|
1479
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1480
|
+
styles[bgModel] = {
|
|
1481
|
+
get() {
|
|
1482
|
+
const { level } = this;
|
|
1483
|
+
return function(...arguments_) {
|
|
1484
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
1485
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
var proto = Object.defineProperties(() => {
|
|
1491
|
+
}, {
|
|
1492
|
+
...styles,
|
|
1493
|
+
level: {
|
|
1494
|
+
enumerable: true,
|
|
1495
|
+
get() {
|
|
1496
|
+
return this._generator.level;
|
|
1497
|
+
},
|
|
1498
|
+
set(level) {
|
|
1499
|
+
this._generator.level = level;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
var createStyler = (open, close, parent) => {
|
|
1504
|
+
let openAll;
|
|
1505
|
+
let closeAll;
|
|
1506
|
+
if (parent === void 0) {
|
|
1507
|
+
openAll = open;
|
|
1508
|
+
closeAll = close;
|
|
1509
|
+
} else {
|
|
1510
|
+
openAll = parent.openAll + open;
|
|
1511
|
+
closeAll = close + parent.closeAll;
|
|
1512
|
+
}
|
|
1513
|
+
return {
|
|
1514
|
+
open,
|
|
1515
|
+
close,
|
|
1516
|
+
openAll,
|
|
1517
|
+
closeAll,
|
|
1518
|
+
parent
|
|
1519
|
+
};
|
|
1520
|
+
};
|
|
1521
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
1522
|
+
const builder2 = (...arguments_) => {
|
|
1523
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
1524
|
+
return applyStyle(builder2, chalkTag(builder2, ...arguments_));
|
|
1525
|
+
}
|
|
1526
|
+
return applyStyle(builder2, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1527
|
+
};
|
|
1528
|
+
Object.setPrototypeOf(builder2, proto);
|
|
1529
|
+
builder2._generator = self;
|
|
1530
|
+
builder2._styler = _styler;
|
|
1531
|
+
builder2._isEmpty = _isEmpty;
|
|
1532
|
+
return builder2;
|
|
1533
|
+
};
|
|
1534
|
+
var applyStyle = (self, string) => {
|
|
1535
|
+
if (self.level <= 0 || !string) {
|
|
1536
|
+
return self._isEmpty ? "" : string;
|
|
1537
|
+
}
|
|
1538
|
+
let styler = self._styler;
|
|
1539
|
+
if (styler === void 0) {
|
|
1540
|
+
return string;
|
|
1541
|
+
}
|
|
1542
|
+
const { openAll, closeAll } = styler;
|
|
1543
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
1544
|
+
while (styler !== void 0) {
|
|
1545
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
1546
|
+
styler = styler.parent;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
const lfIndex = string.indexOf("\n");
|
|
1550
|
+
if (lfIndex !== -1) {
|
|
1551
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1552
|
+
}
|
|
1553
|
+
return openAll + string + closeAll;
|
|
1554
|
+
};
|
|
1555
|
+
var template;
|
|
1556
|
+
var chalkTag = (chalk3, ...strings) => {
|
|
1557
|
+
const [firstString] = strings;
|
|
1558
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
1559
|
+
return strings.join(" ");
|
|
1560
|
+
}
|
|
1561
|
+
const arguments_ = strings.slice(1);
|
|
1562
|
+
const parts = [firstString.raw[0]];
|
|
1563
|
+
for (let i = 1; i < firstString.length; i++) {
|
|
1564
|
+
parts.push(
|
|
1565
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1566
|
+
String(firstString.raw[i])
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
if (template === void 0) {
|
|
1570
|
+
template = require_templates();
|
|
1571
|
+
}
|
|
1572
|
+
return template(chalk3, parts.join(""));
|
|
1573
|
+
};
|
|
1574
|
+
Object.defineProperties(Chalk.prototype, styles);
|
|
1575
|
+
var chalk2 = Chalk();
|
|
1576
|
+
chalk2.supportsColor = stdoutColor;
|
|
1577
|
+
chalk2.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1578
|
+
chalk2.stderr.supportsColor = stderrColor;
|
|
1579
|
+
module2.exports = chalk2;
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
|
|
1583
|
+
// src/index.ts
|
|
1584
|
+
var src_exports = {};
|
|
1585
|
+
__export(src_exports, {
|
|
1586
|
+
builder: () => builder,
|
|
1587
|
+
default: () => src_default,
|
|
1588
|
+
generateQuery: () => generateQuery,
|
|
1589
|
+
generateQueryHeader: () => generateQueryHeader,
|
|
1590
|
+
getReactQueryDependencies: () => getReactQueryDependencies,
|
|
1591
|
+
getSvelteQueryDependencies: () => getSvelteQueryDependencies,
|
|
1592
|
+
getVueQueryDependencies: () => getVueQueryDependencies
|
|
1593
|
+
});
|
|
1594
|
+
module.exports = __toCommonJS(src_exports);
|
|
1595
|
+
var import_core2 = require("@orval/core");
|
|
1596
|
+
var import_lodash = __toESM(require("lodash.omitby"));
|
|
1597
|
+
|
|
1598
|
+
// src/utils.ts
|
|
1599
|
+
var import_core = require("@orval/core");
|
|
1600
|
+
var import_chalk = __toESM(require_source());
|
|
1601
|
+
var normalizeQueryOptions = (queryOptions = {}, outputWorkspace) => {
|
|
1602
|
+
return {
|
|
1603
|
+
...queryOptions.usePrefetch ? { usePrefetch: true } : {},
|
|
1604
|
+
...queryOptions.useQuery ? { useQuery: true } : {},
|
|
1605
|
+
...queryOptions.useInfinite ? { useInfinite: true } : {},
|
|
1606
|
+
...queryOptions.useInfiniteQueryParam ? { useInfiniteQueryParam: queryOptions.useInfiniteQueryParam } : {},
|
|
1607
|
+
...queryOptions.options ? { options: queryOptions.options } : {},
|
|
1608
|
+
...(queryOptions == null ? void 0 : queryOptions.queryKey) ? {
|
|
1609
|
+
queryKey: normalizeMutator(outputWorkspace, queryOptions == null ? void 0 : queryOptions.queryKey)
|
|
1610
|
+
} : {},
|
|
1611
|
+
...(queryOptions == null ? void 0 : queryOptions.queryOptions) ? {
|
|
1612
|
+
queryOptions: normalizeMutator(
|
|
1613
|
+
outputWorkspace,
|
|
1614
|
+
queryOptions == null ? void 0 : queryOptions.queryOptions
|
|
1615
|
+
)
|
|
1616
|
+
} : {},
|
|
1617
|
+
...(queryOptions == null ? void 0 : queryOptions.mutationOptions) ? {
|
|
1618
|
+
mutationOptions: normalizeMutator(
|
|
1619
|
+
outputWorkspace,
|
|
1620
|
+
queryOptions == null ? void 0 : queryOptions.mutationOptions
|
|
1621
|
+
)
|
|
1622
|
+
} : {},
|
|
1623
|
+
...queryOptions.signal ? { signal: true } : {}
|
|
1624
|
+
};
|
|
1625
|
+
};
|
|
1626
|
+
var normalizeMutator = (workspace, mutator) => {
|
|
1627
|
+
var _a;
|
|
1628
|
+
if ((0, import_core.isObject)(mutator)) {
|
|
1629
|
+
if (!mutator.path) {
|
|
1630
|
+
(0, import_core.createLogger)().error(import_chalk.default.red(`Mutator need a path`));
|
|
1631
|
+
process.exit(1);
|
|
1632
|
+
}
|
|
1633
|
+
return {
|
|
1634
|
+
...mutator,
|
|
1635
|
+
path: import_core.upath.resolve(workspace, mutator.path),
|
|
1636
|
+
default: (_a = mutator.default || !mutator.name) != null ? _a : false
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
if ((0, import_core.isString)(mutator)) {
|
|
1640
|
+
return {
|
|
1641
|
+
path: import_core.upath.resolve(workspace, mutator),
|
|
1642
|
+
default: true
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
return mutator;
|
|
1646
|
+
};
|
|
1647
|
+
function vueWrapTypeWithMaybeRef(props) {
|
|
1648
|
+
return props.map((prop) => {
|
|
1649
|
+
const [paramName, paramType] = prop.implementation.split(":");
|
|
1650
|
+
if (!paramType)
|
|
1651
|
+
return prop;
|
|
1652
|
+
const name = prop.type === import_core.GetterPropType.NAMED_PATH_PARAMS ? prop.name : `${paramName}`;
|
|
1653
|
+
const [type, defaultValue] = paramType.split("=");
|
|
1654
|
+
return {
|
|
1655
|
+
...prop,
|
|
1656
|
+
implementation: `${name}: MaybeRef<${type.trim()}>${defaultValue ? ` = ${defaultValue}` : ""}`
|
|
1657
|
+
};
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
var vueUnRefParams = (props) => {
|
|
1661
|
+
return props.map((prop) => {
|
|
1662
|
+
if (prop.type === import_core.GetterPropType.NAMED_PATH_PARAMS) {
|
|
1663
|
+
return `const ${prop.destructured} = unref(${prop.name});`;
|
|
1664
|
+
}
|
|
1665
|
+
return `${prop.name} = unref(${prop.name});`;
|
|
1666
|
+
}).join("\n");
|
|
1667
|
+
};
|
|
1668
|
+
var isVue = (client) => import_core.OutputClient.VUE_QUERY === client;
|
|
1669
|
+
|
|
1670
|
+
// src/index.ts
|
|
1671
|
+
var AXIOS_DEPENDENCIES = [
|
|
1672
|
+
{
|
|
1673
|
+
exports: [
|
|
1674
|
+
{
|
|
1675
|
+
name: "axios",
|
|
1676
|
+
default: true,
|
|
1677
|
+
values: true,
|
|
1678
|
+
syntheticDefaultImport: true
|
|
1679
|
+
},
|
|
1680
|
+
{ name: "AxiosRequestConfig" },
|
|
1681
|
+
{ name: "AxiosResponse" },
|
|
1682
|
+
{ name: "AxiosError" }
|
|
1683
|
+
],
|
|
1684
|
+
dependency: "axios"
|
|
1685
|
+
}
|
|
1686
|
+
];
|
|
1687
|
+
var PARAMS_SERIALIZER_DEPENDENCIES = [
|
|
1688
|
+
{
|
|
1689
|
+
exports: [
|
|
1690
|
+
{
|
|
1691
|
+
name: "qs",
|
|
1692
|
+
default: true,
|
|
1693
|
+
values: true,
|
|
1694
|
+
syntheticDefaultImport: true
|
|
1695
|
+
}
|
|
1696
|
+
],
|
|
1697
|
+
dependency: "qs"
|
|
1698
|
+
}
|
|
1699
|
+
];
|
|
1700
|
+
var SVELTE_QUERY_DEPENDENCIES_V3 = [
|
|
1701
|
+
{
|
|
1702
|
+
exports: [
|
|
1703
|
+
{ name: "useQuery", values: true },
|
|
1704
|
+
{ name: "useInfiniteQuery", values: true },
|
|
1705
|
+
{ name: "useMutation", values: true },
|
|
1706
|
+
{ name: "UseQueryOptions" },
|
|
1707
|
+
{
|
|
1708
|
+
name: "UseInfiniteQueryOptions"
|
|
1709
|
+
},
|
|
1710
|
+
{ name: "UseMutationOptions" },
|
|
1711
|
+
{ name: "QueryFunction" },
|
|
1712
|
+
{ name: "MutationFunction" },
|
|
1713
|
+
{ name: "UseQueryStoreResult" },
|
|
1714
|
+
{ name: "UseInfiniteQueryStoreResult" },
|
|
1715
|
+
{ name: "QueryKey" }
|
|
1716
|
+
],
|
|
1717
|
+
dependency: "@sveltestack/svelte-query"
|
|
1718
|
+
}
|
|
1719
|
+
];
|
|
1720
|
+
var SVELTE_QUERY_DEPENDENCIES = [
|
|
1721
|
+
{
|
|
1722
|
+
exports: [
|
|
1723
|
+
{ name: "createQuery", values: true },
|
|
1724
|
+
{ name: "createInfiniteQuery", values: true },
|
|
1725
|
+
{ name: "createMutation", values: true },
|
|
1726
|
+
{ name: "CreateQueryOptions" },
|
|
1727
|
+
{
|
|
1728
|
+
name: "CreateInfiniteQueryOptions"
|
|
1729
|
+
},
|
|
1730
|
+
{ name: "CreateMutationOptions" },
|
|
1731
|
+
{ name: "QueryFunction" },
|
|
1732
|
+
{ name: "MutationFunction" },
|
|
1733
|
+
{ name: "CreateQueryResult" },
|
|
1734
|
+
{ name: "CreateInfiniteQueryResult" },
|
|
1735
|
+
{ name: "QueryKey" }
|
|
1736
|
+
],
|
|
1737
|
+
dependency: "@tanstack/svelte-query"
|
|
1738
|
+
}
|
|
1739
|
+
];
|
|
1740
|
+
var isSvelteQueryV3 = (packageJson) => {
|
|
1741
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1742
|
+
const hasVueQuery = (_c = (_a = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _a["@sveltestack/svelte-query"]) != null ? _c : (_b = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _b["@sveltestack/svelte-query"];
|
|
1743
|
+
const hasVueQueryV4 = (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@tanstack/svelte-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@tanstack/svelte-query"];
|
|
1744
|
+
return !!hasVueQuery && !hasVueQueryV4;
|
|
1745
|
+
};
|
|
1746
|
+
var getSvelteQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson) => {
|
|
1747
|
+
const hasSvelteQueryV3 = isSvelteQueryV3(packageJson);
|
|
1748
|
+
return [
|
|
1749
|
+
...!hasGlobalMutator ? AXIOS_DEPENDENCIES : [],
|
|
1750
|
+
...hasParamsSerializerOptions ? PARAMS_SERIALIZER_DEPENDENCIES : [],
|
|
1751
|
+
...hasSvelteQueryV3 ? SVELTE_QUERY_DEPENDENCIES_V3 : SVELTE_QUERY_DEPENDENCIES
|
|
1752
|
+
];
|
|
1753
|
+
};
|
|
1754
|
+
var REACT_QUERY_DEPENDENCIES_V3 = [
|
|
1755
|
+
{
|
|
1756
|
+
exports: [
|
|
1757
|
+
{ name: "useQuery", values: true },
|
|
1758
|
+
{ name: "useInfiniteQuery", values: true },
|
|
1759
|
+
{ name: "useMutation", values: true },
|
|
1760
|
+
{ name: "UseQueryOptions" },
|
|
1761
|
+
{ name: "UseInfiniteQueryOptions" },
|
|
1762
|
+
{ name: "UseMutationOptions" },
|
|
1763
|
+
{ name: "QueryFunction" },
|
|
1764
|
+
{ name: "MutationFunction" },
|
|
1765
|
+
{ name: "UseQueryResult" },
|
|
1766
|
+
{ name: "UseInfiniteQueryResult" },
|
|
1767
|
+
{ name: "QueryKey" },
|
|
1768
|
+
{ name: "QueryClient" }
|
|
1769
|
+
],
|
|
1770
|
+
dependency: "react-query"
|
|
1771
|
+
}
|
|
1772
|
+
];
|
|
1773
|
+
var REACT_QUERY_DEPENDENCIES = [
|
|
1774
|
+
{
|
|
1775
|
+
exports: [
|
|
1776
|
+
{ name: "useQuery", values: true },
|
|
1777
|
+
{ name: "useSuspenseQuery", values: true },
|
|
1778
|
+
{ name: "useInfiniteQuery", values: true },
|
|
1779
|
+
{ name: "useSuspenseInfiniteQuery", values: true },
|
|
1780
|
+
{ name: "useMutation", values: true },
|
|
1781
|
+
{ name: "UseQueryOptions" },
|
|
1782
|
+
{ name: "UseSuspenseQueryOptions" },
|
|
1783
|
+
{ name: "UseInfiniteQueryOptions" },
|
|
1784
|
+
{ name: "UseSuspenseInfiniteQueryOptions" },
|
|
1785
|
+
{ name: "UseMutationOptions" },
|
|
1786
|
+
{ name: "QueryFunction" },
|
|
1787
|
+
{ name: "MutationFunction" },
|
|
1788
|
+
{ name: "UseQueryResult" },
|
|
1789
|
+
{ name: "UseSuspenseQueryResult" },
|
|
1790
|
+
{ name: "UseInfiniteQueryResult" },
|
|
1791
|
+
{ name: "UseSuspenseInfiniteQueryResult" },
|
|
1792
|
+
{ name: "QueryKey" },
|
|
1793
|
+
{ name: "QueryClient" },
|
|
1794
|
+
{ name: "InfiniteData" }
|
|
1795
|
+
],
|
|
1796
|
+
dependency: "@tanstack/react-query"
|
|
1797
|
+
}
|
|
1798
|
+
];
|
|
1799
|
+
var getReactQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson) => {
|
|
1800
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1801
|
+
const hasReactQuery = (_c = (_a = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _a["react-query"]) != null ? _c : (_b = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _b["react-query"];
|
|
1802
|
+
const hasReactQueryV4 = (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@tanstack/react-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@tanstack/react-query"];
|
|
1803
|
+
return [
|
|
1804
|
+
...!hasGlobalMutator ? AXIOS_DEPENDENCIES : [],
|
|
1805
|
+
...hasParamsSerializerOptions ? PARAMS_SERIALIZER_DEPENDENCIES : [],
|
|
1806
|
+
...hasReactQuery && !hasReactQueryV4 ? REACT_QUERY_DEPENDENCIES_V3 : REACT_QUERY_DEPENDENCIES
|
|
1807
|
+
];
|
|
1808
|
+
};
|
|
1809
|
+
var VUE_QUERY_DEPENDENCIES_V3 = [
|
|
1810
|
+
{
|
|
1811
|
+
exports: [
|
|
1812
|
+
{ name: "useQuery", values: true },
|
|
1813
|
+
{ name: "useInfiniteQuery", values: true },
|
|
1814
|
+
{ name: "useMutation", values: true }
|
|
1815
|
+
],
|
|
1816
|
+
dependency: "vue-query"
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
exports: [
|
|
1820
|
+
{ name: "UseQueryOptions" },
|
|
1821
|
+
{ name: "UseInfiniteQueryOptions" },
|
|
1822
|
+
{ name: "UseMutationOptions" },
|
|
1823
|
+
{ name: "QueryFunction" },
|
|
1824
|
+
{ name: "MutationFunction" },
|
|
1825
|
+
{ name: "UseQueryResult" },
|
|
1826
|
+
{ name: "UseInfiniteQueryResult" },
|
|
1827
|
+
{ name: "QueryKey" }
|
|
1828
|
+
],
|
|
1829
|
+
dependency: "vue-query/types"
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
exports: [{ name: "unref", values: true }],
|
|
1833
|
+
dependency: "vue"
|
|
1834
|
+
},
|
|
1835
|
+
{
|
|
1836
|
+
exports: [{ name: "UseQueryReturnType" }],
|
|
1837
|
+
dependency: "vue-query/lib/vue/useBaseQuery"
|
|
1838
|
+
}
|
|
1839
|
+
];
|
|
1840
|
+
var VUE_QUERY_DEPENDENCIES = [
|
|
1841
|
+
{
|
|
1842
|
+
exports: [
|
|
1843
|
+
{ name: "useQuery", values: true },
|
|
1844
|
+
{ name: "useInfiniteQuery", values: true },
|
|
1845
|
+
{ name: "useMutation", values: true },
|
|
1846
|
+
{ name: "UseQueryOptions" },
|
|
1847
|
+
{ name: "UseInfiniteQueryOptions" },
|
|
1848
|
+
{ name: "UseMutationOptions" },
|
|
1849
|
+
{ name: "QueryFunction" },
|
|
1850
|
+
{ name: "MutationFunction" },
|
|
1851
|
+
{ name: "QueryKey" },
|
|
1852
|
+
{ name: "UseQueryReturnType" },
|
|
1853
|
+
{ name: "UseInfiniteQueryReturnType" }
|
|
1854
|
+
],
|
|
1855
|
+
dependency: "@tanstack/vue-query"
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
exports: [{ name: "unref", values: true }],
|
|
1859
|
+
dependency: "vue"
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
exports: [{ name: "MaybeRef" }],
|
|
1863
|
+
dependency: "@tanstack/vue-query/build/lib/types"
|
|
1864
|
+
}
|
|
1865
|
+
];
|
|
1866
|
+
var isVueQueryV3 = (packageJson) => {
|
|
1867
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1868
|
+
const hasVueQuery = (_c = (_a = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _a["vue-query"]) != null ? _c : (_b = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _b["vue-query"];
|
|
1869
|
+
const hasVueQueryV4 = (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@tanstack/vue-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@tanstack/vue-query"];
|
|
1870
|
+
return !!hasVueQuery && !hasVueQueryV4;
|
|
1871
|
+
};
|
|
1872
|
+
var getVueQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson) => {
|
|
1873
|
+
const hasVueQueryV3 = isVueQueryV3(packageJson);
|
|
1874
|
+
return [
|
|
1875
|
+
...!hasGlobalMutator ? AXIOS_DEPENDENCIES : [],
|
|
1876
|
+
...hasParamsSerializerOptions ? PARAMS_SERIALIZER_DEPENDENCIES : [],
|
|
1877
|
+
...hasVueQueryV3 ? VUE_QUERY_DEPENDENCIES_V3 : VUE_QUERY_DEPENDENCIES
|
|
1878
|
+
];
|
|
1879
|
+
};
|
|
1880
|
+
var isQueryV5 = (packageJson, queryClient) => {
|
|
1881
|
+
const version = getPackageByQueryClient(packageJson, queryClient);
|
|
1882
|
+
if (!version) {
|
|
1883
|
+
return false;
|
|
1884
|
+
}
|
|
1885
|
+
const withoutRc = version.split("-")[0];
|
|
1886
|
+
return (0, import_core2.compareVersions)(withoutRc, "5.0.0");
|
|
1887
|
+
};
|
|
1888
|
+
var getPackageByQueryClient = (packageJson, queryClient) => {
|
|
1889
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1890
|
+
switch (queryClient) {
|
|
1891
|
+
case "react-query": {
|
|
1892
|
+
return (_c = (_a = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _a["@tanstack/react-query"]) != null ? _c : (_b = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _b["@tanstack/react-query"];
|
|
1893
|
+
}
|
|
1894
|
+
case "svelte-query": {
|
|
1895
|
+
return (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@sveltestack/svelte-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@sveltestack/svelte-query"];
|
|
1896
|
+
}
|
|
1897
|
+
case "vue-query": {
|
|
1898
|
+
return (_i = (_g = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _g["@tanstack/vue-query"]) != null ? _i : (_h = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _h["@tanstack/vue-query"];
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
var generateRequestOptionsArguments = ({
|
|
1903
|
+
isRequestOptions,
|
|
1904
|
+
hasSignal
|
|
1905
|
+
}) => {
|
|
1906
|
+
if (isRequestOptions) {
|
|
1907
|
+
return "options?: AxiosRequestConfig\n";
|
|
1908
|
+
}
|
|
1909
|
+
return hasSignal ? "signal?: AbortSignal\n" : "";
|
|
1910
|
+
};
|
|
1911
|
+
var generateQueryRequestFunction = ({
|
|
1912
|
+
headers,
|
|
1913
|
+
queryParams,
|
|
1914
|
+
operationName,
|
|
1915
|
+
response,
|
|
1916
|
+
mutator,
|
|
1917
|
+
body,
|
|
1918
|
+
props: _props,
|
|
1919
|
+
verb,
|
|
1920
|
+
formData,
|
|
1921
|
+
formUrlEncoded,
|
|
1922
|
+
paramsSerializer,
|
|
1923
|
+
override
|
|
1924
|
+
}, { route, context }, outputClient) => {
|
|
1925
|
+
var _a, _b;
|
|
1926
|
+
let props = _props;
|
|
1927
|
+
if (isVue(outputClient)) {
|
|
1928
|
+
props = vueWrapTypeWithMaybeRef(_props);
|
|
1929
|
+
}
|
|
1930
|
+
const isRequestOptions = override.requestOptions !== false;
|
|
1931
|
+
const isFormData = override.formData !== false;
|
|
1932
|
+
const isFormUrlEncoded = override.formUrlEncoded !== false;
|
|
1933
|
+
const hasSignal = !!override.query.signal;
|
|
1934
|
+
const isSyntheticDefaultImportsAllowed = (0, import_core2.isSyntheticDefaultImportsAllow)(
|
|
1935
|
+
context.tsconfig
|
|
1936
|
+
);
|
|
1937
|
+
const isExactOptionalPropertyTypes = !!((_b = (_a = context.tsconfig) == null ? void 0 : _a.compilerOptions) == null ? void 0 : _b.exactOptionalPropertyTypes);
|
|
1938
|
+
const isBodyVerb = import_core2.VERBS_WITH_BODY.includes(verb);
|
|
1939
|
+
const bodyForm = (0, import_core2.generateFormDataAndUrlEncodedFunction)({
|
|
1940
|
+
formData,
|
|
1941
|
+
formUrlEncoded,
|
|
1942
|
+
body,
|
|
1943
|
+
isFormData,
|
|
1944
|
+
isFormUrlEncoded
|
|
1945
|
+
});
|
|
1946
|
+
if (mutator) {
|
|
1947
|
+
const mutatorConfig = (0, import_core2.generateMutatorConfig)({
|
|
1948
|
+
route,
|
|
1949
|
+
body,
|
|
1950
|
+
headers,
|
|
1951
|
+
queryParams,
|
|
1952
|
+
response,
|
|
1953
|
+
verb,
|
|
1954
|
+
isFormData,
|
|
1955
|
+
isFormUrlEncoded,
|
|
1956
|
+
isBodyVerb,
|
|
1957
|
+
hasSignal,
|
|
1958
|
+
isExactOptionalPropertyTypes
|
|
1959
|
+
});
|
|
1960
|
+
let bodyDefinition = body.definition.replace("[]", "\\[\\]");
|
|
1961
|
+
let propsImplementation = (mutator == null ? void 0 : mutator.bodyTypeName) && body.definition ? (0, import_core2.toObjectString)(props, "implementation").replace(
|
|
1962
|
+
new RegExp(`(\\w*):\\s?${bodyDefinition}`),
|
|
1963
|
+
`$1: ${mutator.bodyTypeName}<${body.definition}>`
|
|
1964
|
+
) : (0, import_core2.toObjectString)(props, "implementation");
|
|
1965
|
+
const requestOptions = isRequestOptions ? (0, import_core2.generateMutatorRequestOptions)(
|
|
1966
|
+
override.requestOptions,
|
|
1967
|
+
mutator.hasSecondArg
|
|
1968
|
+
) : "";
|
|
1969
|
+
if (mutator.isHook) {
|
|
1970
|
+
return `export const use${(0, import_core2.pascal)(operationName)}Hook = () => {
|
|
1971
|
+
const ${operationName} = ${mutator.name}<${response.definition.success || "unknown"}>();
|
|
11
1972
|
|
|
12
1973
|
return (
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
${
|
|
18
|
-
${G});
|
|
1974
|
+
${propsImplementation}
|
|
1975
|
+
${isRequestOptions && mutator.hasSecondArg ? `options?: SecondParameter<ReturnType<typeof ${mutator.name}>>,` : ""}${!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""}) => {${bodyForm}
|
|
1976
|
+
return ${operationName}(
|
|
1977
|
+
${mutatorConfig},
|
|
1978
|
+
${requestOptions});
|
|
19
1979
|
}
|
|
20
1980
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
${
|
|
27
|
-
|
|
28
|
-
${
|
|
29
|
-
${
|
|
1981
|
+
`;
|
|
1982
|
+
}
|
|
1983
|
+
return `export const ${operationName} = (
|
|
1984
|
+
${propsImplementation}
|
|
1985
|
+
${isRequestOptions && mutator.hasSecondArg ? `options?: SecondParameter<typeof ${mutator.name}>,` : ""}${!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""}) => {
|
|
1986
|
+
${isVue(outputClient) ? vueUnRefParams(props) : ""}
|
|
1987
|
+
${bodyForm}
|
|
1988
|
+
return ${mutator.name}<${response.definition.success || "unknown"}>(
|
|
1989
|
+
${mutatorConfig},
|
|
1990
|
+
${requestOptions});
|
|
1991
|
+
}
|
|
1992
|
+
`;
|
|
1993
|
+
}
|
|
1994
|
+
const options = (0, import_core2.generateOptions)({
|
|
1995
|
+
route,
|
|
1996
|
+
body,
|
|
1997
|
+
headers,
|
|
1998
|
+
queryParams,
|
|
1999
|
+
response,
|
|
2000
|
+
verb,
|
|
2001
|
+
requestOptions: override == null ? void 0 : override.requestOptions,
|
|
2002
|
+
isFormData,
|
|
2003
|
+
isFormUrlEncoded,
|
|
2004
|
+
paramsSerializer,
|
|
2005
|
+
paramsSerializerOptions: override == null ? void 0 : override.paramsSerializerOptions,
|
|
2006
|
+
isExactOptionalPropertyTypes,
|
|
2007
|
+
hasSignal
|
|
2008
|
+
});
|
|
2009
|
+
const optionsArgs = generateRequestOptionsArguments({
|
|
2010
|
+
isRequestOptions,
|
|
2011
|
+
hasSignal
|
|
2012
|
+
});
|
|
2013
|
+
const queryProps = (0, import_core2.toObjectString)(props, "implementation");
|
|
2014
|
+
return `export const ${operationName} = (
|
|
2015
|
+
${queryProps} ${optionsArgs} ): Promise<AxiosResponse<${response.definition.success || "unknown"}>> => {${bodyForm}
|
|
2016
|
+
${isVue(outputClient) ? vueUnRefParams(props) : ""}
|
|
2017
|
+
return axios${!isSyntheticDefaultImportsAllowed ? ".default" : ""}.${verb}(${options});
|
|
2018
|
+
}
|
|
2019
|
+
`;
|
|
2020
|
+
};
|
|
2021
|
+
var QueryType = {
|
|
2022
|
+
INFINITE: "infiniteQuery",
|
|
2023
|
+
QUERY: "query",
|
|
2024
|
+
SUSPENSE_QUERY: "suspenseQuery",
|
|
2025
|
+
SUSPENSE_INFINITE: "suspenseInfiniteQuery"
|
|
2026
|
+
};
|
|
2027
|
+
var INFINITE_QUERY_PROPERTIES = ["getNextPageParam", "getPreviousPageParam"];
|
|
2028
|
+
var generateQueryOptions = ({
|
|
2029
|
+
params,
|
|
2030
|
+
options,
|
|
2031
|
+
type
|
|
2032
|
+
}) => {
|
|
2033
|
+
var _a;
|
|
2034
|
+
if (options === false) {
|
|
2035
|
+
return "";
|
|
2036
|
+
}
|
|
2037
|
+
const queryConfig = (0, import_core2.isObject)(options) ? ` ${(_a = (0, import_core2.stringify)(
|
|
2038
|
+
(0, import_lodash.default)(
|
|
2039
|
+
options,
|
|
2040
|
+
(_, key) => (type !== QueryType.INFINITE || type !== QueryType.SUSPENSE_INFINITE) && INFINITE_QUERY_PROPERTIES.includes(key)
|
|
2041
|
+
)
|
|
2042
|
+
)) == null ? void 0 : _a.slice(1, -1)}` : "";
|
|
2043
|
+
if (!params.length) {
|
|
2044
|
+
if (options) {
|
|
2045
|
+
return `${queryConfig} ...queryOptions`;
|
|
30
2046
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
2047
|
+
return "...queryOptions";
|
|
2048
|
+
}
|
|
2049
|
+
return `${!(0, import_core2.isObject)(options) || !options.hasOwnProperty("enabled") ? `enabled: !!(${params.map(({ name }) => name).join(" && ")}),` : ""}${queryConfig} ...queryOptions`;
|
|
2050
|
+
};
|
|
2051
|
+
var getQueryArgumentsRequestType = (mutator) => {
|
|
2052
|
+
if (!mutator) {
|
|
2053
|
+
return `axios?: AxiosRequestConfig`;
|
|
2054
|
+
}
|
|
2055
|
+
if (mutator.hasSecondArg && !mutator.isHook) {
|
|
2056
|
+
return `request?: SecondParameter<typeof ${mutator.name}>`;
|
|
2057
|
+
}
|
|
2058
|
+
if (mutator.hasSecondArg && mutator.isHook) {
|
|
2059
|
+
return `request?: SecondParameter<ReturnType<typeof ${mutator.name}>>`;
|
|
2060
|
+
}
|
|
2061
|
+
return "";
|
|
2062
|
+
};
|
|
2063
|
+
var getQueryOptionsDefinition = ({
|
|
2064
|
+
operationName,
|
|
2065
|
+
definitions,
|
|
2066
|
+
mutator,
|
|
2067
|
+
type,
|
|
2068
|
+
hasSvelteQueryV4,
|
|
2069
|
+
hasQueryV5,
|
|
2070
|
+
queryParams,
|
|
2071
|
+
queryParam,
|
|
2072
|
+
isReturnType
|
|
2073
|
+
}) => {
|
|
2074
|
+
const isMutatorHook = mutator == null ? void 0 : mutator.isHook;
|
|
2075
|
+
const prefix = !hasSvelteQueryV4 ? "Use" : "Create";
|
|
2076
|
+
const partialOptions = !isReturnType && hasQueryV5;
|
|
2077
|
+
if (type) {
|
|
2078
|
+
const funcReturnType = `Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>`;
|
|
2079
|
+
return `${partialOptions ? "Partial<" : ""}${prefix}${(0, import_core2.pascal)(
|
|
2080
|
+
type
|
|
2081
|
+
)}Options<${funcReturnType}, TError, TData${hasQueryV5 && (type === QueryType.INFINITE || type === QueryType.SUSPENSE_INFINITE) && queryParam && queryParams ? `, ${funcReturnType}, QueryKey, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : ""}>${partialOptions ? ">" : ""}`;
|
|
35
2082
|
}
|
|
36
|
-
|
|
37
|
-
|
|
2083
|
+
return `${prefix}MutationOptions<Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>, TError,${definitions ? `{${definitions}}` : "TVariables"}, TContext>`;
|
|
2084
|
+
};
|
|
2085
|
+
var generateQueryArguments = ({
|
|
2086
|
+
operationName,
|
|
2087
|
+
definitions,
|
|
2088
|
+
mutator,
|
|
2089
|
+
isRequestOptions,
|
|
2090
|
+
type,
|
|
2091
|
+
hasSvelteQueryV4,
|
|
2092
|
+
hasQueryV5,
|
|
2093
|
+
queryParams,
|
|
2094
|
+
queryParam
|
|
2095
|
+
}) => {
|
|
2096
|
+
const definition = getQueryOptionsDefinition({
|
|
2097
|
+
operationName,
|
|
2098
|
+
definitions,
|
|
2099
|
+
mutator,
|
|
2100
|
+
type,
|
|
2101
|
+
hasSvelteQueryV4,
|
|
2102
|
+
hasQueryV5,
|
|
2103
|
+
queryParams,
|
|
2104
|
+
queryParam,
|
|
2105
|
+
isReturnType: false
|
|
2106
|
+
});
|
|
2107
|
+
if (!isRequestOptions) {
|
|
2108
|
+
return `${type ? "queryOptions" : "mutationOptions"}?: ${definition}`;
|
|
2109
|
+
}
|
|
2110
|
+
const requestType = getQueryArgumentsRequestType(mutator);
|
|
2111
|
+
return `options?: { ${type ? "query" : "mutation"}?:${definition}, ${requestType}}
|
|
2112
|
+
`;
|
|
2113
|
+
};
|
|
2114
|
+
var generateQueryReturnType = ({
|
|
2115
|
+
outputClient,
|
|
2116
|
+
type,
|
|
2117
|
+
isMutatorHook,
|
|
2118
|
+
operationName,
|
|
2119
|
+
hasVueQueryV4,
|
|
2120
|
+
hasSvelteQueryV4
|
|
2121
|
+
}) => {
|
|
2122
|
+
switch (outputClient) {
|
|
2123
|
+
case import_core2.OutputClient.SVELTE_QUERY: {
|
|
2124
|
+
if (!hasSvelteQueryV4) {
|
|
2125
|
+
return `Use${(0, import_core2.pascal)(type)}StoreResult<Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>, TError, TData, QueryKey> & { queryKey: QueryKey }`;
|
|
2126
|
+
}
|
|
2127
|
+
return `Create${(0, import_core2.pascal)(
|
|
2128
|
+
type
|
|
2129
|
+
)}Result<TData, TError> & { queryKey: QueryKey }`;
|
|
2130
|
+
}
|
|
2131
|
+
case import_core2.OutputClient.VUE_QUERY: {
|
|
2132
|
+
if (!hasVueQueryV4) {
|
|
2133
|
+
return ` UseQueryReturnType<TData, TError, Use${(0, import_core2.pascal)(
|
|
2134
|
+
type
|
|
2135
|
+
)}Result<TData, TError>> & { queryKey: QueryKey }`;
|
|
2136
|
+
}
|
|
2137
|
+
if (type !== QueryType.INFINITE && type !== QueryType.SUSPENSE_INFINITE) {
|
|
2138
|
+
return `UseQueryReturnType<TData, TError> & { queryKey: QueryKey }`;
|
|
2139
|
+
}
|
|
2140
|
+
return `UseInfiniteQueryReturnType<TData, TError> & { queryKey: QueryKey }`;
|
|
2141
|
+
}
|
|
2142
|
+
case import_core2.OutputClient.REACT_QUERY:
|
|
2143
|
+
default: {
|
|
2144
|
+
return ` Use${(0, import_core2.pascal)(
|
|
2145
|
+
type
|
|
2146
|
+
)}Result<TData, TError> & { queryKey: QueryKey }`;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
var getQueryOptions = ({
|
|
2151
|
+
isRequestOptions,
|
|
2152
|
+
mutator,
|
|
2153
|
+
isExactOptionalPropertyTypes,
|
|
2154
|
+
hasSignal
|
|
2155
|
+
}) => {
|
|
2156
|
+
if (!mutator && isRequestOptions) {
|
|
2157
|
+
if (!hasSignal) {
|
|
2158
|
+
return "axiosOptions";
|
|
2159
|
+
}
|
|
2160
|
+
return `{ ${isExactOptionalPropertyTypes ? "...(signal ? { signal } : {})" : "signal"}, ...axiosOptions }`;
|
|
2161
|
+
}
|
|
2162
|
+
if ((mutator == null ? void 0 : mutator.hasSecondArg) && isRequestOptions) {
|
|
2163
|
+
if (!hasSignal) {
|
|
2164
|
+
return "requestOptions";
|
|
2165
|
+
}
|
|
2166
|
+
return "requestOptions, signal";
|
|
2167
|
+
}
|
|
2168
|
+
if (hasSignal) {
|
|
2169
|
+
return "signal";
|
|
2170
|
+
}
|
|
2171
|
+
return "";
|
|
2172
|
+
};
|
|
2173
|
+
var getHookOptions = ({
|
|
2174
|
+
isRequestOptions,
|
|
2175
|
+
mutator
|
|
2176
|
+
}) => {
|
|
2177
|
+
if (!isRequestOptions) {
|
|
2178
|
+
return "";
|
|
2179
|
+
}
|
|
2180
|
+
let value = "const {query: queryOptions";
|
|
2181
|
+
if (!mutator) {
|
|
2182
|
+
value += ", axios: axiosOptions";
|
|
2183
|
+
}
|
|
2184
|
+
if (mutator == null ? void 0 : mutator.hasSecondArg) {
|
|
2185
|
+
value += ", request: requestOptions";
|
|
2186
|
+
}
|
|
2187
|
+
value += "} = options ?? {};";
|
|
2188
|
+
return value;
|
|
2189
|
+
};
|
|
2190
|
+
var getQueryFnArguments = ({
|
|
2191
|
+
hasQueryParam,
|
|
2192
|
+
hasSignal
|
|
2193
|
+
}) => {
|
|
2194
|
+
if (!hasQueryParam && !hasSignal) {
|
|
2195
|
+
return "";
|
|
2196
|
+
}
|
|
2197
|
+
if (hasQueryParam) {
|
|
2198
|
+
if (hasSignal) {
|
|
2199
|
+
return "{ signal, pageParam }";
|
|
2200
|
+
}
|
|
2201
|
+
return "{ pageParam }";
|
|
2202
|
+
}
|
|
2203
|
+
return "{ signal }";
|
|
2204
|
+
};
|
|
2205
|
+
var generateQueryImplementation = ({
|
|
2206
|
+
queryOption: { name, queryParam, options, type },
|
|
2207
|
+
operationName,
|
|
2208
|
+
queryKeyFnName,
|
|
2209
|
+
queryProperties,
|
|
2210
|
+
queryKeyProperties,
|
|
2211
|
+
queryParams,
|
|
2212
|
+
params,
|
|
2213
|
+
props,
|
|
2214
|
+
mutator,
|
|
2215
|
+
queryOptionsMutator,
|
|
2216
|
+
queryKeyMutator,
|
|
2217
|
+
isRequestOptions,
|
|
2218
|
+
response,
|
|
2219
|
+
outputClient,
|
|
2220
|
+
isExactOptionalPropertyTypes,
|
|
2221
|
+
hasSignal,
|
|
2222
|
+
route,
|
|
2223
|
+
hasVueQueryV4,
|
|
2224
|
+
hasSvelteQueryV4,
|
|
2225
|
+
hasQueryV5,
|
|
2226
|
+
doc,
|
|
2227
|
+
usePrefetch
|
|
2228
|
+
}) => {
|
|
2229
|
+
const queryProps = (0, import_core2.toObjectString)(props, "implementation");
|
|
2230
|
+
const hasInfiniteQueryParam = queryParam && (queryParams == null ? void 0 : queryParams.schema.name);
|
|
2231
|
+
const httpFunctionProps = queryParam ? props.map((param) => {
|
|
2232
|
+
if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
|
|
2233
|
+
return param.destructured;
|
|
2234
|
+
return param.name === "params" ? `{...params, ${queryParam}: pageParam || ${isVue(outputClient) ? `unref(params)?.['${queryParam}']` : `params?.['${queryParam}']`}}` : param.name;
|
|
2235
|
+
}).join(",") : queryProperties;
|
|
2236
|
+
const returnType = generateQueryReturnType({
|
|
2237
|
+
outputClient,
|
|
2238
|
+
type,
|
|
2239
|
+
isMutatorHook: mutator == null ? void 0 : mutator.isHook,
|
|
2240
|
+
operationName,
|
|
2241
|
+
hasVueQueryV4,
|
|
2242
|
+
hasSvelteQueryV4
|
|
2243
|
+
});
|
|
2244
|
+
let errorType = `AxiosError<${response.definition.errors || "unknown"}>`;
|
|
2245
|
+
if (mutator) {
|
|
2246
|
+
errorType = mutator.hasErrorType ? `${mutator.default ? (0, import_core2.pascal)(operationName) : ""}ErrorType<${response.definition.errors || "unknown"}>` : response.definition.errors || "unknown";
|
|
2247
|
+
}
|
|
2248
|
+
const dataType = (mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`;
|
|
2249
|
+
const queryArguments = generateQueryArguments({
|
|
2250
|
+
operationName,
|
|
2251
|
+
definitions: "",
|
|
2252
|
+
mutator,
|
|
2253
|
+
isRequestOptions,
|
|
2254
|
+
type,
|
|
2255
|
+
hasSvelteQueryV4,
|
|
2256
|
+
hasQueryV5,
|
|
2257
|
+
queryParams,
|
|
2258
|
+
queryParam
|
|
2259
|
+
});
|
|
2260
|
+
const queryOptions = getQueryOptions({
|
|
2261
|
+
isRequestOptions,
|
|
2262
|
+
isExactOptionalPropertyTypes,
|
|
2263
|
+
mutator,
|
|
2264
|
+
hasSignal
|
|
2265
|
+
});
|
|
2266
|
+
const hookOptions = getHookOptions({
|
|
2267
|
+
isRequestOptions,
|
|
2268
|
+
mutator
|
|
2269
|
+
});
|
|
2270
|
+
const queryFnArguments = getQueryFnArguments({
|
|
2271
|
+
hasQueryParam: !!queryParam && props.some(({ type: type2 }) => type2 === "queryParam"),
|
|
2272
|
+
hasSignal
|
|
2273
|
+
});
|
|
2274
|
+
const queryOptionFnReturnType = getQueryOptionsDefinition({
|
|
2275
|
+
operationName,
|
|
2276
|
+
definitions: "",
|
|
2277
|
+
mutator,
|
|
2278
|
+
type,
|
|
2279
|
+
hasSvelteQueryV4,
|
|
2280
|
+
hasQueryV5,
|
|
2281
|
+
queryParams,
|
|
2282
|
+
queryParam,
|
|
2283
|
+
isReturnType: true
|
|
2284
|
+
});
|
|
2285
|
+
const queryOptionsImp = generateQueryOptions({
|
|
2286
|
+
params,
|
|
2287
|
+
options,
|
|
2288
|
+
type
|
|
2289
|
+
});
|
|
2290
|
+
const queryOptionsFnName = (0, import_core2.camel)(
|
|
2291
|
+
queryKeyMutator || queryOptionsMutator || (mutator == null ? void 0 : mutator.isHook) ? `use-${name}-queryOptions` : `get-${name}-queryOptions`
|
|
2292
|
+
);
|
|
2293
|
+
const queryOptionsVarName = isRequestOptions ? "queryOptions" : "options";
|
|
2294
|
+
const infiniteParam = queryParams && queryParam ? `, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : "";
|
|
2295
|
+
const TData = hasQueryV5 && (type === QueryType.INFINITE || type === QueryType.SUSPENSE_INFINITE) ? `InfiniteData<Awaited<ReturnType<${dataType}>>${infiniteParam}>` : `Awaited<ReturnType<${dataType}>>`;
|
|
2296
|
+
const queryOptionsFn = `export const ${queryOptionsFnName} = <TData = ${TData}, TError = ${errorType}>(${queryProps} ${queryArguments}) => {
|
|
38
2297
|
|
|
39
|
-
${
|
|
2298
|
+
${hookOptions}
|
|
40
2299
|
|
|
41
|
-
const queryKey = ${
|
|
2300
|
+
const queryKey = ${!queryKeyMutator ? `${!hasVueQueryV4 ? "queryOptions?.queryKey ?? " : ""}${queryKeyFnName}(${queryKeyProperties});` : `${queryKeyMutator.name}({ ${queryProperties} }${queryKeyMutator.hasSecondArg ? `, { url: \`${route}\`, queryOptions }` : ""});`}
|
|
42
2301
|
|
|
43
|
-
${
|
|
2302
|
+
${(mutator == null ? void 0 : mutator.isHook) ? `const ${operationName} = use${(0, import_core2.pascal)(operationName)}Hook();` : ""}
|
|
44
2303
|
|
|
45
|
-
const queryFn: QueryFunction<Awaited<ReturnType<${
|
|
2304
|
+
const queryFn: QueryFunction<Awaited<ReturnType<${(mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>${hasQueryV5 && hasInfiniteQueryParam ? `, QueryKey, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : ""}> = (${queryFnArguments}) => ${operationName}(${httpFunctionProps}${httpFunctionProps ? ", " : ""}${queryOptions});
|
|
46
2305
|
|
|
47
|
-
${
|
|
2306
|
+
${isVue(outputClient) ? vueUnRefParams(
|
|
2307
|
+
props.filter(
|
|
2308
|
+
(prop) => prop.type === import_core2.GetterPropType.NAMED_PATH_PARAMS
|
|
2309
|
+
)
|
|
2310
|
+
) : ""}
|
|
48
2311
|
|
|
49
|
-
${
|
|
2312
|
+
${queryOptionsMutator ? `const customOptions = ${queryOptionsMutator.name}({...queryOptions, queryKey, queryFn}${queryOptionsMutator.hasSecondArg ? `, { ${queryProperties} }` : ""}${queryOptionsMutator.hasThirdArg ? `, { url: \`${route}\` }` : ""});` : ""}
|
|
50
2313
|
|
|
51
|
-
return ${
|
|
52
|
-
}
|
|
53
|
-
|
|
2314
|
+
return ${!queryOptionsMutator ? `{ queryKey, queryFn, ${queryOptionsImp}}` : "customOptions"} as ${queryOptionFnReturnType} ${isVue(outputClient) ? "" : "& { queryKey: QueryKey }"}
|
|
2315
|
+
}`;
|
|
2316
|
+
const operationPrefix = hasSvelteQueryV4 ? "create" : "use";
|
|
2317
|
+
return `
|
|
2318
|
+
${queryOptionsFn}
|
|
54
2319
|
|
|
55
|
-
export type ${
|
|
56
|
-
|
|
2320
|
+
export type ${(0, import_core2.pascal)(
|
|
2321
|
+
name
|
|
2322
|
+
)}QueryResult = NonNullable<Awaited<ReturnType<${dataType}>>>
|
|
2323
|
+
export type ${(0, import_core2.pascal)(name)}QueryError = ${errorType}
|
|
57
2324
|
|
|
58
|
-
${
|
|
59
|
-
|
|
60
|
-
)
|
|
2325
|
+
${doc}export const ${(0, import_core2.camel)(
|
|
2326
|
+
`${operationPrefix}-${name}`
|
|
2327
|
+
)} = <TData = ${TData}, TError = ${errorType}>(
|
|
2328
|
+
${queryProps} ${queryArguments}
|
|
2329
|
+
): ${returnType} => {
|
|
61
2330
|
|
|
62
|
-
const ${
|
|
2331
|
+
const ${queryOptionsVarName} = ${queryOptionsFnName}(${queryProperties}${queryProperties ? "," : ""}${isRequestOptions ? "options" : "queryOptions"})
|
|
63
2332
|
|
|
64
|
-
const query = ${
|
|
2333
|
+
const query = ${(0, import_core2.camel)(
|
|
2334
|
+
`${operationPrefix}-${type}`
|
|
2335
|
+
)}(${queryOptionsVarName}) as ${returnType};
|
|
65
2336
|
|
|
66
|
-
query.queryKey = ${
|
|
2337
|
+
query.queryKey = ${queryOptionsVarName}.queryKey ${isVue(outputClient) ? "as QueryKey" : ""};
|
|
67
2338
|
|
|
68
2339
|
return query;
|
|
69
2340
|
}
|
|
70
|
-
`},kt=async({queryParams:e,operationName:n,body:r,props:t,verb:s,params:o,override:i,mutator:u,response:l,operationId:y,summary:d,deprecated:f},{route:g,override:{operations:S={}},context:h,output:R},m)=>{var G,ie,ue;let v=t;I(m)&&(v=xe(t));let a=i==null?void 0:i.query,M=(i==null?void 0:i.requestOptions)!==!1,E=(G=S[y])==null?void 0:G.query,A=!!((ue=(ie=h.tsconfig)==null?void 0:ie.compilerOptions)!=null&&ue.exactOptionalPropertyTypes),C=_core.OutputClient.VUE_QUERY===m&&(!vn(h.packageJson)||a.version===4),_=_core.OutputClient.SVELTE_QUERY===m&&(!Tn(h.packageJson)||a.version===4),B=a.version===5||Rt(h.packageJson,m),L=_core.jsDoc.call(void 0, {summary:d,deprecated:f}),q="",O;if(_core.Verbs.GET===s&&(i.query.useQuery||i.query.useInfinite)||(E==null?void 0:E.useInfinite)||(E==null?void 0:E.useQuery)){let T=a.queryKey?await _core.generateMutator.call(void 0, {output:R,mutator:a.queryKey,name:`${n}QueryKey`,workspace:h.workspace,tsconfig:h.tsconfig}):void 0,Q=a.queryOptions?await _core.generateMutator.call(void 0, {output:R,mutator:a.queryOptions,name:`${n}QueryOptions`,workspace:h.workspace,tsconfig:h.tsconfig}):void 0,U=v.map(p=>p.type===_core.GetterPropType.NAMED_PATH_PARAMS&&!I(m)?p.destructured:p.type===_core.GetterPropType.BODY?r.implementation:p.name).join(","),k=v.filter(p=>p.type!==_core.GetterPropType.HEADER).map(p=>p.type===_core.GetterPropType.NAMED_PATH_PARAMS&&!I(m)?p.destructured:p.type===_core.GetterPropType.BODY?r.implementation:p.name).join(","),V=[...a!=null&&a.useInfinite?[{name:_core.camel.call(void 0, `${n}-infinite`),options:a==null?void 0:a.options,type:x.INFINITE,queryParam:a==null?void 0:a.useInfiniteQueryParam}]:[],...!(a!=null&&a.useQuery)&&!(a!=null&&a.useInfinite)||(a==null?void 0:a.useQuery)?[{name:n,options:a==null?void 0:a.options,type:x.QUERY}]:[],...a!=null&&a.useSuspenseQuery?[{name:_core.camel.call(void 0, `${n}-suspense`),options:a==null?void 0:a.options,type:x.SUSPENSE_QUERY}]:[],...a!=null&&a.useSuspenseInfiniteQuery?[{name:_core.camel.call(void 0, `${n}-suspense-infinite`),options:a==null?void 0:a.options,type:x.SUSPENSE_INFINITE,queryParam:a==null?void 0:a.useInfiniteQueryParam}]:[]],z=_core.camel.call(void 0, `get-${n}-queryKey`),H=_core.toObjectString.call(void 0, v.filter(p=>p.type!==_core.GetterPropType.HEADER),"implementation"),W=`\`${g}\``,Y=`export const ${z} = (${H}) => {
|
|
71
|
-
${I(m)?re(v):""}
|
|
72
|
-
return [${W}${e?", ...(params ? [params]: [])":""}${r.implementation?`, ${r.implementation}`:""}] as const;
|
|
73
|
-
}`;q+=`${T?"":Y}
|
|
74
2341
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
2342
|
+
${usePrefetch ? `${doc}export const ${(0, import_core2.camel)(
|
|
2343
|
+
`prefetch-${name}`
|
|
2344
|
+
)} = async <TData = Awaited<ReturnType<${dataType}>>, TError = ${errorType}>(
|
|
2345
|
+
queryClient: QueryClient, ${queryProps} ${queryArguments}
|
|
2346
|
+
): Promise<QueryClient> => {
|
|
80
2347
|
|
|
81
|
-
|
|
2348
|
+
const ${queryOptionsVarName} = ${queryOptionsFnName}(${queryProperties}${queryProperties ? "," : ""}${isRequestOptions ? "options" : "queryOptions"})
|
|
82
2349
|
|
|
2350
|
+
await queryClient.${(0, import_core2.camel)(`prefetch-${type}`)}(${queryOptionsVarName});
|
|
83
2351
|
|
|
84
|
-
|
|
85
|
-
|
|
2352
|
+
return queryClient;
|
|
2353
|
+
}
|
|
2354
|
+
` : ""}
|
|
2355
|
+
`;
|
|
2356
|
+
};
|
|
2357
|
+
var generateQueryHook = async ({
|
|
2358
|
+
queryParams,
|
|
2359
|
+
operationName,
|
|
2360
|
+
body,
|
|
2361
|
+
props: _props,
|
|
2362
|
+
verb,
|
|
2363
|
+
params,
|
|
2364
|
+
override,
|
|
2365
|
+
mutator,
|
|
2366
|
+
response,
|
|
2367
|
+
operationId,
|
|
2368
|
+
summary,
|
|
2369
|
+
deprecated
|
|
2370
|
+
}, { route, override: { operations = {} }, context, output }, outputClient) => {
|
|
2371
|
+
var _a, _b, _c;
|
|
2372
|
+
let props = _props;
|
|
2373
|
+
if (isVue(outputClient)) {
|
|
2374
|
+
props = vueWrapTypeWithMaybeRef(_props);
|
|
2375
|
+
}
|
|
2376
|
+
const query = override == null ? void 0 : override.query;
|
|
2377
|
+
const isRequestOptions = (override == null ? void 0 : override.requestOptions) !== false;
|
|
2378
|
+
const operationQueryOptions = (_a = operations[operationId]) == null ? void 0 : _a.query;
|
|
2379
|
+
const isExactOptionalPropertyTypes = !!((_c = (_b = context.tsconfig) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.exactOptionalPropertyTypes);
|
|
2380
|
+
const hasVueQueryV4 = import_core2.OutputClient.VUE_QUERY === outputClient && (!isVueQueryV3(context.packageJson) || query.version === 4);
|
|
2381
|
+
const hasSvelteQueryV4 = import_core2.OutputClient.SVELTE_QUERY === outputClient && (!isSvelteQueryV3(context.packageJson) || query.version === 4);
|
|
2382
|
+
const hasQueryV5 = query.version === 5 || isQueryV5(
|
|
2383
|
+
context.packageJson,
|
|
2384
|
+
outputClient
|
|
2385
|
+
);
|
|
2386
|
+
const doc = (0, import_core2.jsDoc)({ summary, deprecated });
|
|
2387
|
+
let implementation = "";
|
|
2388
|
+
let mutators = void 0;
|
|
2389
|
+
const isQuery = import_core2.Verbs.GET === verb && (override.query.useQuery || override.query.useInfinite) || (operationQueryOptions == null ? void 0 : operationQueryOptions.useInfinite) || (operationQueryOptions == null ? void 0 : operationQueryOptions.useQuery);
|
|
2390
|
+
if (isQuery) {
|
|
2391
|
+
const queryKeyMutator = query.queryKey ? await (0, import_core2.generateMutator)({
|
|
2392
|
+
output,
|
|
2393
|
+
mutator: query.queryKey,
|
|
2394
|
+
name: `${operationName}QueryKey`,
|
|
2395
|
+
workspace: context.workspace,
|
|
2396
|
+
tsconfig: context.tsconfig
|
|
2397
|
+
}) : void 0;
|
|
2398
|
+
const queryOptionsMutator = query.queryOptions ? await (0, import_core2.generateMutator)({
|
|
2399
|
+
output,
|
|
2400
|
+
mutator: query.queryOptions,
|
|
2401
|
+
name: `${operationName}QueryOptions`,
|
|
2402
|
+
workspace: context.workspace,
|
|
2403
|
+
tsconfig: context.tsconfig
|
|
2404
|
+
}) : void 0;
|
|
2405
|
+
const queryProperties = props.map((param) => {
|
|
2406
|
+
if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
|
|
2407
|
+
return param.destructured;
|
|
2408
|
+
return param.type === import_core2.GetterPropType.BODY ? body.implementation : param.name;
|
|
2409
|
+
}).join(",");
|
|
2410
|
+
const queryKeyProperties = props.filter((prop) => prop.type !== import_core2.GetterPropType.HEADER).map((param) => {
|
|
2411
|
+
if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
|
|
2412
|
+
return param.destructured;
|
|
2413
|
+
return param.type === import_core2.GetterPropType.BODY ? body.implementation : param.name;
|
|
2414
|
+
}).join(",");
|
|
2415
|
+
const queries = [
|
|
2416
|
+
...(query == null ? void 0 : query.useInfinite) ? [
|
|
2417
|
+
{
|
|
2418
|
+
name: (0, import_core2.camel)(`${operationName}-infinite`),
|
|
2419
|
+
options: query == null ? void 0 : query.options,
|
|
2420
|
+
type: QueryType.INFINITE,
|
|
2421
|
+
queryParam: query == null ? void 0 : query.useInfiniteQueryParam
|
|
2422
|
+
}
|
|
2423
|
+
] : [],
|
|
2424
|
+
...!(query == null ? void 0 : query.useQuery) && !(query == null ? void 0 : query.useInfinite) || (query == null ? void 0 : query.useQuery) ? [
|
|
2425
|
+
{
|
|
2426
|
+
name: operationName,
|
|
2427
|
+
options: query == null ? void 0 : query.options,
|
|
2428
|
+
type: QueryType.QUERY
|
|
2429
|
+
}
|
|
2430
|
+
] : [],
|
|
2431
|
+
...(query == null ? void 0 : query.useSuspenseQuery) ? [
|
|
2432
|
+
{
|
|
2433
|
+
name: (0, import_core2.camel)(`${operationName}-suspense`),
|
|
2434
|
+
options: query == null ? void 0 : query.options,
|
|
2435
|
+
type: QueryType.SUSPENSE_QUERY
|
|
2436
|
+
}
|
|
2437
|
+
] : [],
|
|
2438
|
+
...(query == null ? void 0 : query.useSuspenseInfiniteQuery) ? [
|
|
2439
|
+
{
|
|
2440
|
+
name: (0, import_core2.camel)(`${operationName}-suspense-infinite`),
|
|
2441
|
+
options: query == null ? void 0 : query.options,
|
|
2442
|
+
type: QueryType.SUSPENSE_INFINITE,
|
|
2443
|
+
queryParam: query == null ? void 0 : query.useInfiniteQueryParam
|
|
2444
|
+
}
|
|
2445
|
+
] : []
|
|
2446
|
+
];
|
|
2447
|
+
const queryKeyFnName = (0, import_core2.camel)(`get-${operationName}-queryKey`);
|
|
2448
|
+
let queryKeyProps = (0, import_core2.toObjectString)(
|
|
2449
|
+
props.filter((prop) => prop.type !== import_core2.GetterPropType.HEADER),
|
|
2450
|
+
"implementation"
|
|
2451
|
+
);
|
|
2452
|
+
const routeString = `\`${route}\``;
|
|
2453
|
+
const queryKeyFn = `export const ${queryKeyFnName} = (${queryKeyProps}) => {
|
|
2454
|
+
${isVue(outputClient) ? vueUnRefParams(props) : ""}
|
|
2455
|
+
return [${routeString}${queryParams ? ", ...(params ? [params]: [])" : ""}${body.implementation ? `, ${body.implementation}` : ""}] as const;
|
|
2456
|
+
}`;
|
|
2457
|
+
implementation += `${!queryKeyMutator ? queryKeyFn : ""}
|
|
86
2458
|
|
|
87
|
-
|
|
2459
|
+
${queries.reduce(
|
|
2460
|
+
(acc, queryOption) => acc + generateQueryImplementation({
|
|
2461
|
+
queryOption,
|
|
2462
|
+
operationName,
|
|
2463
|
+
queryKeyFnName,
|
|
2464
|
+
queryProperties,
|
|
2465
|
+
queryKeyProperties,
|
|
2466
|
+
params,
|
|
2467
|
+
props,
|
|
2468
|
+
mutator,
|
|
2469
|
+
isRequestOptions,
|
|
2470
|
+
queryParams,
|
|
2471
|
+
response,
|
|
2472
|
+
outputClient,
|
|
2473
|
+
isExactOptionalPropertyTypes,
|
|
2474
|
+
hasSignal: !!query.signal,
|
|
2475
|
+
queryOptionsMutator,
|
|
2476
|
+
queryKeyMutator,
|
|
2477
|
+
route,
|
|
2478
|
+
hasVueQueryV4,
|
|
2479
|
+
hasSvelteQueryV4,
|
|
2480
|
+
hasQueryV5,
|
|
2481
|
+
doc,
|
|
2482
|
+
usePrefetch: query.usePrefetch
|
|
2483
|
+
}),
|
|
2484
|
+
""
|
|
2485
|
+
)}
|
|
2486
|
+
`;
|
|
2487
|
+
mutators = queryOptionsMutator || queryKeyMutator ? [
|
|
2488
|
+
...queryOptionsMutator ? [queryOptionsMutator] : [],
|
|
2489
|
+
...queryKeyMutator ? [queryKeyMutator] : []
|
|
2490
|
+
] : void 0;
|
|
2491
|
+
}
|
|
2492
|
+
const isMutation = verb !== import_core2.Verbs.GET && override.query.useMutation || (operationQueryOptions == null ? void 0 : operationQueryOptions.useMutation);
|
|
2493
|
+
if (isMutation) {
|
|
2494
|
+
const mutationOptionsMutator = query.mutationOptions ? await (0, import_core2.generateMutator)({
|
|
2495
|
+
output,
|
|
2496
|
+
mutator: query.mutationOptions,
|
|
2497
|
+
name: `${operationName}MutationOptions`,
|
|
2498
|
+
workspace: context.workspace,
|
|
2499
|
+
tsconfig: context.tsconfig
|
|
2500
|
+
}) : void 0;
|
|
2501
|
+
const definitions = props.map(
|
|
2502
|
+
({ definition, type }) => type === import_core2.GetterPropType.BODY ? (mutator == null ? void 0 : mutator.bodyTypeName) ? `data: ${mutator.bodyTypeName}<${body.definition}>` : `data: ${body.definition}` : definition
|
|
2503
|
+
).join(";");
|
|
2504
|
+
const properties = props.map(({ name, type }) => type === import_core2.GetterPropType.BODY ? "data" : name).join(",");
|
|
2505
|
+
let errorType = `AxiosError<${response.definition.errors || "unknown"}>`;
|
|
2506
|
+
if (mutator) {
|
|
2507
|
+
errorType = mutator.hasErrorType ? `${mutator.default ? (0, import_core2.pascal)(operationName) : ""}ErrorType<${response.definition.errors || "unknown"}>` : response.definition.errors || "unknown";
|
|
2508
|
+
}
|
|
2509
|
+
const dataType = (mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`;
|
|
2510
|
+
const mutationOptionFnReturnType = getQueryOptionsDefinition({
|
|
2511
|
+
operationName,
|
|
2512
|
+
definitions,
|
|
2513
|
+
mutator,
|
|
2514
|
+
hasSvelteQueryV4,
|
|
2515
|
+
hasQueryV5,
|
|
2516
|
+
isReturnType: true
|
|
2517
|
+
});
|
|
2518
|
+
const mutationArguments = generateQueryArguments({
|
|
2519
|
+
operationName,
|
|
2520
|
+
definitions,
|
|
2521
|
+
mutator,
|
|
2522
|
+
isRequestOptions,
|
|
2523
|
+
hasSvelteQueryV4,
|
|
2524
|
+
hasQueryV5
|
|
2525
|
+
});
|
|
2526
|
+
const mutationOptionsFnName = (0, import_core2.camel)(
|
|
2527
|
+
mutationOptionsMutator || (mutator == null ? void 0 : mutator.isHook) ? `use-${operationName}-mutationOptions` : `get-${operationName}-mutationOptions`
|
|
2528
|
+
);
|
|
2529
|
+
const mutationOptionsVarName = isRequestOptions ? "mutationOptions" : "options";
|
|
2530
|
+
const mutationOptionsFn = `export const ${mutationOptionsFnName} = <TError = ${errorType},
|
|
2531
|
+
${!definitions ? `TVariables = void,` : ""}
|
|
2532
|
+
TContext = unknown>(${mutationArguments}): ${mutationOptionFnReturnType} => {
|
|
2533
|
+
${isRequestOptions ? `const {mutation: mutationOptions${!mutator ? `, axios: axiosOptions` : (mutator == null ? void 0 : mutator.hasSecondArg) ? ", request: requestOptions" : ""}} = options ?? {};` : ""}
|
|
2534
|
+
|
|
2535
|
+
${(mutator == null ? void 0 : mutator.isHook) ? `const ${operationName} = use${(0, import_core2.pascal)(operationName)}Hook()` : ""}
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<${dataType}>>, ${definitions ? `{${definitions}}` : "TVariables"}> = (${properties ? "props" : ""}) => {
|
|
2539
|
+
${properties ? `const {${properties}} = props ?? {};` : ""}
|
|
2540
|
+
|
|
2541
|
+
return ${operationName}(${properties}${properties ? "," : ""}${isRequestOptions ? !mutator ? `axiosOptions` : (mutator == null ? void 0 : mutator.hasSecondArg) ? "requestOptions" : "" : ""})
|
|
88
2542
|
}
|
|
89
2543
|
|
|
90
|
-
${
|
|
2544
|
+
${mutationOptionsMutator ? `const customOptions = ${mutationOptionsMutator.name}({...mutationOptions, mutationFn}${mutationOptionsMutator.hasThirdArg ? `, { url: \`${route}\` }` : ""});` : ""}
|
|
91
2545
|
|
|
92
2546
|
|
|
93
|
-
return ${
|
|
94
|
-
|
|
2547
|
+
return ${!mutationOptionsMutator ? "{ mutationFn, ...mutationOptions }" : "customOptions"}}`;
|
|
2548
|
+
const operationPrefix = hasSvelteQueryV4 ? "create" : "use";
|
|
2549
|
+
implementation += `
|
|
2550
|
+
${mutationOptionsFn}
|
|
95
2551
|
|
|
96
|
-
export type ${
|
|
97
|
-
|
|
98
|
-
|
|
2552
|
+
export type ${(0, import_core2.pascal)(
|
|
2553
|
+
operationName
|
|
2554
|
+
)}MutationResult = NonNullable<Awaited<ReturnType<${dataType}>>>
|
|
2555
|
+
${body.definition ? `export type ${(0, import_core2.pascal)(operationName)}MutationBody = ${(mutator == null ? void 0 : mutator.bodyTypeName) ? `${mutator.bodyTypeName}<${body.definition}>` : body.definition}` : ""}
|
|
2556
|
+
export type ${(0, import_core2.pascal)(operationName)}MutationError = ${errorType}
|
|
99
2557
|
|
|
100
|
-
${
|
|
101
|
-
|
|
102
|
-
|
|
2558
|
+
${doc}export const ${(0, import_core2.camel)(
|
|
2559
|
+
`${operationPrefix}-${operationName}`
|
|
2560
|
+
)} = <TError = ${errorType},
|
|
2561
|
+
${!definitions ? `TVariables = void,` : ""}
|
|
2562
|
+
TContext = unknown>(${mutationArguments}) => {
|
|
103
2563
|
|
|
104
|
-
const ${
|
|
2564
|
+
const ${mutationOptionsVarName} = ${mutationOptionsFnName}(${isRequestOptions ? "options" : "mutationOptions"});
|
|
105
2565
|
|
|
106
|
-
return ${
|
|
2566
|
+
return ${operationPrefix}Mutation(${mutationOptionsVarName});
|
|
107
2567
|
}
|
|
108
|
-
|
|
2568
|
+
`;
|
|
2569
|
+
mutators = mutationOptionsMutator ? [...mutators != null ? mutators : [], mutationOptionsMutator] : mutators;
|
|
2570
|
+
}
|
|
2571
|
+
return {
|
|
2572
|
+
implementation,
|
|
2573
|
+
mutators
|
|
2574
|
+
};
|
|
2575
|
+
};
|
|
2576
|
+
var generateQueryHeader = ({
|
|
2577
|
+
isRequestOptions,
|
|
2578
|
+
isMutator,
|
|
2579
|
+
hasAwaitedType
|
|
2580
|
+
}) => {
|
|
2581
|
+
return `${!hasAwaitedType ? `type AwaitedInput<T> = PromiseLike<T> | T;
|
|
109
2582
|
|
|
110
2583
|
type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
|
|
111
2584
|
|
|
112
|
-
`}
|
|
113
|
-
${
|
|
2585
|
+
` : ""}
|
|
2586
|
+
${isRequestOptions && isMutator ? `// eslint-disable-next-line
|
|
114
2587
|
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
115
2588
|
config: any,
|
|
116
2589
|
args: infer P,
|
|
@@ -118,7 +2591,64 @@ ${e&&n?`// eslint-disable-next-line
|
|
|
118
2591
|
? P
|
|
119
2592
|
: never;
|
|
120
2593
|
|
|
121
|
-
|
|
122
|
-
|
|
2594
|
+
` : ""}
|
|
2595
|
+
`;
|
|
2596
|
+
};
|
|
2597
|
+
var generateQuery = async (verbOptions, options, outputClient) => {
|
|
2598
|
+
const imports = (0, import_core2.generateVerbImports)(verbOptions);
|
|
2599
|
+
const functionImplementation = generateQueryRequestFunction(
|
|
2600
|
+
verbOptions,
|
|
2601
|
+
options,
|
|
2602
|
+
outputClient
|
|
2603
|
+
);
|
|
2604
|
+
const { implementation: hookImplementation, mutators } = await generateQueryHook(verbOptions, options, outputClient);
|
|
2605
|
+
return {
|
|
2606
|
+
implementation: `${functionImplementation}
|
|
123
2607
|
|
|
124
|
-
${
|
|
2608
|
+
${hookImplementation}`,
|
|
2609
|
+
imports,
|
|
2610
|
+
mutators
|
|
2611
|
+
};
|
|
2612
|
+
};
|
|
2613
|
+
var dependenciesBuilder = {
|
|
2614
|
+
"react-query": getReactQueryDependencies,
|
|
2615
|
+
"vue-query": getVueQueryDependencies,
|
|
2616
|
+
"svelte-query": getSvelteQueryDependencies
|
|
2617
|
+
};
|
|
2618
|
+
var builder = ({
|
|
2619
|
+
type = "react-query",
|
|
2620
|
+
options: queryOptions
|
|
2621
|
+
} = {}) => () => {
|
|
2622
|
+
const client = (verbOptions, options, outputClient) => {
|
|
2623
|
+
if (queryOptions) {
|
|
2624
|
+
const normalizedQueryOptions = normalizeQueryOptions(
|
|
2625
|
+
queryOptions,
|
|
2626
|
+
options.context.workspace
|
|
2627
|
+
);
|
|
2628
|
+
verbOptions.override.query = (0, import_core2.mergeDeep)(
|
|
2629
|
+
normalizedQueryOptions,
|
|
2630
|
+
verbOptions.override.query
|
|
2631
|
+
);
|
|
2632
|
+
options.override.query = (0, import_core2.mergeDeep)(
|
|
2633
|
+
normalizedQueryOptions,
|
|
2634
|
+
verbOptions.override.query
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
return generateQuery(verbOptions, options, outputClient);
|
|
2638
|
+
};
|
|
2639
|
+
return {
|
|
2640
|
+
client,
|
|
2641
|
+
header: generateQueryHeader,
|
|
2642
|
+
dependencies: dependenciesBuilder[type]
|
|
2643
|
+
};
|
|
2644
|
+
};
|
|
2645
|
+
var src_default = builder;
|
|
2646
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2647
|
+
0 && (module.exports = {
|
|
2648
|
+
builder,
|
|
2649
|
+
generateQuery,
|
|
2650
|
+
generateQueryHeader,
|
|
2651
|
+
getReactQueryDependencies,
|
|
2652
|
+
getSvelteQueryDependencies,
|
|
2653
|
+
getVueQueryDependencies
|
|
2654
|
+
});
|