diff --git a/.gitignore b/.gitignore index 2b07904..2b3a41e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,8 @@ node_modules/ .env .env.test .env.production -lib/ +lib/* +!lib/index.js # clojure stuff .nrepl-port diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c56ade..ee5c7ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ this project adheres to no versioning scheme. ## Unreleased +## 0.0.16 - 2024-02-05 + +### Fixed +- Update .gitignore to keep lib/index.js. +- Stop using deprecated `registLanguageClient` method. + ## 0.0.15 - 2024-02-05 ### Added diff --git a/esbuild.js b/esbuild.js index 194bb1a..5a0c5e2 100644 --- a/esbuild.js +++ b/esbuild.js @@ -1,9 +1,9 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -async function start(watch) { - await require("esbuild").build({ +const esbuild = require("esbuild"); + +async function start(plugins) { + const opts = { entryPoints: ["src/index.ts"], bundle: true, - watch, minify: process.env.NODE_ENV === "production", sourcemap: process.env.NODE_ENV === "development", mainFields: ["module", "main"], @@ -11,24 +11,30 @@ async function start(watch) { platform: "node", target: "node14", outfile: "lib/index.js", - }); + plugins, + }; + if (plugins) { + const ctx = await esbuild.context(opts); + await ctx.watch(); + } else { + await esbuild.build(opts); + } } -let watch = false; -let counter = 0; +let plugins = []; if (process.argv.length > 2 && process.argv[2] === "--watch") { console.log("watching..."); - watch = { - onRebuild(error) { - if (error) { - console.error("watch build failed:", error); - } else { + plugins.push({ + name: "watcher", + setup(b) { + let counter = 0; + b.onEnd((result) => { console.log(`watch build #${counter++} succeeded`); - } + }); }, - }; + }); } -start(watch).catch((e) => { +start(plugins).catch((e) => { console.error(e); }); diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..f668cdf --- /dev/null +++ b/lib/index.js @@ -0,0 +1,5 @@ +"use strict";var mn=Object.create;var ve=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var gn=Object.getPrototypeOf,xn=Object.prototype.hasOwnProperty;var y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ot=(e,t)=>{for(var r in t)ve(e,r,{get:t[r],enumerable:!0})},jt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pn(t))!xn.call(e,i)&&i!==r&&ve(e,i,{get:()=>t[i],enumerable:!(n=hn(t,i))||n.enumerable});return e};var A=(e,t,r)=>(r=e!=null?mn(gn(e)):{},jt(t||!e||!e.__esModule?ve(r,"default",{value:e,enumerable:!0}):r,e)),vn=e=>jt(ve({},"__esModule",{value:!0}),e);var Ht=y((Lo,kt)=>{var K=1e3,X=K*60,Z=X*60,W=Z*24,Ln=W*7,On=W*365.25;kt.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return jn(e);if(r==="number"&&isFinite(e))return t.long?qn(e):In(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function jn(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*On;case"weeks":case"week":case"w":return r*Ln;case"days":case"day":case"d":return r*W;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Z;case"minutes":case"minute":case"mins":case"min":case"m":return r*X;case"seconds":case"second":case"secs":case"sec":case"s":return r*K;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function In(e){var t=Math.abs(e);return t>=W?Math.round(e/W)+"d":t>=Z?Math.round(e/Z)+"h":t>=X?Math.round(e/X)+"m":t>=K?Math.round(e/K)+"s":e+"ms"}function qn(e){var t=Math.abs(e);return t>=W?we(e,t,W,"day"):t>=Z?we(e,t,Z,"hour"):t>=X?we(e,t,X,"minute"):t>=K?we(e,t,K,"second"):e+" ms"}function we(e,t,r,n){var i=t>=r*1.5;return Math.round(e/r)+" "+n+(i?"s":"")}});var Ge=y((Oo,Wt)=>{function Pn(e){r.debug=r,r.default=r,r.coerce=f,r.disable=o,r.enable=i,r.enabled=s,r.humanize=Ht(),r.destroy=u,Object.keys(e).forEach(a=>{r[a]=e[a]}),r.names=[],r.skips=[],r.formatters={};function t(a){let d=0;for(let l=0;l{if(oe==="%%")return"%";M++;let se=r.formatters[H];if(typeof se=="function"){let ln=m[M];oe=se.call(v,ln),m.splice(M,1),M--}return oe}),r.formatArgs.call(v,m),(v.log||r.log).apply(v,m)}return p.namespace=a,p.useColors=r.useColors(),p.color=r.selectColor(a),p.extend=n,p.destroy=r.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>l!==null?l:(g!==r.namespaces&&(g=r.namespaces,x=r.enabled(a)),x),set:m=>{l=m}}),typeof r.init=="function"&&r.init(p),p}function n(a,d){let l=r(this.namespace+(typeof d>"u"?":":d)+a);return l.log=this.log,l}function i(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let d,l=(typeof a=="string"?a:"").split(/[\s,]+/),g=l.length;for(d=0;d"-"+d)].join(",");return r.enable(""),a}function s(a){if(a[a.length-1]==="*")return!0;let d,l;for(d=0,l=r.skips.length;d{O.formatArgs=An;O.save=Tn;O.load=Nn;O.useColors=zn;O.storage=Mn();O.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();O.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function zn(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function An(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+be.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(r++,i==="%c"&&(n=r))}),e.splice(n,0,t)}O.log=console.debug||console.log||(()=>{});function Tn(e){try{e?O.storage.setItem("debug",e):O.storage.removeItem("debug")}catch{}}function Nn(){let e;try{e=O.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Mn(){try{return localStorage}catch{}}be.exports=Ge()(O);var{formatters:Bn}=be.exports;Bn.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Jt=y((jo,Gt)=>{"use strict";Gt.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return n!==-1&&(i===-1||n{"use strict";var Un=require("os"),Yt=require("tty"),j=Jt(),{env:b}=process,B;j("no-color")||j("no-colors")||j("color=false")||j("color=never")?B=0:(j("color")||j("colors")||j("color=true")||j("color=always"))&&(B=1);"FORCE_COLOR"in b&&(b.FORCE_COLOR==="true"?B=1:b.FORCE_COLOR==="false"?B=0:B=b.FORCE_COLOR.length===0?1:Math.min(parseInt(b.FORCE_COLOR,10),3));function Je(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Ye(e,t){if(B===0)return 0;if(j("color=16m")||j("color=full")||j("color=truecolor"))return 3;if(j("color=256"))return 2;if(e&&!t&&B===void 0)return 0;let r=B||0;if(b.TERM==="dumb")return r;if(process.platform==="win32"){let n=Un.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in b)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in b)||b.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in b)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(b.TEAMCITY_VERSION)?1:0;if(b.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in b){let n=parseInt((b.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(b.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(b.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(b.TERM)||"COLORTERM"in b?1:r}function Dn(e){let t=Ye(e,e&&e.isTTY);return Je(t)}Kt.exports={supportsColor:Dn,stdout:Je(Ye(!0,Yt.isatty(1))),stderr:Je(Ye(!0,Yt.isatty(2)))}});var Qt=y((E,Ee)=>{var $n=require("tty"),Ce=require("util");E.init=Yn;E.log=Vn;E.formatArgs=Hn;E.save=Gn;E.load=Jn;E.useColors=kn;E.destroy=Ce.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");E.colors=[6,2,3,4,5,1];try{let e=Xt();e&&(e.stderr||e).level>=2&&(E.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}E.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(i,o)=>o.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),e[r]=n,e},{});function kn(){return"colors"in E.inspectOpts?!!E.inspectOpts.colors:$n.isatty(process.stderr.fd)}function Hn(e){let{namespace:t,useColors:r}=this;if(r){let n=this.color,i="\x1B[3"+(n<8?n:"8;5;"+n),o=` ${i};1m${t} \x1B[0m`;e[0]=o+e[0].split(` +`).join(` +`+o),e.push(i+"m+"+Ee.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Wn()+t+" "+e[0]}function Wn(){return E.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Vn(...e){return process.stderr.write(Ce.format(...e)+` +`)}function Gn(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Jn(){return process.env.DEBUG}function Yn(e){e.inspectOpts={};let t=Object.keys(E.inspectOpts);for(let r=0;rt.trim()).join(" ")};Zt.O=function(e){return this.inspectOpts.colors=this.useColors,Ce.inspect(e,this.inspectOpts)}});var Xe=y((qo,Ke)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ke.exports=Vt():Ke.exports=Qt()});var rr=y((Po,tr)=>{tr.exports=er;function er(e,t){if(e&&t)return er(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){r[n]=e[n]}),r;function r(){for(var n=new Array(arguments.length),i=0;i{var nr=rr();Ze.exports=nr(Fe);Ze.exports.strict=nr(ir);Fe.proto=Fe(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Fe(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return ir(this)},configurable:!0})});function Fe(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function ir(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}});var ar=y((Ao,sr)=>{var Kn=Qe(),Xn=function(){},Zn=function(e){return e.setHeader&&typeof e.abort=="function"},Qn=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3},or=function(e,t,r){if(typeof t=="function")return or(e,null,t);t||(t={}),r=Kn(r||Xn);var n=e._writableState,i=e._readableState,o=t.readable||t.readable!==!1&&e.readable,s=t.writable||t.writable!==!1&&e.writable,c=!1,f=function(){e.writable||u()},u=function(){s=!1,o||r.call(e)},a=function(){o=!1,s||r.call(e)},d=function(m){r.call(e,m?new Error("exited with error code: "+m):null)},l=function(m){r.call(e,m)},g=function(){process.nextTick(x)},x=function(){if(!c){if(o&&!(i&&i.ended&&!i.destroyed))return r.call(e,new Error("premature close"));if(s&&!(n&&n.ended&&!n.destroyed))return r.call(e,new Error("premature close"))}},p=function(){e.req.on("finish",u)};return Zn(e)?(e.on("complete",u),e.on("abort",g),e.req?p():e.on("request",p)):s&&!n&&(e.on("end",f),e.on("close",f)),Qn(e)&&e.on("exit",d),e.on("end",a),e.on("finish",u),t.error!==!1&&e.on("error",l),e.on("close",g),function(){c=!0,e.removeListener("complete",u),e.removeListener("abort",g),e.removeListener("request",p),e.req&&e.req.removeListener("finish",u),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",u),e.removeListener("exit",d),e.removeListener("end",a),e.removeListener("error",l),e.removeListener("close",g)}};sr.exports=or});var fr=y((To,ur)=>{var ei=Qe(),ti=ar(),et=require("fs"),ae=function(){},ri=/^v?\.0/.test(process.version),Se=function(e){return typeof e=="function"},ni=function(e){return!ri||!et?!1:(e instanceof(et.ReadStream||ae)||e instanceof(et.WriteStream||ae))&&Se(e.close)},ii=function(e){return e.setHeader&&Se(e.abort)},oi=function(e,t,r,n){n=ei(n);var i=!1;e.on("close",function(){i=!0}),ti(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,ni(e))return e.close(ae);if(ii(e))return e.abort();if(Se(e.destroy))return e.destroy();n(s||new Error("stream was destroyed"))}}},cr=function(e){e()},si=function(e,t){return e.pipe(t)},ai=function(){var e=Array.prototype.slice.call(arguments),t=Se(e[e.length-1]||ae)&&e.pop()||ae;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error("pump requires two streams per minimum");var r,n=e.map(function(i,o){var s=o0;return oi(i,s,c,function(f){r||(r=f),f&&n.forEach(cr),!s&&(n.forEach(cr),t(r))})});return e.reduce(si)};ur.exports=ai});var lr=y((No,dr)=>{"use strict";var{PassThrough:ci}=require("stream");dr.exports=e=>{e={...e};let{array:t}=e,{encoding:r}=e,n=r==="buffer",i=!1;t?i=!(r||n):r=r||"utf8",n&&(r=null);let o=new ci({objectMode:i});r&&o.setEncoding(r);let s=0,c=[];return o.on("data",f=>{c.push(f),i?s=c.length:s+=f.length}),o.getBufferedValue=()=>t?c:n?Buffer.concat(c,s):c.join(""),o.getBufferedLength=()=>s,o}});var mr=y((Mo,Q)=>{"use strict";var{constants:ui}=require("buffer"),fi=fr(),di=lr(),Re=class extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};async function _e(e,t){if(!e)return Promise.reject(new Error("Expected a stream"));t={maxBuffer:1/0,...t};let{maxBuffer:r}=t,n;return await new Promise((i,o)=>{let s=c=>{c&&n.getBufferedLength()<=ui.MAX_LENGTH&&(c.bufferedData=n.getBufferedValue()),o(c)};n=fi(e,di(t),c=>{if(c){s(c);return}i()}),n.on("data",()=>{n.getBufferedLength()>r&&s(new Re)})}),n.getBufferedValue()}Q.exports=_e;Q.exports.default=_e;Q.exports.buffer=(e,t)=>_e(e,{...t,encoding:"buffer"});Q.exports.array=(e,t)=>_e(e,{...t,array:!0});Q.exports.MaxBufferError=Re});var xr=y((Bo,gr)=>{gr.exports=Le;function Le(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}Le.prototype.go=function(e){this.pending0&&e.pending{var ce=require("fs"),Oe=require("util"),tt=require("stream"),vr=tt.Readable,rt=tt.Writable,li=tt.PassThrough,mi=xr(),je=require("events").EventEmitter;ue.createFromBuffer=hi;ue.createFromFd=pi;ue.BufferSlicer=N;ue.FdSlicer=T;Oe.inherits(T,je);function T(e,t){t=t||{},je.call(this),this.fd=e,this.pend=new mi,this.pend.max=1,this.refCount=0,this.autoClose=!!t.autoClose}T.prototype.read=function(e,t,r,n,i){var o=this;o.pend.go(function(s){ce.read(o.fd,e,t,r,n,function(c,f,u){s(),i(c,f,u)})})};T.prototype.write=function(e,t,r,n,i){var o=this;o.pend.go(function(s){ce.write(o.fd,e,t,r,n,function(c,f,u){s(),i(c,f,u)})})};T.prototype.createReadStream=function(e){return new Ie(this,e)};T.prototype.createWriteStream=function(e){return new qe(this,e)};T.prototype.ref=function(){this.refCount+=1};T.prototype.unref=function(){var e=this;if(e.refCount-=1,e.refCount>0)return;if(e.refCount<0)throw new Error("invalid unref");e.autoClose&&ce.close(e.fd,t);function t(r){r?e.emit("error",r):e.emit("close")}};Oe.inherits(Ie,vr);function Ie(e,t){t=t||{},vr.call(this,t),this.context=e,this.context.ref(),this.start=t.start||0,this.endOffset=t.end,this.pos=this.start,this.destroyed=!1}Ie.prototype._read=function(e){var t=this;if(!t.destroyed){var r=Math.min(t._readableState.highWaterMark,e);if(t.endOffset!=null&&(r=Math.min(r,t.endOffset-t.pos)),r<=0){t.destroyed=!0,t.push(null),t.context.unref();return}t.context.pend.go(function(n){if(t.destroyed)return n();var i=new Buffer(r);ce.read(t.context.fd,i,0,r,t.pos,function(o,s){o?t.destroy(o):s===0?(t.destroyed=!0,t.push(null),t.context.unref()):(t.pos+=s,t.push(i.slice(0,s))),n()})})}};Ie.prototype.destroy=function(e){this.destroyed||(e=e||new Error("stream destroyed"),this.destroyed=!0,this.emit("error",e),this.context.unref())};Oe.inherits(qe,rt);function qe(e,t){t=t||{},rt.call(this,t),this.context=e,this.context.ref(),this.start=t.start||0,this.endOffset=t.end==null?1/0:+t.end,this.bytesWritten=0,this.pos=this.start,this.destroyed=!1,this.on("finish",this.destroy.bind(this))}qe.prototype._write=function(e,t,r){var n=this;if(!n.destroyed){if(n.pos+e.length>n.endOffset){var i=new Error("maximum file length exceeded");i.code="ETOOBIG",n.destroy(),r(i);return}n.context.pend.go(function(o){if(n.destroyed)return o();ce.write(n.context.fd,e,0,e.length,n.pos,function(s,c){s?(n.destroy(),o(),r(s)):(n.bytesWritten+=c,n.pos+=c,n.emit("progress"),o(),r())})})}};qe.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.context.unref())};Oe.inherits(N,je);function N(e,t){je.call(this),t=t||{},this.refCount=0,this.buffer=e,this.maxChunkSize=t.maxChunkSize||Number.MAX_SAFE_INTEGER}N.prototype.read=function(e,t,r,n,i){var o=n+r,s=o-this.buffer.length,c=s>0?s:r;this.buffer.copy(e,t,n,o),setImmediate(function(){i(null,c)})};N.prototype.write=function(e,t,r,n,i){e.copy(this.buffer,n,t,t+r),setImmediate(function(){i(null,r,e)})};N.prototype.createReadStream=function(e){e=e||{};var t=new li(e);t.destroyed=!1,t.start=e.start||0,t.endOffset=e.end,t.pos=t.endOffset||this.buffer.length;for(var r=this.buffer.slice(t.start,t.pos),n=0;;){var i=n+this.maxChunkSize;if(i>=r.length){nr.endOffset){var c=new Error("maximum file length exceeded");c.code="ETOOBIG",r.destroyed=!0,o(c);return}n.copy(t.buffer,r.pos,0,n.length),r.bytesWritten+=n.length,r.pos=s,r.emit("progress"),o()}},r.destroy=function(){r.destroyed=!0},r};N.prototype.ref=function(){this.refCount+=1};N.prototype.unref=function(){if(this.refCount-=1,this.refCount<0)throw new Error("invalid unref")};function hi(e,t){return new N(e,t)}function pi(e,t){return new T(e,t)}});var Cr=y((Do,br)=>{var U=require("buffer").Buffer,nt=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(nt=new Int32Array(nt));function wr(e){if(U.isBuffer(e))return e;var t=typeof U.alloc=="function"&&typeof U.from=="function";if(typeof e=="number")return t?U.alloc(e):new U(e);if(typeof e=="string")return t?U.from(e):new U(e);throw new Error("input must be buffer, number, or string, received "+typeof e)}function gi(e){var t=wr(4);return t.writeInt32BE(e,0),t}function it(e,t){e=wr(e),U.isBuffer(t)&&(t=t.readUInt32BE(0));for(var r=~~t^-1,n=0;n>>8;return r^-1}function ot(){return gi(it.apply(null,arguments))}ot.signed=function(){return it.apply(null,arguments)};ot.unsigned=function(){return it.apply(null,arguments)>>>0};br.exports=ot});var Or=y(z=>{var st=require("fs"),xi=require("zlib"),Er=yr(),vi=Cr(),Ae=require("util"),Te=require("events").EventEmitter,Fr=require("stream").Transform,at=require("stream").PassThrough,yi=require("stream").Writable;z.open=wi;z.fromFd=Sr;z.fromBuffer=bi;z.fromRandomAccessReader=ct;z.dosDateTimeToDate=_r;z.validateFileName=Lr;z.ZipFile=D;z.Entry=fe;z.RandomAccessReader=$;function wi(e,t,r){typeof t=="function"&&(r=t,t=null),t==null&&(t={}),t.autoClose==null&&(t.autoClose=!0),t.lazyEntries==null&&(t.lazyEntries=!1),t.decodeStrings==null&&(t.decodeStrings=!0),t.validateEntrySizes==null&&(t.validateEntrySizes=!0),t.strictFileNames==null&&(t.strictFileNames=!1),r==null&&(r=ze),st.open(e,"r",function(n,i){if(n)return r(n);Sr(i,t,function(o,s){o&&st.close(i,ze),r(o,s)})})}function Sr(e,t,r){typeof t=="function"&&(r=t,t=null),t==null&&(t={}),t.autoClose==null&&(t.autoClose=!1),t.lazyEntries==null&&(t.lazyEntries=!1),t.decodeStrings==null&&(t.decodeStrings=!0),t.validateEntrySizes==null&&(t.validateEntrySizes=!0),t.strictFileNames==null&&(t.strictFileNames=!1),r==null&&(r=ze),st.fstat(e,function(n,i){if(n)return r(n);var o=Er.createFromFd(e,{autoClose:!0});ct(o,i.size,t,r)})}function bi(e,t,r){typeof t=="function"&&(r=t,t=null),t==null&&(t={}),t.autoClose=!1,t.lazyEntries==null&&(t.lazyEntries=!1),t.decodeStrings==null&&(t.decodeStrings=!0),t.validateEntrySizes==null&&(t.validateEntrySizes=!0),t.strictFileNames==null&&(t.strictFileNames=!1);var n=Er.createFromBuffer(e,{maxChunkSize:65536});ct(n,e.length,t,r)}function ct(e,t,r,n){typeof r=="function"&&(n=r,r=null),r==null&&(r={}),r.autoClose==null&&(r.autoClose=!0),r.lazyEntries==null&&(r.lazyEntries=!1),r.decodeStrings==null&&(r.decodeStrings=!0);var i=!!r.decodeStrings;if(r.validateEntrySizes==null&&(r.validateEntrySizes=!0),r.strictFileNames==null&&(r.strictFileNames=!1),n==null&&(n=ze),typeof t!="number")throw new Error("expected totalSize parameter to be a number");if(t>Number.MAX_SAFE_INTEGER)throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");e.ref();var o=22,s=65535,c=Math.min(o+s,t),f=P(c),u=t-f.length;ee(e,f,0,c,u,function(a){if(a)return n(a);for(var d=c-o;d>=0;d-=1)if(f.readUInt32LE(d)===101010256){var l=f.slice(d),g=l.readUInt16LE(4);if(g!==0)return n(new Error("multi-disk zip files are not supported: found disk number: "+g));var x=l.readUInt16LE(10),p=l.readUInt32LE(16),m=l.readUInt16LE(20),v=l.length-o;if(m!==v)return n(new Error("invalid comment length. expected: "+v+". found: "+m));var w=i?Pe(l,22,l.length,!1):l.slice(22);if(!(x===65535||p===4294967295))return n(null,new D(e,p,t,x,w,r.autoClose,r.lazyEntries,i,r.validateEntrySizes,r.strictFileNames));var S=P(20),M=u+d-S.length;ee(e,S,0,S.length,M,function(Y){if(Y)return n(Y);if(S.readUInt32LE(0)!==117853008)return n(new Error("invalid zip64 end of central directory locator signature"));var oe=te(S,8),H=P(56);ee(e,H,0,H.length,oe,function(se){return se?n(se):H.readUInt32LE(0)!==101075792?n(new Error("invalid zip64 end of central directory record signature")):(x=te(H,32),p=te(H,48),n(null,new D(e,p,t,x,w,r.autoClose,r.lazyEntries,i,r.validateEntrySizes,r.strictFileNames)))})});return}n(new Error("end of central directory record signature not found"))})}Ae.inherits(D,Te);function D(e,t,r,n,i,o,s,c,f,u){var a=this;Te.call(a),a.reader=e,a.reader.on("error",function(d){Rr(a,d)}),a.reader.once("close",function(){a.emit("close")}),a.readEntryCursor=t,a.fileSize=r,a.entryCount=n,a.comment=i,a.entriesRead=0,a.autoClose=!!o,a.lazyEntries=!!s,a.decodeStrings=!!c,a.validateEntrySizes=!!f,a.strictFileNames=!!u,a.isOpen=!0,a.emittedError=!1,a.lazyEntries||a._readEntry()}D.prototype.close=function(){this.isOpen&&(this.isOpen=!1,this.reader.unref())};function I(e,t){e.autoClose&&e.close(),Rr(e,t)}function Rr(e,t){e.emittedError||(e.emittedError=!0,e.emit("error",t))}D.prototype.readEntry=function(){if(!this.lazyEntries)throw new Error("readEntry() called without lazyEntries:true");this._readEntry()};D.prototype._readEntry=function(){var e=this;if(e.entryCount===e.entriesRead){setImmediate(function(){e.autoClose&&e.close(),!e.emittedError&&e.emit("end")});return}if(!e.emittedError){var t=P(46);ee(e.reader,t,0,t.length,e.readEntryCursor,function(r){if(r)return I(e,r);if(!e.emittedError){var n=new fe,i=t.readUInt32LE(0);if(i!==33639248)return I(e,new Error("invalid central directory file header signature: 0x"+i.toString(16)));if(n.versionMadeBy=t.readUInt16LE(4),n.versionNeededToExtract=t.readUInt16LE(6),n.generalPurposeBitFlag=t.readUInt16LE(8),n.compressionMethod=t.readUInt16LE(10),n.lastModFileTime=t.readUInt16LE(12),n.lastModFileDate=t.readUInt16LE(14),n.crc32=t.readUInt32LE(16),n.compressedSize=t.readUInt32LE(20),n.uncompressedSize=t.readUInt32LE(24),n.fileNameLength=t.readUInt16LE(28),n.extraFieldLength=t.readUInt16LE(30),n.fileCommentLength=t.readUInt16LE(32),n.internalFileAttributes=t.readUInt16LE(36),n.externalFileAttributes=t.readUInt32LE(38),n.relativeOffsetOfLocalHeader=t.readUInt32LE(42),n.generalPurposeBitFlag&64)return I(e,new Error("strong encryption is not supported"));e.readEntryCursor+=46,t=P(n.fileNameLength+n.extraFieldLength+n.fileCommentLength),ee(e.reader,t,0,t.length,e.readEntryCursor,function(o){if(o)return I(e,o);if(!e.emittedError){var s=(n.generalPurposeBitFlag&2048)!==0;n.fileName=e.decodeStrings?Pe(t,0,n.fileNameLength,s):t.slice(0,n.fileNameLength);var c=n.fileNameLength+n.extraFieldLength,f=t.slice(n.fileNameLength,c);n.extraFields=[];for(var u=0;uf.length)return I(e,new Error("extra field length exceeds extra field buffer size"));var x=P(d);f.copy(x,0,l,g),n.extraFields.push({id:a,data:x}),u=g}if(n.fileComment=e.decodeStrings?Pe(t,c,c+n.fileCommentLength,s):t.slice(c,c+n.fileCommentLength),n.comment=n.fileComment,e.readEntryCursor+=t.length,e.entriesRead+=1,n.uncompressedSize===4294967295||n.compressedSize===4294967295||n.relativeOffsetOfLocalHeader===4294967295){for(var p=null,u=0;up.length)return I(e,new Error("zip64 extended information extra field does not include uncompressed size"));n.uncompressedSize=te(p,v),v+=8}if(n.compressedSize===4294967295){if(v+8>p.length)return I(e,new Error("zip64 extended information extra field does not include compressed size"));n.compressedSize=te(p,v),v+=8}if(n.relativeOffsetOfLocalHeader===4294967295){if(v+8>p.length)return I(e,new Error("zip64 extended information extra field does not include relative header offset"));n.relativeOffsetOfLocalHeader=te(p,v),v+=8}}if(e.decodeStrings)for(var u=0;ue.compressedSize)throw new Error("options.start > entry.compressedSize")}if(t.end!=null){if(o=t.end,o<0)throw new Error("options.end < 0");if(o>e.compressedSize)throw new Error("options.end > entry.compressedSize");if(on.fileSize)return r(new Error("file data overflows file bounds: "+g+" + "+e.compressedSize+" > "+n.fileSize));var p=n.reader.createReadStream({start:g+i,end:g+o}),m=p;if(l){var v=!1,w=xi.createInflateRaw();p.on("error",function(S){setImmediate(function(){v||w.emit("error",S)})}),p.pipe(w),n.validateEntrySizes?(m=new de(e.uncompressedSize),w.on("error",function(S){setImmediate(function(){v||m.emit("error",S)})}),w.pipe(m)):m=w,m.destroy=function(){v=!0,w!==m&&w.unpipe(m),p.unpipe(w),p.destroy()}}r(null,m)}finally{n.reader.unref()}})};function fe(){}fe.prototype.getLastModDate=function(){return _r(this.lastModFileDate,this.lastModFileTime)};fe.prototype.isEncrypted=function(){return(this.generalPurposeBitFlag&1)!==0};fe.prototype.isCompressed=function(){return this.compressionMethod===8};function _r(e,t){var r=e&31,n=(e>>5&15)-1,i=(e>>9&127)+1980,o=0,s=(t&31)*2,c=t>>5&63,f=t>>11&31;return new Date(i,n,r,f,c,s,o)}function Lr(e){return e.indexOf("\\")!==-1?"invalid characters in fileName: "+e:/^[a-zA-Z]:/.test(e)||/^\//.test(e)?"absolute path: "+e:e.split("/").indexOf("..")!==-1?"invalid relative path: "+e:null}function ee(e,t,r,n,i,o){if(n===0)return setImmediate(function(){o(null,P(0))});e.read(t,r,n,i,function(s,c){if(s)return o(s);if(cthis.expectedByteCount){var n="too many bytes in the stream. expected "+this.expectedByteCount+". got at least "+this.actualByteCount;return r(new Error(n))}r(null,e)};de.prototype._flush=function(e){if(this.actualByteCount0)return;if(e.refCount<0)throw new Error("invalid unref");e.close(t);function t(r){if(r)return e.emit("error",r);e.emit("close")}};$.prototype.createReadStream=function(e){var t=e.start,r=e.end;if(t===r){var n=new at;return setImmediate(function(){n.end()}),n}var i=this._readStreamForRange(t,r),o=!1,s=new Ne(this);i.on("error",function(f){setImmediate(function(){o||s.emit("error",f)})}),s.destroy=function(){i.unpipe(s),s.unref(),i.destroy()};var c=new de(r-t);return s.on("error",function(f){setImmediate(function(){o||c.emit("error",f)})}),c.destroy=function(){o=!0,s.unpipe(c),s.destroy()},i.pipe(s).pipe(c)};$.prototype._readStreamForRange=function(e,t){throw new Error("not implemented")};$.prototype.read=function(e,t,r,n,i){var o=this.createReadStream({start:n,end:n+r}),s=new yi,c=0;s._write=function(f,u,a){f.copy(e,t+c,0,f.length),c+=f.length,a()},s.on("finish",i),o.on("error",function(f){i(f)}),o.pipe(s)};$.prototype.close=function(e){setImmediate(e)};Ae.inherits(Ne,at);function Ne(e){at.call(this),this.context=e,this.context.ref(),this.unreffedYet=!1}Ne.prototype._flush=function(e){this.unref(),e()};Ne.prototype.unref=function(e){this.unreffedYet||(this.unreffedYet=!0,this.context.unref())};var Ci="\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";function Pe(e,t,r,n){if(n)return e.toString("utf8",t,r);for(var i="",o=t;o{var q=Xe()("extract-zip"),{createWriteStream:Ei,promises:re}=require("fs"),Fi=mr(),V=require("path"),{promisify:ft}=require("util"),Si=require("stream"),Ri=Or(),_i=ft(Ri.open),Li=ft(Si.pipeline),ut=class{constructor(t,r){this.zipPath=t,this.opts=r}async extract(){return q("opening",this.zipPath,"with opts",this.opts),this.zipfile=await _i(this.zipPath,{lazyEntries:!0}),this.canceled=!1,new Promise((t,r)=>{this.zipfile.on("error",n=>{this.canceled=!0,r(n)}),this.zipfile.readEntry(),this.zipfile.on("close",()=>{this.canceled||(q("zip extraction complete"),t())}),this.zipfile.on("entry",async n=>{if(this.canceled){q("skipping entry",n.fileName,{cancelled:this.canceled});return}if(q("zipfile entry",n.fileName),n.fileName.startsWith("__MACOSX/")){this.zipfile.readEntry();return}let i=V.dirname(V.join(this.opts.dir,n.fileName));try{await re.mkdir(i,{recursive:!0});let o=await re.realpath(i);if(V.relative(this.opts.dir,o).split(V.sep).includes(".."))throw new Error(`Out of bound path "${o}" found while processing file ${n.fileName}`);await this.extractEntry(n),q("finished processing",n.fileName),this.zipfile.readEntry()}catch(o){this.canceled=!0,this.zipfile.close(),r(o)}})})}async extractEntry(t){if(this.canceled){q("skipping entry extraction",t.fileName,{cancelled:this.canceled});return}this.opts.onEntry&&this.opts.onEntry(t,this.zipfile);let r=V.join(this.opts.dir,t.fileName),n=t.externalFileAttributes>>16&65535,i=61440,o=16384,c=(n&i)===40960,f=(n&i)===o;!f&&t.fileName.endsWith("/")&&(f=!0);let u=t.versionMadeBy>>8;f||(f=u===0&&t.externalFileAttributes===16),q("extracting entry",{filename:t.fileName,isDir:f,isSymlink:c});let a=this.getExtractedMode(n,f)&511,d=f?r:V.dirname(r),l={recursive:!0};if(f&&(l.mode=a),q("mkdir",{dir:d,...l}),await re.mkdir(d,l),f)return;q("opening read stream",r);let g=await ft(this.zipfile.openReadStream.bind(this.zipfile))(t);if(c){let x=await Fi(g);q("creating symlink",x,r),await re.symlink(x,r)}else await Li(g,Ei(r,{mode:a}))}getExtractedMode(t,r){let n=t;return n===0&&(r?(this.opts.defaultDirMode&&(n=parseInt(this.opts.defaultDirMode,10)),n||(n=493)):(this.opts.defaultFileMode&&(n=parseInt(this.opts.defaultFileMode,10)),n||(n=420))),n}};jr.exports=async function(e,t){if(q("creating target directory",t.dir),!V.isAbsolute(t.dir))throw new Error("Target directory is expected to be absolute");return await re.mkdir(t.dir,{recursive:!0}),t.dir=await re.realpath(t.dir),new ut(e,t).extract()}});var Pr=y((Ho,qr)=>{var le;qr.exports=function(){if(!le){try{le=Xe()("follow-redirects")}catch{}typeof le!="function"&&(le=function(){})}le.apply(null,arguments)}});var Mr=y((Wo,Ct)=>{var pe=require("url"),me=pe.URL,Oi=require("http"),ji=require("https"),pt=require("stream").Writable,gt=require("assert"),zr=Pr(),xt=!1;try{gt(new me)}catch(e){xt=e.code==="ERR_INVALID_URL"}var Ii=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],vt=["abort","aborted","connect","error","socket","timeout"],yt=Object.create(null);vt.forEach(function(e){yt[e]=function(t,r,n){this._redirectable.emit(e,t,r,n)}});var lt=ge("ERR_INVALID_URL","Invalid URL",TypeError),mt=ge("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),qi=ge("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",mt),Pi=ge("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),zi=ge("ERR_STREAM_WRITE_AFTER_END","write after end"),Ai=pt.prototype.destroy||Tr;function R(e,t){pt.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var r=this;this._onNativeResponse=function(n){try{r._processResponse(n)}catch(i){r.emit("error",i instanceof mt?i:new mt({cause:i}))}},this._performRequest()}R.prototype=Object.create(pt.prototype);R.prototype.abort=function(){bt(this._currentRequest),this._currentRequest.abort(),this.emit("abort")};R.prototype.destroy=function(e){return bt(this._currentRequest,e),Ai.call(this,e),this};R.prototype.write=function(e,t,r){if(this._ending)throw new zi;if(!G(e)&&!Mi(e))throw new TypeError("data should be a string, Buffer or Uint8Array");if(he(t)&&(r=t,t=null),e.length===0){r&&r();return}this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,r)):(this.emit("error",new Pi),this.abort())};R.prototype.end=function(e,t,r){if(he(e)?(r=e,e=t=null):he(t)&&(r=t,t=null),!e)this._ended=this._ending=!0,this._currentRequest.end(null,null,r);else{var n=this,i=this._currentRequest;this.write(e,t,function(){n._ended=!0,i.end(null,null,r)}),this._ending=!0}};R.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)};R.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)};R.prototype.setTimeout=function(e,t){var r=this;function n(s){s.setTimeout(e),s.removeListener("timeout",s.destroy),s.addListener("timeout",s.destroy)}function i(s){r._timeout&&clearTimeout(r._timeout),r._timeout=setTimeout(function(){r.emit("timeout"),o()},e),n(s)}function o(){r._timeout&&(clearTimeout(r._timeout),r._timeout=null),r.removeListener("abort",o),r.removeListener("error",o),r.removeListener("response",o),r.removeListener("close",o),t&&r.removeListener("timeout",t),r.socket||r._currentRequest.removeListener("socket",i)}return t&&this.on("timeout",t),this.socket?i(this.socket):this._currentRequest.once("socket",i),this.on("socket",n),this.on("abort",o),this.on("error",o),this.on("response",o),this.on("close",o),this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){R.prototype[e]=function(t,r){return this._currentRequest[e](t,r)}});["aborted","connection","socket"].forEach(function(e){Object.defineProperty(R.prototype,e,{get:function(){return this._currentRequest[e]}})});R.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}};R.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var r=e.slice(0,-1);this._options.agent=this._options.agents[r]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);n._redirectable=this;for(var i of vt)n.on(i,yt[i]);if(this._currentUrl=/^\//.test(this._options.path)?pe.format(this._options):this._options.path,this._isRedirect){var o=0,s=this,c=this._requestBodyBuffers;(function f(u){if(n===s._currentRequest)if(u)s.emit("error",u);else if(o=400){e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),this._requestBodyBuffers=[];return}if(bt(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new qi;var n,i=this._options.beforeRedirect;i&&(n=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var o=this._options.method;((t===301||t===302)&&this._options.method==="POST"||t===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],dt(/^content-/i,this._options.headers));var s=dt(/^host$/i,this._options.headers),c=wt(this._currentUrl),f=s||c.host,u=/^\w+:/.test(r)?this._currentUrl:pe.format(Object.assign(c,{host:f})),a=Ti(r,u);if(zr("redirecting to",a.href),this._isRedirect=!0,ht(a,this._options),(a.protocol!==c.protocol&&a.protocol!=="https:"||a.host!==f&&!Ni(a.host,f))&&dt(/^(?:authorization|cookie)$/i,this._options.headers),he(i)){var d={headers:e.headers,statusCode:t},l={url:u,method:o,headers:n};i(this._options,d,l),this._sanitizeOptions(this._options)}this._performRequest()};function Ar(e){var t={maxRedirects:21,maxBodyLength:10485760},r={};return Object.keys(e).forEach(function(n){var i=n+":",o=r[i]=e[n],s=t[n]=Object.create(o);function c(u,a,d){return Bi(u)?u=ht(u):G(u)?u=ht(wt(u)):(d=a,a=Nr(u),u={protocol:i}),he(a)&&(d=a,a=null),a=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},u,a),a.nativeProtocols=r,!G(a.host)&&!G(a.hostname)&&(a.hostname="::1"),gt.equal(a.protocol,i,"protocol mismatch"),zr("options",a),new R(a,d)}function f(u,a,d){var l=s.request(u,a,d);return l.end(),l}Object.defineProperties(s,{request:{value:c,configurable:!0,enumerable:!0,writable:!0},get:{value:f,configurable:!0,enumerable:!0,writable:!0}})}),t}function Tr(){}function wt(e){var t;if(xt)t=new me(e);else if(t=Nr(pe.parse(e)),!G(t.protocol))throw new lt({input:e});return t}function Ti(e,t){return xt?new me(e,t):wt(pe.resolve(t,e))}function Nr(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new lt({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new lt({input:e.href||e});return e}function ht(e,t){var r=t||{};for(var n of Ii)r[n]=e[n];return r.hostname.startsWith("[")&&(r.hostname=r.hostname.slice(1,-1)),r.port!==""&&(r.port=Number(r.port)),r.path=r.search?r.pathname+r.search:r.pathname,r}function dt(e,t){var r;for(var n in t)e.test(n)&&(r=t[n],delete t[n]);return r===null||typeof r>"u"?void 0:String(r).trim()}function ge(e,t,r){function n(i){Error.captureStackTrace(this,this.constructor),Object.assign(this,i||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return n.prototype=new(r||Error),Object.defineProperties(n.prototype,{constructor:{value:n,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),n}function bt(e,t){for(var r of vt)e.removeListener(r,yt[r]);e.on("error",Tr),e.destroy(t)}function Ni(e,t){gt(G(e)&&G(t));var r=e.length-t.length-1;return r>0&&e[r]==="."&&e.endsWith(t)}function G(e){return typeof e=="string"||e instanceof String}function he(e){return typeof e=="function"}function Mi(e){return typeof e=="object"&&"length"in e}function Bi(e){return me&&e instanceof me}Ct.exports=Ar({http:Oi,https:ji});Ct.exports.wrap=Ar});var kr=y((Vo,$r)=>{$r.exports=Dr;Dr.sync=Di;var Br=require("fs");function Ui(e,t){var r=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n{Gr.exports=Wr;Wr.sync=$i;var Hr=require("fs");function Wr(e,t,r){Hr.stat(e,function(n,i){r(n,n?!1:Vr(i,t))})}function $i(e,t){return Vr(Hr.statSync(e),t)}function Vr(e,t){return e.isFile()&&ki(e,t)}function ki(e,t){var r=e.mode,n=e.uid,i=e.gid,o=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),s=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),c=parseInt("100",8),f=parseInt("010",8),u=parseInt("001",8),a=c|f,d=r&u||r&f&&i===s||r&c&&n===o||r&a&&o===0;return d}});var Kr=y((Yo,Yr)=>{var Jo=require("fs"),Me;process.platform==="win32"||global.TESTING_WINDOWS?Me=kr():Me=Jr();Yr.exports=Et;Et.sync=Hi;function Et(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,i){Et(e,t||{},function(o,s){o?i(o):n(s)})})}Me(e,t||{},function(n,i){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,i=!1),r(n,i)})}function Hi(e,t){try{return Me.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var nn=y((Ko,rn)=>{var ne=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Xr=require("path"),Wi=ne?";":":",Zr=Kr(),Qr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),en=(e,t)=>{let r=t.colon||Wi,n=e.match(/\//)||ne&&e.match(/\\/)?[""]:[...ne?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],i=ne?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=ne?i.split(r):[""];return ne&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:i}},tn=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:n,pathExt:i,pathExtExe:o}=en(e,t),s=[],c=u=>new Promise((a,d)=>{if(u===n.length)return t.all&&s.length?a(s):d(Qr(e));let l=n[u],g=/^".*"$/.test(l)?l.slice(1,-1):l,x=Xr.join(g,e),p=!g&&/^\.[\\\/]/.test(e)?e.slice(0,2)+x:x;a(f(p,u,0))}),f=(u,a,d)=>new Promise((l,g)=>{if(d===i.length)return l(c(a+1));let x=i[d];Zr(u+x,{pathExt:o},(p,m)=>{if(!p&&m)if(t.all)s.push(u+x);else return l(u+x);return l(f(u,a,d+1))})});return r?c(0).then(u=>r(null,u),r):c(0)},Vi=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:n,pathExtExe:i}=en(e,t),o=[];for(let s=0;sno});module.exports=vn(io);var J=require("coc.nvim");var zt=require("coc.nvim"),De=A(require("path"));var It=require("coc.nvim"),qt=require("os"),ye=[{scheme:"file",language:"clojure"},{scheme:"jar",language:"clojure"},{scheme:"zipfile",language:"clojure"}];function L(){let e=It.workspace.getConfiguration("clojure"),t=e.get("lsp-install-path"),r={...e.get("initialization-options",{})};for(let[n,i]of Object.entries(r))Array.isArray(i)&&i.length===0&&delete r[n];return{checkOnStart:e.get("lsp-check-on-start"),keymaps:e.get("keymaps"),enable:e.get("enable"),executable:e.get("executable"),executableArgs:e.get("executable-args",null)||e.get("executableArgs",null)||[],initializationOptions:r,lspVersion:e.get("lsp-version"),lspInstallPath:t!=null&&t.startsWith("~")?t.replace("~",(0,qt.homedir)()):t,startupMessage:e.get("startup-message")}}var h;function Pt(e){h=e.logger}var $e=class{fillClientCapabilities(t){let r=t.experimental??{};r.projectTree=!0,r.testTree=!0,t.experimental=r}initialize(){}dispose(){}};function At(e){h.info("Creating client");let t=De.default.extname(e)===".jar",r=process.env.JAVA_HOME;if(t&&!r){h.error("Trying to use a jar without JAVA_HOME.");return}let n=t?{command:De.default.join(process.env.JAVA_HOME,"bin","java"),args:["-jar",e]}:{command:e,args:L().executableArgs};h.debug("ServerOptions",n);let i={run:n,debug:n},o={disabledFeatures:["signatureHelp"],documentSelector:ye,initializationOptions:L().initializationOptions},s=new zt.LanguageClient("clojure","Clojure Language Client",i,o);return s.registerFeature(new $e),s}var C=require("coc.nvim");var ke={};Ot(ke,{commands:()=>yn,default:()=>wn});var yn=[{command:"add-missing-import",description:"Add Java import for symbol under cursor to current namespace declaration",shortcut:"ai"},{command:"add-missing-libspec",description:"Add require form for symbol under cursor to current namespace declaration",shortcut:"am"},{command:"add-require-suggestion",description:"Add suggested require to ns form",shortcut:"as"},{command:"backward-barf",description:"Paredit: backward barf",shortcut:"bb"},{command:"backward-slurp",description:"Paredit: backward slurp",shortcut:"bs"},{aliases:["change-coll"],choices:["list","map","set","vector"],command:"change-collection",description:"Choose new type of collection",prompt:"New coll type"},{command:"clean-ns",description:"Sort and remove unused required libraries in namespace declaration",shortcut:"cn"},{command:"create-function",description:"Create a function from the current form",shortcut:"fe"},{command:"create-test",description:"Creates a test somewhere, who knows",shortcut:"ct"},{command:"cursor-info",description:"Show debugging information for the symbol at cursor"},{command:"cycle-coll",description:"Cycle the kind of collection: list -> map -> vector -> set -> list",shortcut:"cc"},{command:"cycle-privacy",description:"Cycle the privacy of current function definition",shortcut:"cp"},{command:"demote-fn",description:"Demote fn to #()",shortcut:"dm"},{command:"destructure-keys",description:"Destructure keys",shortcut:"dk"},{command:"docs",description:"Read the docs for a given symbol (in given namespace)"},{aliases:["move-coll-entry-up"],command:"drag-backward",description:"Move coll entry backward in collection",shortcut:"db"},{aliases:["move-coll-entry-down"],command:"drag-forward",description:"Move coll entry forward in collection",shortcut:"df"},{command:"drag-param-backward",description:"Move param backwards in function definition (and all call sites)",shortcut:"ab"},{command:"drag-param-forward",description:"Move param forward in function definition (and all call sites)",shortcut:"af"},{command:"expand-let",description:"Move current let form up a level",shortcut:"el"},{command:"extract-function",description:"Move current form into new top-level function",prompt:"Function name?",shortcut:"ef"},{command:"extract-to-def",description:"Move current form into new top-level def",prompt:"Symbol name?",shortcut:"ed"},{command:"forward-barf",description:"Paredit: forward barf",shortcut:"fb"},{command:"forward-slurp",description:"Paredit: forward slurp",shortcut:"fs"},{command:"get-in-all",description:"Replace current and all nested forms with get-in form",shortcut:"ga"},{command:"get-in-less",description:"Replace first form in current get-in form with nested form",shortcut:"gl"},{command:"get-in-more",description:"Move current form to current get-in form",shortcut:"gm"},{command:"get-in-none",description:"Replace entire current get-in form with nested form",shortcut:"gn"},{command:"inline-symbol",description:"Replace all instances of symbol with symbol definition",shortcut:"is"},{command:"introduce-let",description:"Move current form to let-bound variable",prompt:"Bind to?",shortcut:"il"},{command:"kill-sexp",description:"Paredit: Kill sexp",shortcut:"ks"},{command:"move-form",description:"Move form under cursor to specified file",prompt:"Which file?",shortcut:"mf"},{command:"move-to-let",description:"Move current form into surrounding let block",prompt:"Bind to?",shortcut:"ml"},{command:"project-tree",description:"Show project source-paths and external dependencies"},{command:"promote-fn",description:"Promote #() to fn, or fn to defn",shortcut:"pf"},{command:"raise-sexp",description:"Paredit: Raise sexp",shortcut:"rs"},{command:"replace-refer-all-with-alias",description:"Replace ':refer :all' with alias",shortcut:"ra"},{command:"replace-refer-all-with-refer",description:"Replace ':refer :all' with ':refer [...]'",shortcut:"rr"},{command:"resolve-macro-as",description:"Add entry to .clj-kondo/config.edn to resolve macro as another macro",shortcut:"ma"},{command:"restructure-keys",description:"Inline destructured keys with nested calls",shortcut:"rk"},{command:"server-info",description:"Show server configuration information"},{aliases:["sort-map"],command:"sort-clauses",description:"Sort entries within current clauses/list/map/set/vector",shortcut:"sl"},{command:"suppress-diagnostic",description:"Add a :clj-kondo/ignore to suppress linting current line",prompt:"Lint to ignore?"},{command:"test-tree",description:"Show tests as tree of data for potential UI"},{command:"thread-first",description:"Replace current form with thread-first expession",shortcut:"th"},{command:"thread-first-all",description:"Replace current and all nested forms with thread-first form",shortcut:"tf"},{command:"thread-last",description:"Replace current form with thread-last expession",shortcut:"tt"},{command:"thread-last-all",description:"Replace current and all nested forms with thread-last form",shortcut:"tl"},{command:"unwind-all",description:"Replace entire current threaded form with nested form",shortcut:"ua"},{command:"unwind-thread",description:"Replace first two forms in current threaded form with nested form",shortcut:"uw"}],wn={commands:yn};var F=require("coc.nvim");var Nt=(u=>(u[u.project=1]="project",u[u.sourcePath=2]="sourcePath",u[u.libary=3]="libary",u[u.jar=4]="jar",u[u.ns=5]="ns",u[u.class=6]="class",u[u.function=7]="function",u[u.variable=8]="variable",u[u.interface=9]="interface",u))(Nt||{});async function Mt(e,t){let r=await e.sendRequest("clojure/workspace/projectTree/nodes",t);return h.debug("requestProjectTree",JSON.stringify(r,null,4)),r}var He=class{constructor(t){this._onDidChangeTreeData=new F.Emitter;this.onDidChangeTreeData=this._onDidChangeTreeData.event;this.client=t}setRoot(t,r,n){this.root=t,this.doc=r,this.winid=n,this._onDidChangeTreeData.fire(null)}getTreeItem(t){var o;h.debug("getTreeItem",JSON.stringify(t,null,4));let r=new F.TreeItem(t.name),n=Nt[t.type],i=t.detail?` (${t.detail})`:"";return r.description=`${n}${i}`,((o=t.nodes)==null?void 0:o.length)>0?r.collapsibleState=F.TreeItemCollapsibleState.Expanded:t.final||(r.collapsibleState=F.TreeItemCollapsibleState.Collapsed),t.uri&&(r.resourceUri=F.Uri.parse(t.uri)),t.range&&this.winid&&(r.command={title:"Jump to",command:"workspace.openLocation",arguments:[this.winid,{uri:r.resourceUri||this.doc,range:t.range}]}),r}async getChildren(t){if(h.debug("getChildren",JSON.stringify(t,null,4)),t){if(t.nodes)return t.nodes;let r=await Mt(this.client,t);return(r==null?void 0:r.nodes)||[]}return this.root?[this.root]:[]}getParent(t){if(h.debug("getParent",JSON.stringify(t,null,4)),t===this.root)return;function r(n){let i=(n==null?void 0:n.nodes)||[];for(let o of i){let s=t===o?n:r(o);if(s)return s}}return r(this.root)}};async function Bt(e,t){let r=await Mt(e),n=await F.workspace.nvim.eval("win_getid()"),i=new He(e),{document:o}=await F.workspace.getCurrentState();i.setRoot(r,F.Uri.parse(o.uri),n);let s=F.window.createTreeView("project-tree",{treeDataProvider:i});t.subscriptions.push(s),await s.show()}async function We(e,t=""){return e?(await C.window.requestInput(e,t)).trim():void 0}async function bn(e){let t=await We("Var name?"),r=await We("Namespace?","clojure.core");if(t&&r){let n=await e.sendRequest("clojure/clojuredocs/raw",{symName:t,symNs:r}).catch(i=>{C.window.showErrorMessage(i)});n&&await C.window.showDialog({title:`${n.ns}/${n.name}`,content:n.doc})}}async function Dt(){let{line:e,character:t}=await C.window.getCursorPosition();return[(await C.workspace.document).uri,e,t]}var Cn=[{command:"docs",fn:bn},{command:"cursor-info",fn:async e=>{let[t,r,n]=await Dt();e.sendNotification("clojure/cursorInfo/log",{textDocument:{uri:t},position:{line:r,character:n}})}},{command:"server-info",fn:async e=>{e.sendNotification("clojure/serverInfo/log")}},{command:"test-tree",fn:async e=>{e.sendRequest("clojure/textDocument/testTree")}},{command:"project-tree",fn:Bt}],Ut=(()=>{let{commands:e}=ke,t=new Map;return e.concat(Cn).forEach(r=>{let n=r.command;t.has(n)||t.set(n,{command:n});let i=t.get(n);for(let[o,s]of Object.entries(r))i&&!i[o]&&(i[o]=s)}),Array.from(t.values())})();async function Ve(e,{command:t},r=[]){let n=await Dt();return e.sendRequest("workspace/executeCommand",{command:t,arguments:n.concat(r)}).catch(i=>{C.window.showErrorMessage(i)})}async function En(e,t){if(!e||!t)return;let r=await C.window.showMenuPicker(t,{title:e});if(r!==-1)return t[r]}async function Fn(e,t){let{title:r,choices:n}=t,i=await En(r,n),o=[];return i&&o.push(i),Ve(e,t,o)}async function Sn(e,t){let{title:r}=t,n=await We(r);if(n)return Ve(e,t,[n])}function Rn(e,t,r){let{command:n,fn:i,title:o,choices:s,aliases:c}=r,f=`lsp-clojure-${n}`,u=async()=>{if(s&&!C.workspace.env.dialog){h.info(`Workspace doesn't allow dialogs, cancelling command ${f}`);return}else{if(i)return h.debug(`Executing 'fn' command ${f}`),i(t,e);s?(h.debug(`Executing 'choices' command ${f}`),await Fn(t,r)):o?(h.debug(`Executing 'prompt' command ${f}`),await Sn(t,r)):(h.debug(`Executing 'position' command ${f}`),await Ve(t,r))}};h.debug(`Registering command ${f}`),e.subscriptions.push(C.commands.registerCommand(f,u)),c&&c.forEach(a=>{let d=`lsp-clojure-${a}`;h.debug(`Registering command ${d} as alias of ${f}`),e.subscriptions.push(C.commands.registerCommand(d,u))})}function _n(e,t,r){let{command:n,shortcut:i}=t,o=`lsp-clojure-${n}`,s=`${r.shortcut}${i}`;try{h.debug(`Creating keymap '${s}' for command '${o}'`);let c=`':call CocActionAsync("runCommand", "${o}")'`,f=`{'silent': v:true, 'noremap': v:true, 'desc': '${o}'}`;C.workspace.nvim.command(`call nvim_set_keymap('n', '${s}', ${c}, ${f})`,!0),e.subscriptions.push(C.Disposable.create(()=>{C.workspace.nvim.command(`nunmap ${s}`,!0)}))}catch(c){h.error(`Can't create keymapping ${s} for command ${n}`,c)}}function $t(e,t){for(let n of Ut)Rn(e,t,n);let{keymaps:r}=L();if(r.enable)for(let n of Ut)n.shortcut&&_n(e,n,r)}var _t=require("coc.nvim"),cn=A(Ir()),Lt=A(Mr()),_=A(require("fs")),Rt=require("os"),k=A(require("path")),un=require("url"),fn=A(nn());var on=A(require("fs")),xe=A(require("path")),ie=A(require("process"));var Gi="clojure-lsp-version",Ji={darwin:{x64:"clojure-lsp-native-macos-amd64.zip",arm64:"clojure-lsp-native-macos-amd64.zip"},linux:{x64:"clojure-lsp-native-static-linux-amd64.zip",arm64:"clojure-lsp-native-linux-aarch64.zip"},win32:{x64:"clojure-lsp-native-windows-amd64.zip"}};function Ft(e=ie.platform,t=ie.arch){var r;return((r=Ji[e])==null?void 0:r[t])??"clojure-lsp-standalone.jar"}function Be(e,t=ie.platform,r=ie.arch){let n=Ft(t,r);return xe.extname(n).toLowerCase()!==".jar"&&(n=r==="win32"?"clojure-lsp.exe":"clojure-lsp"),xe.join(e,n)}function St(e){return xe.join(e,Gi)}function sn(e){let t=St(e);try{return on.readFileSync(t,"utf8")}catch(r){return h.error("Could not read clojure-lsp version file.",r.message),""}}async function Yi(e){let t=new un.URL(e);return new Promise((r,n)=>{Lt.https.get({host:t.hostname,path:t.pathname,port:t.port,headers:{"user-agent":"node.js"}},i=>{let o="";i.on("data",s=>{o+=s}),i.on("end",()=>{r(o)})}).on("error",i=>{h.error(`Error downloading file from ${t}: ${i.message}`),n(i)})})}async function Ki(){try{let e=await Yi("https://api.github.com/repos/clojure-lsp/clojure-lsp/releases/latest");return JSON.parse(e).tag_name}catch(e){return h.error("Error while finding latest clojure-lsp version.",e.message),""}}function Xi(e){let t=k.default.join(k.default.dirname(e),"backup"),r=k.default.join(t,k.default.basename(e));try{_.default.existsSync(t)||_.default.mkdirSync(t),h.info("Backing up existing clojure-lsp to",r),_.default.renameSync(e,r)}catch(n){h.error("Error while backing up existing clojure-lsp file.",n.message)}return r}function Zi(e,t){h.info("Downloading clojure-lsp from",e);let r=_t.window.createStatusBarItem(0,{progress:!0});return r.show(),new Promise((n,i)=>{Lt.https.get(e,o=>{if(o.statusCode===200){let s=_.default.createWriteStream(t),c=0,f=Number(o.headers["content-length"]);o.on("data",u=>{c+=u.length;let a=(c/f*100).toFixed(2);r.text=`${a}% Downloading clojure-lsp`}).on("end",()=>{s.close(),r.hide(),h.info("Clojure-lsp artifact downloaded to",t),n()}).pipe(s)}else o.resume(),r.hide(),i(new Error(o.statusMessage))}).on("error",(...o)=>(r.hide(),i(...o)))})}function Qi(e,t){h.info("Writing version file");let r=St(e);try{_.default.writeFileSync(r,t)}catch(n){h.error("Could not write clojure-lsp version file.",n.message)}}async function eo(e,t){return h.info("Unzipping file"),(0,cn.default)(e,{dir:t})}async function to(e,t){let r=Ft(),n=t!=="nightly"?`https://github.com/clojure-lsp/clojure-lsp/releases/download/${t}/${r}`:`https://nightly.link/clojure-lsp/clojure-lsp/workflows/nightly/master/${r}`,i=k.default.join(e,r),o=Be(e),s=_.default.existsSync(o)?Xi(o):o;try{await Zi(n,i),k.default.extname(i)===".zip"&&await eo(i,e),k.default.extname(o)===""&&_.default.chmodSync(o,509),Qi(e,t)}catch(c){return h.error("Error downloading clojure-lsp.",c.message),s}return o}function ro(e){let{executable:t,lspInstallPath:r}=L();{let n=fn.default.sync(t,{nothrow:!0});if(n)return n}if(t.startsWith("~/")&&(t=t.replace("~",(0,Rt.homedir)())),(0,_.existsSync)(t)||(r!=null&&r.startsWith("~/")?r=r.replace("~",(0,Rt.homedir)()):r=e,t=Be(r),(0,_.existsSync)(t)))return t}async function an(e,t){let{lspVersion:r,lspInstallPath:n}=L(),i=sn(e),o=["","latest"].includes(r)?await Ki():r;if(i!==o&&o!==""&&await _t.window.showQuickpick(["Yes","No"],`clojure-lsp is ${t}. Download from Github?`)==0){let f=await to(n||e,o);return h.info(`Successfully downloaded clojure-lsp to ${f}`),f}}async function dn(e){let t=e.storagePath;(0,_.existsSync)(t)||(0,_.mkdirSync)(t);let r=ro(t);if(h.debug("existing clojure-lsp bin:",r),r){let n=Be(t);L().checkOnStart&&r===n&&(r=await an(t,"outdated")||r)}else r=await an(t,"not found");return r}var Ue=class{constructor(t){this.client=t}async provideSignatureHelp(t,r,n,i){return this.client.sendRequest("textDocument/signatureHelp",{textDocument:{uri:t.uri},position:r,context:i},n).catch(o=>this.client.handleFailedRequest({method:"textDocument/signatureHelp"},n,o,null))}};async function no(e){if(Pt(e),h.info("Starting up coc-clojure"),!L().enable)return;let t=null;L().startupMessage&&(t=J.window.createStatusBarItem(void 0,{progress:!0}),t.text="Loading clojure-lsp",t.show());let r=await dn(e);if(!r){h.error("No clojure-lsp installed"),t==null||t.dispose();return}let n=At(r);if(!n){h.error("clojure-lsp did not initialize"),t==null||t.dispose();return}e.subscriptions.push(J.services.registerLanguageClient(n)),e.subscriptions.push(J.languages.registerSignatureHelpProvider(ye,new Ue(n),["("," "])),$t(e,n),await n.onReady(),L().startupMessage&&(t==null||t.dispose(),J.window.showInformationMessage("clojure-lsp loaded!"))}0&&(module.exports={activate}); diff --git a/src/config.ts b/src/config.ts index 0e23b59..898028c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -4,7 +4,6 @@ import { workspace } from "coc.nvim"; import { homedir } from "os"; -import { logger } from "./logger"; import { Dictionary } from "./types"; export const documentSelector = [ diff --git a/src/index.ts b/src/index.ts index a24f358..8283b73 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,7 @@ export async function activate(context: ExtensionContext): Promise { return; } - context.subscriptions.push(services.registLanguageClient(client)); + context.subscriptions.push(services.registerLanguageClient(client)); context.subscriptions.push( languages.registerSignatureHelpProvider(