@rescript/language-server 1.65.0-next-b20cbf8.0 → 1.65.0-next-c1b3031.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.
|
Binary file
|
|
Binary file
|
package/out/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ ${JSON.stringify(h,null,4)}`);let E=h;if(Re.string(E.id)||Re.number(E.id)){let j
|
|
|
37
37
|
${o}`)},console.warn=function(...i){e.warn(t(i))}}});var Pr=x((xC,Np)=>{"use strict";var Zb="2.0.0",Kb=Number.MAX_SAFE_INTEGER||9007199254740991,eR=16,tR=250,nR=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Np.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:eR,MAX_SAFE_BUILD_LENGTH:tR,MAX_SAFE_INTEGER:Kb,RELEASE_TYPES:nR,SEMVER_SPEC_VERSION:Zb,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Cr=x((SC,Ip)=>{"use strict";var rR=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};Ip.exports=rR});var Yn=x((Ct,Ap)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:nc,MAX_SAFE_BUILD_LENGTH:iR,MAX_LENGTH:oR}=Pr(),sR=Cr();Ct=Ap.exports={};var aR=Ct.re=[],cR=Ct.safeRe=[],A=Ct.src=[],uR=Ct.safeSrc=[],O=Ct.t={},lR=0,rc="[a-zA-Z0-9-]",dR=[["\\s",1],["\\d",oR],[rc,iR]],fR=e=>{for(let[t,n]of dR)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},G=(e,t,n)=>{let r=fR(t),i=lR++;sR(e,i,t),O[e]=i,A[i]=t,uR[i]=r,aR[i]=new RegExp(t,n?"g":void 0),cR[i]=new RegExp(r,n?"g":void 0)};G("NUMERICIDENTIFIER","0|[1-9]\\d*");G("NUMERICIDENTIFIERLOOSE","\\d+");G("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${rc}*`);G("MAINVERSION",`(${A[O.NUMERICIDENTIFIER]})\\.(${A[O.NUMERICIDENTIFIER]})\\.(${A[O.NUMERICIDENTIFIER]})`);G("MAINVERSIONLOOSE",`(${A[O.NUMERICIDENTIFIERLOOSE]})\\.(${A[O.NUMERICIDENTIFIERLOOSE]})\\.(${A[O.NUMERICIDENTIFIERLOOSE]})`);G("PRERELEASEIDENTIFIER",`(?:${A[O.NONNUMERICIDENTIFIER]}|${A[O.NUMERICIDENTIFIER]})`);G("PRERELEASEIDENTIFIERLOOSE",`(?:${A[O.NONNUMERICIDENTIFIER]}|${A[O.NUMERICIDENTIFIERLOOSE]})`);G("PRERELEASE",`(?:-(${A[O.PRERELEASEIDENTIFIER]}(?:\\.${A[O.PRERELEASEIDENTIFIER]})*))`);G("PRERELEASELOOSE",`(?:-?(${A[O.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${A[O.PRERELEASEIDENTIFIERLOOSE]})*))`);G("BUILDIDENTIFIER",`${rc}+`);G("BUILD",`(?:\\+(${A[O.BUILDIDENTIFIER]}(?:\\.${A[O.BUILDIDENTIFIER]})*))`);G("FULLPLAIN",`v?${A[O.MAINVERSION]}${A[O.PRERELEASE]}?${A[O.BUILD]}?`);G("FULL",`^${A[O.FULLPLAIN]}$`);G("LOOSEPLAIN",`[v=\\s]*${A[O.MAINVERSIONLOOSE]}${A[O.PRERELEASELOOSE]}?${A[O.BUILD]}?`);G("LOOSE",`^${A[O.LOOSEPLAIN]}$`);G("GTLT","((?:<|>)?=?)");G("XRANGEIDENTIFIERLOOSE",`${A[O.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);G("XRANGEIDENTIFIER",`${A[O.NUMERICIDENTIFIER]}|x|X|\\*`);G("XRANGEPLAIN",`[v=\\s]*(${A[O.XRANGEIDENTIFIER]})(?:\\.(${A[O.XRANGEIDENTIFIER]})(?:\\.(${A[O.XRANGEIDENTIFIER]})(?:${A[O.PRERELEASE]})?${A[O.BUILD]}?)?)?`);G("XRANGEPLAINLOOSE",`[v=\\s]*(${A[O.XRANGEIDENTIFIERLOOSE]})(?:\\.(${A[O.XRANGEIDENTIFIERLOOSE]})(?:\\.(${A[O.XRANGEIDENTIFIERLOOSE]})(?:${A[O.PRERELEASELOOSE]})?${A[O.BUILD]}?)?)?`);G("XRANGE",`^${A[O.GTLT]}\\s*${A[O.XRANGEPLAIN]}$`);G("XRANGELOOSE",`^${A[O.GTLT]}\\s*${A[O.XRANGEPLAINLOOSE]}$`);G("COERCEPLAIN",`(^|[^\\d])(\\d{1,${nc}})(?:\\.(\\d{1,${nc}}))?(?:\\.(\\d{1,${nc}}))?`);G("COERCE",`${A[O.COERCEPLAIN]}(?:$|[^\\d])`);G("COERCEFULL",A[O.COERCEPLAIN]+`(?:${A[O.PRERELEASE]})?(?:${A[O.BUILD]})?(?:$|[^\\d])`);G("COERCERTL",A[O.COERCE],!0);G("COERCERTLFULL",A[O.COERCEFULL],!0);G("LONETILDE","(?:~>?)");G("TILDETRIM",`(\\s*)${A[O.LONETILDE]}\\s+`,!0);Ct.tildeTrimReplace="$1~";G("TILDE",`^${A[O.LONETILDE]}${A[O.XRANGEPLAIN]}$`);G("TILDELOOSE",`^${A[O.LONETILDE]}${A[O.XRANGEPLAINLOOSE]}$`);G("LONECARET","(?:\\^)");G("CARETTRIM",`(\\s*)${A[O.LONECARET]}\\s+`,!0);Ct.caretTrimReplace="$1^";G("CARET",`^${A[O.LONECARET]}${A[O.XRANGEPLAIN]}$`);G("CARETLOOSE",`^${A[O.LONECARET]}${A[O.XRANGEPLAINLOOSE]}$`);G("COMPARATORLOOSE",`^${A[O.GTLT]}\\s*(${A[O.LOOSEPLAIN]})$|^$`);G("COMPARATOR",`^${A[O.GTLT]}\\s*(${A[O.FULLPLAIN]})$|^$`);G("COMPARATORTRIM",`(\\s*)${A[O.GTLT]}\\s*(${A[O.LOOSEPLAIN]}|${A[O.XRANGEPLAIN]})`,!0);Ct.comparatorTrimReplace="$1$2$3";G("HYPHENRANGE",`^\\s*(${A[O.XRANGEPLAIN]})\\s+-\\s+(${A[O.XRANGEPLAIN]})\\s*$`);G("HYPHENRANGELOOSE",`^\\s*(${A[O.XRANGEPLAINLOOSE]})\\s+-\\s+(${A[O.XRANGEPLAINLOOSE]})\\s*$`);G("STAR","(<|>)?=?\\s*\\*");G("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");G("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var wo=x((TC,Op)=>{"use strict";var pR=Object.freeze({loose:!0}),hR=Object.freeze({}),gR=e=>e?typeof e!="object"?pR:e:hR;Op.exports=gR});var ic=x((kC,Lp)=>{"use strict";var Mp=/^[0-9]+$/,Fp=(e,t)=>{let n=Mp.test(e),r=Mp.test(t);return n&&r&&(e=+e,t=+t),e===t?0:n&&!r?-1:r&&!n?1:e<t?-1:1},mR=(e,t)=>Fp(t,e);Lp.exports={compareIdentifiers:Fp,rcompareIdentifiers:mR}});var $e=x((qC,Wp)=>{"use strict";var Po=Cr(),{MAX_LENGTH:$p,MAX_SAFE_INTEGER:Co}=Pr(),{safeRe:Eo,t:xo}=Yn(),yR=wo(),{compareIdentifiers:Qn}=ic(),oc=class e{constructor(t,n){if(n=yR(n),t instanceof e){if(t.loose===!!n.loose&&t.includePrerelease===!!n.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>$p)throw new TypeError(`version is longer than ${$p} characters`);Po("SemVer",t,n),this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease;let r=t.trim().match(n.loose?Eo[xo.LOOSE]:Eo[xo.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>Co||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Co||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Co||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let o=+i;if(o>=0&&o<Co)return o}return i}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(Po("SemVer.compare",this.version,this.options,t),!(t instanceof e)){if(typeof t=="string"&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),Qn(this.major,t.major)||Qn(this.minor,t.minor)||Qn(this.patch,t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{let r=this.prerelease[n],i=t.prerelease[n];if(Po("prerelease compare",n,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return Qn(r,i)}while(++n)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let n=0;do{let r=this.build[n],i=t.build[n];if(Po("build compare",n,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return Qn(r,i)}while(++n)}inc(t,n,r){if(t.startsWith("pre")){if(!n&&r===!1)throw new Error("invalid increment argument: identifier is empty");if(n){let i=`-${n}`.match(this.options.loose?Eo[xo.PRERELEASELOOSE]:Eo[xo.PRERELEASE]);if(!i||i[1]!==n)throw new Error(`invalid identifier: ${n}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",n,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",n,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",n,r),this.inc("pre",n,r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",n,r),this.inc("pre",n,r);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let i=Number(r)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(n===this.prerelease.join(".")&&r===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(n){let o=[n,i];r===!1&&(o=[n]),Qn(this.prerelease[0],n)===0?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Wp.exports=oc});var mn=x((jC,Up)=>{"use strict";var Hp=$e(),vR=(e,t,n=!1)=>{if(e instanceof Hp)return e;try{return new Hp(e,t)}catch(r){if(!n)return null;throw r}};Up.exports=vR});var Bp=x((NC,Vp)=>{"use strict";var bR=mn(),RR=(e,t)=>{let n=bR(e,t);return n?n.version:null};Vp.exports=RR});var Gp=x((IC,zp)=>{"use strict";var DR=mn(),_R=(e,t)=>{let n=DR(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null};zp.exports=_R});var Yp=x((AC,Jp)=>{"use strict";var Xp=$e(),wR=(e,t,n,r,i)=>{typeof n=="string"&&(i=r,r=n,n=void 0);try{return new Xp(e instanceof Xp?e.version:e,n).inc(t,r,i).version}catch{return null}};Jp.exports=wR});var Kp=x((OC,Zp)=>{"use strict";var Qp=mn(),PR=(e,t)=>{let n=Qp(e,null,!0),r=Qp(t,null,!0),i=n.compare(r);if(i===0)return null;let o=i>0,s=o?n:r,u=o?r:n,d=!!s.prerelease.length;if(!!u.prerelease.length&&!d){if(!u.patch&&!u.minor)return"major";if(u.compareMain(s)===0)return u.minor&&!u.patch?"minor":"patch"}let _=d?"pre":"";return n.major!==r.major?_+"major":n.minor!==r.minor?_+"minor":n.patch!==r.patch?_+"patch":"prerelease"};Zp.exports=PR});var th=x((MC,eh)=>{"use strict";var CR=$e(),ER=(e,t)=>new CR(e,t).major;eh.exports=ER});var rh=x((FC,nh)=>{"use strict";var xR=$e(),SR=(e,t)=>new xR(e,t).minor;nh.exports=SR});var oh=x((LC,ih)=>{"use strict";var TR=$e(),kR=(e,t)=>new TR(e,t).patch;ih.exports=kR});var ah=x(($C,sh)=>{"use strict";var qR=mn(),jR=(e,t)=>{let n=qR(e,t);return n&&n.prerelease.length?n.prerelease:null};sh.exports=jR});var at=x((WC,uh)=>{"use strict";var ch=$e(),NR=(e,t,n)=>new ch(e,n).compare(new ch(t,n));uh.exports=NR});var dh=x((HC,lh)=>{"use strict";var IR=at(),AR=(e,t,n)=>IR(t,e,n);lh.exports=AR});var ph=x((UC,fh)=>{"use strict";var OR=at(),MR=(e,t)=>OR(e,t,!0);fh.exports=MR});var So=x((VC,gh)=>{"use strict";var hh=$e(),FR=(e,t,n)=>{let r=new hh(e,n),i=new hh(t,n);return r.compare(i)||r.compareBuild(i)};gh.exports=FR});var yh=x((BC,mh)=>{"use strict";var LR=So(),$R=(e,t)=>e.sort((n,r)=>LR(n,r,t));mh.exports=$R});var bh=x((zC,vh)=>{"use strict";var WR=So(),HR=(e,t)=>e.sort((n,r)=>WR(r,n,t));vh.exports=HR});var Er=x((GC,Rh)=>{"use strict";var UR=at(),VR=(e,t,n)=>UR(e,t,n)>0;Rh.exports=VR});var To=x((XC,Dh)=>{"use strict";var BR=at(),zR=(e,t,n)=>BR(e,t,n)<0;Dh.exports=zR});var sc=x((JC,_h)=>{"use strict";var GR=at(),XR=(e,t,n)=>GR(e,t,n)===0;_h.exports=XR});var ac=x((YC,wh)=>{"use strict";var JR=at(),YR=(e,t,n)=>JR(e,t,n)!==0;wh.exports=YR});var ko=x((QC,Ph)=>{"use strict";var QR=at(),ZR=(e,t,n)=>QR(e,t,n)>=0;Ph.exports=ZR});var qo=x((ZC,Ch)=>{"use strict";var KR=at(),eD=(e,t,n)=>KR(e,t,n)<=0;Ch.exports=eD});var cc=x((KC,Eh)=>{"use strict";var tD=sc(),nD=ac(),rD=Er(),iD=ko(),oD=To(),sD=qo(),aD=(e,t,n,r)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e===n;case"!==":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e!==n;case"":case"=":case"==":return tD(e,n,r);case"!=":return nD(e,n,r);case">":return rD(e,n,r);case">=":return iD(e,n,r);case"<":return oD(e,n,r);case"<=":return sD(e,n,r);default:throw new TypeError(`Invalid operator: ${t}`)}};Eh.exports=aD});var Sh=x((eE,xh)=>{"use strict";var cD=$e(),uD=mn(),{safeRe:jo,t:No}=Yn(),lD=(e,t)=>{if(e instanceof cD)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let n=null;if(!t.rtl)n=e.match(t.includePrerelease?jo[No.COERCEFULL]:jo[No.COERCE]);else{let d=t.includePrerelease?jo[No.COERCERTLFULL]:jo[No.COERCERTL],p;for(;(p=d.exec(e))&&(!n||n.index+n[0].length!==e.length);)(!n||p.index+p[0].length!==n.index+n[0].length)&&(n=p),d.lastIndex=p.index+p[1].length+p[2].length;d.lastIndex=-1}if(n===null)return null;let r=n[2],i=n[3]||"0",o=n[4]||"0",s=t.includePrerelease&&n[5]?`-${n[5]}`:"",u=t.includePrerelease&&n[6]?`+${n[6]}`:"";return uD(`${r}.${i}.${o}${s}${u}`,t)};xh.exports=lD});var kh=x((tE,Th)=>{"use strict";var uc=class{constructor(){this.max=1e3,this.map=new Map}get(t){let n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}delete(t){return this.map.delete(t)}set(t,n){if(!this.delete(t)&&n!==void 0){if(this.map.size>=this.max){let i=this.map.keys().next().value;this.delete(i)}this.map.set(t,n)}return this}};Th.exports=uc});var ct=x((nE,Ih)=>{"use strict";var dD=/\s+/g,lc=class e{constructor(t,n){if(n=pD(n),t instanceof e)return t.loose===!!n.loose&&t.includePrerelease===!!n.includePrerelease?t:new e(t.raw,n);if(t instanceof dc)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease,this.raw=t.trim().replace(dD," "),this.set=this.raw.split("||").map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let r=this.set[0];if(this.set=this.set.filter(i=>!jh(i[0])),this.set.length===0)this.set=[r];else if(this.set.length>1){for(let i of this.set)if(i.length===1&&RD(i[0])){this.set=[i];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let n=this.set[t];for(let r=0;r<n.length;r++)r>0&&(this.formatted+=" "),this.formatted+=n[r].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let r=((this.options.includePrerelease&&vD)|(this.options.loose&&bD))+":"+t,i=qh.get(r);if(i)return i;let o=this.options.loose,s=o?Je[We.HYPHENRANGELOOSE]:Je[We.HYPHENRANGE];t=t.replace(s,kD(this.options.includePrerelease)),ye("hyphen replace",t),t=t.replace(Je[We.COMPARATORTRIM],gD),ye("comparator trim",t),t=t.replace(Je[We.TILDETRIM],mD),ye("tilde trim",t),t=t.replace(Je[We.CARETTRIM],yD),ye("caret trim",t);let u=t.split(" ").map(w=>DD(w,this.options)).join(" ").split(/\s+/).map(w=>TD(w,this.options));o&&(u=u.filter(w=>(ye("loose invalid filter",w,this.options),!!w.match(Je[We.COMPARATORLOOSE])))),ye("range list",u);let d=new Map,p=u.map(w=>new dc(w,this.options));for(let w of p){if(jh(w))return[w];d.set(w.value,w)}d.size>1&&d.has("")&&d.delete("");let _=[...d.values()];return qh.set(r,_),_}intersects(t,n){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(r=>Nh(r,n)&&t.set.some(i=>Nh(i,n)&&r.every(o=>i.every(s=>o.intersects(s,n)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new hD(t,this.options)}catch{return!1}for(let n=0;n<this.set.length;n++)if(qD(this.set[n],t,this.options))return!0;return!1}};Ih.exports=lc;var fD=kh(),qh=new fD,pD=wo(),dc=xr(),ye=Cr(),hD=$e(),{safeRe:Je,t:We,comparatorTrimReplace:gD,tildeTrimReplace:mD,caretTrimReplace:yD}=Yn(),{FLAG_INCLUDE_PRERELEASE:vD,FLAG_LOOSE:bD}=Pr(),jh=e=>e.value==="<0.0.0-0",RD=e=>e.value==="",Nh=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(o=>i.intersects(o,t)),i=r.pop();return n},DD=(e,t)=>(ye("comp",e,t),e=PD(e,t),ye("caret",e),e=_D(e,t),ye("tildes",e),e=ED(e,t),ye("xrange",e),e=SD(e,t),ye("stars",e),e),He=e=>!e||e.toLowerCase()==="x"||e==="*",_D=(e,t)=>e.trim().split(/\s+/).map(n=>wD(n,t)).join(" "),wD=(e,t)=>{let n=t.loose?Je[We.TILDELOOSE]:Je[We.TILDE];return e.replace(n,(r,i,o,s,u)=>{ye("tilde",e,r,i,o,s,u);let d;return He(i)?d="":He(o)?d=`>=${i}.0.0 <${+i+1}.0.0-0`:He(s)?d=`>=${i}.${o}.0 <${i}.${+o+1}.0-0`:u?(ye("replaceTilde pr",u),d=`>=${i}.${o}.${s}-${u} <${i}.${+o+1}.0-0`):d=`>=${i}.${o}.${s} <${i}.${+o+1}.0-0`,ye("tilde return",d),d})},PD=(e,t)=>e.trim().split(/\s+/).map(n=>CD(n,t)).join(" "),CD=(e,t)=>{ye("caret",e,t);let n=t.loose?Je[We.CARETLOOSE]:Je[We.CARET],r=t.includePrerelease?"-0":"";return e.replace(n,(i,o,s,u,d)=>{ye("caret",e,i,o,s,u,d);let p;return He(o)?p="":He(s)?p=`>=${o}.0.0${r} <${+o+1}.0.0-0`:He(u)?o==="0"?p=`>=${o}.${s}.0${r} <${o}.${+s+1}.0-0`:p=`>=${o}.${s}.0${r} <${+o+1}.0.0-0`:d?(ye("replaceCaret pr",d),o==="0"?s==="0"?p=`>=${o}.${s}.${u}-${d} <${o}.${s}.${+u+1}-0`:p=`>=${o}.${s}.${u}-${d} <${o}.${+s+1}.0-0`:p=`>=${o}.${s}.${u}-${d} <${+o+1}.0.0-0`):(ye("no pr"),o==="0"?s==="0"?p=`>=${o}.${s}.${u}${r} <${o}.${s}.${+u+1}-0`:p=`>=${o}.${s}.${u}${r} <${o}.${+s+1}.0-0`:p=`>=${o}.${s}.${u} <${+o+1}.0.0-0`),ye("caret return",p),p})},ED=(e,t)=>(ye("replaceXRanges",e,t),e.split(/\s+/).map(n=>xD(n,t)).join(" ")),xD=(e,t)=>{e=e.trim();let n=t.loose?Je[We.XRANGELOOSE]:Je[We.XRANGE];return e.replace(n,(r,i,o,s,u,d)=>{ye("xRange",e,r,i,o,s,u,d);let p=He(o),_=p||He(s),w=_||He(u),T=w;return i==="="&&T&&(i=""),d=t.includePrerelease?"-0":"",p?i===">"||i==="<"?r="<0.0.0-0":r="*":i&&T?(_&&(s=0),u=0,i===">"?(i=">=",_?(o=+o+1,s=0,u=0):(s=+s+1,u=0)):i==="<="&&(i="<",_?o=+o+1:s=+s+1),i==="<"&&(d="-0"),r=`${i+o}.${s}.${u}${d}`):_?r=`>=${o}.0.0${d} <${+o+1}.0.0-0`:w&&(r=`>=${o}.${s}.0${d} <${o}.${+s+1}.0-0`),ye("xRange return",r),r})},SD=(e,t)=>(ye("replaceStars",e,t),e.trim().replace(Je[We.STAR],"")),TD=(e,t)=>(ye("replaceGTE0",e,t),e.trim().replace(Je[t.includePrerelease?We.GTE0PRE:We.GTE0],"")),kD=e=>(t,n,r,i,o,s,u,d,p,_,w,T)=>(He(r)?n="":He(i)?n=`>=${r}.0.0${e?"-0":""}`:He(o)?n=`>=${r}.${i}.0${e?"-0":""}`:s?n=`>=${n}`:n=`>=${n}${e?"-0":""}`,He(p)?d="":He(_)?d=`<${+p+1}.0.0-0`:He(w)?d=`<${p}.${+_+1}.0-0`:T?d=`<=${p}.${_}.${w}-${T}`:e?d=`<${p}.${_}.${+w+1}-0`:d=`<=${d}`,`${n} ${d}`.trim()),qD=(e,t,n)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let r=0;r<e.length;r++)if(ye(e[r].semver),e[r].semver!==dc.ANY&&e[r].semver.prerelease.length>0){let i=e[r].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}return!1}return!0}});var xr=x((rE,$h)=>{"use strict";var Sr=Symbol("SemVer ANY"),hc=class e{static get ANY(){return Sr}constructor(t,n){if(n=Ah(n),t instanceof e){if(t.loose===!!n.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),pc("comparator",t,n),this.options=n,this.loose=!!n.loose,this.parse(t),this.semver===Sr?this.value="":this.value=this.operator+this.semver.version,pc("comp",this)}parse(t){let n=this.options.loose?Oh[Mh.COMPARATORLOOSE]:Oh[Mh.COMPARATOR],r=t.match(n);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new Fh(r[2],this.options.loose):this.semver=Sr}toString(){return this.value}test(t){if(pc("Comparator.test",t,this.options.loose),this.semver===Sr||t===Sr)return!0;if(typeof t=="string")try{t=new Fh(t,this.options)}catch{return!1}return fc(t,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Lh(t.value,n).test(this.value):t.operator===""?t.value===""?!0:new Lh(this.value,n).test(t.semver):(n=Ah(n),n.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!n.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||fc(this.semver,"<",t.semver,n)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||fc(this.semver,">",t.semver,n)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};$h.exports=hc;var Ah=wo(),{safeRe:Oh,t:Mh}=Yn(),fc=cc(),pc=Cr(),Fh=$e(),Lh=ct()});var Tr=x((iE,Wh)=>{"use strict";var jD=ct(),ND=(e,t,n)=>{try{t=new jD(t,n)}catch{return!1}return t.test(e)};Wh.exports=ND});var Uh=x((oE,Hh)=>{"use strict";var ID=ct(),AD=(e,t)=>new ID(e,t).set.map(n=>n.map(r=>r.value).join(" ").trim().split(" "));Hh.exports=AD});var Bh=x((sE,Vh)=>{"use strict";var OD=$e(),MD=ct(),FD=(e,t,n)=>{let r=null,i=null,o=null;try{o=new MD(t,n)}catch{return null}return e.forEach(s=>{o.test(s)&&(!r||i.compare(s)===-1)&&(r=s,i=new OD(r,n))}),r};Vh.exports=FD});var Gh=x((aE,zh)=>{"use strict";var LD=$e(),$D=ct(),WD=(e,t,n)=>{let r=null,i=null,o=null;try{o=new $D(t,n)}catch{return null}return e.forEach(s=>{o.test(s)&&(!r||i.compare(s)===1)&&(r=s,i=new LD(r,n))}),r};zh.exports=WD});var Yh=x((cE,Jh)=>{"use strict";var gc=$e(),HD=ct(),Xh=Er(),UD=(e,t)=>{e=new HD(e,t);let n=new gc("0.0.0");if(e.test(n)||(n=new gc("0.0.0-0"),e.test(n)))return n;n=null;for(let r=0;r<e.set.length;++r){let i=e.set[r],o=null;i.forEach(s=>{let u=new gc(s.semver.version);switch(s.operator){case">":u.prerelease.length===0?u.patch++:u.prerelease.push(0),u.raw=u.format();case"":case">=":(!o||Xh(u,o))&&(o=u);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${s.operator}`)}}),o&&(!n||Xh(n,o))&&(n=o)}return n&&e.test(n)?n:null};Jh.exports=UD});var Zh=x((uE,Qh)=>{"use strict";var VD=ct(),BD=(e,t)=>{try{return new VD(e,t).range||"*"}catch{return null}};Qh.exports=BD});var Io=x((lE,ng)=>{"use strict";var zD=$e(),tg=xr(),{ANY:GD}=tg,XD=ct(),JD=Tr(),Kh=Er(),eg=To(),YD=qo(),QD=ko(),ZD=(e,t,n,r)=>{e=new zD(e,r),t=new XD(t,r);let i,o,s,u,d;switch(n){case">":i=Kh,o=YD,s=eg,u=">",d=">=";break;case"<":i=eg,o=QD,s=Kh,u="<",d="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(JD(e,t,r))return!1;for(let p=0;p<t.set.length;++p){let _=t.set[p],w=null,T=null;if(_.forEach(P=>{P.semver===GD&&(P=new tg(">=0.0.0")),w=w||P,T=T||P,i(P.semver,w.semver,r)?w=P:s(P.semver,T.semver,r)&&(T=P)}),w.operator===u||w.operator===d||(!T.operator||T.operator===u)&&o(e,T.semver))return!1;if(T.operator===d&&s(e,T.semver))return!1}return!0};ng.exports=ZD});var ig=x((dE,rg)=>{"use strict";var KD=Io(),e_=(e,t,n)=>KD(e,t,">",n);rg.exports=e_});var sg=x((fE,og)=>{"use strict";var t_=Io(),n_=(e,t,n)=>t_(e,t,"<",n);og.exports=n_});var ug=x((pE,cg)=>{"use strict";var ag=ct(),r_=(e,t,n)=>(e=new ag(e,n),t=new ag(t,n),e.intersects(t,n));cg.exports=r_});var dg=x((hE,lg)=>{"use strict";var i_=Tr(),o_=at();lg.exports=(e,t,n)=>{let r=[],i=null,o=null,s=e.sort((_,w)=>o_(_,w,n));for(let _ of s)i_(_,t,n)?(o=_,i||(i=_)):(o&&r.push([i,o]),o=null,i=null);i&&r.push([i,null]);let u=[];for(let[_,w]of r)_===w?u.push(_):!w&&_===s[0]?u.push("*"):w?_===s[0]?u.push(`<=${w}`):u.push(`${_} - ${w}`):u.push(`>=${_}`);let d=u.join(" || "),p=typeof t.raw=="string"?t.raw:String(t);return d.length<p.length?d:t}});var yg=x((gE,mg)=>{"use strict";var fg=ct(),yc=xr(),{ANY:mc}=yc,kr=Tr(),vc=at(),s_=(e,t,n={})=>{if(e===t)return!0;e=new fg(e,n),t=new fg(t,n);let r=!1;e:for(let i of e.set){for(let o of t.set){let s=c_(i,o,n);if(r=r||s!==null,s)continue e}if(r)return!1}return!0},a_=[new yc(">=0.0.0-0")],pg=[new yc(">=0.0.0")],c_=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===mc){if(t.length===1&&t[0].semver===mc)return!0;n.includePrerelease?e=a_:e=pg}if(t.length===1&&t[0].semver===mc){if(n.includePrerelease)return!0;t=pg}let r=new Set,i,o;for(let P of e)P.operator===">"||P.operator===">="?i=hg(i,P,n):P.operator==="<"||P.operator==="<="?o=gg(o,P,n):r.add(P.semver);if(r.size>1)return null;let s;if(i&&o){if(s=vc(i.semver,o.semver,n),s>0)return null;if(s===0&&(i.operator!==">="||o.operator!=="<="))return null}for(let P of r){if(i&&!kr(P,String(i),n)||o&&!kr(P,String(o),n))return null;for(let L of t)if(!kr(P,String(L),n))return!1;return!0}let u,d,p,_,w=o&&!n.includePrerelease&&o.semver.prerelease.length?o.semver:!1,T=i&&!n.includePrerelease&&i.semver.prerelease.length?i.semver:!1;w&&w.prerelease.length===1&&o.operator==="<"&&w.prerelease[0]===0&&(w=!1);for(let P of t){if(_=_||P.operator===">"||P.operator===">=",p=p||P.operator==="<"||P.operator==="<=",i){if(T&&P.semver.prerelease&&P.semver.prerelease.length&&P.semver.major===T.major&&P.semver.minor===T.minor&&P.semver.patch===T.patch&&(T=!1),P.operator===">"||P.operator===">="){if(u=hg(i,P,n),u===P&&u!==i)return!1}else if(i.operator===">="&&!kr(i.semver,String(P),n))return!1}if(o){if(w&&P.semver.prerelease&&P.semver.prerelease.length&&P.semver.major===w.major&&P.semver.minor===w.minor&&P.semver.patch===w.patch&&(w=!1),P.operator==="<"||P.operator==="<="){if(d=gg(o,P,n),d===P&&d!==o)return!1}else if(o.operator==="<="&&!kr(o.semver,String(P),n))return!1}if(!P.operator&&(o||i)&&s!==0)return!1}return!(i&&p&&!o&&s!==0||o&&_&&!i&&s!==0||T||w)},hg=(e,t,n)=>{if(!e)return t;let r=vc(e.semver,t.semver,n);return r>0?e:r<0||t.operator===">"&&e.operator===">="?t:e},gg=(e,t,n)=>{if(!e)return t;let r=vc(e.semver,t.semver,n);return r<0?e:r>0||t.operator==="<"&&e.operator==="<="?t:e};mg.exports=s_});var qr=x((mE,Rg)=>{"use strict";var bc=Yn(),vg=Pr(),u_=$e(),bg=ic(),l_=mn(),d_=Bp(),f_=Gp(),p_=Yp(),h_=Kp(),g_=th(),m_=rh(),y_=oh(),v_=ah(),b_=at(),R_=dh(),D_=ph(),__=So(),w_=yh(),P_=bh(),C_=Er(),E_=To(),x_=sc(),S_=ac(),T_=ko(),k_=qo(),q_=cc(),j_=Sh(),N_=xr(),I_=ct(),A_=Tr(),O_=Uh(),M_=Bh(),F_=Gh(),L_=Yh(),$_=Zh(),W_=Io(),H_=ig(),U_=sg(),V_=ug(),B_=dg(),z_=yg();Rg.exports={parse:l_,valid:d_,clean:f_,inc:p_,diff:h_,major:g_,minor:m_,patch:y_,prerelease:v_,compare:b_,rcompare:R_,compareLoose:D_,compareBuild:__,sort:w_,rsort:P_,gt:C_,lt:E_,eq:x_,neq:S_,gte:T_,lte:k_,cmp:q_,coerce:j_,Comparator:N_,Range:I_,satisfies:A_,toComparators:O_,maxSatisfying:M_,minSatisfying:F_,minVersion:L_,validRange:$_,outside:W_,gtr:H_,ltr:U_,intersects:V_,simplifyRange:B_,subset:z_,SemVer:u_,re:bc.re,src:bc.src,tokens:bc.t,SEMVER_SPEC_VERSION:vg.SEMVER_SPEC_VERSION,RELEASE_TYPES:vg.RELEASE_TYPES,compareIdentifiers:bg.compareIdentifiers,rcompareIdentifiers:bg.rcompareIdentifiers}});var Sy=te(require("fs")),Ty=te(require("path"));var bn=te(require("process")),I=te(he()),nn=te(jp()),ts=te(Ei()),oe=te(require("path")),tu=te(qr()),Se=te(require("fs")),et=te(he());var Or=te(require("fs")),Ne=te(require("path"));var Ye=te(require("path"));var Rc=process.arch=="arm64"?process.platform+process.arch:process.platform,W="2.0",Dg="rescript-editor-analysis.exe",Dc=Ye.join(Ye.dirname(__dirname),"..",Dg),_c=Ye.join(Ye.dirname(__dirname),"analysis_binaries",Rc,Dg);var _g=Ye.join("node_modules",".bin"),wg=".bsb.lock",jr="bsconfig.json",Nr="rescript.json",tn=Ye.join("lib","bs"),Pg=Ye.join("lib","ocaml"),wc=Ye.join("lib","bs",".compiler.log"),Ao=Ye.join("lib","bs","compiler-info.json"),Oo=Ye.join("lib","bs","build.ninja"),Cg=Ye.join("lib","rewatch.lock"),Eg=Ye.join("lib","rescript.lock"),Et=".res",Ir=".resi",xg=".cmi",Pc="Start Build",Sg="commonjs",Tg=".js",Cc="rescript_configuration_request",kg=1e4;var G_=e=>{switch(e){case"esmodule":case"es6":return"es6";case"es6-global":return"es6_global";case"commonjs":default:return"js"}},Fo=(e,t)=>{let n=Ne.basename(e,Ne.extname(e));return Ne.format({dir:Ne.dirname(e),name:n,ext:t})},Ar=(e,t)=>{if(e==null)return null;let n=Ne.join(e,t);if(Or.existsSync(n))return n;let r=Ne.dirname(e);return r===e?null:Ar(r,t)},Lo=e=>{try{let t=Ne.join(e,Nr),n=Ne.join(e,jr),r=Or.readFileSync(Or.existsSync(t)?t:n,{encoding:"utf-8"});return JSON.parse(r)}catch{return null}},qg=e=>{let t=e["package-specs"],n="",r=Sg,i={module:r},o=Tg;return t&&(!Array.isArray(t)&&typeof t!="string"&&t.module?i=t:typeof t=="string"?r=t:Array.isArray(t)&&t[0]&&(typeof t[0]=="string"?r=t[0]:i=t[0])),i.module&&(r=i.module),i["in-source"]||(n="lib/"+G_(r)),i.suffix?o=i.suffix:e.suffix&&(o=e.suffix),[o,n]},jg=(e,t)=>{let n=Lo(e);if(!n)return null;let[r,i]=qg(n),o=Fo(t,r);return Ne.join(e,i,o)},Ng=(e,t)=>{let n=Ar(Ne.join("..",e),Nr);if(n||(n=Ar(Ne.join("..",e),jr)),!n)return null;let r=Lo(Ne.dirname(n));if(!r)return null;let[i,o]=qg(r),s=Fo(t,i);return Ne.join(e,o,s)};var Mt=te(require("child_process")),Ie=te(require("path"));var Ag;(function(e){function t(n){return typeof n=="string"}e.is=t})(Ag||(Ag={}));var Ec;(function(e){function t(n){return typeof n=="string"}e.is=t})(Ec||(Ec={}));var Og;(function(e){e.MIN_VALUE=-2147483648,e.MAX_VALUE=2147483647;function t(n){return typeof n=="number"&&e.MIN_VALUE<=n&&n<=e.MAX_VALUE}e.is=t})(Og||(Og={}));var $o;(function(e){e.MIN_VALUE=0,e.MAX_VALUE=2147483647;function t(n){return typeof n=="number"&&e.MIN_VALUE<=n&&n<=e.MAX_VALUE}e.is=t})($o||($o={}));var vt;(function(e){function t(r,i){return r===Number.MAX_VALUE&&(r=$o.MAX_VALUE),i===Number.MAX_VALUE&&(i=$o.MAX_VALUE),{line:r,character:i}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&D.uinteger(i.line)&&D.uinteger(i.character)}e.is=n})(vt||(vt={}));var Ce;(function(e){function t(r,i,o,s){if(D.uinteger(r)&&D.uinteger(i)&&D.uinteger(o)&&D.uinteger(s))return{start:vt.create(r,i),end:vt.create(o,s)};if(vt.is(r)&&vt.is(i))return{start:r,end:i};throw new Error(`Range#create called with invalid arguments[${r}, ${i}, ${o}, ${s}]`)}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&vt.is(i.start)&&vt.is(i.end)}e.is=n})(Ce||(Ce={}));var Wo;(function(e){function t(r,i){return{uri:r,range:i}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&Ce.is(i.range)&&(D.string(i.uri)||D.undefined(i.uri))}e.is=n})(Wo||(Wo={}));var Mg;(function(e){function t(r,i,o,s){return{targetUri:r,targetRange:i,targetSelectionRange:o,originSelectionRange:s}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&Ce.is(i.targetRange)&&D.string(i.targetUri)&&Ce.is(i.targetSelectionRange)&&(Ce.is(i.originSelectionRange)||D.undefined(i.originSelectionRange))}e.is=n})(Mg||(Mg={}));var xc;(function(e){function t(r,i,o,s){return{red:r,green:i,blue:o,alpha:s}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&D.numberRange(i.red,0,1)&&D.numberRange(i.green,0,1)&&D.numberRange(i.blue,0,1)&&D.numberRange(i.alpha,0,1)}e.is=n})(xc||(xc={}));var Fg;(function(e){function t(r,i){return{range:r,color:i}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&Ce.is(i.range)&&xc.is(i.color)}e.is=n})(Fg||(Fg={}));var Lg;(function(e){function t(r,i,o){return{label:r,textEdit:i,additionalTextEdits:o}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&D.string(i.label)&&(D.undefined(i.textEdit)||Kn.is(i))&&(D.undefined(i.additionalTextEdits)||D.typedArray(i.additionalTextEdits,Kn.is))}e.is=n})(Lg||(Lg={}));var $g;(function(e){e.Comment="comment",e.Imports="imports",e.Region="region"})($g||($g={}));var Wg;(function(e){function t(r,i,o,s,u,d){let p={startLine:r,endLine:i};return D.defined(o)&&(p.startCharacter=o),D.defined(s)&&(p.endCharacter=s),D.defined(u)&&(p.kind=u),D.defined(d)&&(p.collapsedText=d),p}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&D.uinteger(i.startLine)&&D.uinteger(i.startLine)&&(D.undefined(i.startCharacter)||D.uinteger(i.startCharacter))&&(D.undefined(i.endCharacter)||D.uinteger(i.endCharacter))&&(D.undefined(i.kind)||D.string(i.kind))}e.is=n})(Wg||(Wg={}));var Sc;(function(e){function t(r,i){return{location:r,message:i}}e.create=t;function n(r){let i=r;return D.defined(i)&&Wo.is(i.location)&&D.string(i.message)}e.is=n})(Sc||(Sc={}));var bt;(function(e){e.Error=1,e.Warning=2,e.Information=3,e.Hint=4})(bt||(bt={}));var Mr;(function(e){e.Unnecessary=1,e.Deprecated=2})(Mr||(Mr={}));var Hg;(function(e){function t(n){let r=n;return D.objectLiteral(r)&&D.string(r.href)}e.is=t})(Hg||(Hg={}));var Ho;(function(e){function t(r,i,o,s,u,d){let p={range:r,message:i};return D.defined(o)&&(p.severity=o),D.defined(s)&&(p.code=s),D.defined(u)&&(p.source=u),D.defined(d)&&(p.relatedInformation=d),p}e.create=t;function n(r){var i;let o=r;return D.defined(o)&&Ce.is(o.range)&&D.string(o.message)&&(D.number(o.severity)||D.undefined(o.severity))&&(D.integer(o.code)||D.string(o.code)||D.undefined(o.code))&&(D.undefined(o.codeDescription)||D.string((i=o.codeDescription)===null||i===void 0?void 0:i.href))&&(D.string(o.source)||D.undefined(o.source))&&(D.undefined(o.relatedInformation)||D.typedArray(o.relatedInformation,Sc.is))}e.is=n})(Ho||(Ho={}));var Zn;(function(e){function t(r,i,...o){let s={title:r,command:i};return D.defined(o)&&o.length>0&&(s.arguments=o),s}e.create=t;function n(r){let i=r;return D.defined(i)&&D.string(i.title)&&D.string(i.command)}e.is=n})(Zn||(Zn={}));var Kn;(function(e){function t(o,s){return{range:o,newText:s}}e.replace=t;function n(o,s){return{range:{start:o,end:o},newText:s}}e.insert=n;function r(o){return{range:o,newText:""}}e.del=r;function i(o){let s=o;return D.objectLiteral(s)&&D.string(s.newText)&&Ce.is(s.range)}e.is=i})(Kn||(Kn={}));var Tc;(function(e){function t(r,i,o){let s={label:r};return i!==void 0&&(s.needsConfirmation=i),o!==void 0&&(s.description=o),s}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&D.string(i.label)&&(D.boolean(i.needsConfirmation)||i.needsConfirmation===void 0)&&(D.string(i.description)||i.description===void 0)}e.is=n})(Tc||(Tc={}));var er;(function(e){function t(n){let r=n;return D.string(r)}e.is=t})(er||(er={}));var Ug;(function(e){function t(o,s,u){return{range:o,newText:s,annotationId:u}}e.replace=t;function n(o,s,u){return{range:{start:o,end:o},newText:s,annotationId:u}}e.insert=n;function r(o,s){return{range:o,newText:"",annotationId:s}}e.del=r;function i(o){let s=o;return Kn.is(s)&&(Tc.is(s.annotationId)||er.is(s.annotationId))}e.is=i})(Ug||(Ug={}));var kc;(function(e){function t(r,i){return{textDocument:r,edits:i}}e.create=t;function n(r){let i=r;return D.defined(i)&&Ac.is(i.textDocument)&&Array.isArray(i.edits)}e.is=n})(kc||(kc={}));var qc;(function(e){function t(r,i,o){let s={kind:"create",uri:r};return i!==void 0&&(i.overwrite!==void 0||i.ignoreIfExists!==void 0)&&(s.options=i),o!==void 0&&(s.annotationId=o),s}e.create=t;function n(r){let i=r;return i&&i.kind==="create"&&D.string(i.uri)&&(i.options===void 0||(i.options.overwrite===void 0||D.boolean(i.options.overwrite))&&(i.options.ignoreIfExists===void 0||D.boolean(i.options.ignoreIfExists)))&&(i.annotationId===void 0||er.is(i.annotationId))}e.is=n})(qc||(qc={}));var jc;(function(e){function t(r,i,o,s){let u={kind:"rename",oldUri:r,newUri:i};return o!==void 0&&(o.overwrite!==void 0||o.ignoreIfExists!==void 0)&&(u.options=o),s!==void 0&&(u.annotationId=s),u}e.create=t;function n(r){let i=r;return i&&i.kind==="rename"&&D.string(i.oldUri)&&D.string(i.newUri)&&(i.options===void 0||(i.options.overwrite===void 0||D.boolean(i.options.overwrite))&&(i.options.ignoreIfExists===void 0||D.boolean(i.options.ignoreIfExists)))&&(i.annotationId===void 0||er.is(i.annotationId))}e.is=n})(jc||(jc={}));var Nc;(function(e){function t(r,i,o){let s={kind:"delete",uri:r};return i!==void 0&&(i.recursive!==void 0||i.ignoreIfNotExists!==void 0)&&(s.options=i),o!==void 0&&(s.annotationId=o),s}e.create=t;function n(r){let i=r;return i&&i.kind==="delete"&&D.string(i.uri)&&(i.options===void 0||(i.options.recursive===void 0||D.boolean(i.options.recursive))&&(i.options.ignoreIfNotExists===void 0||D.boolean(i.options.ignoreIfNotExists)))&&(i.annotationId===void 0||er.is(i.annotationId))}e.is=n})(Nc||(Nc={}));var Ic;(function(e){function t(n){let r=n;return r&&(r.changes!==void 0||r.documentChanges!==void 0)&&(r.documentChanges===void 0||r.documentChanges.every(i=>D.string(i.kind)?qc.is(i)||jc.is(i)||Nc.is(i):kc.is(i)))}e.is=t})(Ic||(Ic={}));var Vg;(function(e){function t(r){return{uri:r}}e.create=t;function n(r){let i=r;return D.defined(i)&&D.string(i.uri)}e.is=n})(Vg||(Vg={}));var Bg;(function(e){function t(r,i){return{uri:r,version:i}}e.create=t;function n(r){let i=r;return D.defined(i)&&D.string(i.uri)&&D.integer(i.version)}e.is=n})(Bg||(Bg={}));var Ac;(function(e){function t(r,i){return{uri:r,version:i}}e.create=t;function n(r){let i=r;return D.defined(i)&&D.string(i.uri)&&(i.version===null||D.integer(i.version))}e.is=n})(Ac||(Ac={}));var zg;(function(e){function t(r,i,o,s){return{uri:r,languageId:i,version:o,text:s}}e.create=t;function n(r){let i=r;return D.defined(i)&&D.string(i.uri)&&D.string(i.languageId)&&D.integer(i.version)&&D.string(i.text)}e.is=n})(zg||(zg={}));var Oc;(function(e){e.PlainText="plaintext",e.Markdown="markdown";function t(n){let r=n;return r===e.PlainText||r===e.Markdown}e.is=t})(Oc||(Oc={}));var Fr;(function(e){function t(n){let r=n;return D.objectLiteral(n)&&Oc.is(r.kind)&&D.string(r.value)}e.is=t})(Fr||(Fr={}));var Gg;(function(e){e.Text=1,e.Method=2,e.Function=3,e.Constructor=4,e.Field=5,e.Variable=6,e.Class=7,e.Interface=8,e.Module=9,e.Property=10,e.Unit=11,e.Value=12,e.Enum=13,e.Keyword=14,e.Snippet=15,e.Color=16,e.File=17,e.Reference=18,e.Folder=19,e.EnumMember=20,e.Constant=21,e.Struct=22,e.Event=23,e.Operator=24,e.TypeParameter=25})(Gg||(Gg={}));var Xg;(function(e){e.PlainText=1,e.Snippet=2})(Xg||(Xg={}));var Jg;(function(e){e.Deprecated=1})(Jg||(Jg={}));var Yg;(function(e){function t(r,i,o){return{newText:r,insert:i,replace:o}}e.create=t;function n(r){let i=r;return i&&D.string(i.newText)&&Ce.is(i.insert)&&Ce.is(i.replace)}e.is=n})(Yg||(Yg={}));var Qg;(function(e){e.asIs=1,e.adjustIndentation=2})(Qg||(Qg={}));var Zg;(function(e){function t(n){let r=n;return r&&(D.string(r.detail)||r.detail===void 0)&&(D.string(r.description)||r.description===void 0)}e.is=t})(Zg||(Zg={}));var Kg;(function(e){function t(n){return{label:n}}e.create=t})(Kg||(Kg={}));var em;(function(e){function t(n,r){return{items:n||[],isIncomplete:!!r}}e.create=t})(em||(em={}));var Uo;(function(e){function t(r){return r.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}e.fromPlainText=t;function n(r){let i=r;return D.string(i)||D.objectLiteral(i)&&D.string(i.language)&&D.string(i.value)}e.is=n})(Uo||(Uo={}));var tm;(function(e){function t(n){let r=n;return!!r&&D.objectLiteral(r)&&(Fr.is(r.contents)||Uo.is(r.contents)||D.typedArray(r.contents,Uo.is))&&(n.range===void 0||Ce.is(n.range))}e.is=t})(tm||(tm={}));var nm;(function(e){function t(n,r){return r?{label:n,documentation:r}:{label:n}}e.create=t})(nm||(nm={}));var rm;(function(e){function t(n,r,...i){let o={label:n};return D.defined(r)&&(o.documentation=r),D.defined(i)?o.parameters=i:o.parameters=[],o}e.create=t})(rm||(rm={}));var im;(function(e){e.Text=1,e.Read=2,e.Write=3})(im||(im={}));var om;(function(e){function t(n,r){let i={range:n};return D.number(r)&&(i.kind=r),i}e.create=t})(om||(om={}));var sm;(function(e){e.File=1,e.Module=2,e.Namespace=3,e.Package=4,e.Class=5,e.Method=6,e.Property=7,e.Field=8,e.Constructor=9,e.Enum=10,e.Interface=11,e.Function=12,e.Variable=13,e.Constant=14,e.String=15,e.Number=16,e.Boolean=17,e.Array=18,e.Object=19,e.Key=20,e.Null=21,e.EnumMember=22,e.Struct=23,e.Event=24,e.Operator=25,e.TypeParameter=26})(sm||(sm={}));var am;(function(e){e.Deprecated=1})(am||(am={}));var cm;(function(e){function t(n,r,i,o,s){let u={name:n,kind:r,location:{uri:o,range:i}};return s&&(u.containerName=s),u}e.create=t})(cm||(cm={}));var um;(function(e){function t(n,r,i,o){return o!==void 0?{name:n,kind:r,location:{uri:i,range:o}}:{name:n,kind:r,location:{uri:i}}}e.create=t})(um||(um={}));var lm;(function(e){function t(r,i,o,s,u,d){let p={name:r,detail:i,kind:o,range:s,selectionRange:u};return d!==void 0&&(p.children=d),p}e.create=t;function n(r){let i=r;return i&&D.string(i.name)&&D.number(i.kind)&&Ce.is(i.range)&&Ce.is(i.selectionRange)&&(i.detail===void 0||D.string(i.detail))&&(i.deprecated===void 0||D.boolean(i.deprecated))&&(i.children===void 0||Array.isArray(i.children))&&(i.tags===void 0||Array.isArray(i.tags))}e.is=n})(lm||(lm={}));var dm;(function(e){e.Empty="",e.QuickFix="quickfix",e.Refactor="refactor",e.RefactorExtract="refactor.extract",e.RefactorInline="refactor.inline",e.RefactorRewrite="refactor.rewrite",e.Source="source",e.SourceOrganizeImports="source.organizeImports",e.SourceFixAll="source.fixAll"})(dm||(dm={}));var Vo;(function(e){e.Invoked=1,e.Automatic=2})(Vo||(Vo={}));var fm;(function(e){function t(r,i,o){let s={diagnostics:r};return i!=null&&(s.only=i),o!=null&&(s.triggerKind=o),s}e.create=t;function n(r){let i=r;return D.defined(i)&&D.typedArray(i.diagnostics,Ho.is)&&(i.only===void 0||D.typedArray(i.only,D.string))&&(i.triggerKind===void 0||i.triggerKind===Vo.Invoked||i.triggerKind===Vo.Automatic)}e.is=n})(fm||(fm={}));var pm;(function(e){function t(r,i,o){let s={title:r},u=!0;return typeof i=="string"?(u=!1,s.kind=i):Zn.is(i)?s.command=i:s.edit=i,u&&o!==void 0&&(s.kind=o),s}e.create=t;function n(r){let i=r;return i&&D.string(i.title)&&(i.diagnostics===void 0||D.typedArray(i.diagnostics,Ho.is))&&(i.kind===void 0||D.string(i.kind))&&(i.edit!==void 0||i.command!==void 0)&&(i.command===void 0||Zn.is(i.command))&&(i.isPreferred===void 0||D.boolean(i.isPreferred))&&(i.edit===void 0||Ic.is(i.edit))}e.is=n})(pm||(pm={}));var hm;(function(e){function t(r,i){let o={range:r};return D.defined(i)&&(o.data=i),o}e.create=t;function n(r){let i=r;return D.defined(i)&&Ce.is(i.range)&&(D.undefined(i.command)||Zn.is(i.command))}e.is=n})(hm||(hm={}));var gm;(function(e){function t(r,i){return{tabSize:r,insertSpaces:i}}e.create=t;function n(r){let i=r;return D.defined(i)&&D.uinteger(i.tabSize)&&D.boolean(i.insertSpaces)}e.is=n})(gm||(gm={}));var mm;(function(e){function t(r,i,o){return{range:r,target:i,data:o}}e.create=t;function n(r){let i=r;return D.defined(i)&&Ce.is(i.range)&&(D.undefined(i.target)||D.string(i.target))}e.is=n})(mm||(mm={}));var ym;(function(e){function t(r,i){return{range:r,parent:i}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&Ce.is(i.range)&&(i.parent===void 0||e.is(i.parent))}e.is=n})(ym||(ym={}));var vm;(function(e){e.namespace="namespace",e.type="type",e.class="class",e.enum="enum",e.interface="interface",e.struct="struct",e.typeParameter="typeParameter",e.parameter="parameter",e.variable="variable",e.property="property",e.enumMember="enumMember",e.event="event",e.function="function",e.method="method",e.macro="macro",e.keyword="keyword",e.modifier="modifier",e.comment="comment",e.string="string",e.number="number",e.regexp="regexp",e.operator="operator",e.decorator="decorator"})(vm||(vm={}));var bm;(function(e){e.declaration="declaration",e.definition="definition",e.readonly="readonly",e.static="static",e.deprecated="deprecated",e.abstract="abstract",e.async="async",e.modification="modification",e.documentation="documentation",e.defaultLibrary="defaultLibrary"})(bm||(bm={}));var Rm;(function(e){function t(n){let r=n;return D.objectLiteral(r)&&(r.resultId===void 0||typeof r.resultId=="string")&&Array.isArray(r.data)&&(r.data.length===0||typeof r.data[0]=="number")}e.is=t})(Rm||(Rm={}));var Dm;(function(e){function t(r,i){return{range:r,text:i}}e.create=t;function n(r){let i=r;return i!=null&&Ce.is(i.range)&&D.string(i.text)}e.is=n})(Dm||(Dm={}));var _m;(function(e){function t(r,i,o){return{range:r,variableName:i,caseSensitiveLookup:o}}e.create=t;function n(r){let i=r;return i!=null&&Ce.is(i.range)&&D.boolean(i.caseSensitiveLookup)&&(D.string(i.variableName)||i.variableName===void 0)}e.is=n})(_m||(_m={}));var wm;(function(e){function t(r,i){return{range:r,expression:i}}e.create=t;function n(r){let i=r;return i!=null&&Ce.is(i.range)&&(D.string(i.expression)||i.expression===void 0)}e.is=n})(wm||(wm={}));var Pm;(function(e){function t(r,i){return{frameId:r,stoppedLocation:i}}e.create=t;function n(r){let i=r;return D.defined(i)&&Ce.is(r.stoppedLocation)}e.is=n})(Pm||(Pm={}));var Mc;(function(e){e.Type=1,e.Parameter=2;function t(n){return n===1||n===2}e.is=t})(Mc||(Mc={}));var Fc;(function(e){function t(r){return{value:r}}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&(i.tooltip===void 0||D.string(i.tooltip)||Fr.is(i.tooltip))&&(i.location===void 0||Wo.is(i.location))&&(i.command===void 0||Zn.is(i.command))}e.is=n})(Fc||(Fc={}));var Cm;(function(e){function t(r,i,o){let s={position:r,label:i};return o!==void 0&&(s.kind=o),s}e.create=t;function n(r){let i=r;return D.objectLiteral(i)&&vt.is(i.position)&&(D.string(i.label)||D.typedArray(i.label,Fc.is))&&(i.kind===void 0||Mc.is(i.kind))&&i.textEdits===void 0||D.typedArray(i.textEdits,Kn.is)&&(i.tooltip===void 0||D.string(i.tooltip)||Fr.is(i.tooltip))&&(i.paddingLeft===void 0||D.boolean(i.paddingLeft))&&(i.paddingRight===void 0||D.boolean(i.paddingRight))}e.is=n})(Cm||(Cm={}));var Em;(function(e){function t(n){return{kind:"snippet",value:n}}e.createSnippet=t})(Em||(Em={}));var xm;(function(e){function t(n,r,i,o){return{insertText:n,filterText:r,range:i,command:o}}e.create=t})(xm||(xm={}));var Sm;(function(e){function t(n){return{items:n}}e.create=t})(Sm||(Sm={}));var Tm;(function(e){e.Invoked=0,e.Automatic=1})(Tm||(Tm={}));var km;(function(e){function t(n,r){return{range:n,text:r}}e.create=t})(km||(km={}));var qm;(function(e){function t(n,r){return{triggerKind:n,selectedCompletionInfo:r}}e.create=t})(qm||(qm={}));var jm;(function(e){function t(n){let r=n;return D.objectLiteral(r)&&Ec.is(r.uri)&&D.string(r.name)}e.is=t})(jm||(jm={}));var Nm;(function(e){function t(o,s,u,d){return new Lc(o,s,u,d)}e.create=t;function n(o){let s=o;return!!(D.defined(s)&&D.string(s.uri)&&(D.undefined(s.languageId)||D.string(s.languageId))&&D.uinteger(s.lineCount)&&D.func(s.getText)&&D.func(s.positionAt)&&D.func(s.offsetAt))}e.is=n;function r(o,s){let u=o.getText(),d=i(s,(_,w)=>{let T=_.range.start.line-w.range.start.line;return T===0?_.range.start.character-w.range.start.character:T}),p=u.length;for(let _=d.length-1;_>=0;_--){let w=d[_],T=o.offsetAt(w.range.start),P=o.offsetAt(w.range.end);if(P<=p)u=u.substring(0,T)+w.newText+u.substring(P,u.length);else throw new Error("Overlapping edit");p=T}return u}e.applyEdits=r;function i(o,s){if(o.length<=1)return o;let u=o.length/2|0,d=o.slice(0,u),p=o.slice(u);i(d,s),i(p,s);let _=0,w=0,T=0;for(;_<d.length&&w<p.length;)s(d[_],p[w])<=0?o[T++]=d[_++]:o[T++]=p[w++];for(;_<d.length;)o[T++]=d[_++];for(;w<p.length;)o[T++]=p[w++];return o}})(Nm||(Nm={}));var Lc=class{constructor(t,n,r,i){this._uri=t,this._languageId=n,this._version=r,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(t){if(t){let n=this.offsetAt(t.start),r=this.offsetAt(t.end);return this._content.substring(n,r)}return this._content}update(t,n){this._content=t.text,this._version=n,this._lineOffsets=void 0}getLineOffsets(){if(this._lineOffsets===void 0){let t=[],n=this._content,r=!0;for(let i=0;i<n.length;i++){r&&(t.push(i),r=!1);let o=n.charAt(i);r=o==="\r"||o===`
|
|
38
38
|
`,o==="\r"&&i+1<n.length&&n.charAt(i+1)===`
|
|
39
39
|
`&&i++}r&&n.length>0&&t.push(n.length),this._lineOffsets=t}return this._lineOffsets}positionAt(t){t=Math.max(Math.min(t,this._content.length),0);let n=this.getLineOffsets(),r=0,i=n.length;if(i===0)return vt.create(0,t);for(;r<i;){let s=Math.floor((r+i)/2);n[s]>t?i=s:r=s+1}let o=r-1;return vt.create(o,t-n[o])}offsetAt(t){let n=this.getLineOffsets();if(t.line>=n.length)return this._content.length;if(t.line<0)return 0;let r=n[t.line],i=t.line+1<n.length?n[t.line+1]:this._content.length;return Math.max(Math.min(r+t.character,i),r)}get lineCount(){return this.getLineOffsets().length}},D;(function(e){let t=Object.prototype.toString;function n(P){return typeof P<"u"}e.defined=n;function r(P){return typeof P>"u"}e.undefined=r;function i(P){return P===!0||P===!1}e.boolean=i;function o(P){return t.call(P)==="[object String]"}e.string=o;function s(P){return t.call(P)==="[object Number]"}e.number=s;function u(P,L,H){return t.call(P)==="[object Number]"&&L<=P&&P<=H}e.numberRange=u;function d(P){return t.call(P)==="[object Number]"&&-2147483648<=P&&P<=2147483647}e.integer=d;function p(P){return t.call(P)==="[object Number]"&&0<=P&&P<=2147483647}e.uinteger=p;function _(P){return t.call(P)==="[object Function]"}e.func=_;function w(P){return P!==null&&typeof P=="object"}e.objectLiteral=w;function T(P,L){return Array.isArray(P)&&P.every(L)}e.typedArray=T})(D||(D={}));var Ot=te(require("fs")),Hc=te(require("fs/promises")),Yo=te(require("os")),Xo=te(qr());var At=te(he());var Om=require("url"),Bo=(e,t,n)=>{let r=e.start.line===e.end.line&&e.start.character===e.end.character?1:0,i={start:{line:e.start.line,character:e.start.character-r},end:{line:e.start.line,character:e.start.character-r}},o={start:{line:e.end.line,character:e.end.character},end:{line:e.end.line,character:e.end.character}};return[{range:i,newText:t},{range:o,newText:n}]},J_=(e,t)=>{let n={line:e.end.line,character:e.end.character-1};return[{range:{start:n,end:n},newText:t}]},Y_=(e,t)=>[{range:e,newText:t}],Im=e=>{let t=e.trim();return t.endsWith(",")?t.slice(0,t.length-1):t},Am=e=>{let t=[];for(let n=0;n<=e.length-1;n+=1){let r=e[n];if(r.includes("(defined as")){let[i,o]=r.split("(defined as");t.push(Im(i));break}else t.push(Im(r))}return t.join("").trim()},Q_=(e,t)=>{let n=[],r=e.slice(),i=!1;return r.forEach(o=>{i||(o.startsWith(t)?i=!0:n.push(o))}),n},Mm=async({diagnostic:e,diagnosticMessage:t,file:n,range:r,addFoundActionsHere:i})=>{for(let[o,s]of t.entries()){let u=[ow,Z_,ew,tw,nw,rw,iw,K_];for(let d of u){let p=!1;try{p=await d({array:t,codeActions:i,diagnostic:e,file:n,index:o,line:s,range:r})}catch(_){console.error(_)}if(p)break}}},Z_=async({codeActions:e,diagnostic:t,file:n,line:r,range:i})=>{if(r.startsWith("Hint: Did you mean")){let o=/Did you mean ([A-Za-z0-9_]*)?/,s=r.match(o);if(s===null)return!1;let[u,d]=s;if(d!=null){e[n]=e[n]||[];let p={title:`Replace with '${d}'`,edit:{changes:{[n]:[{range:i,newText:d}]}},diagnostics:[t],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return e[n].push({range:i,codeAction:p}),!0}}return!1},K_=async({codeActions:e,diagnostic:t,file:n,line:r,range:i,array:o,index:s})=>{if(r.startsWith("This pattern matches values of type")){let u=/This pattern matches values of type (.*)$/,d=r.match(u);if(d===null)return!1;let[p,_]=d;if(!_.startsWith("option<")){let w=o.slice(s+1),T=w.findIndex(H=>H.trim().startsWith("but a pattern was expected which matches values of type"));if(T===-1)return!1;let[P,L=""]=w[T].split("but a pattern was expected which matches values of type");if(L.trim()===""&&(L=(w[T+1]??"").trim()),L.trim().startsWith("option<")){e[n]=e[n]||[];let H={title:"Wrap in option Some",edit:{changes:{[n]:Bo(i,"Some(",")")}},diagnostics:[t],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return e[n].push({range:i,codeAction:H}),!0}}}return!1},Fm=({recordFieldNames:e,codeActions:t,file:n,range:r,diagnostic:i,todoValue:o})=>{if(e!=null){t[n]=t[n]||[];let s=r.start.line!==r.end.line,u="";if(s){let p=s?r.end.character+2:0,_=Array.from({length:p}).join(" "),w=Array.from({length:r.end.character}).join(" ");e.forEach((T,P)=>{P===0?u+=" ":u+=_,u+=`${T}: ${o},
|
|
40
|
-
`}),u+=`${w}`}else r.end.character-r.start.character>2&&(u+=", "),u+=e.map(p=>`${p}: ${o}`).join(", ");let d={title:"Add missing record fields",edit:{changes:{[n]:J_(r,u)}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:d}),!0}return!1},ew=async({array:e,codeActions:t,diagnostic:n,file:r,index:i,line:o,range:s})=>{if(o.startsWith("Some record fields are undefined:")){let u=o.trim().split("Some record fields are undefined: ")[1]?.split(" ");return e.slice(i+1).forEach(d=>{u.push(...d.trim().split(" "))}),Fm({recordFieldNames:u,codeActions:t,diagnostic:n,file:r,range:s,todoValue:'failwith("TODO")'})}return!1},tw=async({array:e,codeActions:t,diagnostic:n,file:r,index:i,line:o,range:s})=>{if(o.startsWith("Some required record fields are missing:")){let u=o;u.endsWith(".")&&(u=u.slice(0,u.length-1));let d=u.trim().split("Some required record fields are missing: ")[1]?.split(" "),p=!1;return e.slice(i+1).forEach(_=>{p||(d.push(..._.trim().split(".")[0].split(" ")),_.includes(".")&&(p=!0))}),Fm({recordFieldNames:d,codeActions:t,diagnostic:n,file:r,range:s,todoValue:"%todo"})}return!1},nw=async({line:e,codeActions:t,file:n,range:r,diagnostic:i})=>{if(e.startsWith("You can convert ")){let o=/You can convert (\w*) to (\w*) with ([\w.]*).$/,s=e.match(o);if(s===null)return!1;let[u,d,p,_]=s;if(d!=null&&p!=null&&_!=null){t[n]=t[n]||[];let w={title:`Convert ${d} to ${p} with ${_}`,edit:{changes:{[n]:Bo(r,`${_}(`,")")}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:w}),!0}}return!1},rw=async({line:e,codeActions:t,file:n,range:r,diagnostic:i})=>{if(e.startsWith("This is an uncurried ReScript function. It must be applied with a dot.")){let o={line:r.end.line,character:r.end.character+1};t[n]=t[n]||[];let s={title:"Apply uncurried function call with dot",edit:{changes:{[n]:[{range:{start:o,end:o},newText:". "}]}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:s}),!0}return!1},iw=async({line:e,codeActions:t,file:n,range:r,diagnostic:i,array:o,index:s})=>{if(e.startsWith("You forgot to handle a possible case here, for example:")){let u=o.slice(s+1).join("").trim(),d=(0,Om.fileURLToPath)(n),p=await Rt(d,["codemod",d,r.start.line,r.start.character,"add-missing-cases",u]);t[n]=t[n]||[];let _={title:"Insert missing cases",edit:{changes:{[n]:Y_(r,p)}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:_}),!0}return!1},ow=async({line:e,codeActions:t,file:n,range:r,diagnostic:i,array:o,index:s})=>{let u="This has type:";if(e.startsWith(u)){let d=Q_([e.slice(u.length),...o.slice(s+1)],"Somewhere wanted:"),p=o.slice(s+d.length).map(T=>T.replace("Somewhere wanted:","")),_=Am(d),w=Am(p);if(_===`option<${w}>`){t[n]=t[n]||[];let T="assert false";switch(w){case"string":{T='"-"';break}case"bool":{T="false";break}case"int":{T="-1";break}case"float":{T="-1.";break}}let P={title:"Unwrap optional value",edit:{changes:{[n]:Bo(r,"switch ",` { | None => ${T} | Some(v) => v }`)}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:P}),!0}if(`option<${_}>`===w){t[n]=t[n]||[];let T={title:"Wrap value in Some",edit:{changes:{[n]:Bo(r,"Some(",")")}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:T}),!0}}return!1};var Go=[],$c={},Lm=e=>(Go.push(e),()=>{Go=Go.filter(t=>t!==e)}),$m=(e,t)=>{($c[e]==null||$c[e]<Date.now()-9e5)&&($c[e]=Date.now(),Go.forEach(n=>n(t)))};var aw={extensionConfiguration:{askToStartBuild:!0,inlayHints:{enable:!1,maxLength:25},codeLens:!1,binaryPath:null,platformPath:null,signatureHelp:{enabled:!0,forConstructorPayloads:!0},incrementalTypechecking:{enable:!0,acrossFiles:!1,debugLogging:!1},cache:{projectConfig:{enable:!0}}}},Q=aw;var Ee=new Map;var cw="rescript_format_file_"+process.pid+"_",Wc=0,Ft=(e="")=>{let t=cw+Wc+e;return Wc=Wc+1,Ie.join(Yo.tmpdir(),t)},Hm=e=>{let t=Ie.dirname(e);return Ot.default.existsSync(Ie.join(t,Nr))||Ot.default.existsSync(Ie.join(t,jr))?t:t===e?null:Hm(t)},ut=(e,t)=>{let n=null;for(let r of Ee.keys())e.startsWith(r)&&(!t||e!==r)&&(n==null||r.length>n.length)&&(n=r);if(n!=null)return n;{let r=Ie.extname(e)==="";return Hm(r&&!t?Ie.join(e,"dummy.res"):e)}},$r=async(e,t)=>{if(Q.extensionConfiguration.platformPath!=null)return Ie.join(Q.extensionConfiguration.platformPath,t);if(e!==null&&t==="bsc.exe")try{let s=Ie.resolve(e,Ao),u=await Hc.default.readFile(s,"utf8"),d=JSON.parse(u);if(d&&d.
|
|
40
|
+
`}),u+=`${w}`}else r.end.character-r.start.character>2&&(u+=", "),u+=e.map(p=>`${p}: ${o}`).join(", ");let d={title:"Add missing record fields",edit:{changes:{[n]:J_(r,u)}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:d}),!0}return!1},ew=async({array:e,codeActions:t,diagnostic:n,file:r,index:i,line:o,range:s})=>{if(o.startsWith("Some record fields are undefined:")){let u=o.trim().split("Some record fields are undefined: ")[1]?.split(" ");return e.slice(i+1).forEach(d=>{u.push(...d.trim().split(" "))}),Fm({recordFieldNames:u,codeActions:t,diagnostic:n,file:r,range:s,todoValue:'failwith("TODO")'})}return!1},tw=async({array:e,codeActions:t,diagnostic:n,file:r,index:i,line:o,range:s})=>{if(o.startsWith("Some required record fields are missing:")){let u=o;u.endsWith(".")&&(u=u.slice(0,u.length-1));let d=u.trim().split("Some required record fields are missing: ")[1]?.split(" "),p=!1;return e.slice(i+1).forEach(_=>{p||(d.push(..._.trim().split(".")[0].split(" ")),_.includes(".")&&(p=!0))}),Fm({recordFieldNames:d,codeActions:t,diagnostic:n,file:r,range:s,todoValue:"%todo"})}return!1},nw=async({line:e,codeActions:t,file:n,range:r,diagnostic:i})=>{if(e.startsWith("You can convert ")){let o=/You can convert (\w*) to (\w*) with ([\w.]*).$/,s=e.match(o);if(s===null)return!1;let[u,d,p,_]=s;if(d!=null&&p!=null&&_!=null){t[n]=t[n]||[];let w={title:`Convert ${d} to ${p} with ${_}`,edit:{changes:{[n]:Bo(r,`${_}(`,")")}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:w}),!0}}return!1},rw=async({line:e,codeActions:t,file:n,range:r,diagnostic:i})=>{if(e.startsWith("This is an uncurried ReScript function. It must be applied with a dot.")){let o={line:r.end.line,character:r.end.character+1};t[n]=t[n]||[];let s={title:"Apply uncurried function call with dot",edit:{changes:{[n]:[{range:{start:o,end:o},newText:". "}]}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:s}),!0}return!1},iw=async({line:e,codeActions:t,file:n,range:r,diagnostic:i,array:o,index:s})=>{if(e.startsWith("You forgot to handle a possible case here, for example:")){let u=o.slice(s+1).join("").trim(),d=(0,Om.fileURLToPath)(n),p=await Rt(d,["codemod",d,r.start.line,r.start.character,"add-missing-cases",u]);t[n]=t[n]||[];let _={title:"Insert missing cases",edit:{changes:{[n]:Y_(r,p)}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:_}),!0}return!1},ow=async({line:e,codeActions:t,file:n,range:r,diagnostic:i,array:o,index:s})=>{let u="This has type:";if(e.startsWith(u)){let d=Q_([e.slice(u.length),...o.slice(s+1)],"Somewhere wanted:"),p=o.slice(s+d.length).map(T=>T.replace("Somewhere wanted:","")),_=Am(d),w=Am(p);if(_===`option<${w}>`){t[n]=t[n]||[];let T="assert false";switch(w){case"string":{T='"-"';break}case"bool":{T="false";break}case"int":{T="-1";break}case"float":{T="-1.";break}}let P={title:"Unwrap optional value",edit:{changes:{[n]:Bo(r,"switch ",` { | None => ${T} | Some(v) => v }`)}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:P}),!0}if(`option<${_}>`===w){t[n]=t[n]||[];let T={title:"Wrap value in Some",edit:{changes:{[n]:Bo(r,"Some(",")")}},diagnostics:[i],kind:At.CodeActionKind.QuickFix,isPreferred:!0};return t[n].push({range:r,codeAction:T}),!0}}return!1};var Go=[],$c={},Lm=e=>(Go.push(e),()=>{Go=Go.filter(t=>t!==e)}),$m=(e,t)=>{($c[e]==null||$c[e]<Date.now()-9e5)&&($c[e]=Date.now(),Go.forEach(n=>n(t)))};var aw={extensionConfiguration:{askToStartBuild:!0,inlayHints:{enable:!1,maxLength:25},codeLens:!1,binaryPath:null,platformPath:null,signatureHelp:{enabled:!0,forConstructorPayloads:!0},incrementalTypechecking:{enable:!0,acrossFiles:!1,debugLogging:!1},cache:{projectConfig:{enable:!0}}}},Q=aw;var Ee=new Map;var cw="rescript_format_file_"+process.pid+"_",Wc=0,Ft=(e="")=>{let t=cw+Wc+e;return Wc=Wc+1,Ie.join(Yo.tmpdir(),t)},Hm=e=>{let t=Ie.dirname(e);return Ot.default.existsSync(Ie.join(t,Nr))||Ot.default.existsSync(Ie.join(t,jr))?t:t===e?null:Hm(t)},ut=(e,t)=>{let n=null;for(let r of Ee.keys())e.startsWith(r)&&(!t||e!==r)&&(n==null||r.length>n.length)&&(n=r);if(n!=null)return n;{let r=Ie.extname(e)==="";return Hm(r&&!t?Ie.join(e,"dummy.res"):e)}},$r=async(e,t)=>{if(Q.extensionConfiguration.platformPath!=null)return Ie.join(Q.extensionConfiguration.platformPath,t);if(e!==null&&t==="bsc.exe")try{let s=Ie.resolve(e,Ao),u=await Hc.default.readFile(s,"utf8"),d=JSON.parse(u);if(d&&d.bsc_path)return d.bsc_path}catch{}let n=Ar(e,Ie.join("node_modules","rescript"));if(n==null)return null;let r=null,i=null;try{let s=Ie.join(n,"package.json"),u=JSON.parse(await Hc.default.readFile(s,"utf-8"));r=u.version,i=u.bin.rescript}catch{return null}let o=null;if(t=="rescript")o=Ie.join(n,i);else if(Xo.default.gte(r,"12.0.0-alpha.13")){let s=`${process.platform}-${process.arch}`,u=Ie.join(n,"..",`@rescript/${s}/bin.js`),{binPaths:d}=await import(u);t=="bsc.exe"?o=d.bsc_exe:t=="rescript-editor-analysis.exe"?o=d.rescript_editor_analysis_exe:t=="rewatch.exe"?o=d.rewatch_exe:t=="rescript.exe"&&(o=d.rescript_exe)}else o=Ie.join(n,Rc,t);return o!=null&&Ot.default.existsSync(o)?o:null},Um=e=>$r(e,"rescript"),Uc=e=>$r(e,"bsc.exe"),Vm=e=>$r(e,"rescript-editor-analysis.exe"),Bm=e=>$r(e,"rewatch.exe"),zm=e=>$r(e,"rescript.exe"),Gm=(e,t,n)=>{let r=Ie.extname(t),i=Ft(r);Ot.default.writeFileSync(i,n,{encoding:"utf-8"});try{if(e!=null)return{kind:"success",result:Mt.execFileSync(e,["-color","never","-format",i]).toString()};throw new Error("Could not find ReScript compiler for project.")}catch(o){return{kind:"error",error:o instanceof Error?o.message:String(o)}}finally{Ot.default.unlink(i,()=>null)}};async function Qo(e){if(e==null)return;let t=await Uc(e);if(t!=null)try{return Mt.execSync(`${t} -v`).toString().replace(/rescript/gi,"").trim()}catch{return}}var Jo=null;Ot.default.existsSync(Dc)?Jo=Dc:Ot.default.existsSync(_c)&&(Jo=_c);var Rt=async(e,t,n=!1)=>{let r=ut(e);if(r==null&&n)return null;let i=Ee.get(r??"")?.rescriptVersion??await Qo(r),o=Jo,s=r?Ee.get(r):null,u=Xo.default.valid(i)&&Xo.default.lt(i,"12.0.0-alpha.5");if(!u&&s!=null)o=s.editorAnalysisLocation;else{if(!u&&s==null)return null;o=Jo}let d={cwd:r||void 0,maxBuffer:1/0,env:{...process.env,RESCRIPT_VERSION:i,RESCRIPT_INCREMENTAL_TYPECHECKING:Q.extensionConfiguration.incrementalTypechecking?.enable===!0?"true":void 0,RESCRIPT_PROJECT_CONFIG_CACHE:Q.extensionConfiguration.cache?.projectConfig?.enable===!0?"true":void 0}};if(o==null)return null;let p="";try{return p=Mt.execFileSync(o,t,d).toString(),JSON.parse(p)}catch(_){return console.error(_),console.error("Original response: ",p),console.error("Args: ",t),$m(String(t[0]),String(_)),null}},lt=async(e,t,n,r=!0)=>{let i=await Rt(e,t,r);return{jsonrpc:W,id:n.id,result:i}},Vc=async(e,t)=>await Rt(e,["references",e,t.line,t.character]),Wm=e=>e.replace(/(?:^\w|[A-Z]|\b\w)/g,t=>t.toUpperCase()).replace(/(\s|-)+/g,""),Wr=e=>{let t=Lo(e),n="";return t?(t.namespace===!0?n=Wm(t.name):typeof t.namespace=="string"&&(n=Wm(t.namespace)),{kind:"success",result:n}):{kind:"error",error:"Could not read ReScript config file"}},Xm=(e,t)=>{let n={kind:"error",error:"Could not read ReScript config file"},r=e.split(t)[1],i=jg(t,r);if(!i)return n;let o=i;if(!Ot.default.existsSync(o)){let s=Ng(t,r);if(!s)return n;o=s}return{kind:"success",result:o}},Jm=(e,t)=>{let n={cwd:t};return process.platform==="win32"?Mt.exec(`"${e}".cmd build -w`,n):Mt.execFile(e,["build","-w"],n)},Lr=e=>process.platform==="win32"?`file:\\\\\\${e}`:`file://${e}`,uw=e=>{let t=/(.+)\:(\d+)\:(\d+)(-(\d+)(\:(\d+))?)?$/,n=e.trim(),r=n.match(t);if(r===null)return{file:Lr(n),range:{start:{line:0,character:0},end:{line:0,character:0}}};let[i,o,s,u,d,p,_,w]=r,T;if(d==null){let P={line:parseInt(s)-1,character:parseInt(u)};T={start:P,end:P}}else{let P=w==null,[L,H]=P?[s,p]:[p,w];T={start:{line:parseInt(s)-1,character:parseInt(u)-1},end:{line:parseInt(L)-1,character:parseInt(H)}}}return{file:Lr(o),range:T}},Zo=async e=>{let t=[],n=[],r=e.split(Yo.EOL),i=!1;for(let u=0;u<r.length;u++){let d=r[u];if(d.startsWith(" We've found a bug for you!"))t.push({code:void 0,severity:bt.Error,tag:void 0,content:[]});else if(!d.startsWith("FAILED: cannot make progress due to previous errors.")){if(!d.startsWith("FAILED: dependency cycle"))if(d.startsWith("FAILED:"))t.push({code:void 0,severity:bt.Error,tag:void 0,content:[d]});else if(d.startsWith("Fatal error:"))t.push({code:void 0,severity:bt.Error,tag:void 0,content:[d]});else if(d.startsWith(" Warning number ")){let p=parseInt(d.slice(17)),_;switch(p){case 11:case 20:case 26:case 27:case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 60:case 66:case 67:case 101:_=Mr.Unnecessary;break;case 3:_=Mr.Deprecated;break}let w=d.includes("(configured as error)")?bt.Error:bt.Warning;t.push({code:Number.isNaN(p)?void 0:p,severity:w,tag:_,content:[]})}else d.startsWith(" Syntax error!")?t.push({code:void 0,severity:bt.Error,tag:void 0,content:[]}):d.startsWith(" Warning genType")?t.push({code:void 0,severity:bt.Error,tag:void 0,content:[]}):d.startsWith("#Start(")||(d.startsWith("#Done(")?i=!0:d.startsWith("File ")&&u+1<r.length&&r[u+1].startsWith("Warning ")?u++:d.startsWith("File ")&&u+1<r.length&&r[u+1].startsWith("Error: Syntax error")?(t.push({code:void 0,severity:bt.Error,tag:void 0,content:[r[u],r[u+1]]}),u++):/^ +([0-9]+| +|\.) (│|┆)/.test(d)||(d.startsWith(" ")?t[t.length-1]==null?n.push(d):t[t.length-1].content.push(d.slice(2)):d.trim()!=""&&(t[t.length-1]==null?n.push(d):t[t.length-1].content.push(d))))}}let o={},s={};for(let u of t){let[d,...p]=u.content,{file:_,range:w}=uw(d);o[_]==null&&(o[_]=[]);let T=p.join(`
|
|
41
41
|
`).trim();if(T!=""){let P={severity:u.severity,tags:u.tag===void 0?[]:[u.tag],code:u.code,range:w,source:"ReScript",message:T};await Mm({addFoundActionsHere:s,diagnostic:P,diagnosticMessage:p,file:_,range:w}),o[_].push(P)}}return{done:i,result:o,codeActions:s,linesWithParseErrors:n}},Ym=(e,t)=>!(t.start.line<e.start.line||t.end.line<e.start.line||t.start.line>e.end.line||t.end.line>e.end.line||t.start.line===e.start.line&&t.start.character<e.start.character||t.end.line===e.end.line&&t.end.character>e.end.character);var ru=require("console"),le=require("url");var ue=te(require("path")),St=te(require("fs"));var zc=require("url"),Ko=require("perf_hooks"),ay=te(he()),cy=te(require("node:child_process")),Gc=te(qr()),uy=te(require("os"));var Km=te(require("path"));var ey=te(require("node:child_process")),ty=te(he()),yn=te(qr());var xt=require("fs/promises"),Lt=require("path");async function lw(e,t=12){let n=[],r=[{dir:e,depth:0}],i=new Set;for(;r.length;){let{dir:o,depth:s}=r.pop();if(s>t||i.has(o))continue;i.add(o);let u;try{u=await(0,xt.readdir)(o)}catch{continue}if(u.includes("node_modules")){let d=(0,Lt.join)(o,"node_modules");try{if((await(0,xt.stat)(d)).isDirectory()){n.push(d);continue}}catch{}}for(let d of u){if(d==="node_modules"||d.startsWith("."))continue;let p=(0,Lt.join)(o,d);try{(await(0,xt.stat)(p)).isDirectory()&&r.push({dir:p,depth:s+1})}catch{}}}return n}async function Qm(e,t){let n=(0,Lt.join)(t,e),r;try{r=await(0,xt.readdir)(n)}catch{return[]}let i=r.filter(s=>s.startsWith("@rescript+runtime@"));if(i.length===0)return[];let o=[];for(let s of i){let u=(0,Lt.join)(n,s,"node_modules","@rescript","runtime");try{(await(0,xt.stat)(u)).isDirectory()&&o.push(u)}catch{}}return o}async function dw(e){let t=(0,Lt.resolve)(e,Ao);try{let i=await(0,xt.readFile)(t,"utf8"),o=JSON.parse(i);if(o&&o.runtime_path)return[o.runtime_path]}catch{}let n=await lw(e);return(await Promise.all(n.map(async i=>{let o=[],s=(0,Lt.join)(i,"@rescript","runtime");try{if((await(0,xt.stat)(s)).isDirectory())return o.push(s),o}catch{}let u=await Qm(".pnpm",i);if(o.push(...u),o.length>0)return o;let d=await Qm(".deno",i);return o.push(...d),o})).then(i=>i.flatMap(o=>o))).map(i=>(0,Lt.resolve)(i))}function fw(){let e=new Map;return async t=>{if(e.has(t))return e.get(t);let n=await dw(t);return e.set(t,n),n}}var Zm=fw();async function pw(e){let t=Q.extensionConfiguration.runtimePath??null;if(t!==null)return xe()&&console.log(`Using configured runtime path as RESCRIPT_RUNTIME: ${t}`),t;let n=await Zm(e.project.workspaceRootPath);return xe()&&(n.length===0?console.log(`Did not find @rescript/runtime directory for ${e.project.workspaceRootPath}`):n.length>1?console.warn(`Found multiple @rescript/runtime directories, using the first one as RESCRIPT_RUNTIME: ${n.join(", ")}`):console.log(`Found @rescript/runtime directory: ${n.join(", ")}`)),n.at(0)??null}async function ny(e,t,n,r){let i=r.buildRewatch;if(i!=null&&i.lastFile===r.file.sourceFilePath)return Promise.resolve(i.compilerArgs);try{let o=n.get(r.project.rootPath);if(o?.rescriptVersion==null)return null;let s=Km.resolve(r.project.workspaceRootPath,"node_modules/@rolandpeelen/rewatch/rewatch"),u=null;yn.default.valid(o.rescriptVersion)&&yn.default.satisfies(o.rescriptVersion,">11",{includePrerelease:!0})&&(u=await Bm(r.project.workspaceRootPath)),yn.default.valid(o.rescriptVersion)&&yn.default.satisfies(o.rescriptVersion,">=12.0.0-beta.1",{includePrerelease:!0})&&(u=await zm(r.project.workspaceRootPath)),u!=null?(s=u,xe()&&console.log(`Found rewatch binary bundled with v12: ${u}`)):xe()&&console.log("Did not find rewatch binary bundled with v12");let d=yn.default.satisfies(o.rescriptVersion,">=12.0.0-beta.2",{includePrerelease:!0})?["compiler-args",r.file.sourceFilePath]:["--rescript-version",o.rescriptVersion,"--compiler-args",r.file.sourceFilePath],p={};if(t!=null&&(p.RESCRIPT_BSC_EXE=t),yn.default.satisfies(o.rescriptVersion,">=12.0.0-beta.11",{includePrerelease:!0})){let w=await pw(r);if(w!==null)p.RESCRIPT_RUNTIME=w;else{let T={type:ty.MessageType.Error,message:"[Incremental type checking] The @rescript/runtime package was not found in your project. It is normally included with ReScript, but either it's missing or could not be detected. Check that it exists in your dependencies, or configure 'rescript.settings.runtimePath' to point to it. Without this package, incremental type checking may not work as expected."};e({jsonrpc:W,method:"window/showMessage",params:T})}}let _=JSON.parse(ey.execFileSync(s,d,{env:p}).toString().trim());return r.buildRewatch={lastFile:r.file.sourceFilePath,compilerArgs:_},_}catch(o){return console.error(o),null}}var ry=te(require("path")),Bc=te(require("fs"));async function iy(e){let t=ry.resolve(e.project.rootPath,Oo),n;try{n=await Bc.default.promises.stat(t)}catch{return null}let r=e.buildNinja;if(r&&r.fileMtime>=n.mtimeMs)return r.rawExtracted;let i=await Bc.default.promises.open(t,"r");try{let o=!1,s=!1,u=[];for await(let d of i.readLines()){let p=String(d).trim();if(o&&(u.push(p),o=!1,s&&u.length===2))break;p.startsWith("rule astj")?(o=!0,s=!0):p.startsWith("rule mij")&&(o=!0)}return u.length!==2?null:(e.buildNinja={fileMtime:n.mtimeMs,rawExtracted:u},u)}finally{await i.close()}}function xe(){return Q.extensionConfiguration.incrementalTypechecking?.debugLogging??!1}var ly="___incremental",tr=ue.join(tn,ly),vn=new Map,oy=new Set,Jc=new Map;function dy(e){let t=Jc.get(e);if(t!=null){let n=vn.get(t);n!=null&&(xe()&&console.log("[watcher] Cleaning up incremental files for "+t),n.compilation!=null&&(xe()&&console.log("[watcher] Was compiling, killing"),clearTimeout(n.compilation.timeout),n.killCompilationListeners.forEach(r=>r()),n.compilation=null),py(n.file.sourceFilePath,n.project.rootPath))}}function Yc(e,t){St.default.rm(ue.resolve(e,tr),{force:!0,recursive:!0},n=>{t?.()})}function fy(e){xe()&&console.log("Recreating incremental file folder"),Yc(e,()=>{St.default.mkdir(ue.resolve(e,tr),{recursive:!0},t=>{})})}function py(e,t){let n=e.endsWith(".resi")?".resi":".res",r=Wr(t),i=ue.basename(e,n),o=r.kind==="success"&&r.result!==""?`${i}-${r.result}`:i;xe()&&console.log("Cleaning up incremental file assets for: "+i),St.default.unlink(ue.resolve(t,tr,ue.basename(e)),s=>{}),[o+".ast",o+".cmt",o+".cmti",o+".cmi",o+".cmj"].forEach(s=>{St.default.unlink(ue.resolve(t,tr,s),u=>{})})}async function hw(e,t){return t.buildSystem==="bsb"?await iy(t):await ny(e,t.project.bscBinaryLocation,Ee,t)}function Xc(e){let t=[];for(let n=0;n<=e.length-1;n++){let r=e[n],i=n+1,o=e[i]??"";if(r.startsWith("-")&&o.startsWith("-"))t.push([r]);else if(r.startsWith("-")&&o.startsWith("'")){let s=[o.slice(1)];for(let u=i+1;u<=e.length-1;u++){let d=e[u],p=!1;if(d.endsWith("'")&&(d=d.slice(0,d.length-1),n=u,p=!0),s.push(d),p)break}t.push([r,s.join(" ")])}else r.startsWith("-")&&t.push([r,o])}return t}function sy(e){let t=e.trim().split("command = ")[1].split(" ").map(n=>n.trim()).filter(n=>n!=="");return Xc(t)}function gw(e){let t=/\x1B[@-_][0-?]*[ -/]*[@-~]/g;return e.replace(t,"")}function mw(e,t,n,r){let i=vn.get(e);if(i==null){let d=ut(e);if(d==null){xe()&&console.log("Did not find project root path for "+e);return}let p=Ee.get(d);if(p==null){xe()&&console.log("Did not find open project for "+e);return}let _=[ue.resolve(d,Cg),ue.resolve(d,Eg)],w=!1;_.some(k=>St.default.existsSync(k))?w=!0:xe()&&console.log(`Did not find ${_.join(" or ")} in project root, assuming bsb`);let T=d&&!w?ut(d,!0):null,P=p.bscBinaryLocation;if(P==null){xe()&&console.log("Could not find bsc binary location for "+e);return}let L=e.endsWith(".resi")?".resi":".res",H=ue.basename(e,L),se=p.namespaceName!=null?`${H}-${p.namespaceName}`:H,U=ue.join(d,tr),y=ue.resolve(d,tn,ue.relative(d,e)),v=ue.parse(y);v.ext=L===".res"?".cmt":".cmti",v.base="",y=ue.format(v),i={file:{originalTypeFileLocation:y,extension:L,moduleName:H,moduleNameNamespaced:se,sourceFileName:H+L,sourceFilePath:e,incrementalFilePath:ue.join(U,H+L)},project:{workspaceRootPath:T??d,rootPath:d,callArgs:Promise.resolve([]),bscBinaryLocation:P,incrementalFolderPath:U},buildSystem:w?"rewatch":"bsb",buildRewatch:null,buildNinja:null,compilation:null,killCompilationListeners:[],codeActions:[]},i.project.callArgs=hy(n,i),Jc.set(i.file.originalTypeFileLocation,i.file.sourceFilePath),vn.set(e,i)}if(i==null)return;let o=i;o.compilation!=null&&(clearTimeout(o.compilation.timeout),o.killCompilationListeners.forEach(d=>d()),o.killCompilationListeners=[]);let s=Ko.performance.now(),u=setTimeout(()=>{bw(o,t,n,r)},20);o.compilation!=null?(o.compilation.timeout=u,o.compilation.triggerToken=s):o.compilation={timeout:u,triggerToken:s}}function yw(e,t){return vn.get(e)?.compilation?.triggerToken===t}var vw=uy.platform()==="win32";async function hy(e,t){let n=Ee.get(t.project.rootPath);if(n?.rescriptVersion==null)return xe()&&console.log("Found no project (or ReScript version) for "+t.file.sourceFilePath),null;let r=await hw(e,t);if(r==null)return null;let i=[],o=[],s=Array.isArray(r);if(Array.isArray(r)){let[d,p]=r;i=sy(d),o=sy(p)}else i=Xc(r.parser_args),o=Xc(r.compiler_args);let u=[];return Q.extensionConfiguration.incrementalTypechecking?.acrossFiles&&u.push("-I",ue.resolve(t.project.rootPath,tr)),o.forEach(([d,p])=>{if(d==="-I")s?(p=p.startsWith('"')&&p.endsWith('"')?p.substring(1,p.length-1):p,vw&&p.includes(":\\")?u.push("-I",p):u.push("-I",ue.resolve(t.project.rootPath,tn,p))):p==="."?u.push("-I",ue.resolve(t.project.rootPath,Pg)):u.push("-I",p);else if(d==="-bs-v")u.push("-bs-v",Date.now().toString());else{if(d==="-bs-package-output")return;p==null||p===""?u.push(d):u.push(d,p)}}),i.forEach(([d,p])=>{(d.startsWith("-bs-jsx")||d.startsWith("-ppx"))&&u.push(d,p)}),u.push("-color","never"),Gc.default.valid(n.rescriptVersion)&&Gc.default.satisfies(n.rescriptVersion,">=11",{includePrerelease:!0})&&u.push("-ignore-parse-errors"),u=u.filter(d=>d!=null&&d!==""),u.push(t.file.incrementalFilePath),u}async function bw(e,t,n,r){let i=e.compilation?.triggerToken,o=await e.project.callArgs;if(o==null){let u=await hy(n,e);if(u!=null)o=u,e.project.callArgs=Promise.resolve(u);else{xe()&&console.log("Could not figure out call args. Maybe build.ninja does not exist yet?");return}}let s=Ko.performance.now();if(!St.default.existsSync(e.project.incrementalFolderPath))try{St.default.mkdirSync(e.project.incrementalFolderPath,{recursive:!0})}catch{}try{St.default.writeFileSync(e.file.incrementalFilePath,t);let u=e.buildSystem==="bsb"?e.project.rootPath:ue.resolve(e.project.rootPath,tn);xe()&&(console.log(`About to invoke bsc from "${u}", used ${e.buildSystem}`),console.log(`${e.project.bscBinaryLocation} ${o.map(p=>`"${p}"`).join(" ")}`));let d=cy.execFile(e.project.bscBinaryLocation,o,{cwd:u},async(p,_,w)=>{p?.killed?xe()&&console.log(`Compilation of ${e.file.sourceFileName} was killed.`):xe()&&console.log(`Recompiled ${e.file.sourceFileName} in ${(Ko.performance.now()-s)/1e3}s`);let T=!1;if(!p?.killed&&i!=null&&yw(e.file.sourceFilePath,i)){xe()&&console.log("Resetting compilation status."),e.compilation=null;let{result:P,codeActions:L}=await Zo(`${w}
|
|
42
42
|
#Done()`),H=Object.values(L)[0]??[];H.forEach(y=>{if(y.codeAction.edit!=null&&y.codeAction.edit.changes!=null){let v=Object.values(y.codeAction.edit.changes)[0];y.codeAction.edit.changes={[(0,zc.pathToFileURL)(e.file.sourceFilePath).toString()]:v}}}),e.codeActions=H;let se=(Object.values(P)[0]??[]).map(y=>({...y,message:gw(y.message)})).filter(y=>!y.message.startsWith("Uninterpreted extension 'rescript.")&&(!y.message.includes(`/${ly}/${e.file.sourceFileName}`)||y.message.startsWith("Multiple definition of the")||y.message.startsWith("Signature mismatch")||y.message.startsWith("In this `with' constraint")||y.message.startsWith("This `with' constraint on"))?(T=!0,!0):!1);if(se.length===0&&w!==""&&!T&&!oy.has(e.project.rootPath))try{oy.add(e.project.rootPath);let y=ue.resolve(e.project.incrementalFolderPath,"error.log");St.default.writeFileSync(y,`== BSC ARGS ==
|
|
43
43
|
${o?.join(" ")}
|