9remote 0.1.61 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs
CHANGED
|
@@ -9,7 +9,7 @@ var Zn=Object.create;var Dt=Object.defineProperty;var er=Object.getOwnPropertyDe
|
|
|
9
9
|
`:`
|
|
10
10
|
`)+t,e=o+1,o=r.indexOf(`
|
|
11
11
|
`,e)}while(o!==-1);return i+=r.slice(e),i}var{stdout:Yt,stderr:Vt}=Ht,ft=Symbol("GENERATOR"),Te=Symbol("STYLER"),Ie=Symbol("IS_EMPTY"),Jt=["ansi","ansi","ansi256","ansi16m"],Ee=Object.create(null),hr=(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 hr(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,ht(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 pt=(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"?pt("rgb",n,t,...Z.hexToRgb(...o)):Z[t][r](...o),mr=["rgb","hex","ansi256"];for(let r of mr){Ee[r]={get(){let{level:t}=this;return function(...o){let e=ht(pt(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=ht(pt(r,Jt[t],"bgColor",...o),Z.bgColor.close,this[Te]);return Qe(this,e,this[Ie])}}}}var gr=Object.defineProperties(()=>{},{...Ee,level:{enumerable:!0,get(){return this[ft].level},set(r){this[ft].level=r}}}),ht=(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)=>yr(o,e.length===1?""+e[0]:e.join(" "));return Object.setPrototypeOf(o,gr),o[ft]=r,o[Te]=n,o[Ie]=t,o},yr=(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 vr=Me(),yo=Me({level:Vt?Vt.level:0});var v=vr;var Mt=M(Tn(),1),ke=require("child_process"),ge=M(require("path"),1),Vn=require("url"),st=M(require("fs"),1),Jn=M(require("os"),1);var bn=M(En(),1),Tt=M(require("crypto"),1),{machineIdSync:Rr}=bn.default;async function be(r=null){let n=r||process.env.MACHINE_ID_SALT||"9remote-salt";try{let t=Rr();return Tt.default.createHash("sha256").update(t+n).digest("hex").substring(0,16)}catch(t){return console.error("Error getting machine ID:",t),Tt.default.randomUUID().replace(/-/g,"").substring(0,16)}}var _n=M(require("crypto"),1),Ar=process.env.API_KEY_SECRET||"9remote-api-key-secret";function Or(){let r="abcdefghijklmnopqrstuvwxyz0123456789",n="";for(let t=0;t<4;t++)n+=r.charAt(Math.floor(Math.random()*r.length));return n}function Pr(r,n){return _n.default.createHmac("sha256",Ar).update(r+n).digest("hex").slice(0,6)}function _e(r){let n=r.slice(0,8),t=Or(),o=Pr(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"),Et=Ne.default.join($e,"state.json"),bt=Ne.default.join($e,"keys.json"),qe=Ne.default.join($e,"cmd.json");function Xe(){Q.default.existsSync($e)||Q.default.mkdirSync($e,{recursive:!0})}function _t(r){try{Xe(),Q.default.writeFileSync(Et,JSON.stringify(r,null,2))}catch(n){console.error("Error saving state:",n)}}function Sn(){try{Q.default.existsSync(Et)&&Q.default.unlinkSync(Et)}catch{}}function Be(){try{return Xe(),Q.default.existsSync(bt)?JSON.parse(Q.default.readFileSync(bt,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function kn(r){try{Xe(),Q.default.writeFileSync(qe,JSON.stringify({cmd:r,ts:Date.now()}))}catch{}}function Rn(){try{if(!Q.default.existsSync(qe))return null;let r=JSON.parse(Q.default.readFileSync(qe,"utf8"));return Q.default.unlinkSync(qe),r.cmd}catch{return null}}function xe(r,n,t="Default"){try{Xe();let o={machineId:r,key:n,name:t,createdAt:new Date().toISOString()};return Q.default.writeFileSync(bt,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 he=require("fs"),An=require("url"),On=require("child_process"),je=M(require("path"),1),xt=M(require("os"),1),Cr=je.default.dirname((0,An.fileURLToPath)(__importMetaUrl)),Y="9remote",Pn=`https://registry.npmjs.org/${Y}/latest`,Cn=3e3,Ir=8e3;function In(){return"0.1.
|
|
12
|
+
`);return i!==-1&&(n=Qt(n,e,o,i)),o+n+e};Object.defineProperties(Me.prototype,Ee);var vr=Me(),yo=Me({level:Vt?Vt.level:0});var v=vr;var Mt=M(Tn(),1),ke=require("child_process"),ge=M(require("path"),1),Vn=require("url"),st=M(require("fs"),1),Jn=M(require("os"),1);var bn=M(En(),1),Tt=M(require("crypto"),1),{machineIdSync:Rr}=bn.default;async function be(r=null){let n=r||process.env.MACHINE_ID_SALT||"9remote-salt";try{let t=Rr();return Tt.default.createHash("sha256").update(t+n).digest("hex").substring(0,16)}catch(t){return console.error("Error getting machine ID:",t),Tt.default.randomUUID().replace(/-/g,"").substring(0,16)}}var _n=M(require("crypto"),1),Ar=process.env.API_KEY_SECRET||"9remote-api-key-secret";function Or(){let r="abcdefghijklmnopqrstuvwxyz0123456789",n="";for(let t=0;t<4;t++)n+=r.charAt(Math.floor(Math.random()*r.length));return n}function Pr(r,n){return _n.default.createHmac("sha256",Ar).update(r+n).digest("hex").slice(0,6)}function _e(r){let n=r.slice(0,8),t=Or(),o=Pr(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"),Et=Ne.default.join($e,"state.json"),bt=Ne.default.join($e,"keys.json"),qe=Ne.default.join($e,"cmd.json");function Xe(){Q.default.existsSync($e)||Q.default.mkdirSync($e,{recursive:!0})}function _t(r){try{Xe(),Q.default.writeFileSync(Et,JSON.stringify(r,null,2))}catch(n){console.error("Error saving state:",n)}}function Sn(){try{Q.default.existsSync(Et)&&Q.default.unlinkSync(Et)}catch{}}function Be(){try{return Xe(),Q.default.existsSync(bt)?JSON.parse(Q.default.readFileSync(bt,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function kn(r){try{Xe(),Q.default.writeFileSync(qe,JSON.stringify({cmd:r,ts:Date.now()}))}catch{}}function Rn(){try{if(!Q.default.existsSync(qe))return null;let r=JSON.parse(Q.default.readFileSync(qe,"utf8"));return Q.default.unlinkSync(qe),r.cmd}catch{return null}}function xe(r,n,t="Default"){try{Xe();let o={machineId:r,key:n,name:t,createdAt:new Date().toISOString()};return Q.default.writeFileSync(bt,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 he=require("fs"),An=require("url"),On=require("child_process"),je=M(require("path"),1),xt=M(require("os"),1),Cr=je.default.dirname((0,An.fileURLToPath)(__importMetaUrl)),Y="9remote",Pn=`https://registry.npmjs.org/${Y}/latest`,Cn=3e3,Ir=8e3;function In(){return"0.1.62"}function Mn(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 Mr(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,he.existsSync)("/.dockerenv")?"Docker":null}async function Ln(){try{let r=In();if(!r)return null;let n=await fetch(Pn,{signal:AbortSignal.timeout(Cn)});if(!n.ok)return null;let{version:t}=await n.json();return t&&Mn(r,t)?{current:r,latest:t}:null}catch{return null}}async function $n(r=!1){if(r)return!1;let n=In();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),Ir);i("Checking for updates..."),fetch(Pn,{signal:AbortSignal.timeout(Cn)}).then(f=>f.json()).then(f=>{if(c)return;clearTimeout(u);let h=f.version;if(!h||!Mn(n,h)){l(!1);return}s(),console.log(v.green(`\u2705 New version available: ${n} \u2192 ${h}`));let d=Mr();if(d){console.log(v.yellow(` \u26A0\uFE0F ${d} detected - manual update required`)),console.log(v.gray(` Run: npm install -g ${Y}@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...
|
|
@@ -60,7 +60,7 @@ fi
|
|
|
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",h),process.stdin.pause()}},h=(d,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",h),process.stdin.resume(),u(),e&&e(u)})}function Gn(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 Hn(r,n){let t=null,o=!1,e=()=>{o||(t=Fn.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 Yr=process.argv.includes("--skip-update"),ct=ge.default.dirname((0,Vn.fileURLToPath)(__importMetaUrl)),Xo=ge.default.resolve(ct,"../.."),Vr=ge.default.resolve(ct,"../dist/server.cjs"),Wn=ge.default.resolve(ct,"../index.js"),U="https://9remote.cc",B=2208,It=10,Qn=6e4,te=v.rgb(230,138,110),qn=v.rgb(200,120,95);function Lt(){return"0.1.
|
|
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 Yr=process.argv.includes("--skip-update"),ct=ge.default.dirname((0,Vn.fileURLToPath)(__importMetaUrl)),Xo=ge.default.resolve(ct,"../.."),Vr=ge.default.resolve(ct,"../dist/server.cjs"),Wn=ge.default.resolve(ct,"../index.js"),U="https://9remote.cc",B=2208,It=10,Qn=6e4,te=v.rgb(230,138,110),qn=v.rgb(200,120,95);function Lt(){return"0.1.62"}function Jr(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 qr(r){return new Promise(n=>{Mt.default.generate(r,{small:!0,type:"terminal",margin:0},t=>{n(qn("\u{1F4F1} Scan QR to connect:")+`
|
|
65
65
|
`+t.trim())})})}async function Xn(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}),Jr(o),console.log(v.gray(`
|
|
66
66
|
QR will expire in 30 minutes (one-time use)
|
|
@@ -5,4 +5,4 @@ Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),i.put(r,13)}},Le=o,L
|
|
|
5
5
|
The chosen QR Code version cannot contain this amount of data.
|
|
6
6
|
Minimum version required to store current data is: `+w+`.
|
|
7
7
|
`);const S=k(p,g,E),T=t.getSymbolSize(p),R=new i(T);return f(R,p),v(R),C(R,p),y(R,g,0),p>=7&&P(R,p),b(R,S),isNaN(m)&&(m=s.getBestMask(R,y.bind(null,R,g))),s.applyMask(m,R),y(R,g,m),{modules:R,version:p,errorCorrectionLevel:g,maskPattern:m,segments:E}}return ye.create=function(p,g){if(typeof p>"u"||p==="")throw new Error("No input text");let m=e.M,E,w;return typeof g<"u"&&(m=e.from(g.errorCorrectionLevel,e.M),E=d.from(g.version),w=s.from(g.maskPattern),g.toSJISFunc&&t.setToSJISFunction(g.toSJISFunc)),A(p,E,m,w)},ye}var Ue={},qe={},Dt;function an(){return Dt||(Dt=1,(function(t){function e(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let i=o.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+o);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(r){return[r,r]}))),i.length===6&&i.push("F","F");const n=parseInt(i.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+i.slice(0,6).join("")}}t.getOptions=function(i){i||(i={}),i.color||(i.color={});const n=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,r=i.width&&i.width>=21?i.width:void 0,s=i.scale||4;return{width:r,scale:r?4:s,margin:n,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},t.getScale=function(i,n){return n.width&&n.width>=i+n.margin*2?n.width/(i+n.margin*2):n.scale},t.getImageWidth=function(i,n){const r=t.getScale(i,n);return Math.floor((i+n.margin*2)*r)},t.qrToImageData=function(i,n,r){const s=n.modules.size,l=n.modules.data,a=t.getScale(s,r),d=Math.floor((s+r.margin*2)*a),h=r.margin*a,c=[r.color.light,r.color.dark];for(let _=0;_<d;_++)for(let f=0;f<d;f++){let v=(_*d+f)*4,C=r.color.light;if(_>=h&&f>=h&&_<d-h&&f<d-h){const P=Math.floor((_-h)/a),y=Math.floor((f-h)/a);C=c[l[P*s+y]?1:0]}i[v++]=C.r,i[v++]=C.g,i[v++]=C.b,i[v]=C.a}}})(qe)),qe}var Ut;function Yn(){return Ut||(Ut=1,(function(t){const e=an();function o(n,r,s){n.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=s,r.width=s,r.style.height=s+"px",r.style.width=s+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(r,s,l){let a=l,d=s;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),s||(d=i()),a=e.getOptions(a);const h=e.getImageWidth(r.modules.size,a),c=d.getContext("2d"),_=c.createImageData(h,h);return e.qrToImageData(_.data,r,a),o(c,d,h),c.putImageData(_,0,0),d},t.renderToDataURL=function(r,s,l){let a=l;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),a||(a={});const d=t.render(r,s,a),h=a.type||"image/png",c=a.rendererOpts||{};return d.toDataURL(h,c.quality)}})(Ue)),Ue}var Fe={},qt;function Gn(){if(qt)return Fe;qt=1;const t=an();function e(n,r){const s=n.a/255,l=r+'="'+n.hex+'"';return s<1?l+" "+r+'-opacity="'+s.toFixed(2).slice(1)+'"':l}function o(n,r,s){let l=n+r;return typeof s<"u"&&(l+=" "+s),l}function i(n,r,s){let l="",a=0,d=!1,h=0;for(let c=0;c<n.length;c++){const _=Math.floor(c%r),f=Math.floor(c/r);!_&&!d&&(d=!0),n[c]?(h++,c>0&&_>0&&n[c-1]||(l+=d?o("M",_+s,.5+f+s):o("m",a,0),a=0,d=!1),_+1<r&&n[c+1]||(l+=o("h",h),h=0)):a++}return l}return Fe.render=function(r,s,l){const a=t.getOptions(s),d=r.modules.size,h=r.modules.data,c=d+a.margin*2,_=a.color.light.a?"<path "+e(a.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",f="<path "+e(a.color.dark,"stroke")+' d="'+i(h,d,a.margin)+'"/>',v='viewBox="0 0 '+c+" "+c+'"',P='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+v+' shape-rendering="crispEdges">'+_+f+`</svg>
|
|
8
|
-
`;return typeof l=="function"&&l(null,P),P},Fe}var Ft;function Qn(){if(Ft)return Y;Ft=1;const t=Pn(),e=Jn(),o=Yn(),i=Gn();function n(r,s,l,a,d){const h=[].slice.call(arguments,1),c=h.length,_=typeof h[c-1]=="function";if(!_&&!t())throw new Error("Callback required as last argument");if(_){if(c<2)throw new Error("Too few arguments provided");c===2?(d=l,l=s,s=a=void 0):c===3&&(s.getContext&&typeof d>"u"?(d=a,a=void 0):(d=a,a=l,l=s,s=void 0))}else{if(c<1)throw new Error("Too few arguments provided");return c===1?(l=s,s=a=void 0):c===2&&!s.getContext&&(a=l,l=s,s=void 0),new Promise(function(f,v){try{const C=e.create(l,a);f(r(C,s,a))}catch(C){v(C)}})}try{const f=e.create(l,a);d(null,r(f,s,a))}catch(f){d(f)}}return Y.create=e.create,Y.toCanvas=n.bind(null,o.render),Y.toDataURL=n.bind(null,o.renderToDataURL),Y.toString=n.bind(null,function(r,s,l){return i.render(r,l)}),Y}var Wn=Qn();const Xn=Tn(Wn);function Oe({message:t,confirmLabel:e="Confirm",confirmDanger:o=!1,onConfirm:i,onCancel:n}){return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},children:u("div",{className:"glass-card p-5 flex flex-col gap-4 w-72",children:[u("p",{className:"text-sm text-center",style:{color:"var(--text-main)"},children:t}),u("div",{className:"flex gap-2",children:[u("button",{onClick:n,className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:"Cancel"}),u("button",{onClick:i,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:o?"rgba(220,53,69,0.8)":"var(--brand-500)",color:"#fff"},children:e})]})]})})}const Ht="9remote.cc";function Zn(t){if(t<=0)return"Expired";const e=Math.floor(t/1e3),o=Math.floor(e/60),i=e%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function ne({icon:t,onClick:e,title:o,danger:i}){return u("button",{onClick:e,title:o,className:"glass-btn w-7 h-7 flex items-center justify-center flex-shrink-0",style:i?{color:"rgba(255,100,100,0.7)"}:{color:"var(--text-muted)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:15},children:t})})}function zt({qrUrl:t,oneTimeKey:e,oneTimeKeyExpiresAt:o,permanentKey:i,onGenerateOneTimeKey:n,onRegenerateKey:r}){const s=tn(null),[l,a]=L(null),[d,h]=L(null),[c,_]=L(null);Z(()=>{!t||!s.current||Xn.toCanvas(s.current,t,{width:160,margin:1,color:{dark:"#0f1923",light:"#ffffff"}}).catch(()=>{})},[t]),Z(()=>{if(!o){a(null);return}const v=()=>a(o-Date.now());v();const C=setInterval(v,1e3);return()=>clearInterval(C)},[o]);const f=(v,C)=>{navigator.clipboard.writeText(v).catch(()=>{}),h(C),setTimeout(()=>h(null),2e3)};return u(K,{children:[c==="oneTime"&&u(Oe,{message:"Generate a new one-time key? The current one will expire immediately.",confirmLabel:"Generate",onConfirm:()=>{_(null),n==null||n()},onCancel:()=>_(null)}),c==="regen"&&u(Oe,{message:"Regenerate permanent key? All existing sessions will be disconnected.",confirmLabel:"Regenerate",confirmDanger:!0,onConfirm:()=>{_(null),r==null||r()},onCancel:()=>_(null)}),u("div",{className:"glass-card p-5 flex flex-col items-center gap-4",children:[u("div",{className:"w-44 h-44 rounded-xl overflow-hidden bg-white p-2 flex items-center justify-center flex-shrink-0",children:t?u("canvas",{ref:s}):u("span",{className:"material-symbols-outlined text-gray-300 text-6xl",children:"qr_code_2"})}),u("a",{href:`https://${Ht}/login`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 hover:opacity-80 transition-opacity",children:[u("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 flex-shrink-0"}),u("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:[Ht,"/login"]})]}),u("div",{className:"w-full h-px",style:{background:"var(--border)"}}),u("div",{className:"w-full flex flex-col gap-1.5",children:[u("div",{className:"flex items-center justify-between px-0.5",children:[u("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"One-Time Key"}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Single use · expires"})]}),u("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"timer"}),u("span",{className:"flex-1 font-mono font-bold tracking-[0.18em] text-base truncate",style:{color:e?"var(--brand-500)":"var(--border)"},children:e||"• • • • • •"}),l!==null&&u("span",{className:`text-xs font-mono flex-shrink-0 ${l<=0?"text-red-400":""}`,style:l>0?{color:"var(--text-muted)"}:{},children:Zn(l)}),e&&u(ne,{icon:d==="oneTime"?"check":"content_copy",onClick:()=>f(e,"oneTime"),title:"Copy one-time key"}),u(ne,{icon:"refresh",onClick:()=>_("oneTime"),title:"New one-time key"})]})]}),u("div",{className:"w-full flex flex-col gap-1.5",children:[u("div",{className:"flex items-center justify-between px-0.5",children:[u("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Permanent Key"}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Reusable · no expiry"})]}),u("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"key"}),u("span",{className:"flex-1 font-mono text-xs truncate",style:{color:"var(--text-muted)"},children:i||"— not set —"}),i&&u(ne,{icon:d==="permanent"?"check":"content_copy",onClick:()=>f(i,"permanent"),title:"Copy permanent key"}),u(ne,{icon:"autorenew",onClick:()=>_("regen"),title:"Regenerate permanent key",danger:!0})]})]})]})]})}const $n="https://docs.9remote.cc/",cn={screenRecording:{label:"Screen Recording",icon:"screenshot_monitor",desc:"Capture screen content"},accessibility:{label:"Accessibility",icon:"accessibility_new",desc:"Control mouse & keyboard"}};function er({type:t,granted:e,onRequest:o}){const i=cn[t]||{label:t,desc:""};return u("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[u("span",{className:`material-symbols-outlined flex-shrink-0 ${e?"text-green-400":""}`,style:{fontSize:18,color:e?void 0:"var(--text-muted)"},children:e?"check_circle":"cancel"}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-medium",style:{color:e?"var(--text-main)":"var(--text-muted)"},children:i.label}),u("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:i.desc})]}),!e&&u("button",{onClick:()=>o(t),className:"flex-shrink-0 text-xs px-2.5 py-1 rounded-lg font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Grant"})]})}function tr(){return u("div",{className:"glass-card p-4 flex items-center gap-3",children:[u("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(255,87,10,0.15)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:20,color:"var(--brand-400)"},children:"terminal"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"Remote Terminal"}),u("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Full shell access · always on"})]}),u("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-full",style:{background:"rgba(74,222,128,0.1)"},children:[u("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400"}),u("span",{className:"text-xs text-green-400 font-medium",children:"On"})]})]})}function nr({enabled:t,onToggle:e,permissions:o,onRequestPermission:i}){const n=Object.entries(cn);return u("div",{className:"glass-card p-4 flex flex-col gap-3",children:[u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:t?"rgba(255,87,10,0.15)":"var(--glass-bg)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:20,color:t?"var(--brand-400)":"var(--text-muted)"},children:"desktop_windows"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"Remote Desktop"}),u("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Control screen, mouse & keyboard"})]}),u("button",{onClick:e,className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:t?"var(--brand-500)":"var(--border)"},children:u("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:t?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),t&&u("div",{className:"flex flex-col border-t pt-2",style:{borderColor:"var(--border)"},children:[u("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"System Permissions"}),n.map(([r])=>u(er,{type:r,granted:(o==null?void 0:o[r])??!1,onRequest:i},r))]})]})}function rr({version:t}){return t?u("div",{className:"px-5 py-2 flex items-center gap-2 border-b",style:{background:"rgba(255,87,10,0.08)",borderColor:"rgba(255,87,10,0.2)"},children:[u("span",{className:"material-symbols-outlined text-sm flex-shrink-0",style:{color:"var(--brand-400)"},children:"system_update"}),u("span",{className:"text-xs flex-1",style:{color:"var(--brand-400)"},children:["Version ",t," available"]}),u("button",{onClick:()=>fetch("/api/update",{method:"POST"}).catch(()=>{}),className:"flex-shrink-0 text-xs px-2 py-0.5 rounded font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Update"})]}):null}const or=[{icon:"terminal",label:"Terminal",desc:"Full shell access"},{icon:"desktop_windows",label:"Desktop",desc:"Remote screen control"},{icon:"folder_open",label:"Files",desc:"Browse & edit files"}],ir=[{icon:"qr_code_scanner",text:"Scan QR to connect instantly"},{icon:"wifi_off",text:"No port forwarding needed"},{icon:"devices",text:"Works on any device"}];function sr({onStart:t}){const[e,o]=L(!1),i=()=>{o(!0),t()};return u("div",{className:"flex-1 flex flex-col items-center justify-between px-6 py-6 overflow-y-auto",children:[u("div",{className:"flex flex-col items-center gap-2 text-center mt-2",children:[u("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mb-1",style:{background:"var(--brand-500)",boxShadow:"0 8px 32px rgba(255,87,10,0.35)"},children:u("span",{className:"material-symbols-outlined text-white",style:{fontSize:30},children:"terminal"})}),u("h1",{className:"text-lg font-bold tracking-tight",style:{color:"var(--text-main)"},children:"9Remote"}),u("p",{className:"text-xs leading-5 max-w-[220px]",style:{color:"var(--text-muted)"},children:"Access your terminal, desktop & files from anywhere"})]}),u("div",{className:"flex gap-2 w-full mt-5",children:or.map(n=>u("div",{className:"flex-1 dark-card flex flex-col items-center gap-1.5 py-3 px-1",children:[u("span",{className:"material-symbols-outlined",style:{fontSize:22,color:"var(--brand-400)"},children:n.icon}),u("p",{className:"text-xs font-semibold",style:{color:"var(--text-main)"},children:n.label}),u("p",{className:"text-[10px] text-center leading-4",style:{color:"var(--text-muted)"},children:n.desc})]},n.label))}),u("div",{className:"flex flex-col gap-2 w-full mt-4",children:ir.map(n=>u("div",{className:"flex items-center gap-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--brand-400)"},children:n.icon}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:n.text})]},n.text))}),u("button",{onClick:e?void 0:i,disabled:e,className:"btn-primary w-full py-3.5 flex items-center justify-center gap-2 text-sm font-semibold mt-6",style:{borderRadius:"var(--radius-brand)",opacity:e?.7:1},children:e?u(K,{children:[u("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(n=>u("span",{className:"w-1.5 h-1.5 rounded-full bg-white dot-bounce",style:{animationDelay:`${n*.18}s`}},n))}),"Connecting..."]}):u(K,{children:[u("span",{className:"material-symbols-outlined text-base",children:"play_arrow"}),"Connect"]})})]})}function lr({conn:t}){return u("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[u("div",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-medium truncate",style:{color:"var(--text-main)"},children:t.ip||"Unknown"}),u("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.connectedAt?new Date(t.connectedAt).toLocaleTimeString():""})]}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.type||"ws"})]})}function ar({step:t,tunnelUrl:e,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,qrUrl:r,permissions:s,desktopEnabled:l,updateVersion:a,connections:d=[],version:h="",onRequestPermission:c,onDesktopToggle:_,onStop:f,onStart:v,onGenerateOneTimeKey:C,onRegenerateKey:P,logs:y=[],theme:b,onToggleTheme:k}){const[N,A]=L("connect"),[x,p]=L(!1),g=tn(null),m=t===0,E=t>0&&t<4;return Z(()=>{var w;N==="log"&&((w=g.current)==null||w.scrollIntoView({behavior:"smooth"}))},[y,N]),u("div",{className:"h-full flex flex-col relative overflow-hidden",style:{background:"var(--bg-main)"},children:[u("div",{className:"flex-1 flex flex-col w-full min-h-0 dot-grid-bg overflow-hidden md:max-w-6xl",style:{margin:"0 auto"},children:[u("div",{className:"flex items-center justify-between px-5 py-4",style:{boxShadow:"var(--header-shadow)",backdropFilter:"blur(10px)"},children:[u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--brand-500)"},children:u("span",{className:"material-symbols-outlined text-white text-base",children:"terminal"})}),u("div",{className:"flex flex-col leading-tight",children:[u("span",{className:"brand-text text-xs",children:"9Remote"}),h&&u("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:["v",h]})]})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{onClick:k,className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},title:b==="dark"?"Switch to light mode":"Switch to dark mode",children:u("span",{className:"material-symbols-outlined text-sm",children:b==="dark"?"light_mode":"dark_mode"})}),u("button",{onClick:()=>window.open($n,"_blank"),className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},children:u("span",{className:"material-symbols-outlined text-sm",children:"help_outline"})}),!m&&u("button",{onClick:()=>p(!0),className:"btn-danger px-3 h-7 flex items-center gap-1.5 text-xs font-medium",children:[u("span",{className:"material-symbols-outlined text-sm",children:"stop_circle"}),"Disconnect"]})]})]}),u(rr,{version:a}),m?u(sr,{onStart:v,connecting:!1}):E?u("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4 max-w-2xl mx-auto w-full",children:u(Sn,{currentStep:t})}):u("div",{className:"flex-1 flex flex-col md:flex-row min-h-0",children:[u("div",{className:"hidden md:flex md:flex-col sidebar w-96 flex-shrink-0 overflow-y-auto p-5 gap-4",children:u(zt,{qrUrl:r,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,tunnelUrl:e,onGenerateOneTimeKey:C,onRegenerateKey:P})}),u("div",{className:"flex-1 flex flex-col min-h-0",children:[u("div",{className:"flex px-5 pt-3 gap-3",style:{borderColor:"var(--border)"},children:[{id:"connect",label:"Connection"},{id:"log",label:"Logs"}].map(w=>u("button",{onClick:()=>A(w.id),className:"py-2 text-xs font-medium border-b-2 transition-colors",style:N===w.id?{borderColor:"var(--brand-500)",color:"var(--brand-500)"}:{borderColor:"transparent",color:"var(--text-muted)"},children:w.label},w.id))}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4",children:[N==="connect"&&u(K,{children:[u("div",{className:"md:hidden",children:u(zt,{qrUrl:r,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,tunnelUrl:e,onGenerateOneTimeKey:C,onRegenerateKey:P})}),u(tr,{}),u(nr,{enabled:l,onToggle:_,permissions:s,onRequestPermission:c}),u("div",{className:"glass-card p-4 flex flex-col gap-1",children:[u("p",{className:"text-xs font-medium uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:["Clients",d.length>0?` (${d.length})`:""]}),d.length===0?u("p",{className:"text-xs text-center py-3",style:{color:"var(--text-muted)"},children:"No active connections"}):d.map((w,S)=>u(lr,{conn:w},S))]})]}),N==="log"&&u("div",{className:"flex-1 flex flex-col",children:y.length===0?u("p",{className:"text-xs text-center mt-8",style:{color:"var(--text-muted)"},children:"No logs yet"}):u("div",{className:"flex flex-col gap-0.5",children:[y.map((w,S)=>u("p",{className:"text-xs font-mono leading-5 break-all",style:{color:"var(--text-muted)"},children:w},S)),u("div",{ref:g})]})})]})]})]})]}),x&&u(Oe,{message:"Disconnect and stop the tunnel? Remote clients will be disconnected.",confirmLabel:"Disconnect",confirmDanger:!0,onConfirm:()=>{p(!1),f==null||f()},onCancel:()=>p(!1)})]})}const jt={step:0,tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:"",qrUrl:"",latency:null,uptime:null},cr={screenRecording:!1,accessibility:!1},Kt=200;function ur(){const[t,e]=L(jt),[o,i]=L(cr),[n,r]=L(!1),[s,l]=L([]),[a,d]=L(null),[h,c]=L([]),[_,f]=L(""),[v,C]=L(()=>localStorage.getItem("9remote-theme")||"dark");Z(()=>{document.documentElement.setAttribute("data-theme",v),localStorage.setItem("9remote-theme",v)},[v]);const P=()=>{C(p=>p==="dark"?"light":"dark")};Z(()=>{fetch("/api/version").then(g=>g.json()).then(g=>f(g.version??"")).catch(()=>{}),fetch("/api/ui/state").then(g=>g.json()).then(g=>{e({step:g.step??0,tunnelUrl:g.tunnelUrl??"",oneTimeKey:g.oneTimeKey??"",oneTimeKeyExpiresAt:g.oneTimeKeyExpiresAt??null,permanentKey:g.permanentKey??"",qrUrl:g.qrUrl??"",latency:g.latency??null,uptime:g.uptime??null}),i({screenRecording:g.screenRecording??!1,accessibility:g.accessibility??!1}),g.desktopEnabled!==void 0&&r(g.desktopEnabled),g.theme&&(g.theme==="light"||g.theme==="dark")&&C(g.theme)}).catch(()=>{});const p=new EventSource("/api/ui/events");return p.onmessage=g=>{try{const m=JSON.parse(g.data);m.type==="state"?e({step:m.step??0,tunnelUrl:m.tunnelUrl??"",oneTimeKey:m.oneTimeKey??"",oneTimeKeyExpiresAt:m.oneTimeKeyExpiresAt??null,permanentKey:m.permanentKey??"",qrUrl:m.qrUrl??"",latency:m.latency??null,uptime:m.uptime??null}):m.type==="log"?l(E=>{const w=[...E,m.message];return w.length>Kt?w.slice(-Kt):w}):m.type==="updateAvailable"?d(m.version):m.type==="permissions"?(i({screenRecording:m.screenRecording,accessibility:m.accessibility}),m.desktopEnabled!==void 0&&r(m.desktopEnabled)):m.type==="connections"&&c(m.connections??[])}catch{}},p.onerror=()=>{},()=>p.close()},[]);const y=async p=>{await fetch("/api/permissions/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:p})}).catch(()=>{})},b=()=>{fetch("/api/ui/stop",{method:"POST"}).catch(()=>{}),e(jt)},k=()=>{fetch("/api/ui/start",{method:"POST"}).catch(()=>{})},N=async()=>{const p=await fetch("/api/key/one-time",{method:"POST"}).catch(()=>null);if(!(p!=null&&p.ok))return;const g=await p.json().catch(()=>null);g!=null&&g.oneTimeKey&&e(m=>({...m,oneTimeKey:g.oneTimeKey,oneTimeKeyExpiresAt:g.expiresAt,qrUrl:g.qrUrl??m.qrUrl}))},A=async()=>{const p=!n;r(p),await fetch("/api/desktop/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:p})}).catch(()=>{})},x=async()=>{const p=await fetch("/api/key/regenerate",{method:"POST"}).catch(()=>null);if(!(p!=null&&p.ok))return;const g=await p.json().catch(()=>null);g!=null&&g.permanentKey&&e(m=>({...m,permanentKey:g.permanentKey}))};return u(ar,{step:t.step,tunnelUrl:t.tunnelUrl,oneTimeKey:t.oneTimeKey,oneTimeKeyExpiresAt:t.oneTimeKeyExpiresAt,permanentKey:t.permanentKey,qrUrl:t.qrUrl,permissions:o,desktopEnabled:n,updateVersion:a,connections:h,onRequestPermission:y,onDesktopToggle:A,onStop:b,onStart:k,onGenerateOneTimeKey:N,onRegenerateKey:x,logs:s,version:_,theme:v,onToggleTheme:P})}bn(u(ur,{}),document.getElementById("root"));
|
|
8
|
+
`;return typeof l=="function"&&l(null,P),P},Fe}var Ft;function Qn(){if(Ft)return Y;Ft=1;const t=Pn(),e=Jn(),o=Yn(),i=Gn();function n(r,s,l,a,d){const h=[].slice.call(arguments,1),c=h.length,_=typeof h[c-1]=="function";if(!_&&!t())throw new Error("Callback required as last argument");if(_){if(c<2)throw new Error("Too few arguments provided");c===2?(d=l,l=s,s=a=void 0):c===3&&(s.getContext&&typeof d>"u"?(d=a,a=void 0):(d=a,a=l,l=s,s=void 0))}else{if(c<1)throw new Error("Too few arguments provided");return c===1?(l=s,s=a=void 0):c===2&&!s.getContext&&(a=l,l=s,s=void 0),new Promise(function(f,v){try{const C=e.create(l,a);f(r(C,s,a))}catch(C){v(C)}})}try{const f=e.create(l,a);d(null,r(f,s,a))}catch(f){d(f)}}return Y.create=e.create,Y.toCanvas=n.bind(null,o.render),Y.toDataURL=n.bind(null,o.renderToDataURL),Y.toString=n.bind(null,function(r,s,l){return i.render(r,l)}),Y}var Wn=Qn();const Xn=Tn(Wn);function Oe({message:t,confirmLabel:e="Confirm",confirmDanger:o=!1,onConfirm:i,onCancel:n}){return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},children:u("div",{className:"glass-card p-5 flex flex-col gap-4 w-72",children:[u("p",{className:"text-sm text-center",style:{color:"var(--text-main)"},children:t}),u("div",{className:"flex gap-2",children:[u("button",{onClick:n,className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:"Cancel"}),u("button",{onClick:i,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:o?"rgba(220,53,69,0.8)":"var(--brand-500)",color:"#fff"},children:e})]})]})})}const Ht="9remote.cc";function Zn(t){if(t<=0)return"Expired";const e=Math.floor(t/1e3),o=Math.floor(e/60),i=e%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function ne({icon:t,onClick:e,title:o,danger:i}){return u("button",{onClick:e,title:o,className:"glass-btn w-7 h-7 flex items-center justify-center flex-shrink-0",style:i?{color:"rgba(255,100,100,0.7)"}:{color:"var(--text-muted)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:15},children:t})})}function zt({qrUrl:t,oneTimeKey:e,oneTimeKeyExpiresAt:o,permanentKey:i,onGenerateOneTimeKey:n,onRegenerateKey:r}){const s=tn(null),[l,a]=L(null),[d,h]=L(null),[c,_]=L(null);Z(()=>{!t||!s.current||Xn.toCanvas(s.current,t,{width:160,margin:1,color:{dark:"#0f1923",light:"#ffffff"}}).catch(()=>{})},[t]),Z(()=>{if(!o){a(null);return}const v=()=>a(o-Date.now());v();const C=setInterval(v,1e3);return()=>clearInterval(C)},[o]);const f=(v,C)=>{navigator.clipboard.writeText(v).catch(()=>{}),h(C),setTimeout(()=>h(null),2e3)};return u(K,{children:[c==="oneTime"&&u(Oe,{message:"Generate a new one-time key? The current one will expire immediately.",confirmLabel:"Generate",onConfirm:()=>{_(null),n==null||n()},onCancel:()=>_(null)}),c==="regen"&&u(Oe,{message:"Regenerate permanent key? All existing sessions will be disconnected.",confirmLabel:"Regenerate",confirmDanger:!0,onConfirm:()=>{_(null),r==null||r()},onCancel:()=>_(null)}),u("div",{className:"glass-card p-5 flex flex-col items-center gap-4",children:[u("div",{className:"w-44 h-44 rounded-xl overflow-hidden bg-white p-2 flex items-center justify-center flex-shrink-0",children:t?u("canvas",{ref:s}):u("span",{className:"material-symbols-outlined text-gray-300 text-6xl",children:"qr_code_2"})}),u("a",{href:`https://${Ht}/login`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 hover:opacity-80 transition-opacity",children:[u("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 flex-shrink-0"}),u("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:[Ht,"/login"]})]}),u("div",{className:"w-full h-px",style:{background:"var(--border)"}}),u("div",{className:"w-full flex flex-col gap-1.5",children:[u("div",{className:"flex items-center justify-between px-0.5",children:[u("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"One-Time Key"}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Single use · expires"})]}),u("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"timer"}),u("span",{className:"flex-1 font-mono font-bold tracking-[0.18em] text-base truncate",style:{color:e?"var(--brand-500)":"var(--border)"},children:e||"• • • • • •"}),l!==null&&u("span",{className:`text-xs font-mono flex-shrink-0 ${l<=0?"text-red-400":""}`,style:l>0?{color:"var(--text-muted)"}:{},children:Zn(l)}),e&&u(ne,{icon:d==="oneTime"?"check":"content_copy",onClick:()=>f(e,"oneTime"),title:"Copy one-time key"}),u(ne,{icon:"refresh",onClick:()=>_("oneTime"),title:"New one-time key"})]})]}),u("div",{className:"w-full flex flex-col gap-1.5",children:[u("div",{className:"flex items-center justify-between px-0.5",children:[u("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Permanent Key"}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Reusable · no expiry"})]}),u("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"key"}),u("span",{className:"flex-1 font-mono text-xs truncate",style:{color:"var(--text-muted)"},children:i||"— not set —"}),i&&u(ne,{icon:d==="permanent"?"check":"content_copy",onClick:()=>f(i,"permanent"),title:"Copy permanent key"}),u(ne,{icon:"autorenew",onClick:()=>_("regen"),title:"Regenerate permanent key",danger:!0})]})]})]})]})}const $n="https://docs.9remote.cc/",cn={screenRecording:{label:"Screen Recording",icon:"screenshot_monitor",desc:"Capture screen content"},accessibility:{label:"Accessibility",icon:"accessibility_new",desc:"Control mouse & keyboard"}};function er({type:t,granted:e,onRequest:o}){const i=cn[t]||{label:t,desc:""};return u("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[u("span",{className:`material-symbols-outlined flex-shrink-0 ${e?"text-green-400":""}`,style:{fontSize:18,color:e?void 0:"var(--text-muted)"},children:e?"check_circle":"cancel"}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-medium",style:{color:e?"var(--text-main)":"var(--text-muted)"},children:i.label}),u("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:i.desc})]}),!e&&u("button",{onClick:()=>o(t),className:"flex-shrink-0 text-xs px-2.5 py-1 rounded-lg font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Grant"})]})}function tr({desktopEnabled:t,onDesktopToggle:e,permissions:o,onRequestPermission:i}){const n=Object.entries(cn);return u("div",{className:"glass-card p-4 flex flex-col gap-3",children:[u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(255,87,10,0.15)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:20,color:"var(--brand-400)"},children:"terminal"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"Remote Terminal"}),u("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Full shell access · always on"})]}),u("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-full",style:{background:"rgba(74,222,128,0.1)"},children:[u("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400"}),u("span",{className:"text-xs text-green-400 font-medium",children:"On"})]})]}),u("div",{className:"w-full h-px",style:{background:"var(--border)"}}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:t?"rgba(255,87,10,0.15)":"var(--glass-bg)"},children:u("span",{className:"material-symbols-outlined",style:{fontSize:20,color:t?"var(--brand-400)":"var(--text-muted)"},children:"desktop_windows"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"Remote Desktop"}),u("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Control screen, mouse & keyboard"})]}),u("button",{onClick:e,className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:t?"var(--brand-500)":"var(--border)"},children:u("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:t?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),t&&u("div",{className:"flex flex-col border-t pt-2",style:{borderColor:"var(--border)"},children:[u("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"System Permissions"}),n.map(([r])=>u(er,{type:r,granted:(o==null?void 0:o[r])??!1,onRequest:i},r))]})]})}function nr({version:t}){return t?u("div",{className:"px-5 py-2 flex items-center gap-2 border-b",style:{background:"rgba(255,87,10,0.08)",borderColor:"rgba(255,87,10,0.2)"},children:[u("span",{className:"material-symbols-outlined text-sm flex-shrink-0",style:{color:"var(--brand-400)"},children:"system_update"}),u("span",{className:"text-xs flex-1",style:{color:"var(--brand-400)"},children:["Version ",t," available"]}),u("button",{onClick:()=>fetch("/api/update",{method:"POST"}).catch(()=>{}),className:"flex-shrink-0 text-xs px-2 py-0.5 rounded font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Update"})]}):null}const rr=[{icon:"terminal",label:"Terminal",desc:"Full shell access"},{icon:"desktop_windows",label:"Desktop",desc:"Remote screen control"},{icon:"folder_open",label:"Files",desc:"Browse & edit files"}],or=[{icon:"qr_code_scanner",text:"Scan QR to connect instantly"},{icon:"wifi_off",text:"No port forwarding needed"},{icon:"devices",text:"Works on any device"}];function ir({onStart:t}){const[e,o]=L(!1),i=()=>{o(!0),t()};return u("div",{className:"flex-1 flex flex-col items-center justify-between px-6 py-6 overflow-y-auto",children:[u("div",{className:"flex flex-col items-center gap-2 text-center mt-2",children:[u("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mb-1",style:{background:"var(--brand-500)",boxShadow:"0 8px 32px rgba(255,87,10,0.35)"},children:u("span",{className:"material-symbols-outlined text-white",style:{fontSize:30},children:"terminal"})}),u("h1",{className:"text-lg font-bold tracking-tight",style:{color:"var(--text-main)"},children:"9Remote"}),u("p",{className:"text-xs leading-5 max-w-[220px]",style:{color:"var(--text-muted)"},children:"Access your terminal, desktop & files from anywhere"})]}),u("div",{className:"flex gap-2 w-full mt-5",children:rr.map(n=>u("div",{className:"flex-1 dark-card flex flex-col items-center gap-1.5 py-3 px-1",children:[u("span",{className:"material-symbols-outlined",style:{fontSize:22,color:"var(--brand-400)"},children:n.icon}),u("p",{className:"text-xs font-semibold",style:{color:"var(--text-main)"},children:n.label}),u("p",{className:"text-[10px] text-center leading-4",style:{color:"var(--text-muted)"},children:n.desc})]},n.label))}),u("div",{className:"flex flex-col gap-2 w-full mt-4",children:or.map(n=>u("div",{className:"flex items-center gap-2.5",children:[u("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--brand-400)"},children:n.icon}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:n.text})]},n.text))}),u("button",{onClick:e?void 0:i,disabled:e,className:"btn-primary w-full py-3.5 flex items-center justify-center gap-2 text-sm font-semibold mt-6",style:{borderRadius:"var(--radius-brand)",opacity:e?.7:1},children:e?u(K,{children:[u("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(n=>u("span",{className:"w-1.5 h-1.5 rounded-full bg-white dot-bounce",style:{animationDelay:`${n*.18}s`}},n))}),"Connecting..."]}):u(K,{children:[u("span",{className:"material-symbols-outlined text-base",children:"play_arrow"}),"Connect"]})})]})}function sr({conn:t}){return u("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[u("div",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-medium truncate",style:{color:"var(--text-main)"},children:t.ip||"Unknown"}),u("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.connectedAt?new Date(t.connectedAt).toLocaleTimeString():""})]}),u("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:t.type||"ws"})]})}function lr({step:t,tunnelUrl:e,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,qrUrl:r,permissions:s,desktopEnabled:l,updateVersion:a,connections:d=[],version:h="",onRequestPermission:c,onDesktopToggle:_,onStop:f,onStart:v,onGenerateOneTimeKey:C,onRegenerateKey:P,logs:y=[],theme:b,onToggleTheme:k}){const[N,A]=L("connect"),[x,p]=L(!1),g=tn(null),m=t===0,E=t>0&&t<4;return Z(()=>{var w;N==="log"&&((w=g.current)==null||w.scrollIntoView({behavior:"smooth"}))},[y,N]),u("div",{className:"h-full flex flex-col relative overflow-hidden",style:{background:"var(--bg-main)"},children:[u("div",{className:"flex-1 flex flex-col w-full min-h-0 dot-grid-bg overflow-hidden md:max-w-6xl",style:{margin:"0 auto"},children:[u("div",{className:"flex items-center justify-between px-5 py-4",style:{boxShadow:"var(--header-shadow)",backdropFilter:"blur(10px)"},children:[u("div",{className:"flex items-center gap-3",children:[u("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--brand-500)"},children:u("span",{className:"material-symbols-outlined text-white text-base",children:"terminal"})}),u("div",{className:"flex flex-col leading-tight",children:[u("span",{className:"brand-text text-xs",children:"9Remote"}),h&&u("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:["v",h]})]})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{onClick:k,className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},title:b==="dark"?"Switch to light mode":"Switch to dark mode",children:u("span",{className:"material-symbols-outlined text-sm",children:b==="dark"?"light_mode":"dark_mode"})}),u("button",{onClick:()=>window.open($n,"_blank"),className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},children:u("span",{className:"material-symbols-outlined text-sm",children:"help_outline"})}),!m&&u("button",{onClick:()=>p(!0),className:"btn-danger px-3 h-7 flex items-center gap-1.5 text-xs font-medium",children:[u("span",{className:"material-symbols-outlined text-sm",children:"stop_circle"}),"Disconnect"]})]})]}),u(nr,{version:a}),m?u(ir,{onStart:v,connecting:!1}):E?u("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4 max-w-2xl mx-auto w-full",children:u(Sn,{currentStep:t})}):u("div",{className:"flex-1 flex flex-col md:flex-row min-h-0",children:[u("div",{className:"hidden md:flex md:flex-col sidebar w-96 flex-shrink-0 overflow-y-auto p-5 gap-4",children:u(zt,{qrUrl:r,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,tunnelUrl:e,onGenerateOneTimeKey:C,onRegenerateKey:P})}),u("div",{className:"flex-1 flex flex-col min-h-0",children:[u("div",{className:"flex px-5 pt-3 gap-3",style:{borderColor:"var(--border)"},children:[{id:"connect",label:"Connection"},{id:"log",label:"Logs"}].map(w=>u("button",{onClick:()=>A(w.id),className:"py-2 text-xs font-medium border-b-2 transition-colors",style:N===w.id?{borderColor:"var(--brand-500)",color:"var(--brand-500)"}:{borderColor:"transparent",color:"var(--text-muted)"},children:w.label},w.id))}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4",children:[N==="connect"&&u(K,{children:[u("div",{className:"md:hidden",children:u(zt,{qrUrl:r,oneTimeKey:o,oneTimeKeyExpiresAt:i,permanentKey:n,tunnelUrl:e,onGenerateOneTimeKey:C,onRegenerateKey:P})}),u(tr,{desktopEnabled:l,onDesktopToggle:_,permissions:s,onRequestPermission:c}),u("div",{className:"glass-card p-4 flex flex-col gap-1",children:[u("p",{className:"text-xs font-medium uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:["Clients",d.length>0?` (${d.length})`:""]}),d.length===0?u("p",{className:"text-xs text-center py-3",style:{color:"var(--text-muted)"},children:"No active connections"}):d.map((w,S)=>u(sr,{conn:w},S))]})]}),N==="log"&&u("div",{className:"flex-1 flex flex-col",children:y.length===0?u("p",{className:"text-xs text-center mt-8",style:{color:"var(--text-muted)"},children:"No logs yet"}):u("div",{className:"flex flex-col gap-0.5",children:[y.map((w,S)=>u("p",{className:"text-xs font-mono leading-5 break-all",style:{color:"var(--text-muted)"},children:w},S)),u("div",{ref:g})]})})]})]})]})]}),x&&u(Oe,{message:"Disconnect and stop the tunnel? Remote clients will be disconnected.",confirmLabel:"Disconnect",confirmDanger:!0,onConfirm:()=>{p(!1),f==null||f()},onCancel:()=>p(!1)})]})}const jt={step:0,tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:"",qrUrl:"",latency:null,uptime:null},ar={screenRecording:!1,accessibility:!1},Kt=200;function cr(){const[t,e]=L(jt),[o,i]=L(ar),[n,r]=L(!1),[s,l]=L([]),[a,d]=L(null),[h,c]=L([]),[_,f]=L(""),[v,C]=L(()=>localStorage.getItem("9remote-theme")||"dark");Z(()=>{document.documentElement.setAttribute("data-theme",v),localStorage.setItem("9remote-theme",v)},[v]);const P=()=>{C(p=>p==="dark"?"light":"dark")};Z(()=>{fetch("/api/version").then(g=>g.json()).then(g=>f(g.version??"")).catch(()=>{}),fetch("/api/ui/state").then(g=>g.json()).then(g=>{e({step:g.step??0,tunnelUrl:g.tunnelUrl??"",oneTimeKey:g.oneTimeKey??"",oneTimeKeyExpiresAt:g.oneTimeKeyExpiresAt??null,permanentKey:g.permanentKey??"",qrUrl:g.qrUrl??"",latency:g.latency??null,uptime:g.uptime??null}),i({screenRecording:g.screenRecording??!1,accessibility:g.accessibility??!1}),g.desktopEnabled!==void 0&&r(g.desktopEnabled),g.theme&&(g.theme==="light"||g.theme==="dark")&&C(g.theme)}).catch(()=>{});const p=new EventSource("/api/ui/events");return p.onmessage=g=>{try{const m=JSON.parse(g.data);m.type==="state"?e({step:m.step??0,tunnelUrl:m.tunnelUrl??"",oneTimeKey:m.oneTimeKey??"",oneTimeKeyExpiresAt:m.oneTimeKeyExpiresAt??null,permanentKey:m.permanentKey??"",qrUrl:m.qrUrl??"",latency:m.latency??null,uptime:m.uptime??null}):m.type==="log"?l(E=>{const w=[...E,m.message];return w.length>Kt?w.slice(-Kt):w}):m.type==="updateAvailable"?d(m.version):m.type==="permissions"?(i({screenRecording:m.screenRecording,accessibility:m.accessibility}),m.desktopEnabled!==void 0&&r(m.desktopEnabled)):m.type==="connections"&&c(m.connections??[])}catch{}},p.onerror=()=>{},()=>p.close()},[]);const y=async p=>{await fetch("/api/permissions/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:p})}).catch(()=>{})},b=()=>{fetch("/api/ui/stop",{method:"POST"}).catch(()=>{}),e(jt)},k=()=>{fetch("/api/ui/start",{method:"POST"}).catch(()=>{})},N=async()=>{const p=await fetch("/api/key/one-time",{method:"POST"}).catch(()=>null);if(!(p!=null&&p.ok))return;const g=await p.json().catch(()=>null);g!=null&&g.oneTimeKey&&e(m=>({...m,oneTimeKey:g.oneTimeKey,oneTimeKeyExpiresAt:g.expiresAt,qrUrl:g.qrUrl??m.qrUrl}))},A=async()=>{const p=!n;r(p),await fetch("/api/desktop/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:p})}).catch(()=>{})},x=async()=>{const p=await fetch("/api/key/regenerate",{method:"POST"}).catch(()=>null);if(!(p!=null&&p.ok))return;const g=await p.json().catch(()=>null);g!=null&&g.permanentKey&&e(m=>({...m,permanentKey:g.permanentKey}))};return u(lr,{step:t.step,tunnelUrl:t.tunnelUrl,oneTimeKey:t.oneTimeKey,oneTimeKeyExpiresAt:t.oneTimeKeyExpiresAt,permanentKey:t.permanentKey,qrUrl:t.qrUrl,permissions:o,desktopEnabled:n,updateVersion:a,connections:h,onRequestPermission:y,onDesktopToggle:A,onStop:b,onStart:k,onGenerateOneTimeKey:N,onRegenerateKey:x,logs:s,version:_,theme:v,onToggleTheme:P})}bn(u(cr,{}),document.getElementById("root"));
|
package/dist/ui/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
const savedTheme = localStorage.getItem("9remote-theme") || "dark";
|
|
15
15
|
document.documentElement.setAttribute("data-theme", savedTheme);
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-B37vtDoz.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-BfTPkO8b.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|