9remote 0.1.55 ā 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.js +1 -7
- package/dist/cli.cjs +12 -12
- package/lib/socketio.js +84 -0
- package/package.json +3 -2
package/cli/index.js
CHANGED
|
@@ -830,13 +830,7 @@ async function startUiMode() {
|
|
|
830
830
|
|
|
831
831
|
if (!alreadyRunning) await new Promise(resolve => setTimeout(resolve, 2000));
|
|
832
832
|
|
|
833
|
-
|
|
834
|
-
const url = `http://localhost:${SERVER_PORT}`;
|
|
835
|
-
const openCmd = process.platform === "darwin" ? "open"
|
|
836
|
-
: process.platform === "win32" ? "start"
|
|
837
|
-
: "xdg-open";
|
|
838
|
-
spawn(openCmd, [url], { detached: true, stdio: "ignore" }).unref();
|
|
839
|
-
console.log(chalk.green(`\nš UI ready at ${url}`));
|
|
833
|
+
console.log(chalk.green(`\nš UI ready at http://localhost:${SERVER_PORT}`));
|
|
840
834
|
|
|
841
835
|
// Mutable ref for active tunnel
|
|
842
836
|
let activeTunnel = null;
|
package/dist/cli.cjs
CHANGED
|
@@ -4,12 +4,12 @@ var zn=Object.create;var Dt=Object.defineProperty;var Zn=Object.getOwnPropertyDe
|
|
|
4
4
|
`;for(var h=0;h<a;h+=2){e+=u.WHITE_ALL;for(var p=0;p<a;p++)c[h][p]===s&&c[h+1][p]===s?e+=u.WHITE_ALL:c[h][p]===s&&c[h+1][p]===i?e+=u.WHITE_BLACK:c[h][p]===i&&c[h+1][p]===s?e+=u.BLACK_WHITE:e+=u.BLACK_ALL;e+=u.WHITE_ALL+`
|
|
5
5
|
`}l||(e+=d)}else{var g=gt(Je).times(o.getModuleCount()+3);e+=g+`
|
|
6
6
|
`,o.modules.forEach(function(T){e+=Je,e+=T.map(xr).join(""),e+=Je+`
|
|
7
|
-
`}),e+=g}t?t(e):console.log(e)},setErrorLevel:function(r){this.error=vn[r]||this.error}}});var En=Y((Le,yt)=>{(function(r,n){typeof Le=="object"&&typeof yt=="object"?yt.exports=n(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],n):typeof Le=="object"?Le["electron-machine-id"]=n(require("child_process"),require("crypto")):r["electron-machine-id"]=n(r.child_process,r.crypto)})(Le,function(r,n){return(function(t){function o(i){if(e[i])return e[i].exports;var s=e[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var e={};return o.m=t,o.c=e,o.p="",o(0)})([function(t,o,e){t.exports=e(34)},function(t,o,e){var i=e(29)("wks"),s=e(33),a=e(2).Symbol,c=typeof a=="function",l=t.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(t,o){var e=t.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=e)},function(t,o,e){var i=e(9);t.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(t,o,e){t.exports=!e(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(t,o,e){var i=e(12),s=e(17);t.exports=e(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(t,o){var e=t.exports={version:"2.4.0"};typeof __e=="number"&&(__e=e)},function(t,o,e){var i=e(14);t.exports=function(s,a,c){if(i(s),a===void 0)return s;switch(c){case 1:return function(l){return s.call(a,l)};case 2:return function(l,u){return s.call(a,l,u)};case 3:return function(l,u,f){return s.call(a,l,u,f)}}return function(){return s.apply(a,arguments)}}},function(t,o){var e={}.hasOwnProperty;t.exports=function(i,s){return e.call(i,s)}},function(t,o){t.exports=function(e){return typeof e=="object"?e!==null:typeof e=="function"}},function(t,o){t.exports={}},function(t,o){var e={}.toString;t.exports=function(i){return e.call(i).slice(8,-1)}},function(t,o,e){var i=e(3),s=e(26),a=e(32),c=Object.defineProperty;o.f=e(4)?Object.defineProperty:function(l,u,f){if(i(l),u=a(u,!0),i(f),s)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(t,o,e){var i=e(42),s=e(15);t.exports=function(a){return i(s(a))}},function(t,o){t.exports=function(e){if(typeof e!="function")throw TypeError(e+" is not a function!");return e}},function(t,o){t.exports=function(e){if(e==null)throw TypeError("Can't call method on "+e);return e}},function(t,o,e){var i=e(9),s=e(2).document,a=i(s)&&i(s.createElement);t.exports=function(c){return a?s.createElement(c):{}}},function(t,o){t.exports=function(e,i){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:i}}},function(t,o,e){var i=e(12).f,s=e(8),a=e(1)("toStringTag");t.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(t,o,e){var i=e(29)("keys"),s=e(33);t.exports=function(a){return i[a]||(i[a]=s(a))}},function(t,o){var e=Math.ceil,i=Math.floor;t.exports=function(s){return isNaN(s=+s)?0:(s>0?i:e)(s)}},function(t,o,e){var i=e(11),s=e(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};t.exports=function(l){var u,f,d;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(d=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":d}},function(t,o){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,o,e){var i=e(2),s=e(6),a=e(7),c=e(5),l="prototype",u=function(f,d,h){var p,g,T,k=f&u.F,_=f&u.G,x=f&u.S,b=f&u.P,A=f&u.B,w=f&u.W,R=_?s:s[d]||(s[d]={}),O=R[l],L=_?i:x?i[d]:(i[d]||{})[l];_&&(h=d);for(p in h)g=!k&&L&&L[p]!==void 0,g&&p in R||(T=g?L[p]:h[p],R[p]=_&&typeof L[p]!="function"?h[p]:A&&g?a(T,i):w&&L[p]==T?(function(F){var X=function(z,G,ie){if(this instanceof F){switch(arguments.length){case 0:return new F;case 1:return new F(z);case 2:return new F(z,G)}return new F(z,G,ie)}return F.apply(this,arguments)};return X[l]=F[l],X})(T):b&&typeof T=="function"?a(Function.call,T):T,b&&((R.virtual||(R.virtual={}))[p]=T,f&u.R&&O&&!O[p]&&c(O,p,T)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,o){t.exports=function(e){try{return!!e()}catch{return!0}}},function(t,o,e){t.exports=e(2).document&&document.documentElement},function(t,o,e){t.exports=!e(4)&&!e(24)(function(){return Object.defineProperty(e(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,o,e){"use strict";var i=e(28),s=e(23),a=e(57),c=e(5),l=e(8),u=e(10),f=e(45),d=e(18),h=e(52),p=e(1)("iterator"),g=!([].keys&&"next"in[].keys()),T="@@iterator",k="keys",_="values",x=function(){return this};t.exports=function(b,A,w,R,O,L,F){f(w,A,R);var X,z,G,ie=function(y){if(!g&&y in H)return H[y];switch(y){case k:return function(){return new w(this,y)};case _:return function(){return new w(this,y)}}return function(){return new w(this,y)}},
|
|
8
|
-
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return x.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(x){var b=c((0,h.execSync)(_[T]).toString());return x?b:a(b)}function u(x){return new d.default(function(b,A){return(0,h.exec)(_[T],{},function(w,R,O){if(w)return A(new Error("Error while obtaining machine id: "+w.stack));var L=c(R.toString());return b(x?L:a(L))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=e(35),d=i(f);o.machineIdSync=l,o.machineId=u;var h=e(70),p=e(71),g=process,T=g.platform,k={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},_={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:k[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(t,o,e){t.exports={default:e(36),__esModule:!0}},function(t,o,e){e(66),e(68),e(69),e(67),t.exports=e(6).Promise},function(t,o){t.exports=function(){}},function(t,o){t.exports=function(e,i,s,a){if(!(e instanceof i)||a!==void 0&&a in e)throw TypeError(s+": incorrect invocation!");return e}},function(t,o,e){var i=e(13),s=e(31),a=e(62);t.exports=function(c){return function(l,u,f){var d,h=i(l),p=s(h.length),g=a(f,p);if(c&&u!=u){for(;p>g;)if(d=h[g++],d!=d)return!0}else for(;p>g;g++)if((c||g in h)&&h[g]===u)return c||g||0;return!c&&-1}}},function(t,h,e){var i=e(7),s=e(44),a=e(43),c=e(3),l=e(31),u=e(64),f={},d={},h=t.exports=function(p,g,T,k,_){var x,b,A,w,R=_?function(){return p}:u(p),O=i(T,k,g?2:1),L=0;if(typeof R!="function")throw TypeError(p+" is not iterable!");if(a(R)){for(x=l(p.length);x>L;L++)if(w=g?O(c(b=p[L])[0],b[1]):O(p[L]),w===f||w===d)return w}else for(A=R.call(p);!(b=A.next()).done;)if(w=s(A,O,b.value,g),w===f||w===d)return w};h.BREAK=f,h.RETURN=d},function(t,o){t.exports=function(e,i,s){var a=s===void 0;switch(i.length){case 0:return a?e():e.call(s);case 1:return a?e(i[0]):e.call(s,i[0]);case 2:return a?e(i[0],i[1]):e.call(s,i[0],i[1]);case 3:return a?e(i[0],i[1],i[2]):e.call(s,i[0],i[1],i[2]);case 4:return a?e(i[0],i[1],i[2],i[3]):e.call(s,i[0],i[1],i[2],i[3])}return e.apply(s,i)}},function(t,o,e){var i=e(11);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(t,o,e){var i=e(10),s=e(1)("iterator"),a=Array.prototype;t.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(t,o,e){var i=e(3);t.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(t,o,e){"use strict";var i=e(49),s=e(17),a=e(18),c={};e(5)(c,e(1)("iterator"),function(){return this}),t.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(t,o,e){var i=e(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}t.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],d=f[i]();d.next=function(){return{done:u=!0}},f[i]=function(){return d},c(f)}catch{}return u}},function(t,o){t.exports=function(e,i){return{value:i,done:!!e}}},function(t,o,e){var i=e(2),s=e(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=e(11)(c)=="process";t.exports=function(){var f,d,h,p=function(){var _,x;for(u&&(_=c.domain)&&_.exit();f;){x=f.fn,f=f.next;try{x()}catch(b){throw f?h():d=void 0,b}}d=void 0,_&&_.enter()};if(u)h=function(){c.nextTick(p)};else if(a){var g=!0,T=document.createTextNode("");new a(p).observe(T,{characterData:!0}),h=function(){T.data=g=!g}}else if(l&&l.resolve){var k=l.resolve();h=function(){k.then(p)}}else h=function(){s.call(i,p)};return function(_){var x={fn:_,next:void 0};d&&(d.next=x),f||(f=x,h()),d=x}}},function(t,o,e){var i=e(3),s=e(50),a=e(22),c=e(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var d,h=e(16)("iframe"),p=a.length,g=">";for(h.style.display="none",e(25).appendChild(h),h.src="javascript:",d=h.contentWindow.document,d.open(),d.write("<script>document.F=Object</script"+g),d.close(),f=d.F;p--;)delete f[u][a[p]];return f()};t.exports=Object.create||function(d,h){var p;return d!==null?(l[u]=i(d),p=new l,l[u]=null,p[c]=d):p=f(),h===void 0?p:s(p,h)}},function(t,o,e){var i=e(12),s=e(3),a=e(54);t.exports=e(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),d=f.length,h=0;d>h;)i.f(c,u=f[h++],l[u]);return c}},function(t,o,e){var i=e(55),s=e(17),a=e(13),c=e(32),l=e(8),u=e(26),f=Object.getOwnPropertyDescriptor;o.f=e(4)?f:function(d,h){if(d=a(d),h=c(h,!0),u)try{return f(d,h)}catch{}if(l(d,h))return s(!i.f.call(d,h),d[h])}},function(t,o,e){var i=e(8),s=e(63),a=e(19)("IE_PROTO"),c=Object.prototype;t.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(t,o,e){var i=e(8),s=e(13),a=e(39)(!1),c=e(19)("IE_PROTO");t.exports=function(l,u){var f,d=s(l),h=0,p=[];for(f in d)f!=c&&i(d,f)&&p.push(f);for(;u.length>h;)i(d,f=u[h++])&&(~a(p,f)||p.push(f));return p}},function(t,o,e){var i=e(53),s=e(22);t.exports=Object.keys||function(a){return i(a,s)}},function(t,o){o.f={}.propertyIsEnumerable},function(t,o,e){var i=e(5);t.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(t,o,e){t.exports=e(5)},function(t,o,e){var i=e(9),s=e(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=e(7)(Function.call,e(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,d){return a(f,d),l?f.__proto__=d:u(f,d),f}})({},!1):void 0),check:a}},function(t,o,e){"use strict";var i=e(2),s=e(6),a=e(12),c=e(4),l=e(1)("species");t.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(t,o,e){var i=e(3),s=e(14),a=e(1)("species");t.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(t,o,e){var i=e(20),s=e(15);t.exports=function(a){return function(c,l){var u,f,d=String(s(c)),h=i(l),p=d.length;return h<0||h>=p?a?"":void 0:(u=d.charCodeAt(h),u<55296||u>56319||h+1===p||(f=d.charCodeAt(h+1))<56320||f>57343?a?d.charAt(h):u:a?d.slice(h,h+2):(u-55296<<10)+(f-56320)+65536)}}},function(t,o,e){var i=e(20),s=Math.max,a=Math.min;t.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(t,o,e){var i=e(15);t.exports=function(s){return Object(i(s))}},function(t,o,e){var i=e(21),s=e(1)("iterator"),a=e(10);t.exports=e(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(t,o,e){"use strict";var i=e(37),s=e(47),a=e(10),c=e(13);t.exports=e(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(t,o){},function(t,o,e){"use strict";var i,s,a,c=e(28),l=e(2),u=e(7),f=e(21),d=e(23),h=e(9),p=(e(3),e(14)),g=e(38),T=e(40),k=(e(58).set,e(60)),_=e(30).set,x=e(48)(),b="Promise",A=l.TypeError,R=l.process,w=l[b],R=l.process,O=f(R)=="process",L=function(){},F=!!(function(){try{var m=w.resolve(1),y=(m.constructor={})[e(1)("species")]=function(E){E(L,L)};return(O||typeof PromiseRejectionEvent=="function")&&m.then(L)instanceof y}catch{}})(),X=function(m,y){return m===y||m===w&&y===a},z=function(m){var y;return!(!h(m)||typeof(y=m.then)!="function")&&y},G=function(m){return X(w,m)?new ie(m):new s(m)},ie=s=function(m){var y,E;this.promise=new m(function(P,K){if(y!==void 0||E!==void 0)throw A("Bad Promise constructor");y=P,E=K}),this.resolve=p(y),this.reject=p(E)},ve=function(m){try{m()}catch(y){return{error:y}}},ue=function(m,y){if(!m._n){m._n=!0;var E=m._c;x(function(){for(var P=m._v,K=m._s==1,fe=0,we=function(ae){var ne,Ke,Pe=K?ae.ok:ae.fail,Ce=ae.resolve,Te=ae.reject,Ge=ae.domain;try{Pe?(K||(m._h==2&&se(m),m._h=1),Pe===!0?ne=P:(Ge&&Ge.enter(),ne=Pe(P),Ge&&Ge.exit()),ne===ae.promise?Te(A("Promise-chain cycle")):(Ke=z(ne))?Ke.call(ne,Ce,Te):Ce(ne)):Te(P)}catch(Xn){Te(Xn)}};E.length>fe;)we(E[fe++]);m._c=[],m._n=!1,y&&!m._h&&Ae(m)})}},Ae=function(m){_.call(l,function(){var y,E,P,K=m._v;if(H(m)&&(y=ve(function(){O?R.emit("unhandledRejection",K,m):(E=l.onunhandledrejection)?E({promise:m,reason:K}):(P=l.console)&&P.error&&P.error("Unhandled promise rejection",K)}),m._h=O||H(m)?2:1),m._a=void 0,y)throw y.error})},H=function(m){if(m._h==1)return!1;for(var y,E=m._a||m._c,P=0;E.length>P;)if(y=E[P++],y.fail||!H(y.promise))return!1;return!0},se=function(m){_.call(l,function(){var y;O?R.emit("rejectionHandled",m):(y=l.onrejectionhandled)&&y({promise:m,reason:m._v})})},W=function(m){var y=this;y._d||(y._d=!0,y=y._w||y,y._v=m,y._s=2,y._a||(y._a=y._c.slice()),ue(y,!0))},Oe=function(m){var y,E=this;if(!E._d){E._d=!0,E=E._w||E;try{if(E===m)throw A("Promise can't be resolved itself");(y=z(m))?x(function(){var P={_w:E,_d:!1};try{y.call(m,u(Oe,P,1),u(W,P,1))}catch(K){W.call(P,K)}}):(E._v=m,E._s=1,ue(E,!1))}catch(P){W.call({_w:E,_d:!1},P)}}};F||(w=function(m){g(this,w,b,"_h"),p(m),i.call(this);try{m(u(Oe,this,1),u(W,this,1))}catch(y){W.call(this,y)}},i=function(m){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=e(56)(w.prototype,{then:function(m,y){var E=G(k(this,w));return E.ok=typeof m!="function"||m,E.fail=typeof y=="function"&&y,E.domain=O?R.domain:void 0,this._c.push(E),this._a&&this._a.push(E),this._s&&ue(this,!1),E.promise},catch:function(m){return this.then(void 0,m)}}),ie=function(){var m=new i;this.promise=m,this.resolve=u(Oe,m,1),this.reject=u(W,m,1)}),d(d.G+d.W+d.F*!F,{Promise:w}),e(18)(w,b),e(59)(b),a=e(6)[b],d(d.S+d.F*!F,b,{reject:function(m){var y=G(this),E=y.reject;return E(m),y.promise}}),d(d.S+d.F*(c||!F),b,{resolve:function(m){if(m instanceof w&&X(m.constructor,this))return m;var y=G(this),E=y.resolve;return E(m),y.promise}}),d(d.S+d.F*!(F&&e(46)(function(m){w.all(m).catch(L)})),b,{all:function(m){var y=this,E=G(y),P=E.resolve,K=E.reject,fe=ve(function(){var we=[],ae=0,ne=1;T(m,!1,function(Ke){var Pe=ae++,Ce=!1;we.push(void 0),ne++,y.resolve(Ke).then(function(Te){Ce||(Ce=!0,we[Pe]=Te,--ne||P(we))},K)}),--ne||P(we)});return fe&&K(fe.error),E.promise},race:function(m){var y=this,E=G(y),P=E.reject,K=ve(function(){T(m,!1,function(fe){y.resolve(fe).then(E.resolve,P)})});return K&&P(K.error),E.promise}})},function(t,o,e){"use strict";var i=e(61)(!0);e(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(t,o,e){e(65);for(var i=e(2),s=e(5),a=e(10),c=e(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],d=i[f],h=d&&d.prototype;h&&!h[c]&&s(h,c,f),a[f]=a.Array}},function(t,o){t.exports=require("child_process")},function(t,o){t.exports=require("crypto")}])})});var jt=(r=0)=>n=>`\x1B[${n+r}m`,Ut=(r=0)=>n=>`\x1B[${38+r};5;${n}m`,Ft=(r=0)=>(n,t,o)=>`\x1B[${38+r};2;${n};${t};${o}m`,C={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ao=Object.keys(C.modifier),or=Object.keys(C.color),ir=Object.keys(C.bgColor),co=[...or,...ir];function sr(){let r=new Map;for(let[n,t]of Object.entries(C)){for(let[o,e]of Object.entries(t))C[o]={open:`\x1B[${e[0]}m`,close:`\x1B[${e[1]}m`},t[o]=C[o],r.set(e[0],e[1]);Object.defineProperty(C,n,{value:t,enumerable:!1})}return Object.defineProperty(C,"codes",{value:r,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=jt(),C.color.ansi256=Ut(),C.color.ansi16m=Ft(),C.bgColor.ansi=jt(10),C.bgColor.ansi256=Ut(10),C.bgColor.ansi16m=Ft(10),Object.defineProperties(C,{rgbToAnsi256:{value(n,t,o){return n===t&&t===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(n){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!t)return[0,0,0];let[o]=t;o.length===3&&(o=[...o].map(i=>i+i).join(""));let e=Number.parseInt(o,16);return[e>>16&255,e>>8&255,e&255]},enumerable:!1},hexToAnsi256:{value:n=>C.rgbToAnsi256(...C.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let t,o,e;if(n>=232)t=((n-232)*10+8)/255,o=t,e=t;else{n-=16;let a=n%36;t=Math.floor(n/36)/5,o=Math.floor(a/6)/5,e=a%6/5}let i=Math.max(t,o,e)*2;if(i===0)return 30;let s=30+(Math.round(e)<<2|Math.round(o)<<1|Math.round(t));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(n,t,o)=>C.ansi256ToAnsi(C.rgbToAnsi256(n,t,o)),enumerable:!1},hexToAnsi:{value:n=>C.ansi256ToAnsi(C.hexToAnsi256(n)),enumerable:!1}}),C}var ar=sr(),Z=ar;var We=M(require("node:process"),1),Gt=M(require("node:os"),1),ct=M(require("node:tty"),1);function V(r,n=globalThis.Deno?globalThis.Deno.args:We.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",o=n.indexOf(t+r),e=n.indexOf("--");return o!==-1&&(e===-1||o<e)}var{env:I}=We.default,He;V("no-color")||V("no-colors")||V("color=false")||V("color=never")?He=0:(V("color")||V("colors")||V("color=true")||V("color=always"))&&(He=1);function cr(){if("FORCE_COLOR"in I)return I.FORCE_COLOR==="true"?1:I.FORCE_COLOR==="false"?0:I.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(I.FORCE_COLOR,10),3)}function lr(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function ur(r,{streamIsTTY:n,sniffFlags:t=!0}={}){let o=cr();o!==void 0&&(He=o);let e=t?He:o;if(e===0)return 0;if(t){if(V("color=16m")||V("color=full")||V("color=truecolor"))return 3;if(V("color=256"))return 2}if("TF_BUILD"in I&&"AGENT_NAME"in I)return 1;if(r&&!n&&e===void 0)return 0;let i=e||0;if(I.TERM==="dumb")return i;if(We.default.platform==="win32"){let s=Gt.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in I)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in I)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in I)||I.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in I)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(I.TEAMCITY_VERSION)?1:0;if(I.COLORTERM==="truecolor"||I.TERM==="xterm-kitty"||I.TERM==="xterm-ghostty"||I.TERM==="wezterm")return 3;if("TERM_PROGRAM"in I){let s=Number.parseInt((I.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(I.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(I.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(I.TERM)||"COLORTERM"in I?1:i}function Kt(r,n={}){let t=ur(r,{streamIsTTY:r&&r.isTTY,...n});return lr(t)}var fr={stdout:Kt({isTTY:ct.default.isatty(1)}),stderr:Kt({isTTY:ct.default.isatty(2)})},Ht=fr;function Wt(r,n,t){let o=r.indexOf(n);if(o===-1)return r;let e=n.length,i=0,s="";do s+=r.slice(i,o)+n+t,i=o+e,o=r.indexOf(n,i);while(o!==-1);return s+=r.slice(i),s}function Qt(r,n,t,o){let e=0,i="";do{let s=r[o-1]==="\r";i+=r.slice(e,s?o-1:o)+n+(s?`\r
|
|
7
|
+
`}),e+=g}t?t(e):console.log(e)},setErrorLevel:function(r){this.error=vn[r]||this.error}}});var En=Y((Le,yt)=>{(function(r,n){typeof Le=="object"&&typeof yt=="object"?yt.exports=n(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],n):typeof Le=="object"?Le["electron-machine-id"]=n(require("child_process"),require("crypto")):r["electron-machine-id"]=n(r.child_process,r.crypto)})(Le,function(r,n){return(function(t){function o(i){if(e[i])return e[i].exports;var s=e[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var e={};return o.m=t,o.c=e,o.p="",o(0)})([function(t,o,e){t.exports=e(34)},function(t,o,e){var i=e(29)("wks"),s=e(33),a=e(2).Symbol,c=typeof a=="function",l=t.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(t,o){var e=t.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=e)},function(t,o,e){var i=e(9);t.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(t,o,e){t.exports=!e(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(t,o,e){var i=e(12),s=e(17);t.exports=e(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(t,o){var e=t.exports={version:"2.4.0"};typeof __e=="number"&&(__e=e)},function(t,o,e){var i=e(14);t.exports=function(s,a,c){if(i(s),a===void 0)return s;switch(c){case 1:return function(l){return s.call(a,l)};case 2:return function(l,u){return s.call(a,l,u)};case 3:return function(l,u,f){return s.call(a,l,u,f)}}return function(){return s.apply(a,arguments)}}},function(t,o){var e={}.hasOwnProperty;t.exports=function(i,s){return e.call(i,s)}},function(t,o){t.exports=function(e){return typeof e=="object"?e!==null:typeof e=="function"}},function(t,o){t.exports={}},function(t,o){var e={}.toString;t.exports=function(i){return e.call(i).slice(8,-1)}},function(t,o,e){var i=e(3),s=e(26),a=e(32),c=Object.defineProperty;o.f=e(4)?Object.defineProperty:function(l,u,f){if(i(l),u=a(u,!0),i(f),s)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(t,o,e){var i=e(42),s=e(15);t.exports=function(a){return i(s(a))}},function(t,o){t.exports=function(e){if(typeof e!="function")throw TypeError(e+" is not a function!");return e}},function(t,o){t.exports=function(e){if(e==null)throw TypeError("Can't call method on "+e);return e}},function(t,o,e){var i=e(9),s=e(2).document,a=i(s)&&i(s.createElement);t.exports=function(c){return a?s.createElement(c):{}}},function(t,o){t.exports=function(e,i){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:i}}},function(t,o,e){var i=e(12).f,s=e(8),a=e(1)("toStringTag");t.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(t,o,e){var i=e(29)("keys"),s=e(33);t.exports=function(a){return i[a]||(i[a]=s(a))}},function(t,o){var e=Math.ceil,i=Math.floor;t.exports=function(s){return isNaN(s=+s)?0:(s>0?i:e)(s)}},function(t,o,e){var i=e(11),s=e(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};t.exports=function(l){var u,f,d;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(d=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":d}},function(t,o){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,o,e){var i=e(2),s=e(6),a=e(7),c=e(5),l="prototype",u=function(f,d,h){var p,g,T,k=f&u.F,_=f&u.G,x=f&u.S,b=f&u.P,A=f&u.B,w=f&u.W,R=_?s:s[d]||(s[d]={}),O=R[l],L=_?i:x?i[d]:(i[d]||{})[l];_&&(h=d);for(p in h)g=!k&&L&&L[p]!==void 0,g&&p in R||(T=g?L[p]:h[p],R[p]=_&&typeof L[p]!="function"?h[p]:A&&g?a(T,i):w&&L[p]==T?(function(F){var X=function(z,G,ie){if(this instanceof F){switch(arguments.length){case 0:return new F;case 1:return new F(z);case 2:return new F(z,G)}return new F(z,G,ie)}return F.apply(this,arguments)};return X[l]=F[l],X})(T):b&&typeof T=="function"?a(Function.call,T):T,b&&((R.virtual||(R.virtual={}))[p]=T,f&u.R&&O&&!O[p]&&c(O,p,T)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,o){t.exports=function(e){try{return!!e()}catch{return!0}}},function(t,o,e){t.exports=e(2).document&&document.documentElement},function(t,o,e){t.exports=!e(4)&&!e(24)(function(){return Object.defineProperty(e(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,o,e){"use strict";var i=e(28),s=e(23),a=e(57),c=e(5),l=e(8),u=e(10),f=e(45),d=e(18),h=e(52),p=e(1)("iterator"),g=!([].keys&&"next"in[].keys()),T="@@iterator",k="keys",_="values",x=function(){return this};t.exports=function(b,A,w,R,O,L,F){f(w,A,R);var X,z,G,ie=function(y){if(!g&&y in H)return H[y];switch(y){case k:return function(){return new w(this,y)};case _:return function(){return new w(this,y)}}return function(){return new w(this,y)}},ye=A+" Iterator",ue=O==_,Ae=!1,H=b.prototype,se=H[p]||H[T]||O&&H[O],W=se||ie(O),Oe=O?ue?ie("entries"):W:void 0,m=A=="Array"&&H.entries||se;if(m&&(G=h(m.call(new b)),G!==Object.prototype&&(d(G,ye,!0),i||l(G,p)||c(G,p,x))),ue&&se&&se.name!==_&&(Ae=!0,W=function(){return se.call(this)}),i&&!F||!g&&!Ae&&H[p]||c(H,p,W),u[A]=W,u[ye]=x,O)if(X={values:ue?W:ie(_),keys:L?W:ie(k),entries:Oe},F)for(z in X)z in H||a(H,z,X[z]);else s(s.P+s.F*(g||Ae),A,X);return X}},function(t,o){t.exports=!0},function(t,o,e){var i=e(2),s="__core-js_shared__",a=i[s]||(i[s]={});t.exports=function(c){return a[c]||(a[c]={})}},function(t,o,e){var i,s,a,c=e(7),l=e(41),u=e(25),f=e(16),d=e(2),h=d.process,p=d.setImmediate,g=d.clearImmediate,T=d.MessageChannel,k=0,_={},x="onreadystatechange",b=function(){var w=+this;if(_.hasOwnProperty(w)){var R=_[w];delete _[w],R()}},A=function(w){b.call(w.data)};p&&g||(p=function(w){for(var R=[],O=1;arguments.length>O;)R.push(arguments[O++]);return _[++k]=function(){l(typeof w=="function"?w:Function(w),R)},i(k),k},g=function(w){delete _[w]},e(11)(h)=="process"?i=function(w){h.nextTick(c(b,w,1))}:T?(s=new T,a=s.port2,s.port1.onmessage=A,i=c(a.postMessage,a,1)):d.addEventListener&&typeof postMessage=="function"&&!d.importScripts?(i=function(w){d.postMessage(w+"","*")},d.addEventListener("message",A,!1)):i=x in f("script")?function(w){u.appendChild(f("script"))[x]=function(){u.removeChild(this),b.call(w)}}:function(w){setTimeout(c(b,w,1),0)}),t.exports={set:p,clear:g}},function(t,o,e){var i=e(20),s=Math.min;t.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(t,o,e){var i=e(9);t.exports=function(s,a){if(!i(s))return s;var c,l;if(a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s))||typeof(c=s.valueOf)=="function"&&!i(l=c.call(s))||!a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s)))return l;throw TypeError("Can't convert object to primitive value")}},function(t,o){var e=0,i=Math.random();t.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++e+i).toString(36))}},function(t,o,e){"use strict";function i(x){return x&&x.__esModule?x:{default:x}}function s(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(x){return(0,p.createHash)("sha256").update(x).digest("hex")}function c(x){switch(T){case"darwin":return x.split("IOPlatformUUID")[1].split(`
|
|
8
|
+
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return x.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(x){var b=c((0,h.execSync)(_[T]).toString());return x?b:a(b)}function u(x){return new d.default(function(b,A){return(0,h.exec)(_[T],{},function(w,R,O){if(w)return A(new Error("Error while obtaining machine id: "+w.stack));var L=c(R.toString());return b(x?L:a(L))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=e(35),d=i(f);o.machineIdSync=l,o.machineId=u;var h=e(70),p=e(71),g=process,T=g.platform,k={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},_={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:k[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(t,o,e){t.exports={default:e(36),__esModule:!0}},function(t,o,e){e(66),e(68),e(69),e(67),t.exports=e(6).Promise},function(t,o){t.exports=function(){}},function(t,o){t.exports=function(e,i,s,a){if(!(e instanceof i)||a!==void 0&&a in e)throw TypeError(s+": incorrect invocation!");return e}},function(t,o,e){var i=e(13),s=e(31),a=e(62);t.exports=function(c){return function(l,u,f){var d,h=i(l),p=s(h.length),g=a(f,p);if(c&&u!=u){for(;p>g;)if(d=h[g++],d!=d)return!0}else for(;p>g;g++)if((c||g in h)&&h[g]===u)return c||g||0;return!c&&-1}}},function(t,h,e){var i=e(7),s=e(44),a=e(43),c=e(3),l=e(31),u=e(64),f={},d={},h=t.exports=function(p,g,T,k,_){var x,b,A,w,R=_?function(){return p}:u(p),O=i(T,k,g?2:1),L=0;if(typeof R!="function")throw TypeError(p+" is not iterable!");if(a(R)){for(x=l(p.length);x>L;L++)if(w=g?O(c(b=p[L])[0],b[1]):O(p[L]),w===f||w===d)return w}else for(A=R.call(p);!(b=A.next()).done;)if(w=s(A,O,b.value,g),w===f||w===d)return w};h.BREAK=f,h.RETURN=d},function(t,o){t.exports=function(e,i,s){var a=s===void 0;switch(i.length){case 0:return a?e():e.call(s);case 1:return a?e(i[0]):e.call(s,i[0]);case 2:return a?e(i[0],i[1]):e.call(s,i[0],i[1]);case 3:return a?e(i[0],i[1],i[2]):e.call(s,i[0],i[1],i[2]);case 4:return a?e(i[0],i[1],i[2],i[3]):e.call(s,i[0],i[1],i[2],i[3])}return e.apply(s,i)}},function(t,o,e){var i=e(11);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(t,o,e){var i=e(10),s=e(1)("iterator"),a=Array.prototype;t.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(t,o,e){var i=e(3);t.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(t,o,e){"use strict";var i=e(49),s=e(17),a=e(18),c={};e(5)(c,e(1)("iterator"),function(){return this}),t.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(t,o,e){var i=e(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}t.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],d=f[i]();d.next=function(){return{done:u=!0}},f[i]=function(){return d},c(f)}catch{}return u}},function(t,o){t.exports=function(e,i){return{value:i,done:!!e}}},function(t,o,e){var i=e(2),s=e(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=e(11)(c)=="process";t.exports=function(){var f,d,h,p=function(){var _,x;for(u&&(_=c.domain)&&_.exit();f;){x=f.fn,f=f.next;try{x()}catch(b){throw f?h():d=void 0,b}}d=void 0,_&&_.enter()};if(u)h=function(){c.nextTick(p)};else if(a){var g=!0,T=document.createTextNode("");new a(p).observe(T,{characterData:!0}),h=function(){T.data=g=!g}}else if(l&&l.resolve){var k=l.resolve();h=function(){k.then(p)}}else h=function(){s.call(i,p)};return function(_){var x={fn:_,next:void 0};d&&(d.next=x),f||(f=x,h()),d=x}}},function(t,o,e){var i=e(3),s=e(50),a=e(22),c=e(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var d,h=e(16)("iframe"),p=a.length,g=">";for(h.style.display="none",e(25).appendChild(h),h.src="javascript:",d=h.contentWindow.document,d.open(),d.write("<script>document.F=Object</script"+g),d.close(),f=d.F;p--;)delete f[u][a[p]];return f()};t.exports=Object.create||function(d,h){var p;return d!==null?(l[u]=i(d),p=new l,l[u]=null,p[c]=d):p=f(),h===void 0?p:s(p,h)}},function(t,o,e){var i=e(12),s=e(3),a=e(54);t.exports=e(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),d=f.length,h=0;d>h;)i.f(c,u=f[h++],l[u]);return c}},function(t,o,e){var i=e(55),s=e(17),a=e(13),c=e(32),l=e(8),u=e(26),f=Object.getOwnPropertyDescriptor;o.f=e(4)?f:function(d,h){if(d=a(d),h=c(h,!0),u)try{return f(d,h)}catch{}if(l(d,h))return s(!i.f.call(d,h),d[h])}},function(t,o,e){var i=e(8),s=e(63),a=e(19)("IE_PROTO"),c=Object.prototype;t.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(t,o,e){var i=e(8),s=e(13),a=e(39)(!1),c=e(19)("IE_PROTO");t.exports=function(l,u){var f,d=s(l),h=0,p=[];for(f in d)f!=c&&i(d,f)&&p.push(f);for(;u.length>h;)i(d,f=u[h++])&&(~a(p,f)||p.push(f));return p}},function(t,o,e){var i=e(53),s=e(22);t.exports=Object.keys||function(a){return i(a,s)}},function(t,o){o.f={}.propertyIsEnumerable},function(t,o,e){var i=e(5);t.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(t,o,e){t.exports=e(5)},function(t,o,e){var i=e(9),s=e(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=e(7)(Function.call,e(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,d){return a(f,d),l?f.__proto__=d:u(f,d),f}})({},!1):void 0),check:a}},function(t,o,e){"use strict";var i=e(2),s=e(6),a=e(12),c=e(4),l=e(1)("species");t.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(t,o,e){var i=e(3),s=e(14),a=e(1)("species");t.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(t,o,e){var i=e(20),s=e(15);t.exports=function(a){return function(c,l){var u,f,d=String(s(c)),h=i(l),p=d.length;return h<0||h>=p?a?"":void 0:(u=d.charCodeAt(h),u<55296||u>56319||h+1===p||(f=d.charCodeAt(h+1))<56320||f>57343?a?d.charAt(h):u:a?d.slice(h,h+2):(u-55296<<10)+(f-56320)+65536)}}},function(t,o,e){var i=e(20),s=Math.max,a=Math.min;t.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(t,o,e){var i=e(15);t.exports=function(s){return Object(i(s))}},function(t,o,e){var i=e(21),s=e(1)("iterator"),a=e(10);t.exports=e(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(t,o,e){"use strict";var i=e(37),s=e(47),a=e(10),c=e(13);t.exports=e(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(t,o){},function(t,o,e){"use strict";var i,s,a,c=e(28),l=e(2),u=e(7),f=e(21),d=e(23),h=e(9),p=(e(3),e(14)),g=e(38),T=e(40),k=(e(58).set,e(60)),_=e(30).set,x=e(48)(),b="Promise",A=l.TypeError,R=l.process,w=l[b],R=l.process,O=f(R)=="process",L=function(){},F=!!(function(){try{var m=w.resolve(1),y=(m.constructor={})[e(1)("species")]=function(E){E(L,L)};return(O||typeof PromiseRejectionEvent=="function")&&m.then(L)instanceof y}catch{}})(),X=function(m,y){return m===y||m===w&&y===a},z=function(m){var y;return!(!h(m)||typeof(y=m.then)!="function")&&y},G=function(m){return X(w,m)?new ie(m):new s(m)},ie=s=function(m){var y,E;this.promise=new m(function(P,K){if(y!==void 0||E!==void 0)throw A("Bad Promise constructor");y=P,E=K}),this.resolve=p(y),this.reject=p(E)},ye=function(m){try{m()}catch(y){return{error:y}}},ue=function(m,y){if(!m._n){m._n=!0;var E=m._c;x(function(){for(var P=m._v,K=m._s==1,fe=0,ve=function(ae){var ne,Ke,Pe=K?ae.ok:ae.fail,Ce=ae.resolve,we=ae.reject,Ge=ae.domain;try{Pe?(K||(m._h==2&&se(m),m._h=1),Pe===!0?ne=P:(Ge&&Ge.enter(),ne=Pe(P),Ge&&Ge.exit()),ne===ae.promise?we(A("Promise-chain cycle")):(Ke=z(ne))?Ke.call(ne,Ce,we):Ce(ne)):we(P)}catch(Xn){we(Xn)}};E.length>fe;)ve(E[fe++]);m._c=[],m._n=!1,y&&!m._h&&Ae(m)})}},Ae=function(m){_.call(l,function(){var y,E,P,K=m._v;if(H(m)&&(y=ye(function(){O?R.emit("unhandledRejection",K,m):(E=l.onunhandledrejection)?E({promise:m,reason:K}):(P=l.console)&&P.error&&P.error("Unhandled promise rejection",K)}),m._h=O||H(m)?2:1),m._a=void 0,y)throw y.error})},H=function(m){if(m._h==1)return!1;for(var y,E=m._a||m._c,P=0;E.length>P;)if(y=E[P++],y.fail||!H(y.promise))return!1;return!0},se=function(m){_.call(l,function(){var y;O?R.emit("rejectionHandled",m):(y=l.onrejectionhandled)&&y({promise:m,reason:m._v})})},W=function(m){var y=this;y._d||(y._d=!0,y=y._w||y,y._v=m,y._s=2,y._a||(y._a=y._c.slice()),ue(y,!0))},Oe=function(m){var y,E=this;if(!E._d){E._d=!0,E=E._w||E;try{if(E===m)throw A("Promise can't be resolved itself");(y=z(m))?x(function(){var P={_w:E,_d:!1};try{y.call(m,u(Oe,P,1),u(W,P,1))}catch(K){W.call(P,K)}}):(E._v=m,E._s=1,ue(E,!1))}catch(P){W.call({_w:E,_d:!1},P)}}};F||(w=function(m){g(this,w,b,"_h"),p(m),i.call(this);try{m(u(Oe,this,1),u(W,this,1))}catch(y){W.call(this,y)}},i=function(m){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=e(56)(w.prototype,{then:function(m,y){var E=G(k(this,w));return E.ok=typeof m!="function"||m,E.fail=typeof y=="function"&&y,E.domain=O?R.domain:void 0,this._c.push(E),this._a&&this._a.push(E),this._s&&ue(this,!1),E.promise},catch:function(m){return this.then(void 0,m)}}),ie=function(){var m=new i;this.promise=m,this.resolve=u(Oe,m,1),this.reject=u(W,m,1)}),d(d.G+d.W+d.F*!F,{Promise:w}),e(18)(w,b),e(59)(b),a=e(6)[b],d(d.S+d.F*!F,b,{reject:function(m){var y=G(this),E=y.reject;return E(m),y.promise}}),d(d.S+d.F*(c||!F),b,{resolve:function(m){if(m instanceof w&&X(m.constructor,this))return m;var y=G(this),E=y.resolve;return E(m),y.promise}}),d(d.S+d.F*!(F&&e(46)(function(m){w.all(m).catch(L)})),b,{all:function(m){var y=this,E=G(y),P=E.resolve,K=E.reject,fe=ye(function(){var ve=[],ae=0,ne=1;T(m,!1,function(Ke){var Pe=ae++,Ce=!1;ve.push(void 0),ne++,y.resolve(Ke).then(function(we){Ce||(Ce=!0,ve[Pe]=we,--ne||P(ve))},K)}),--ne||P(ve)});return fe&&K(fe.error),E.promise},race:function(m){var y=this,E=G(y),P=E.reject,K=ye(function(){T(m,!1,function(fe){y.resolve(fe).then(E.resolve,P)})});return K&&P(K.error),E.promise}})},function(t,o,e){"use strict";var i=e(61)(!0);e(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(t,o,e){e(65);for(var i=e(2),s=e(5),a=e(10),c=e(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],d=i[f],h=d&&d.prototype;h&&!h[c]&&s(h,c,f),a[f]=a.Array}},function(t,o){t.exports=require("child_process")},function(t,o){t.exports=require("crypto")}])})});var jt=(r=0)=>n=>`\x1B[${n+r}m`,Ut=(r=0)=>n=>`\x1B[${38+r};5;${n}m`,Ft=(r=0)=>(n,t,o)=>`\x1B[${38+r};2;${n};${t};${o}m`,C={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ao=Object.keys(C.modifier),or=Object.keys(C.color),ir=Object.keys(C.bgColor),co=[...or,...ir];function sr(){let r=new Map;for(let[n,t]of Object.entries(C)){for(let[o,e]of Object.entries(t))C[o]={open:`\x1B[${e[0]}m`,close:`\x1B[${e[1]}m`},t[o]=C[o],r.set(e[0],e[1]);Object.defineProperty(C,n,{value:t,enumerable:!1})}return Object.defineProperty(C,"codes",{value:r,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=jt(),C.color.ansi256=Ut(),C.color.ansi16m=Ft(),C.bgColor.ansi=jt(10),C.bgColor.ansi256=Ut(10),C.bgColor.ansi16m=Ft(10),Object.defineProperties(C,{rgbToAnsi256:{value(n,t,o){return n===t&&t===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(n){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!t)return[0,0,0];let[o]=t;o.length===3&&(o=[...o].map(i=>i+i).join(""));let e=Number.parseInt(o,16);return[e>>16&255,e>>8&255,e&255]},enumerable:!1},hexToAnsi256:{value:n=>C.rgbToAnsi256(...C.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let t,o,e;if(n>=232)t=((n-232)*10+8)/255,o=t,e=t;else{n-=16;let a=n%36;t=Math.floor(n/36)/5,o=Math.floor(a/6)/5,e=a%6/5}let i=Math.max(t,o,e)*2;if(i===0)return 30;let s=30+(Math.round(e)<<2|Math.round(o)<<1|Math.round(t));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(n,t,o)=>C.ansi256ToAnsi(C.rgbToAnsi256(n,t,o)),enumerable:!1},hexToAnsi:{value:n=>C.ansi256ToAnsi(C.hexToAnsi256(n)),enumerable:!1}}),C}var ar=sr(),Z=ar;var We=M(require("node:process"),1),Gt=M(require("node:os"),1),ct=M(require("node:tty"),1);function V(r,n=globalThis.Deno?globalThis.Deno.args:We.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",o=n.indexOf(t+r),e=n.indexOf("--");return o!==-1&&(e===-1||o<e)}var{env:I}=We.default,He;V("no-color")||V("no-colors")||V("color=false")||V("color=never")?He=0:(V("color")||V("colors")||V("color=true")||V("color=always"))&&(He=1);function cr(){if("FORCE_COLOR"in I)return I.FORCE_COLOR==="true"?1:I.FORCE_COLOR==="false"?0:I.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(I.FORCE_COLOR,10),3)}function lr(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function ur(r,{streamIsTTY:n,sniffFlags:t=!0}={}){let o=cr();o!==void 0&&(He=o);let e=t?He:o;if(e===0)return 0;if(t){if(V("color=16m")||V("color=full")||V("color=truecolor"))return 3;if(V("color=256"))return 2}if("TF_BUILD"in I&&"AGENT_NAME"in I)return 1;if(r&&!n&&e===void 0)return 0;let i=e||0;if(I.TERM==="dumb")return i;if(We.default.platform==="win32"){let s=Gt.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in I)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in I)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in I)||I.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in I)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(I.TEAMCITY_VERSION)?1:0;if(I.COLORTERM==="truecolor"||I.TERM==="xterm-kitty"||I.TERM==="xterm-ghostty"||I.TERM==="wezterm")return 3;if("TERM_PROGRAM"in I){let s=Number.parseInt((I.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(I.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(I.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(I.TERM)||"COLORTERM"in I?1:i}function Kt(r,n={}){let t=ur(r,{streamIsTTY:r&&r.isTTY,...n});return lr(t)}var fr={stdout:Kt({isTTY:ct.default.isatty(1)}),stderr:Kt({isTTY:ct.default.isatty(2)})},Ht=fr;function Wt(r,n,t){let o=r.indexOf(n);if(o===-1)return r;let e=n.length,i=0,s="";do s+=r.slice(i,o)+n+t,i=o+e,o=r.indexOf(n,i);while(o!==-1);return s+=r.slice(i),s}function Qt(r,n,t,o){let e=0,i="";do{let s=r[o-1]==="\r";i+=r.slice(e,s?o-1:o)+n+(s?`\r
|
|
9
9
|
`:`
|
|
10
10
|
`)+t,e=o+1,o=r.indexOf(`
|
|
11
|
-
`,e)}while(o!==-1);return i+=r.slice(e),i}var{stdout:Yt,stderr:Vt}=Ht,lt=Symbol("GENERATOR"),
|
|
12
|
-
`);return i!==-1&&(n=Qt(n,e,o,i)),o+n+e};Object.defineProperties(Me.prototype,
|
|
11
|
+
`,e)}while(o!==-1);return i+=r.slice(e),i}var{stdout:Yt,stderr:Vt}=Ht,lt=Symbol("GENERATOR"),Te=Symbol("STYLER"),Ie=Symbol("IS_EMPTY"),Jt=["ansi","ansi","ansi256","ansi16m"],Ee=Object.create(null),pr=(r,n={})=>{if(n.level&&!(Number.isInteger(n.level)&&n.level>=0&&n.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Yt?Yt.level:0;r.level=n.level===void 0?t:n.level};var dr=r=>{let n=(...t)=>t.join(" ");return pr(n,r),Object.setPrototypeOf(n,Me.prototype),n};function Me(r){return dr(r)}Object.setPrototypeOf(Me.prototype,Function.prototype);for(let[r,n]of Object.entries(Z))Ee[r]={get(){let t=Qe(this,ft(n.open,n.close,this[Te]),this[Ie]);return Object.defineProperty(this,r,{value:t}),t}};Ee.visible={get(){let r=Qe(this,this[Te],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var ut=(r,n,t,...o)=>r==="rgb"?n==="ansi16m"?Z[t].ansi16m(...o):n==="ansi256"?Z[t].ansi256(Z.rgbToAnsi256(...o)):Z[t].ansi(Z.rgbToAnsi(...o)):r==="hex"?ut("rgb",n,t,...Z.hexToRgb(...o)):Z[t][r](...o),hr=["rgb","hex","ansi256"];for(let r of hr){Ee[r]={get(){let{level:t}=this;return function(...o){let e=ft(ut(r,Jt[t],"color",...o),Z.color.close,this[Te]);return Qe(this,e,this[Ie])}}};let n="bg"+r[0].toUpperCase()+r.slice(1);Ee[n]={get(){let{level:t}=this;return function(...o){let e=ft(ut(r,Jt[t],"bgColor",...o),Z.bgColor.close,this[Te]);return Qe(this,e,this[Ie])}}}}var mr=Object.defineProperties(()=>{},{...Ee,level:{enumerable:!0,get(){return this[lt].level},set(r){this[lt].level=r}}}),ft=(r,n,t)=>{let o,e;return t===void 0?(o=r,e=n):(o=t.openAll+r,e=n+t.closeAll),{open:r,close:n,openAll:o,closeAll:e,parent:t}},Qe=(r,n,t)=>{let o=(...e)=>gr(o,e.length===1?""+e[0]:e.join(" "));return Object.setPrototypeOf(o,mr),o[lt]=r,o[Te]=n,o[Ie]=t,o},gr=(r,n)=>{if(r.level<=0||!n)return r[Ie]?"":n;let t=r[Te];if(t===void 0)return n;let{openAll:o,closeAll:e}=t;if(n.includes("\x1B"))for(;t!==void 0;)n=Wt(n,t.close,t.open),t=t.parent;let i=n.indexOf(`
|
|
12
|
+
`);return i!==-1&&(n=Qt(n,e,o,i)),o+n+e};Object.defineProperties(Me.prototype,Ee);var yr=Me(),go=Me({level:Vt?Vt.level:0});var v=yr;var Mt=M(Tn(),1),ke=require("child_process"),ge=M(require("path"),1),Yn=require("url"),ot=M(require("fs"),1),Vn=M(require("os"),1);var bn=M(En(),1),vt=M(require("crypto"),1),{machineIdSync:kr}=bn.default;async function be(r=null){let n=r||process.env.MACHINE_ID_SALT||"9remote-salt";try{let t=kr();return vt.default.createHash("sha256").update(t+n).digest("hex").substring(0,16)}catch(t){return console.error("Error getting machine ID:",t),vt.default.randomUUID().replace(/-/g,"").substring(0,16)}}var _n=M(require("crypto"),1),Rr=process.env.API_KEY_SECRET||"9remote-api-key-secret";function Ar(){let r="abcdefghijklmnopqrstuvwxyz0123456789",n="";for(let t=0;t<4;t++)n+=r.charAt(Math.floor(Math.random()*r.length));return n}function Or(r,n){return _n.default.createHmac("sha256",Rr).update(r+n).digest("hex").slice(0,6)}function _e(r){let n=r.slice(0,8),t=Ar(),o=Or(n,t);return{key:`sk-${n}-${t}-${o}`,keyId:t}}var q=M(require("fs"),1),Ne=M(require("path"),1),xn=M(require("os"),1),$e=Ne.default.join(xn.default.homedir(),".9remote"),Tt=Ne.default.join($e,"state.json"),Et=Ne.default.join($e,"keys.json"),wt=Ne.default.join($e,"cmd.json");function bt(){q.default.existsSync($e)||q.default.mkdirSync($e,{recursive:!0})}function _t(r){try{bt(),q.default.writeFileSync(Tt,JSON.stringify(r,null,2))}catch(n){console.error("Error saving state:",n)}}function Sn(){try{q.default.existsSync(Tt)&&q.default.unlinkSync(Tt)}catch{}}function Be(){try{return bt(),q.default.existsSync(Et)?JSON.parse(q.default.readFileSync(Et,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function kn(){try{if(!q.default.existsSync(wt))return null;let r=JSON.parse(q.default.readFileSync(wt,"utf8"));return q.default.unlinkSync(wt),r.cmd}catch{return null}}function xe(r,n,t="Default"){try{bt();let o={machineId:r,key:n,name:t,createdAt:new Date().toISOString()};return q.default.writeFileSync(Et,JSON.stringify(o,null,2)),o}catch(o){return console.error("Error saving key:",o),null}}async function De(r,n){try{let t=await fetch(`${n}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r,expiryMinutes:30})});if(!t.ok){let o=await t.json();throw new Error(o.error||"Failed to create temp key")}return await t.json()}catch(t){return console.error("Error creating temp key:",t),null}}var de=require("fs"),Rn=require("url"),An=require("child_process"),je=M(require("path"),1),xt=M(require("os"),1),Pr=je.default.dirname((0,Rn.fileURLToPath)(__importMetaUrl)),Q="9remote",On=`https://registry.npmjs.org/${Q}/latest`,Pn=3e3,Cr=8e3;function Cn(){return"0.1.56"}function In(r,n){let t=r.split(".").map(Number),o=n.split(".").map(Number);for(let e=0;e<3;e++){if(o[e]>t[e])return!0;if(o[e]<t[e])return!1}return!1}function Ir(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,de.existsSync)("/.dockerenv")?"Docker":null}async function Mn(){try{let r=Cn();if(!r)return null;let n=await fetch(On,{signal:AbortSignal.timeout(Pn)});if(!n.ok)return null;let{version:t}=await n.json();return t&&In(r,t)?{current:r,latest:t}:null}catch{return null}}async function Ln(r=!1){if(r)return!1;let n=Cn();if(!n)return!1;let t=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],o=0,e=null,i=a=>{process.stdout.isTTY&&(process.stdout.write(`\r${t[0]} ${a}`),e=setInterval(()=>{process.stdout.write(`\r${t[o++%t.length]} ${a}`)},80))},s=()=>{e&&(clearInterval(e),e=null),process.stdout.isTTY&&process.stdout.write("\r\x1B[K")};return new Promise(a=>{let c=!1,l=f=>{c||(c=!0,s(),a(f))},u=setTimeout(()=>l(!1),Cr);i("Checking for updates..."),fetch(On,{signal:AbortSignal.timeout(Pn)}).then(f=>f.json()).then(f=>{if(c)return;clearTimeout(u);let d=f.version;if(!d||!In(n,d)){l(!1);return}s(),console.log(v.green(`\u2705 New version available: ${n} \u2192 ${d}`));let h=Ir();if(h){console.log(v.yellow(` \u26A0\uFE0F ${h} detected - manual update required`)),console.log(v.gray(` Run: npm install -g ${Q}@latest
|
|
13
13
|
`)),l(!1);return}console.log(v.yellow(`\u{1F504} Auto-updating...
|
|
14
14
|
`));let g=process.argv.slice(2).filter(b=>b!=="--skip-update").join(" "),T=process.platform,k,_;if(T==="win32"){let b=`@echo off
|
|
15
15
|
echo \u{1F4E5} Downloading update...
|
|
@@ -55,12 +55,12 @@ else
|
|
|
55
55
|
echo "\u{1F504} Starting with current version..."
|
|
56
56
|
${Q} ${g} --skip-update
|
|
57
57
|
fi
|
|
58
|
-
`;k=je.default.join(xt.default.tmpdir(),`${Q}-update.sh`),(0,de.writeFileSync)(k,b,{mode:493}),_=["sh",[k]]}(0,An.spawn)(_[0],_[1],{detached:!0,stdio:"inherit"}).unref(),process.exit(0)}).catch(()=>{clearTimeout(u),l(!1)})})}var N=M(require("fs"),1),he=M(require("path"),1),Nn=M(require("https"),1),me=M(require("os"),1),Xe=require("child_process"),St=null,Mr=null,Lr=null,Ue=he.default.join(me.default.homedir(),".9remote","bin"),$n="cloudflared",kt=me.default.platform()==="win32",$r=kt?`${$n}.exe`:$n,
|
|
58
|
+
`;k=je.default.join(xt.default.tmpdir(),`${Q}-update.sh`),(0,de.writeFileSync)(k,b,{mode:493}),_=["sh",[k]]}(0,An.spawn)(_[0],_[1],{detached:!0,stdio:"inherit"}).unref(),process.exit(0)}).catch(()=>{clearTimeout(u),l(!1)})})}var N=M(require("fs"),1),he=M(require("path"),1),Nn=M(require("https"),1),me=M(require("os"),1),Xe=require("child_process"),St=null,Mr=null,Lr=null,Ue=he.default.join(me.default.homedir(),".9remote","bin"),$n="cloudflared",kt=me.default.platform()==="win32",$r=kt?`${$n}.exe`:$n,Se=he.default.join(Ue,$r),qe=he.default.join(me.default.homedir(),".9remote","cloudflared.pid"),Rt=!1,Nr=5,Br=6e4,Fe=[],At=null,Dr="https://github.com/cloudflare/cloudflared/releases/latest/download",jr={darwin:{x64:"cloudflared-darwin-amd64.tgz",arm64:"cloudflared-darwin-amd64.tgz"},win32:{x64:"cloudflared-windows-amd64.exe"},linux:{x64:"cloudflared-linux-amd64",arm64:"cloudflared-linux-arm64"}};function Ur(){let r=me.default.platform(),n=me.default.arch(),t=jr[r];if(!t)throw new Error(`Unsupported platform: ${r}`);let o=t[n];if(!o)throw new Error(`Unsupported architecture: ${n} for platform ${r}`);return`${Dr}/${o}`}async function Bn(r,n){return new Promise((t,o)=>{let e=N.default.createWriteStream(n);Nn.default.get(r,i=>{if([301,302].includes(i.statusCode)){e.close(),N.default.unlinkSync(n),Bn(i.headers.location,n).then(t).catch(o);return}if(i.statusCode!==200){e.close(),N.default.unlinkSync(n),o(new Error(`Download failed with status ${i.statusCode}`));return}i.pipe(e),e.on("finish",()=>{e.close(()=>t(n))}),e.on("error",s=>{e.close(),N.default.unlinkSync(n),o(s)})}).on("error",i=>{e.close(),N.default.existsSync(n)&&N.default.unlinkSync(n),o(i)})})}async function ze(){if(N.default.existsSync(Ue)||N.default.mkdirSync(Ue,{recursive:!0}),N.default.existsSync(Se))return kt||N.default.chmodSync(Se,"755"),Se;console.log("\u{1F4E5} Downloading tunnel binary...");let r=Ur(),n=r.endsWith(".tgz"),t=n?he.default.join(Ue,"cloudflared.tgz"):Se;try{return await Bn(r,t),n&&(console.log("\u2705 Extracting..."),(0,Xe.execSync)(`tar -xzf "${t}" -C "${Ue}"`,{stdio:"pipe"}),N.default.unlinkSync(t)),kt||N.default.chmodSync(Se,"755"),console.log("\u2705 cloudflared ready"),Se}catch(o){throw console.error("\u274C Failed to download cloudflared:",o.message),o}}function Fr(r){let n=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,t=[];for(let o of r.matchAll(n))o[1]!=="api"&&t.push(`https://${o[1]}.trycloudflare.com`);return t.length?t[t.length-1]:null}async function Ze(r,n=null){let t=await ze(),o=N.default.mkdtempSync(he.default.join(me.default.tmpdir(),"9remote-quick-")),e=he.default.join(o,"config.yml");N.default.writeFileSync(e,`# quick-tunnel
|
|
59
59
|
`,"utf8");let i=!1,s=()=>{if(!i){i=!0;try{N.default.rmSync(o,{recursive:!0,force:!0})}catch{}}},a=(0,Xe.spawn)(t,["tunnel","--url",`http://localhost:${r}`,"--config",e,"--no-autoupdate"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return N.default.writeFileSync(qe,a.pid.toString()),Rt=!1,new Promise((c,l)=>{let u=!1,f=null,d=setTimeout(()=>{u||(u=!0,s(),l(new Error("Quick tunnel timed out after 90s")))},9e4),h=p=>{let g=p.toString(),T=Fr(g);if(T){if(!u){u=!0,f=T,clearTimeout(d),s(),c({child:a,tunnelUrl:T});return}T!==f&&(f=T,n?.(T))}};a.stdout.on("data",h),a.stderr.on("data",h),a.on("error",p=>{u||(u=!0,clearTimeout(d),s(),l(p))}),a.on("exit",p=>{if(s(),!u){u=!0,clearTimeout(d),l(new Error(`cloudflared exited with code ${p}`));return}if(!Rt&&At){let g=Date.now();Fe.push(g),Fe=Fe.filter(T=>T>g-Br),Fe.length<=Nr&&setTimeout(()=>At(r),2e3)}})})}function Ot(){try{if(N.default.existsSync(qe)){Rt=!0;let r=parseInt(N.default.readFileSync(qe,"utf8"));process.kill(r),N.default.unlinkSync(qe),console.log("\u2705 Cloudflared killed")}}catch{}}function Dn(){Fe=[],At=null,Lr=null,Kr()}function Kr(){St&&(clearInterval(St),St=null),Mr=null}var Pt=M(require("readline"),1),Un=M(require("http"),1);var jn=require("child_process"),Gr={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function et(r){let n=Gr[r];n&&process.platform==="darwin"&&(0,jn.exec)(`open "${n}"`,()=>{})}var S={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",orange:"\x1B[38;2;230;138;110m",green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",white:"\x1B[37m"},Hr=()=>Math.min(44,process.stdout.columns||44);function nt(r,n=null){let o=Hr()-2,e=(s="")=>{let a=s.replace(/\x1b\[[0-9;]*m/g,""),c=Math.max(0,o-a.length);return S.orange+"\u2551"+S.reset+s+" ".repeat(c)+S.orange+"\u2551"+S.reset},i=(s,a=c=>c)=>{let c=s.replace(/\x1b\[[0-9;]*m/g,""),l=Math.floor((o-c.length)/2),u=o-c.length-l;return S.orange+"\u2551"+S.reset+" ".repeat(l)+a(s)+" ".repeat(u)+S.orange+"\u2551"+S.reset};if(console.log(""),console.log(S.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+S.reset),console.log(e()),console.log(i(`\u{1F680} 9Remote v${r}`,s=>S.bold+S.orange+s+S.reset)),console.log(i("Remote terminal access from anywhere",s=>S.dim+s+S.reset)),console.log(e()),n){let s=`\u2B06 New version v${n} available!`;console.log(i(s,c=>S.yellow+S.bold+c+S.reset)),console.log(i("Run: npm i -g 9remote@latest",c=>S.dim+c+S.reset)),console.log(e())}console.log(S.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+S.reset),console.log("")}var Wr=[{label:"Preparing",desc:"Checking dependencies"},{label:"Connecting",desc:"Creating session"},{label:"Starting tunnel",desc:"Spawning cloudflared"},{label:"Ready",desc:"Tunnel is live"}],tt=0;function rt(r,n=!1){n&&tt>0&&process.stdout.write(`\x1B[${tt}A\x1B[0J`);let t=[];Wr.forEach((o,e)=>{e<r?t.push(` ${S.green}\u2713${S.reset} ${S.dim}${o.label}${S.reset}`):e===r?t.push(` ${S.orange}\u25CF${S.reset} ${S.bold}${o.label}${S.reset} ${S.dim}${o.desc}${S.reset}`):t.push(` ${S.dim}\u25CB ${o.label}${S.reset}`)}),t.forEach(o=>console.log(o)),tt=t.length}function Fn(){tt=0}function Ct(r,n,t=0,o="",e=null,i=null){return new Promise(s=>{let a=t,c=!0,l=process.platform==="win32",u=()=>{if(!c)return;process.stdout.write("\x1B[2J\x1B[H");let h=typeof o=="function"?o():o;h&&process.stdout.write(h+`
|
|
60
60
|
`),process.stdout.write(`${S.dim}${r}${S.reset}
|
|
61
61
|
|
|
62
62
|
`),n.forEach((p,g)=>{let T=g===a?l?">":"\u2605":l?" ":"\u2606";console.log(g===a?` \x1B[7m${S.bold}${T} ${p.label}${S.reset}`:` ${T} ${p.label}`)})},f=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",d),process.stdin.pause()}},d=(h,p)=>{!c||!p||(p.name==="up"?(a=(a-1+n.length)%n.length,u()):p.name==="down"?(a=(a+1)%n.length,u()):p.name==="return"?(f(),s(a)):p.name==="escape"?(f(),s(-1)):p.ctrl&&p.name==="c"&&(f(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),Pt.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{s(-1);return}process.stdin.on("keypress",d),process.stdin.resume(),u(),e&&e(u)})}function Kn(r){return new Promise(n=>{if(process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeAllListeners("keypress");let t=Pt.default.createInterface({input:process.stdin,output:process.stdout});t.question(`${r} (y/N): `,o=>{t.close(),n(o.trim().toLowerCase()==="y")})})}function Gn(r,n){let t=null,o=!1,e=()=>{o||(t=Un.default.get(`http://localhost:${r}/api/ui/events`,i=>{let s="";i.on("data",a=>{s+=a.toString();let c=s.split(`
|
|
63
|
-
`);s=c.pop();let l="";for(let u of c)if(u.startsWith("data: "))l=u.slice(6);else if(u===""&&l){try{let f=JSON.parse(l);n(f.type,f)}catch{}l=""}}),i.on("end",()=>{o||setTimeout(e,2e3)})}),t.on("error",()=>{o||setTimeout(e,2e3)}))};return e(),()=>{o=!0,t?.destroy()}}var Qr=process.argv.includes("--skip-update"),st=
|
|
63
|
+
`);s=c.pop();let l="";for(let u of c)if(u.startsWith("data: "))l=u.slice(6);else if(u===""&&l){try{let f=JSON.parse(l);n(f.type,f)}catch{}l=""}}),i.on("end",()=>{o||setTimeout(e,2e3)})}),t.on("error",()=>{o||setTimeout(e,2e3)}))};return e(),()=>{o=!0,t?.destroy()}}var Qr=process.argv.includes("--skip-update"),st=ge.default.dirname((0,Yn.fileURLToPath)(__importMetaUrl)),qo=ge.default.resolve(st,"../.."),Yr=ge.default.resolve(st,"../dist/server.cjs"),Hn=ge.default.resolve(st,"../index.js"),U="https://9remote.cc",B=2208,It=10,Wn=6e4,te=v.rgb(230,138,110),Jn=v.rgb(200,120,95);function Lt(){return"0.1.56"}function Vr(r,n="\u{1F4F1} Scan QR to connect:"){console.log(te(`
|
|
64
64
|
${n}`)),Mt.default.generate(r,{small:!0,type:"terminal",margin:0},t=>{console.log(t.trim())})}function Jr(r){return new Promise(n=>{Mt.default.generate(r,{small:!0,type:"terminal",margin:0},t=>{n(Jn("\u{1F4F1} Scan QR to connect:")+`
|
|
65
65
|
`+t.trim())})})}async function qn(r,n){let t=await De(r,U);if(!t){console.log(v.red("\u274C Failed to create temp key"));return}let o=`${U}/login?k=${t.tempKey}`,e=Math.min(44,process.stdout.columns||55);D({step:4,tunnelUrl:n,oneTimeKey:t.tempKey,oneTimeKeyExpiresAt:t.expiresAt,permanentKey:r,qrUrl:o,workerUrl:U}),Vr(o),console.log(v.gray(`
|
|
66
66
|
QR will expire in 30 minutes (one-time use)
|
|
@@ -69,15 +69,15 @@ QR expires in 30 minutes (one-time use)
|
|
|
69
69
|
`))}else e.push(v.gray(`
|
|
70
70
|
(One-time key used \u2014 generate a new one from menu)
|
|
71
71
|
`));return e.push(te("\u2550".repeat(o)),v.white("App URL".padEnd(14))+v.gray(`${U}/login`),v.white("One-Time Key".padEnd(14))+(r?te.bold(r)+v.dim(" (expires in 30m)"):v.gray("\u2014")),v.white("Key".padEnd(14))+v.dim(n),te("\u2550".repeat(o))),e.join(`
|
|
72
|
-
`)}function at(r){try{process.platform==="win32"?(0,
|
|
72
|
+
`)}function at(r){try{process.platform==="win32"?(0,ke.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${r}') do taskkill /F /PID %a`,{stdio:"ignore"}):(0,ke.execSync)(`lsof -ti:${r} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function $t(r,n){let t=[],o=null,e=!1,i=!0,s=()=>{i&&(at(B),i=!1);let a=process.env.NODE_ENV==="development"&&ot.default.existsSync(Hn),c=a?Hn:Yr;ot.default.existsSync(c)||(console.error(`\u274C Server not found: ${c}`),process.exit(1));let l={...process.env,PORT:String(B)};a||delete l.NODE_ENV,o=(0,ke.spawn)("node",[c],{cwd:ge.default.dirname(c),stdio:["ignore","inherit","inherit"],detached:!1,env:l}),o.on("exit",(u,f)=>{if(!e&&(u!==0||f)){console.log(v.red(`
|
|
73
73
|
\u{1F4A5} Server crashed (code: ${u}, signal: ${f})`));let d=Date.now();for(t.push(d);t.length>0&&t[0]<d-Wn;)t.shift();t.length>It&&(console.log(v.red(`\u274C Too many restarts (${It} in ${Wn/1e3}s). Giving up.`)),process.exit(1)),console.log(v.yellow(`\u{1F504} Restarting server... (attempt ${t.length}/${It})`)),console.log(Jn("\u26A0\uFE0F [DEBUG] NOTE: Tunnel connection may be stale - will restart tunnel")),n&&(console.log(v.yellow("\u2705 Restarting tunnel connection...")),n()),setTimeout(()=>{s()},1e3)}}),o.on("error",u=>{console.log(v.red(`\u274C Server error: ${u.message}`))}),r&&r(o)};return s(),{getProcess:()=>o,shutdown:()=>{e=!0,o&&o.kill()}}}var Qn=!1;function Nt(r,n,t){Qn||(Qn=!0,process.on("SIGINT",async()=>{console.log(v.yellow(`
|
|
74
74
|
|
|
75
75
|
\u{1F6D1} Stopping server...`)),r.shutdown(),n&&n.kill(),at(B),Dn(),Sn(),console.log(v.green("\u2705 Server stopped")),process.exit(0)}))}function qr(){let r=Vn.default.networkInterfaces();for(let n of Object.values(r))for(let t of n)if(t.family==="IPv4"&&!t.internal)return t.address;return null}async function D(r){try{await fetch(`http://localhost:${B}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch{}}async function Re(r,n){let t=qr();try{await fetch(`${U}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r,tunnelUrl:n,localIp:t?`${t}:${B}`:null})})}catch{}}async function Xr(r){console.log(te(`
|
|
76
|
-
\u{1F680} Starting server...`)),D({step:1});try{Ot(),await new Promise(i=>setTimeout(i,500))}catch{}try{let i=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r})});if(!i.ok){let s=await i.text();return console.log(v.red(`\u274C Failed to create session: ${i.status} ${s.substring(0,200)}`)),null}}catch(i){return console.log(v.red(`\u274C Failed to create session: ${i.message}`)),null}let n=await Bt(),t=n?{getProcess:()=>null,shutdown:()=>{}}:$t(null,null);n||await new Promise(i=>setTimeout(i,2e3)),console.log(te("\u2705 Starting tunnel...")),D({step:2});let o,e;try{let i=await Ze(B,async s=>{console.log(te(`\u{1F504} Tunnel URL rotated: ${s}`)),await Re(r,s),D({tunnelUrl:s})});o=i.child,e=i.tunnelUrl}catch(i){return console.log(v.red(`\u274C Failed to start tunnel: ${i.message}`)),t.shutdown(),null}return await Re(r,e),_t({apiKey:r,tunnelUrl:e,serverPid:t.getProcess()?.pid,tunnelPid:o.pid}),{serverManager:t,tunnelProcess:o,tunnelUrl:e}}async function zr(){console.clear();let r=await
|
|
76
|
+
\u{1F680} Starting server...`)),D({step:1});try{Ot(),await new Promise(i=>setTimeout(i,500))}catch{}try{let i=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r})});if(!i.ok){let s=await i.text();return console.log(v.red(`\u274C Failed to create session: ${i.status} ${s.substring(0,200)}`)),null}}catch(i){return console.log(v.red(`\u274C Failed to create session: ${i.message}`)),null}let n=await Bt(),t=n?{getProcess:()=>null,shutdown:()=>{}}:$t(null,null);n||await new Promise(i=>setTimeout(i,2e3)),console.log(te("\u2705 Starting tunnel...")),D({step:2});let o,e;try{let i=await Ze(B,async s=>{console.log(te(`\u{1F504} Tunnel URL rotated: ${s}`)),await Re(r,s),D({tunnelUrl:s})});o=i.child,e=i.tunnelUrl}catch(i){return console.log(v.red(`\u274C Failed to start tunnel: ${i.message}`)),t.shutdown(),null}return await Re(r,e),_t({apiKey:r,tunnelUrl:e,serverPid:t.getProcess()?.pid,tunnelPid:o.pid}),{serverManager:t,tunnelProcess:o,tunnelUrl:e}}async function zr(){console.clear();let r=await be(),n=Be();if(!n.key){let{key:p}=_e(r);n=xe(r,p,"Default")}let t={getProcess:()=>null,shutdown:()=>{}},[o]=await Promise.all([Mn(),(async()=>{await Bt()||(t=$t(null,null),await new Promise(g=>setTimeout(g,2e3)))})()]),e=Lt();nt(e,o?.latest??null),Fn(),rt(0);try{Ot(),await new Promise(p=>setTimeout(p,300))}catch{}await ze(),rt(1,!0);try{let p=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n.key})});if(!p.ok)throw new Error(`Session create failed: ${p.status}`)}catch(p){console.log(v.red(`
|
|
77
77
|
\u274C Failed to connect: ${p.message}`)),process.exit(1)}rt(2,!0);let i,s;try{let p=await Ze(B,async g=>{await Re(n.key,g),await D({tunnelUrl:g})});i=p.child,s=p.tunnelUrl}catch(p){console.log(v.red(`
|
|
78
|
-
\u274C Tunnel failed: ${p.message}`)),process.exit(1)}await Re(n.key,s),_t({apiKey:n.key,tunnelUrl:s,tunnelPid:i.pid});let a=await De(n.key,U),c=a?`${U}/login?k=${a.tempKey}`:`${U}/login`;await D({step:4,tunnelUrl:s,oneTimeKey:a?.tempKey||"",oneTimeKeyExpiresAt:a?.expiresAt||null,permanentKey:n.key,qrUrl:c,workerUrl:U});let l=a?.tempKey||"",u=c,f=await it(l,n.key,u),d=null,h=Gn(B,async(p,g)=>{if(p==="state"){let T=g.permanentKey||n.key,k=g.oneTimeKey!==void 0?g.oneTimeKey:l,_=g.qrUrl!==void 0?g.qrUrl:u;(k!==l||T!==n.key)&&(l=k,u=_,g.permanentKey&&(n={...n,key:g.permanentKey}),f=await it(l,n.key,u),d?.())}else p==="permissions"&&d?.()});Nt({getProcess:t.getProcess,shutdown:()=>{t.shutdown(),h()}},i,n.key),await eo(n,s,()=>f,p=>{f=p},p=>{d=p},()=>{t.shutdown(),at(B),h()})}async function Zr(){try{let r=await fetch(`http://localhost:${B}/api/ui/state`);if(r.ok)return!!(await r.json()).desktopEnabled}catch{}return!1}async function eo(r,n,t=()=>"",o=()=>{},e=()=>{},i=null){for(;;){let a=`Remote Desktop: ${await Zr()?v.green("ON"):v.gray("OFF")} \u25B6`,c=[{label:"Open Web UI"},{label:"New One-Time Key"},{label:"Regenerate Permanent Key"},{label:a},{label:v.gray("Exit")}],l=null;e(()=>l?.());let u=await Ct("Select action",c,0,t,f=>{l=f},i);if(u===0){let f=`http://localhost:${B}`,d=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";(0,
|
|
78
|
+
\u274C Tunnel failed: ${p.message}`)),process.exit(1)}await Re(n.key,s),_t({apiKey:n.key,tunnelUrl:s,tunnelPid:i.pid});let a=await De(n.key,U),c=a?`${U}/login?k=${a.tempKey}`:`${U}/login`;await D({step:4,tunnelUrl:s,oneTimeKey:a?.tempKey||"",oneTimeKeyExpiresAt:a?.expiresAt||null,permanentKey:n.key,qrUrl:c,workerUrl:U});let l=a?.tempKey||"",u=c,f=await it(l,n.key,u),d=null,h=Gn(B,async(p,g)=>{if(p==="state"){let T=g.permanentKey||n.key,k=g.oneTimeKey!==void 0?g.oneTimeKey:l,_=g.qrUrl!==void 0?g.qrUrl:u;(k!==l||T!==n.key)&&(l=k,u=_,g.permanentKey&&(n={...n,key:g.permanentKey}),f=await it(l,n.key,u),d?.())}else p==="permissions"&&d?.()});Nt({getProcess:t.getProcess,shutdown:()=>{t.shutdown(),h()}},i,n.key),await eo(n,s,()=>f,p=>{f=p},p=>{d=p},()=>{t.shutdown(),at(B),h()})}async function Zr(){try{let r=await fetch(`http://localhost:${B}/api/ui/state`);if(r.ok)return!!(await r.json()).desktopEnabled}catch{}return!1}async function eo(r,n,t=()=>"",o=()=>{},e=()=>{},i=null){for(;;){let a=`Remote Desktop: ${await Zr()?v.green("ON"):v.gray("OFF")} \u25B6`,c=[{label:"Open Web UI"},{label:"New One-Time Key"},{label:"Regenerate Permanent Key"},{label:a},{label:v.gray("Exit")}],l=null;e(()=>l?.());let u=await Ct("Select action",c,0,t,f=>{l=f},i);if(u===0){let f=`http://localhost:${B}`,d=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";(0,ke.spawn)(d,[f],{detached:!0,stdio:"ignore"}).unref(),console.log(v.green(`
|
|
79
79
|
\u{1F310} Opening ${f}
|
|
80
|
-
`))}else if(u===1){let f=await De(r.key,U);if(f){let d=`${U}/login?k=${f.tempKey}`;o(await it(f.tempKey,r.key,d)),await D({oneTimeKey:f.tempKey,oneTimeKeyExpiresAt:f.expiresAt,qrUrl:d})}}else if(u===2){if(await Kn(v.yellow("\u26A0\uFE0F Replace current key and disconnect all sessions? Continue?"))){let d=await
|
|
80
|
+
`))}else if(u===1){let f=await De(r.key,U);if(f){let d=`${U}/login?k=${f.tempKey}`;o(await it(f.tempKey,r.key,d)),await D({oneTimeKey:f.tempKey,oneTimeKeyExpiresAt:f.expiresAt,qrUrl:d})}}else if(u===2){if(await Kn(v.yellow("\u26A0\uFE0F Replace current key and disconnect all sessions? Continue?"))){let d=await be(),{key:h}=_e(d);r=xe(d,h,r.name||"Default"),await D({permanentKey:r.key});let p=await De(r.key,U);if(p){let g=`${U}/login?k=${p.tempKey}`;o(await it(p.tempKey,r.key,g)),await D({oneTimeKey:p.tempKey,oneTimeKeyExpiresAt:p.expiresAt,qrUrl:g})}}}else u===3?await to():(at(B),console.log(v.gray(`
|
|
81
81
|
Goodbye!
|
|
82
|
-
`)),process.exit(0))}}async function to(){for(;;){let r=!1,n={screenRecording:!1,accessibility:!1};try{let s=await fetch(`http://localhost:${B}/api/ui/state`);if(s.ok){let a=await s.json();r=!!a.desktopEnabled,n={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility}}}catch{}let t=`Toggle: ${r?v.green("ON \u2192 turn OFF"):v.gray("OFF \u2192 turn ON")}`,o=`Screen Recording ${n.screenRecording?v.green("\u2713"):v.red("\u2717 (click to grant)")}`,e=`Mouse & Keyboard control ${n.accessibility?v.green("\u2713"):v.red("\u2717 (click to grant)")}`,i=await Ct("Remote Desktop",[{label:t},{label:o},{label:e},{label:v.gray("\u2190 Back")}],0);if(i===0)try{await fetch(`http://localhost:${B}/api/desktop/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!r})})}catch{}else if(i===1&&!n.screenRecording)try{await fetch(`http://localhost:${B}/api/permissions/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"screenRecording"})})}catch{et("screenRecording")}else if(i===2&&!n.accessibility)try{await fetch(`http://localhost:${B}/api/permissions/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"accessibility"})})}catch{et("accessibility")}else if(i===3||i===-1)return}}async function no(){nt(Lt());let r=await
|
|
83
|
-
\u{1F310} UI ready at
|
|
82
|
+
`)),process.exit(0))}}async function to(){for(;;){let r=!1,n={screenRecording:!1,accessibility:!1};try{let s=await fetch(`http://localhost:${B}/api/ui/state`);if(s.ok){let a=await s.json();r=!!a.desktopEnabled,n={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility}}}catch{}let t=`Toggle: ${r?v.green("ON \u2192 turn OFF"):v.gray("OFF \u2192 turn ON")}`,o=`Screen Recording ${n.screenRecording?v.green("\u2713"):v.red("\u2717 (click to grant)")}`,e=`Mouse & Keyboard control ${n.accessibility?v.green("\u2713"):v.red("\u2717 (click to grant)")}`,i=await Ct("Remote Desktop",[{label:t},{label:o},{label:e},{label:v.gray("\u2190 Back")}],0);if(i===0)try{await fetch(`http://localhost:${B}/api/desktop/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!r})})}catch{}else if(i===1&&!n.screenRecording)try{await fetch(`http://localhost:${B}/api/permissions/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"screenRecording"})})}catch{et("screenRecording")}else if(i===2&&!n.accessibility)try{await fetch(`http://localhost:${B}/api/permissions/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"accessibility"})})}catch{et("accessibility")}else if(i===3||i===-1)return}}async function no(){nt(Lt());let r=await be(),n=Be();if(!n.key){console.log(v.yellow("\u26A0\uFE0F No key found. Creating default key..."));let{key:a}=_e(r);n=xe(r,a,"Default"),console.log(v.green("\u2705 Default key created!"))}console.log(v.gray(`Using key: ${n.key.slice(0,20)}... (${n.name})`));let t=await Xr(n.key);t||process.exit(1);let{serverManager:o,tunnelProcess:e,tunnelUrl:i}=t;await qn(n.key,i),Nt(o,e,n.key),setupKeyRegenListener();let s=Date.now();setInterval(()=>{let a=Math.floor((Date.now()-s)/1e3),c=Math.floor(a/3600),l=Math.floor(a%3600/60),u=a%60;D({uptime:`${c}:${String(l).padStart(2,"0")}:${String(u).padStart(2,"0")}`})},5e3),await new Promise(()=>{})}function ro(r,n,t){let o=!1;setInterval(async()=>{if(o)return;let e=kn();if(e){o=!0;try{if(e==="stop-tunnel"){let i=r();i&&(i.kill(),n(null),console.log(v.yellow("\u{1F6D1} Tunnel stopped"))),await D({step:0,tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null})}if(e==="start-tunnel"){if(r()){o=!1;return}console.log(te("\u{1F680} Starting tunnel..."));try{await D({step:1}),await ze(),await D({step:2});let i=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t})});if(!i.ok)throw new Error(`Session create failed: ${i.status}`);await D({step:3});let s=await Ze(B,async a=>{await Re(t,a),await D({tunnelUrl:a})});n(s.child),await Re(t,s.tunnelUrl),await qn(t,s.tunnelUrl)}catch(i){console.log(v.red(`\u274C Failed to start tunnel: ${i.message}`)),await D({step:0})}}if(e==="regenerate-key"){let i=await be(),{key:s}=_e(i),a=Be();xe(i,s,a?.name||"Default"),await D({permanentKey:s}),console.log(v.green(`\u2705 Key regenerated: ${s}`))}}finally{o=!1}}},1e3)}async function Bt(){try{return(await fetch(`http://localhost:${B}/api/health`)).ok}catch{return!1}}async function oo(){nt(Lt());let r=await be(),n=Be();if(!n.key){let{key:a}=_e(r);n=xe(r,a,"Default")}let t=await Bt(),o=t?{getProcess:()=>null,shutdown:()=>{}}:$t(null,null);t||await new Promise(a=>setTimeout(a,2e3)),console.log(v.green(`
|
|
83
|
+
\u{1F310} UI ready at http://localhost:${B}`));let e=null,i=()=>e,s=a=>{e=a};await D({permanentKey:n.key,step:0}),Nt(o,null,n.key),ro(i,s,n.key),await new Promise(()=>{})}async function io(){if(await Ln(Qr))return;let n=process.argv[2];n==="ui"?await oo():n==="start"||process.argv.includes("--auto")?await no():await zr()}io().catch(console.error);
|
package/lib/socketio.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Main Socket.IO setup
|
|
2
|
+
import { Server } from "socket.io";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { homedir } from "os";
|
|
6
|
+
import { setupTerminalSocket } from "../features/terminal/terminalSocket.js";
|
|
7
|
+
import { setupRemoteSocket, checkRemoteAvailable } from "../features/remote/remoteSocket.js";
|
|
8
|
+
import { setupFileExplorerSocket } from "../features/fileExplorer/fileExplorerSocket.js";
|
|
9
|
+
import { trackConnection, untrackConnection, pushUiLog, clearOneTimeKey } from "../index.js";
|
|
10
|
+
|
|
11
|
+
function loadApiKey() {
|
|
12
|
+
try {
|
|
13
|
+
const keysFile = join(homedir(), ".9remote", "keys.json");
|
|
14
|
+
const data = JSON.parse(readFileSync(keysFile, "utf8"));
|
|
15
|
+
return data.key || null;
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let ioInstance = null;
|
|
22
|
+
|
|
23
|
+
export function getIO() {
|
|
24
|
+
return ioInstance;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function setupSocketIO(server) {
|
|
28
|
+
const io = new Server(server, {
|
|
29
|
+
cors: {
|
|
30
|
+
origin: "*",
|
|
31
|
+
methods: ["GET", "POST"],
|
|
32
|
+
credentials: true,
|
|
33
|
+
allowedHeaders: ["*"]
|
|
34
|
+
},
|
|
35
|
+
transports: ["websocket", "polling"],
|
|
36
|
+
allowEIO3: true,
|
|
37
|
+
allowUpgrades: true,
|
|
38
|
+
pingTimeout: 60000,
|
|
39
|
+
pingInterval: 25000
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Verify apiKey on every Socket.IO connection
|
|
43
|
+
// io.use((socket, next) => {
|
|
44
|
+
// const serverKey = loadApiKey();
|
|
45
|
+
// console.log("š ~ setupSocketIO ~ serverKey:", serverKey)
|
|
46
|
+
// // If no key configured yet (first run), allow through
|
|
47
|
+
// if (!serverKey) return next();
|
|
48
|
+
// const clientKey = socket.handshake.auth?.apiKey;
|
|
49
|
+
// console.log("š ~ setupSocketIO ~ clientKey:", clientKey)
|
|
50
|
+
// if (clientKey === serverKey) return next();
|
|
51
|
+
// next(new Error("unauthorized"));
|
|
52
|
+
// });
|
|
53
|
+
|
|
54
|
+
// Check remote availability at startup
|
|
55
|
+
await checkRemoteAvailable();
|
|
56
|
+
|
|
57
|
+
// Track connections for UI display + log
|
|
58
|
+
io.on("connection", (socket) => {
|
|
59
|
+
const ip = socket.handshake.headers["x-forwarded-for"] || socket.handshake.address || "unknown";
|
|
60
|
+
trackConnection(socket.id, ip);
|
|
61
|
+
pushUiLog(`Client connected: ${ip}`);
|
|
62
|
+
|
|
63
|
+
// If client connected using a one-time key, clear it from UI state
|
|
64
|
+
pushUiLog(`Auth received: tempKey=${socket.handshake.auth?.tempKey ?? "null"}`);
|
|
65
|
+
if (socket.handshake.auth?.tempKey) {
|
|
66
|
+
pushUiLog(`One-time key used ā clearing from UI`);
|
|
67
|
+
clearOneTimeKey();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
socket.on("disconnect", (reason) => {
|
|
71
|
+
untrackConnection(socket.id);
|
|
72
|
+
pushUiLog(`Client disconnected: ${ip} (${reason})`);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Setup Terminal + Remote on same root namespace
|
|
77
|
+
setupTerminalSocket(io, loadApiKey());
|
|
78
|
+
|
|
79
|
+
// Setup File Explorer (uses default namespace)
|
|
80
|
+
setupFileExplorerSocket(io);
|
|
81
|
+
|
|
82
|
+
ioInstance = io;
|
|
83
|
+
return io;
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "9remote",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Remote terminal access from anywhere",
|
|
6
6
|
"main": "index.js",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist/",
|
|
23
|
-
"cli/"
|
|
23
|
+
"cli/",
|
|
24
|
+
"lib/"
|
|
24
25
|
],
|
|
25
26
|
"keywords": [
|
|
26
27
|
"remote",
|