herdr-remote 0.3.33 → 0.3.34
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/chunks/{VD54DF7R.js → 2IM3AVNW.js} +1 -1
- package/dist/chunks/{MCUVFSSK.js → 2RUREFQO.js} +1 -1
- package/dist/chunks/{RMHH3IAX.js → 6M7I477E.js} +1 -1
- package/dist/chunks/{KGOQKOHH.js → 72JMGTAK.js} +1 -1
- package/dist/chunks/{MEFDV375.js → FN6VM2O7.js} +1 -1
- package/dist/chunks/{O2LNVFUT.js → I6K6O3EE.js} +1 -1
- package/dist/chunks/{K5RFPHSF.js → IRV2W3ZL.js} +1 -1
- package/dist/chunks/J427SPKK.js +3 -0
- package/dist/chunks/{M52LJEES.js → MHS44P3Y.js} +1 -1
- package/dist/chunks/{CVJ4HBMP.js → MLSLOPR7.js} +1 -1
- package/dist/chunks/{QCSILMFB.js → MRXHG2UD.js} +1 -1
- package/dist/chunks/NKDFWWLU.js +3 -0
- package/dist/chunks/{LPR662JH.js → NY3SVG3W.js} +2 -2
- package/dist/chunks/{MKAEXKXG.js → QRQJLJWT.js} +1 -1
- package/dist/chunks/{WY7WHEJ4.js → QXMBBOKS.js} +1 -1
- package/dist/chunks/{H24ZP5D5.js → S3V2O6BK.js} +1 -1
- package/dist/chunks/{DGUZCGQN.js → S57VTPH5.js} +1 -1
- package/dist/chunks/{FONUO5O5.js → TSP3KNDA.js} +1 -1
- package/dist/chunks/{44IGVPMA.js → UK7XZS2G.js} +1 -1
- package/dist/chunks/{LY2ZGCXN.js → W24FRSKQ.js} +1 -1
- package/dist/chunks/W27D73NQ.js +3 -0
- package/dist/chunks/{B76DFI4H.js → WDPLLWBV.js} +1 -1
- package/dist/chunks/{AX4EPJCP.js → Y5CEFDIU.js} +1 -1
- package/dist/chunks/{PBRQ3HEG.js → ZZOEVJ3V.js} +1 -1
- package/dist/cli.js +4 -4
- package/dist/connector/main.js +12 -12
- package/herdr-plugin.toml +1 -1
- package/node_modules/herdr-remote-relay/bin/herdr-remote-relay.js +10 -10
- package/node_modules/herdr-remote-relay/package.json +1 -1
- package/node_modules/herdr-remote-relay/web/dist/assets/index-CnRQXj8k.js +61 -0
- package/node_modules/herdr-remote-relay/web/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/chunks/5LZFJ6UZ.js +0 -3
- package/dist/chunks/BYGDPZZD.js +0 -3
- package/dist/chunks/PBMBFWLQ.js +0 -3
- package/node_modules/herdr-remote-relay/web/dist/assets/index-DfycvWFA.js +0 -61
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a as F,b as B,c as q,d as Q,e as P,g as r,h,m as i}from"./
|
|
3
|
+
import{a as F,b as B,c as q,d as Q,e as P,g as r,h,m as i}from"./6M7I477E.js";import{a as m,b as G,c as a}from"./MLSLOPR7.js";import{o as u}from"./MHS44P3Y.js";import{b as U,c as j}from"./KRVF37OW.js";import{a as w,b as M,c as W}from"./QRGNEKME.js";import{b as C,c as d,f as N}from"./TNLCNVA2.js";import{c as it}from"./I6NRCYLI.js";var It={};it(It,{detectManager:()=>rt,enableLinger:()=>At,escapeXml:()=>F,install:()=>Pt,logsHint:()=>xt,renderLaunchdPlist:()=>B,renderSystemdUnit:()=>O,restart:()=>Dt,serviceEnvironment:()=>a,servicePath:()=>G,status:()=>st,stopManaged:()=>bt,systemdEnvironmentLine:()=>L,uninstall:()=>Rt});import{spawnSync as Et}from"node:child_process";import tt from"node:fs";import Nt from"node:os";import et from"node:path";import{spawn as at}from"node:child_process";import D from"node:fs";import ct from"node:path";function k(){return ct.join(d(),"supervisor.pid")}function b(){let t=W(k(),{});return j([t]).length>0?t.pid:null}function X(){let t=b();if(t!==null)return{ok:!0,alreadyRunning:!0,pid:t};w(d());let e=D.openSync(N("supervisor"),"a");try{let n=at(process.execPath,[m(),"run","--daemon"],{cwd:d(),env:{...process.env,HERDR_REMOTE_SERVICE:"1",...a()},detached:!0,windowsHide:!0,stdio:["ignore",e,e]});return n.unref(),M(k(),{pid:n.pid,processStart:n.pid?U(n.pid):null,startedAt:new Date().toISOString()}),{ok:!0,pid:n.pid,note:"this fallback does not survive a reboot"}}finally{D.closeSync(e)}}function R(){let t=b();if(t!==null)try{process.kill(t,"SIGTERM")}catch{}return D.rmSync(k(),{force:!0}),{ok:!0,stoppedPid:t}}function A(t=process.platform,e=N("supervisor")){return t==="win32"?`Get-Content -Wait -Tail 40 "${e}"`:`tail -f ${e}`}var J={name:"supervisor",status(){let t=b(),e=t!==null;return{manager:"supervisor",installed:e,active:e,enabled:!1,pid:e?t:null,unitPath:k(),state:e?"running":"stopped"}},async install(){return X()},async uninstall(){return R()},restart(){return R(),X()},stop(){R()},logsHint(){return A()}};import{spawnSync as V}from"node:child_process";import x from"node:fs";import I from"node:os";import _ from"node:path";var c="herdr-remote.service";function $(){let t=process.env.XDG_CONFIG_HOME||_.join(I.homedir(),".config");return _.join(t,"systemd","user",c)}function L(t,e){let n=String(e).replace(/[\r\n]+/g," ").replace(/%/g,"%%");return/^[\w@+=:,./-]*$/.test(n)?`Environment=${t}=${n}`:`Environment="${t}=${n.replace(/([\\"])/g,"\\$1")}"`}function O({nodePath:t=process.execPath,entryPoint:e=m(),environment:n={}}={}){let s=Object.entries(n).map(([o,S])=>L(o,S)).join(`
|
|
4
4
|
`);return`[Unit]
|
|
5
5
|
Description=Herdr Remote (relay and host connector)
|
|
6
6
|
Documentation=https://github.com/dibin666/herdr-remote
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{d as m,e as n,f as c,g as p}from"./
|
|
3
|
+
import{d as m,e as n,f as c,g as p}from"./UK7XZS2G.js";import{a as l,h as o}from"./U6QAYG3E.js";import{d as s,g as i,h as v,j as f}from"./2IM3AVNW.js";import{o as t}from"./MHS44P3Y.js";function u(a){let e=s(a);return e.installed||e.active?e:null}function S(a=t()){let e=u(a);return e?(e.active||i(a),{ok:!0,managed:!0,manager:e.manager,alreadyRunning:!!e.active}):{...m(),managed:!1}}function w(a=t()){let e=v(a);return e.managed?(n(),{ok:!0,managed:!0,manager:e.manager}):{...n(),managed:!1}}function P(a=t()){let e=u(a);return e?(i(a),{ok:!0,managed:!0,manager:e.manager}):{...c(),managed:!1}}function y(a=t()){if(u(a)?.active)return!0;let e=l();return o(e).some(({pid:r})=>r===e.hostPid)}async function x(a,e,{platform:r=process.platform,isRunning:d=()=>y(a),stop:g=w,start:k=S}={}){if(r!=="win32"||!d())return e();await g(a);try{return await e()}finally{await k(a)}}async function B(a=t()){let[e,r]=[await p(),s(a)];return{...e,keepalive:r,logsHint:f(a)}}export{u as a,S as b,w as c,P as d,y as e,x as f,B as g};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a as m,c as S}from"./
|
|
3
|
+
import{a as m,c as S}from"./MLSLOPR7.js";import{a as x}from"./QRGNEKME.js";import{a as R,b as D,c,f as g}from"./TNLCNVA2.js";import{spawnSync as T}from"node:child_process";import $ from"node:fs";import M from"node:os";import W from"node:path";var k="dev.herdr.remote";function C(){return W.join(M.homedir(),"Library","LaunchAgents",`${k}.plist`)}function n(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function V({nodePath:t=process.execPath,entryPoint:e=m(),label:r=k,outLog:o=g("supervisor"),errLog:i=g("supervisor"),environment:p={}}={}){let u=Object.entries(p).map(([y,v])=>` <key>${n(y)}</key>
|
|
4
4
|
<string>${n(v)}</string>`).join(`
|
|
5
5
|
`),s=u?` <key>EnvironmentVariables</key>
|
|
6
6
|
<dict>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{p as b,q as Q,r as G,s as K}from"./NKDFWWLU.js";import{a as E,c as Z}from"./TNLCNVA2.js";import h from"node:fs";import w from"node:path";var Ae=["EBUSY","EPERM","EACCES"];function ee(e){return/\b(EBUSY|EPERM)\b/.test(e??"")}function $e(e,t,o){try{o(e,t)}catch(n){if(!Ae.includes(n.code??""))throw n;h.renameSync(t,`${t}.${process.pid}.old`),o(e,t)}}function P(e,t,o=h.copyFileSync,n=new Set){h.mkdirSync(t,{recursive:!0});let s=new Set;for(let r of h.readdirSync(e,{withFileTypes:!0})){s.add(r.name.toLowerCase());let i=w.join(e,r.name),c=w.join(t,r.name),a=h.lstatSync(c,{throwIfNoEntry:!1});a&&a.isDirectory()!==r.isDirectory()&&h.rmSync(c,{recursive:!0,force:!0}),r.isDirectory()?P(i,c,o,n):$e(i,c,o)}for(let r of h.readdirSync(t))if(!(s.has(r.toLowerCase())||n.has(w.join(t,r))))try{h.rmSync(w.join(t,r),{recursive:!0,force:!0})}catch{}}async function re(e,t,{target:o=E,stage:n=w.join(Z(),"update-stage"),platform:s=process.platform}={}){h.rmSync(n,{recursive:!0,force:!0});try{let r=await t([...e,"--prefix",n]);if(!r.ok)return r;let i=s==="win32"?w.join(n,"node_modules"):w.join(n,"lib","node_modules");try{P(w.join(i,w.basename(o)),o)}catch(c){return{ok:!1,output:`${r.output}
|
|
4
4
|
${c.message}`}}return r}finally{try{h.rmSync(n,{recursive:!0,force:!0})}catch{}}}import H from"node:fs";import z from"node:path";import{spawn as Fe}from"node:child_process";import{createRequire as Me}from"node:module";import Te from"node:fs";import te from"node:path";function ve({args:e,platform:t=process.platform,env:o=process.env,execPath:n=process.execPath,exists:s=Te.existsSync}){if(t!=="win32")return{command:"npm",args:e};let r=o.npm_execpath;if(r&&/npm-cli\.js$/i.test(r)&&s(r))return{command:n,args:[r,...e]};let i=te.join(te.dirname(n),"node_modules","npm","bin","npm-cli.js");return s(i)?{command:n,args:[i,...e]}:null}function Y(e,t,o,n={}){return new Promise(s=>{let r;try{let l=ve({args:t,...n});if(!l){s({ok:!1,spawnFailed:!0,output:"npm-cli.js was not found next to this Node.js; run npm install -g herdr-remote yourself."});return}r=e(l.command,l.args,{timeout:o,windowsHide:!0})}catch(l){s({ok:!1,spawnFailed:!0,output:String(l?.message||l)});return}let i="",c=!1,a=l=>{c||(c=!0,s(l))},u=l=>{i+=String(l)};r.stdout?.on("data",u),r.stderr?.on("data",u),r.on("error",l=>a({ok:!1,spawnFailed:!0,output:l.message})),r.on("close",l=>a({ok:l===0,output:i.trim()}))})}import p from"node:fs";import{createRequire as Pe}from"node:module";import y from"node:path";import N from"node:fs";import O from"node:path";import xe from"node:zlib";var _=512;function A(e,t,o){let n=e.subarray(t,t+o),s=n.indexOf(0);return n.subarray(0,s===-1?o:s).toString("utf8")}function ne(e,t,o){let n=A(e,t,o).trim();return n?Number.parseInt(n,8):0}function je(e){let t=null,o=0;for(;o<e.length;){let n=e.indexOf(32,o);if(n===-1)break;let s=Number.parseInt(e.subarray(o,n).toString("utf8"),10);if(!(s>0))break;let r=e.subarray(n+1,o+s-1).toString("utf8"),i=r.indexOf("=");r.slice(0,i)==="path"&&(t=r.slice(i+1)),o+=s}return t}function oe(e,t){let o=xe.gunzipSync(e),n=O.resolve(t);N.mkdirSync(n,{recursive:!0});let s=null,r=0;for(;r+_<=o.length;){let i=o.subarray(r,r+_);if(i.every(f=>f===0))break;let c=ne(i,124,12),a=String.fromCharCode(i[156]||48),u=o.subarray(r+_,r+_+c);if(u.length<c)throw new Error("truncated release archive");if(r+=_+Math.ceil(c/_)*_,a==="x"){s=je(u);continue}if(a==="L"){s=A(u,0,u.length);continue}if(a==="g")continue;let l=A(i,345,155),g=s??(l?`${l}/${A(i,0,100)}`:A(i,0,100));s=null;let x=g.replace(/^package\//,"");if(x===g)throw new Error(`unexpected path in release archive: ${g}`);let m=O.resolve(n,x);if(m!==n&&!m.startsWith(`${n}${O.sep}`))throw new Error(`path escapes the release archive: ${g}`);if(a==="5")N.mkdirSync(m,{recursive:!0});else if(a==="0"){N.mkdirSync(O.dirname(m),{recursive:!0});let f=ne(i,100,8)&73?493:420;N.writeFileSync(m,u,{mode:f})}else throw new Error(`unsupported entry type '${a}' in release archive: ${g}`)}}var Ne=["EBUSY","EPERM","EACCES"];function U(e){try{return JSON.parse(p.readFileSync(y.join(e,"package.json"),"utf8"))}catch{return null}}function ie(e){let t=new Set(e.bundleDependencies??[]);return Object.entries(e.dependencies??{}).filter(([o])=>!t.has(o))}function Oe(e,t,o){if(JSON.stringify(e.bin)!==JSON.stringify(t.bin))return!1;let n=Pe(y.join(o,"package.json")).resolve;return ie(t).every(([s,r])=>{if(e.dependencies?.[s]!==r)return!1;try{return n(`${s}/package.json`),!0}catch{return!1}})}function Ce(e,t){let o=[],n=ie(e).map(([s])=>s);for(;n.length>0;){let s=n.shift(),r=y.join(t,"node_modules",s);if(o.includes(s)||!p.existsSync(r))continue;o.push(s);let i=U(r);n.push(...Object.keys({...i?.dependencies,...i?.optionalDependencies}))}return o}async function He(e,t,o){let n=new AbortController,s=setTimeout(()=>n.abort(),o);try{let r=await t(e,{signal:n.signal,headers:{Accept:"application/octet-stream"}});if(!r.ok)throw new Error(`${e}: HTTP ${r.status??"?"}`);return Buffer.from(await r.arrayBuffer())}catch(r){throw r.name==="AbortError"?new Error(`${e}: timed out`):r}finally{clearTimeout(s)}}function se(e,t,o){for(let n of e){let s=y.join(o,"node_modules",n);p.mkdirSync(y.dirname(s),{recursive:!0}),p.renameSync(y.join(t,"node_modules",n),s)}}function Ie(e,t,o,n){let s=`${t}.previous-${process.pid}`;try{p.renameSync(t,s)}catch(r){let i=r.code??"";if(n!=="win32"||!Ne.includes(i))throw r;let c=new Set(o.map(a=>y.join(t,"node_modules",a)));P(e,t,p.copyFileSync,c);return}try{se(o,s,e),p.renameSync(e,t)}catch(r){try{for(let i of o)p.existsSync(y.join(e,"node_modules",i))&&se([i],e,s);p.renameSync(s,t)}catch{}throw r}try{p.rmSync(s,{recursive:!0,force:!0})}catch{}}async function ce({url:e,version:t,target:o=E,fetchImpl:n=globalThis.fetch,timeoutMs:s=18e4,platform:r=process.platform}){let i=y.join(y.dirname(o),`.herdr-remote-update-${process.pid}`);try{p.rmSync(i,{recursive:!0,force:!0}),oe(await He(e,n,s),i);let c=U(i),a=U(o);return c?.name!=="herdr-remote"||t&&c.version!==t?{ok:!1,output:`${e} is not herdr-remote ${t??""}`.trim()}:!a||!Oe(a,c,o)?{ok:!1,needsNpm:!0,output:"the release changes installed dependencies"}:(Ie(i,o,Ce(c,o),r),{ok:!0,output:`installed ${c.version} from ${e}`})}catch(c){return{ok:!1,output:String(c?.message||c)}}finally{try{p.rmSync(i,{recursive:!0,force:!0})}catch{}}}import De from"node:fs";import Le from"node:os";import ae from"node:path";var ue="herdr-remote",fe="https://registry.npmjs.org",pe="https://registry.npmmirror.com";function C(e){if(typeof e!="string")return null;let t=e.trim().replace(/\/+$/,"");return/^https?:\/\//i.test(t)?t:null}function le(e){let t;try{t=De.readFileSync(e,"utf8")}catch{return null}let o=null;for(let n of t.split(/\r?\n/)){let s=n.trim();if(!s||s.startsWith("#")||s.startsWith(";"))continue;let r=/^registry\s*=\s*(.+)$/i.exec(s);r&&(o=C(r[1].replace(/^["']|["']$/g,"")))}return o}function me({env:e=process.env,home:t=Le.homedir(),cwd:o=process.cwd()}={}){let n=[],s=r=>{let i=C(r);i&&!n.includes(i)&&n.push(i)};return s(e.npm_config_registry),s(e.NPM_CONFIG_REGISTRY),s(e.HERDR_REMOTE_REGISTRY),s(le(ae.join(o,".npmrc"))),s(le(ae.join(t,".npmrc"))),s(fe),s(pe),n}async function de(e,{timeoutMs:t,fetchImpl:o}){let n=new AbortController,s=setTimeout(()=>n.abort(),t);try{let r=await o(e,{signal:n.signal,headers:{Accept:"application/json","Cache-Control":"no-cache"}});return r.ok?{ok:!0,body:await r.json()}:{ok:!1,message:`HTTP ${r.status??"?"}`}}catch(r){let i=r;return{ok:!1,message:i?.name==="AbortError"?"timed out":String(i?.message||r)}}finally{clearTimeout(s)}}async function he(e,{timeoutMs:t,fetchImpl:o}){let n=[{url:`${e}/-/package/${ue}/dist-tags`,read:r=>r?.latest},{url:`${e}/${ue}/latest`,read:r=>r?.version}],s=null;for(let r of n){let i=await de(r.url,{timeoutMs:t,fetchImpl:o});if(!i.ok){s=i.message;continue}let c=r.read(i.body);if(typeof c=="string"&&c)return{ok:!0,latest:c};s="registry answered without a version"}return{ok:!1,message:s}}var V=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;async function ye(e,{timeoutMs:t,fetchImpl:o}){let n=await de(e,{timeoutMs:t,fetchImpl:o});if(!n.ok)return n;let s=n.body?.version;return typeof s=="string"&&V.test(s)?{ok:!0,latest:s}:{ok:!1,message:"release manifest has no version"}}var Be="herdr-remote",Ge="herdr-remote-relay";function Ke(){try{return JSON.parse(H.readFileSync(z.join(E,"package.json"),"utf8")).version}catch{return"0.0.0"}}function Nr(){try{let e=Me(import.meta.url).resolve(`${Ge}/package.json`);return JSON.parse(H.readFileSync(e,"utf8")).version}catch{return null}}function we(){let e=E;if(!e.split(z.sep).includes("node_modules"))return"source";try{if(H.lstatSync(e).isSymbolicLink())return"linked"}catch{}return"npm"}function Or(e=process.env){return e.HERDR_REMOTE_UPDATE_CHECK!=="0"}function Cr(){return we()==="npm"}function $(e,t){let o=r=>String(r).split("-")[0].split(".").map(i=>Number.parseInt(i,10)||0),n=o(e),s=o(t);for(let r=0;r<Math.max(n.length,s.length);r+=1){let i=(n[r]||0)-(s[r]||0);if(i>0)return 1;if(i<0)return-1}return 0}async function Hr({timeoutMs:e=6e3,fetchImpl:t=globalThis.fetch,registries:o,releaseManifest:n=Q,current:s=Ke()}={}){let r=(u,l)=>({ok:!0,current:s,latest:u,source:l,updateAvailable:$(u,s)>0}),i=[];if(n){let u=await ye(n,{timeoutMs:e,fetchImpl:t});if(u.ok)return r(u.latest,b);i.push(`${b}: ${u.message??""}`)}let c=await Promise.all((o??me()).map(async u=>({source:u,...await he(u,{timeoutMs:e,fetchImpl:t})}))),a=null;for(let u of c)u.ok?(!a||$(u.latest,a.latest)>0)&&(a=u):i.push(`${u.source}: ${u.message??""}`);return a?r(a.latest,a.source):{ok:!1,current:s,errorKey:"update.errorNetwork",message:i.join("; ")}}function Ye(e){let t=String(e||"").split(/\r?\n/).map(o=>o.trim()).filter(o=>/^npm (error|ERR!)/.test(o)&&!/complete log of this run/i.test(o)).map(o=>o.replace(/^npm (error|ERR!)\s*/,"")).filter(Boolean);return(t.length>0?t.slice(0,3):String(e||"").trim().split(/\r?\n/).slice(-3)).join(" ")}function Ue(e){return/\bETARGET\b|notarget|No matching version found/i.test(String(e||""))}function Ve(){try{return JSON.parse(H.readFileSync(z.join(E,"package.json"),"utf8")).version}catch{return null}}function Se(e,t,o){let n=o();return e&&n&&$(n,e)<0?{ok:!1,errorKey:"update.errorNotApplied",installed:n,output:t.slice(-2e3)}:{ok:!0,installed:n,output:t.slice(-2e3)}}async function Ir({spawnImpl:e=Fe,timeoutMs:t=18e4,installKindImpl:o=we,source:n="",version:s=null,attempts:r=3,retryDelayMs:i=15e3,sleep:c=m=>new Promise(f=>setTimeout(f,m)),readInstalledVersion:a=Ve,onAttempt:u=()=>{},platform:l=process.platform,inPlace:g=re,installReleaseImpl:x=ce}={}){let m=o();if(m!=="npm")return{ok:!1,errorKey:`update.cannot.${m}`};let f=typeof s=="string"&&V.test(s)?s:null,D=C(n),L,X="";if(!D||D===b){u({source:b,attempt:1});let k=f?K(f):G,R=await x({url:k,version:f,platform:l});if(R.ok)return Se(f,R.output,a);L=R.needsNpm?[b,""]:[""],X=`${k}: ${R.output}
|
|
5
5
|
`}else L=[D];let F={ok:!1,output:""},M=!1;for(let k of L){let R=k===b,B=R?["install","-g",f?K(f):G]:["install","-g",`${Be}@${f||"latest"}`,"--prefer-online"];k&&!R&&B.push("--registry",k);for(let j=1;j<=r;j+=1){u({source:k,attempt:j});let d=await Y(e,B,t);if(!d.ok&&l==="win32"&&ee(d.output)&&(d=await g(B,_e=>Y(e,_e,t))),d.ok)return Se(f,d.output,a);if(F=d,d.spawnFailed)return{ok:!1,errorKey:"update.errorFailed",output:d.output,summary:d.output};if(M=Ue(d.output),!M)break;j<r&&await c(i)}}return{ok:!1,errorKey:M?"update.errorNotYetPublished":"update.errorFailed",output:`${X}${String(F.output||"")}`.slice(-2e3),summary:Ye(F.output)}}import J from"node:fs";import q from"node:os";import S from"node:path";import{spawnSync as ze}from"node:child_process";var T="herdr",Ee="0.9.3",Je=["~/.local/bin","~/.cargo/bin","~/bin","/opt/homebrew/bin","/usr/local/bin","/home/linuxbrew/.linuxbrew/bin","/usr/bin"];function qe(e,t){return e==="~"?t:e.startsWith("~/")?S.join(t,e.slice(2)):e}function v(e=T,t=process.platform){return t!=="win32"?[e]:[/\.exe$/i.test(e)?e:`${e}.exe`]}function I(e){try{return J.statSync(e).isFile()?(J.accessSync(e,J.constants.X_OK),!0):!1}catch{return!1}}function W(e,t=v()){if(!e)return null;for(let o of t){let n=S.join(e,o);if(I(n))return n}return null}function ge(e,t=v()){for(let o of String(e||"").split(S.delimiter)){let n=W(o.trim(),t);if(n)return n}return null}function ke(e=q.homedir(),t=process.platform,o=process.env){return t==="win32"?[S.join(o.LOCALAPPDATA||S.join(e,"AppData","Local"),"Programs","Herdr","bin"),S.join(e,".cargo","bin"),S.join(e,"scoop","shims")]:Je.map(n=>qe(n,e))}function Re(e){return e.includes("/")||e.includes(S.sep)}function We(e,t,o){let n=String(e||"").trim();if(!n)return null;if(Re(n)){let s=S.resolve(n);if(I(s))return s;if(o==="win32"&&S.extname(s)===""){let r=`${s}.exe`;if(I(r))return r}return W(s,v(T,o))}return ge(t,v(n,o))}function be({env:e=process.env,home:t=q.homedir(),platform:o=process.platform,directories:n=ke(t,o,e)}={}){let s=v(T,o),r=We(e.HERDR_BIN_PATH,e.PATH,o);if(r)return{command:r,source:"env",found:!0};let i=ge(e.PATH,s);if(i)return{command:i,source:"path",found:!0};for(let c of n){let a=W(c,s);if(a)return{command:a,source:"fallback",found:!0}}return{command:T,source:"unresolved",found:!1}}function Xe(e){return be(e).command}function Kr(e,t={}){return typeof e=="string"&&Re(e)&&I(e)?{command:e,source:"verified",found:!0}:be(t)}function Ze(e){let t=/(\d+)\.(\d+)\.(\d+)/.exec(String(e||""));return t?`${t[1]}.${t[2]}.${t[3]}`:null}function Qe(e,t=Ee){return e?$(e,t)>=0:!0}function Yr({command:e,timeout:t=1e4,...o}={}){let n=e||Xe(o),s={command:n,version:null,raw:null,supported:!0,ok:!1},r;try{r=ze(n,["--version"],{encoding:"utf8",timeout:t,windowsHide:!0})}catch{return s}if(r.error||r.status!==0&&r.status!==1)return s;let i=`${r.stdout||""}${r.stderr||""}`.trim(),c=Ze(i);return{command:n,version:c,raw:i||null,supported:Qe(c),ok:!0}}function Ur(e){return`Herdr ${e} is older than ${Ee}, which herdr-remote is written against. Run "herdr update" \u2014 window titles, large pastes, taps on a pane and Alt shortcuts all misbehave in browser windows before that release.`}function Vr({env:e=process.env,home:t=q.homedir(),platform:o=process.platform,directories:n=ke(t,o,e)}={}){let s=String(e.HERDR_BIN_PATH||"").trim(),r=[`Herdr executable "${T}" was not found.`];return s&&r.push(`HERDR_BIN_PATH=${s} does not point at an executable.`),r.push(n.length?`Searched PATH and ${n.join(", ")}.`:"Searched PATH."),r.push("Install Herdr or set HERDR_BIN_PATH to its full path, then restart herdr-remote."),r.join(" ")}export{ee as a,Ke as b,Nr as c,we as d,Or as e,Cr as f,$ as g,Hr as h,Ve as i,Ir as j,Ee as k,be as l,Xe as m,Kr as n,Yr as o,Ur as p,Vr as q};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a as M,b as O}from"./3FQAXVGC.js";import{h as I}from"./42KARAL4.js";import{b as g}from"./JJGEV4EZ.js";import{a as x}from"./
|
|
3
|
+
import{a as M,b as O}from"./3FQAXVGC.js";import{h as I}from"./42KARAL4.js";import{b as g}from"./JJGEV4EZ.js";import{a as x}from"./MLSLOPR7.js";import R from"node:net";var H=1e4,B=8*1024*1024,v=1e3,N=1e4,T=0;function L(r,t,n={},a={}){let{timeout:c=H,connect:o=R.connect}=a;T+=1;let m=`herdr-remote:${T}`;return new Promise((y,p)=>{let i,s="",h=!1,l=(e,u)=>{h||(h=!0,clearTimeout(w),i&&(i.removeAllListeners(),i.destroy()),e?p(e):y(u))},w=setTimeout(()=>l(new Error(`Herdr API did not answer ${t} in time`)),c);typeof w.unref=="function"&&w.unref();try{i=o(g(r))}catch(e){l(e);return}let f=i;f.setEncoding("utf8"),f.on("connect",()=>{f.write(`${JSON.stringify({id:m,method:t,params:n})}
|
|
4
4
|
`)}),f.on("data",e=>{if(s+=e,s.length>B){l(new Error("Herdr API sent an oversized response"));return}let u=s.indexOf(`
|
|
5
5
|
`);if(u===-1)return;let d;try{d=JSON.parse(s.slice(0,u))}catch{l(new Error("Herdr API sent a line that is not JSON"));return}if(d.error){let b=Object.assign(new Error(d.error.message||"Herdr API request failed"),{code:d.error.code||"herdr_api_error"});l(b);return}l(null,d.result)}),f.on("error",e=>l(e)),f.on("close",()=>l(new Error(`Herdr API closed before answering ${t}`)))})}function z(r,t,n,a={}){let{connect:c=R.connect,retryBaseMs:o=v,retryMaxMs:m=N,onStarted:y}=a,p=null,i=null,s=null,h=0,l=!1,w=()=>{if(l||i)return;let e=Math.min(o*2**h,m);h+=1,i=setTimeout(()=>{i=null,f()},e),typeof i.unref=="function"&&i.unref()},f=()=>{if(l)return;let e;try{e=c(g(r))}catch{w();return}p=e;let u="",d=null,b=!1,A=()=>{s&&clearTimeout(s),s=null};e.setEncoding("utf8"),e.on("connect",()=>{T+=1,d=`herdr-remote:subscription:${T}`,e.write(`${JSON.stringify({id:d,method:"events.subscribe",params:{subscriptions:t}})}
|
|
6
6
|
`),s=setTimeout(()=>e.destroy(),H),typeof s.unref=="function"&&s.unref()}),e.on("data",k=>{if(u+=k,Buffer.byteLength(u,"utf8")>B){e.destroy();return}let E=u.indexOf(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./ZZOEVJ3V.js";import"./U6QAYG3E.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./NKDFWWLU.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{b as ANSI_KEYS,a as ANSI_SLOTS,n as captureTerminalPalette,h as collectPalette,o as hostTerminalPalette,f as paletteFromEnvironment,d as parseOscColorReply,c as parseXColor,j as probeConsolePalette,i as probeTerminalPalette,k as rememberTerminalPalette,l as rememberedTerminalPalette,m as resolveHostPalette,e as sanitizePalette,g as takeOscColorReply};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import"./C2UUZY6J.js";import{b as P,c as I}from"./
|
|
3
|
+
import"./C2UUZY6J.js";import{b as P,c as I}from"./UK7XZS2G.js";import"./S57VTPH5.js";import"./JJGEV4EZ.js";import"./S3V2O6BK.js";import"./ZZOEVJ3V.js";import{c as a,d as w,g as l,h as M}from"./U6QAYG3E.js";import"./72JMGTAK.js";import{o as u}from"./MHS44P3Y.js";import{a as y,c as n}from"./KRVF37OW.js";import{a as g}from"./QRGNEKME.js";import"./NKDFWWLU.js";import{c as f,f as m}from"./TNLCNVA2.js";import"./I6NRCYLI.js";import S from"node:fs";import{spawn as v}from"node:child_process";var T=500,k=3e4,A=3e4,d=class{config;state;logToFiles;onEvent;specs;children=new Map;stopping=!1;constructor({config:t=u(),state:s=w(),logToFiles:i=!1,onEvent:e=null,specs:r=null}={}){this.config=t,this.state=s,this.logToFiles=i,this.onEvent=e,this.specs=r}emit(t){this.onEvent&&this.onEvent(t);let s=`[${new Date().toISOString()}] herdr-remote supervisor: ${t.message}
|
|
4
4
|
`;process.stdout.write(s)}async reclaimStrays({timeoutMs:t=5e3}={}){let s=M().filter(e=>e.pid!==process.pid);if(s.length===0)return s;for(let{pid:e,name:r}of s){this.emit({type:"reclaim",name:r,pid:e,message:`stopping stray ${r} from an earlier start (pid ${e})`});try{process.kill(e,"SIGTERM")}catch{}}let i=Date.now()+t;for(;Date.now()<i;){if(s.every(({pid:e})=>!y(e)))return s;await new Promise(e=>{setTimeout(e,100)})}for(let{pid:e,name:r}of n(s)){this.emit({type:"reclaim",name:r,pid:e,message:`stray ${r} (pid ${e}) ignored SIGTERM, killing`});try{process.kill(e,"SIGKILL")}catch{}}return s}async start(){if(this.stopping=!1,g(f()),await this.reclaimStrays(),!this.stopping){for(let t of this.specs??P(this.config,this.state))this.children.set(t.name,{spec:t,child:null,pid:null,restarts:0,backoffMs:T,timer:null}),this.spawnChild(t.name);this.persistPids()}}spawnChild(t){if(this.stopping)return;let s=this.children.get(t);if(!s||s.child)return;let i=["ignore","inherit","inherit"],e=null;this.logToFiles&&(e=S.openSync(m(t),"a"),i=["ignore",e,e]);let r;try{r=v(s.spec.command,s.spec.args,{cwd:s.spec.cwd,env:{...I(),...s.spec.env},windowsHide:!0,stdio:i})}catch(o){this.emit({type:"spawn_failed",name:t,message:`could not start ${t}: ${o.message}`}),this.scheduleRestart(t);return}finally{if(e!==null)try{S.closeSync(e)}catch{}}s.child=r,s.pid=r.pid,s.startedAt=Date.now(),this.emit({type:"started",name:t,pid:r.pid,message:`${t} started (pid ${r.pid})`}),this.persistPids(),r.on("exit",(o,c)=>{let h=Date.now()-(s.startedAt??Date.now());if(s.child=null,s.pid=null,this.persistPids(),!this.stopping){if(o===12){this.emit({type:"replaced",name:t,message:`${t} stood down: another instance owns this workstation. Not restarting it.`});return}if(o===13){this.emit({type:"fatal",name:t,message:`${t} stopped: relay authentication failed. Update credentials before restarting it.`});return}h>=A&&(s.backoffMs=T),this.emit({type:"exited",name:t,code:o,signal:c,message:`${t} exited (${c||`code ${o}`}) after ${Math.round(h/1e3)}s, restarting in ${s.backoffMs}ms`}),this.scheduleRestart(t)}}),r.on("error",o=>{this.emit({type:"error",name:t,message:`${t} error: ${o.message}`})})}scheduleRestart(t){if(this.stopping)return;let s=this.children.get(t);if(!s||s.timer)return;let i=s.backoffMs;s.restarts+=1,s.backoffMs=Math.min(k,Math.round(s.backoffMs*2));let e=setTimeout(()=>{s.timer=null,this.spawnChild(t)},i);s.timer=e,e.unref?.()}persistPids(){try{a(t=>{t.supervisorPid=process.pid,t.relayPid=this.children.get("relay")?.pid||null,t.hostPid=this.children.get("host")?.pid||null,t.startedAt=t.startedAt||new Date().toISOString(),t.mode=this.config.relay.mode,l(t,"supervisor",process.pid);for(let[s,i]of this.children)i.pid&&l(t,s,i.pid)})}catch(t){process.stderr.write(`herdr-remote supervisor: could not persist pids: ${t.message}
|
|
5
5
|
`)}}async stop({graceMs:t=5e3}={}){this.stopping=!0;let s=[];for(let i of this.children.values()){i.timer&&(clearTimeout(i.timer),i.timer=null);let e=i.child;e&&s.push(new Promise(r=>{let o=setTimeout(()=>{try{e.kill("SIGKILL")}catch{}r()},t);o.unref?.(),e.once("exit",()=>{clearTimeout(o),r()});try{e.kill("SIGTERM")}catch{r()}}))}await Promise.all(s);try{a(i=>{i.supervisorPid=null,i.relayPid=null,i.hostPid=null,i.startedAt=null,i.managedPids=n((i.managedPids||[]).filter(Boolean))})}catch{}}};async function x({logToFiles:p=!1}={}){let t=new d({logToFiles:p});return await t.start(),new Promise(s=>{let i=!1,e=async r=>{i||(i=!0,t.emit({type:"shutdown",message:`${r} received, stopping services`}),await t.stop(),s(0))};process.on("SIGINT",()=>{e("SIGINT")}),process.on("SIGTERM",()=>{e("SIGTERM")}),process.on("SIGHUP",()=>{e("SIGHUP")})})}export{T as MIN_BACKOFF_MS,d as Supervisor,x as runForeground};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g}from"./2RUREFQO.js";import"./UK7XZS2G.js";import"./S57VTPH5.js";import"./JJGEV4EZ.js";import"./S3V2O6BK.js";import"./ZZOEVJ3V.js";import"./U6QAYG3E.js";import"./2IM3AVNW.js";import"./6M7I477E.js";import"./MLSLOPR7.js";import"./72JMGTAK.js";import"./MHS44P3Y.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./NKDFWWLU.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{g as fullStatus,a as managerInUse,d as restartAll,e as servicesRunning,b as startAll,c as stopAll,f as whileServicesStopped};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{i as m}from"./
|
|
3
|
+
import{i as m}from"./NKDFWWLU.js";import{d,g as _}from"./TNLCNVA2.js";function i(e){return e==="127.0.0.1"||e==="localhost"||e==="::1"||e==="[::1]"}function E(e){let r=typeof e=="string"?e.trim().toLowerCase():"";return r==="0.0.0.0"||r==="::"||r==="[::]"}function R(e){try{let r=new URL(e).hostname.toLowerCase();return r==="0.0.0.0"||r==="::"||r==="[::]"}catch{return!1}}function h(e){return typeof e=="string"?e.trim().replace(/\/+$/,""):""}function N(e){return e.relay.mode!=="remote"}function b(e){return e.relay.mode==="lan"?"0.0.0.0":"127.0.0.1"}function M(e,r=null){if(e.relay.mode==="lan"){let t=e.relay.lanHost;return t&&!i(t)&&!E(t)?t:r&&!i(r)&&!E(r)?r:"127.0.0.1"}return"127.0.0.1"}function B(e,r=null){return e.relay.publicUrl?e.relay.publicUrl:e.relay.mode==="remote"?A(e.relay.remoteUrl):`http://${M(e,r)}:${e.relay.port}`}function I(e){return e.relay.mode==="remote"?A(e.relay.remoteUrl):`http://127.0.0.1:${e.relay.port}`}function w(e){let r=e.relay.mode==="remote"?e.relay.remoteUrl:`ws://127.0.0.1:${e.relay.port}`;return T(r)}function A(e){try{let r=new URL(e);r.protocol==="ws:"&&(r.protocol="http:"),r.protocol==="wss:"&&(r.protocol="https:");let t=r.pathname.replace(/\/+$/,"");return`${r.origin}${t}`}catch{return h(e)}}function T(e){let r=new URL(e);r.protocol==="http:"&&(r.protocol="ws:"),r.protocol==="https:"&&(r.protocol="wss:");let t=r.pathname.replace(/\/+$/,"");return!t||t==="/"?r.pathname=m:t.endsWith(m)||(r.pathname=`${t}${m}`),r.toString()}import u from"node:fs";import c from"node:os";import x from"node:path";import S from"node:path";var F=S.resolve(import.meta.dirname,"..");var s={relay:{mode:"remote",host:"127.0.0.1",port:8787,publicUrl:"http://127.0.0.1:8787",maxPayloadBytes:5*1024*1024,maxClientsPerHost:16,maxHosts:1024,maxPendingHandshakes:1024,maxBufferedBytesPerClient:4*1024*1024,allowedOrigins:[],trustProxy:!1,hostReconnectGraceMs:30*1e3},auth:{pairingTtlMs:600*1e3,deviceTtlMs:720*60*60*1e3,maxDevices:32,password:null,adminToken:null,stateFile:null},cleanup:{intervalMs:60*1e3,heartbeatIntervalMs:30*1e3,staleAfterMs:90*1e3}};var p=["local","lan","remote"],z="wss://herdr-remote.564616.xyz",L=["auto","zh","en"],P=["auto","systemd","launchd","supervisor","windows-task","windows-service","none"];function y(e,r){return e.includes(r)}var a={ui:{language:"auto"},relay:{mode:"local",port:8787,lanHost:"",publicUrl:"",remoteUrl:"",maxPayloadBytes:s.relay.maxPayloadBytes,maxClientsPerHost:s.relay.maxClientsPerHost,maxHosts:s.relay.maxHosts,maxPendingHandshakes:s.relay.maxPendingHandshakes,maxBufferedBytesPerClient:s.relay.maxBufferedBytesPerClient,hostReconnectGraceMs:s.relay.hostReconnectGraceMs,allowedOrigins:[]},herdr:{socketPath:null,args:[],cwd:c.homedir(),autoStart:!1},auth:{pairingTtlMs:s.auth.pairingTtlMs,deviceTtlMs:s.auth.deviceTtlMs,maxDevices:s.auth.maxDevices},cleanup:{...s.cleanup},keepalive:{manager:"auto"}};function H(e){return JSON.parse(JSON.stringify(e))}function O(e){try{return JSON.parse(u.readFileSync(e,"utf8"))}catch(r){let{code:t,message:o}=r;return t!=="ENOENT"&&process.stderr.write(`herdr-remote: ignoring invalid JSON at ${e}: ${o}
|
|
4
4
|
`),{}}}function V(){let e=d();if(u.existsSync(e))return{migrated:!1,reason:"config already exists"};let r=_();if(!r||!u.existsSync(r))return{migrated:!1,reason:"no legacy config"};try{return u.mkdirSync(x.dirname(e),{recursive:!0,mode:448}),u.copyFileSync(r,e),{migrated:!0,from:r,to:e}}catch(t){return{migrated:!1,reason:t.message}}}function f(e){let r=H(a),t=e??{};for(let o of Object.keys(r)){let n=t[o];n&&typeof n=="object"&&Object.assign(r[o],n)}return r}function U(e,r){let t=r?.relay||{};y(p,t.mode)||(t.local===!1&&typeof t.url=="string"&&t.url?(e.relay.mode="remote",e.relay.remoteUrl||(e.relay.remoteUrl=t.url)):typeof t.host=="string"&&t.host&&!i(t.host)?e.relay.mode="lan":e.relay.mode="local"),e.relay.mode==="lan"&&!e.relay.lanHost&&typeof t.host=="string"&&!i(t.host)&&t.host!=="0.0.0.0"&&(e.relay.lanHost=t.host),delete e.relay.local,delete e.relay.host,delete e.relay.url,typeof e.relay.publicUrl=="string"&&/^https?:\/\/(127\.0\.0\.1|localhost)(:\d+)?\/?$/.test(e.relay.publicUrl)&&(e.relay.publicUrl="")}function l(e,r,t,o){let n=Number(e);return!Number.isInteger(n)||n<t||n>o?r:n}function D(e){y(p,e.relay.mode)||(e.relay.mode=a.relay.mode),y(L,e.ui.language)||(e.ui.language=a.ui.language),y(P,e.keepalive.manager)||(e.keepalive.manager=a.keepalive.manager),e.relay.port=l(e.relay.port,a.relay.port,1,65535),e.relay.maxPayloadBytes=l(e.relay.maxPayloadBytes,a.relay.maxPayloadBytes,4096,16*1024*1024),e.relay.maxClientsPerHost=l(e.relay.maxClientsPerHost,a.relay.maxClientsPerHost,1,256),e.relay.maxHosts=l(e.relay.maxHosts,a.relay.maxHosts,1,1e5),e.relay.maxPendingHandshakes=l(e.relay.maxPendingHandshakes,a.relay.maxPendingHandshakes,16,1e5),e.relay.maxBufferedBytesPerClient=l(e.relay.maxBufferedBytesPerClient,a.relay.maxBufferedBytesPerClient,64*1024,256*1024*1024),e.relay.hostReconnectGraceMs=l(e.relay.hostReconnectGraceMs,a.relay.hostReconnectGraceMs,1e3,1440*60*1e3),e.auth.pairingTtlMs=l(e.auth.pairingTtlMs,a.auth.pairingTtlMs,30*1e3,1440*60*1e3),e.auth.deviceTtlMs=l(e.auth.deviceTtlMs,a.auth.deviceTtlMs,60*1e3,365*24*60*60*1e3),e.auth.maxDevices=l(e.auth.maxDevices,a.auth.maxDevices,1,1e4),e.cleanup.intervalMs=l(e.cleanup.intervalMs,a.cleanup.intervalMs,1e3,1440*60*1e3),e.cleanup.heartbeatIntervalMs=l(e.cleanup.heartbeatIntervalMs,a.cleanup.heartbeatIntervalMs,1e3,600*1e3),e.cleanup.staleAfterMs=l(e.cleanup.staleAfterMs,a.cleanup.staleAfterMs,e.cleanup.heartbeatIntervalMs*2,1440*60*1e3),e.relay.publicUrl=h(e.relay.publicUrl),e.relay.remoteUrl=h(e.relay.remoteUrl),e.relay.lanHost=typeof e.relay.lanHost=="string"?e.relay.lanHost.trim():"",e.relay.mode==="lan"&&(i(e.relay.lanHost)||E(e.relay.lanHost))&&(e.relay.lanHost=""),R(e.relay.publicUrl)&&(e.relay.publicUrl=""),Array.isArray(e.relay.allowedOrigins)||(e.relay.allowedOrigins=[]),(!Array.isArray(e.herdr.args)||!e.herdr.args.every(t=>typeof t=="string"))&&(e.herdr.args=[]);let r=e.herdr.args;return r.includes("--no-session")&&(e.herdr.args=r.filter(t=>t!=="--no-session"),process.stderr.write(`herdr-remote: ignoring removed --no-session argument (removed in Herdr 0.9.0)
|
|
5
5
|
`)),(typeof e.herdr.socketPath!="string"||e.herdr.socketPath.length===0)&&(e.herdr.socketPath=null),(typeof e.herdr.cwd!="string"||e.herdr.cwd.length===0)&&(e.herdr.cwd=c.homedir()),e.herdr.autoStart=e.herdr.autoStart===!0,e.relay.mode==="remote"&&!e.relay.remoteUrl&&(e.relay.mode="local"),e}function Y(e){let r=process.env;if(r.HERDR_REMOTE_LANG&&y(L,r.HERDR_REMOTE_LANG)&&(e.ui.language=r.HERDR_REMOTE_LANG),r.HERDR_REMOTE_MODE&&y(p,r.HERDR_REMOTE_MODE)&&(e.relay.mode=r.HERDR_REMOTE_MODE),r.RELAY_PORT&&(e.relay.port=r.RELAY_PORT),r.RELAY_PUBLIC_URL&&(e.relay.publicUrl=r.RELAY_PUBLIC_URL),r.RELAY_REMOTE_URL&&(e.relay.remoteUrl=r.RELAY_REMOTE_URL),r.RELAY_MAX_HOSTS&&(e.relay.maxHosts=r.RELAY_MAX_HOSTS),r.RELAY_MAX_PENDING_HANDSHAKES&&(e.relay.maxPendingHandshakes=r.RELAY_MAX_PENDING_HANDSHAKES),r.RELAY_MAX_BUFFERED_BYTES_PER_CLIENT&&(e.relay.maxBufferedBytesPerClient=r.RELAY_MAX_BUFFERED_BYTES_PER_CLIENT),r.RELAY_HOST_RECONNECT_GRACE_MS&&(e.relay.hostReconnectGraceMs=r.RELAY_HOST_RECONNECT_GRACE_MS),r.HERDR_SOCKET_PATH&&(e.herdr.socketPath=r.HERDR_SOCKET_PATH),r.HERDR_CWD&&(e.herdr.cwd=r.HERDR_CWD),r.HERDR_ARGS_JSON)try{let t=JSON.parse(r.HERDR_ARGS_JSON);Array.isArray(t)&&(e.herdr.args=t)}catch(t){process.stderr.write(`herdr-remote: invalid HERDR_ARGS_JSON: ${t.message}
|
|
6
6
|
`)}}function q(){let e=O(d()),r=f(e);return U(r,e),Y(r),D(r)}function Q(){return u.existsSync(d())}export{i as a,E as b,R as c,N as d,b as e,B as f,I as g,w as h,T as i,p as j,z as k,L as l,P as m,V as n,q as o,Q as p};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{l as c}from"./
|
|
3
|
+
import{l as c}from"./72JMGTAK.js";import{a as s}from"./TNLCNVA2.js";import f from"node:os";import i from"node:path";function h(){return i.join(s,"bin","herdr-remote.js")}function p({env:o=process.env,herdrCommand:e=null}={}){let n=String(o.PATH||"").split(i.delimiter).map(r=>r.trim()).filter(Boolean);return e&&n.push(i.dirname(e)),[...new Set(n)].join(i.delimiter)}function P({env:o=process.env,home:e=f.homedir(),directories:n}={}){let r={},t=c({env:o,home:e,...n?{directories:n}:{}});t.found&&(r.HERDR_BIN_PATH=t.command);let m=p({env:o,herdrCommand:t.found?t.command:null});return m&&(r.PATH=m),r}export{h as a,p as b,P as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n}from"./
|
|
3
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n}from"./2IM3AVNW.js";import{a as c,b as d}from"./6M7I477E.js";import{b as a,c as b}from"./MLSLOPR7.js";import"./72JMGTAK.js";import"./MHS44P3Y.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./NKDFWWLU.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{g as detectManager,m as enableLinger,c as escapeXml,i as install,n as logsHint,d as renderLaunchdPlist,f as renderSystemdUnit,k as restart,b as serviceEnvironment,a as servicePath,h as status,l as stopManaged,e as systemdEnvironmentLine,j as uninstall};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
var T=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],R=["regular","bold","italic","boldItalic"],S=["truetype","opentype"],I=["cjk","all"];var M=/^#[0-9a-f]{6}$/i,y=/["'\\;,{}<>@\u0000-\u001f\u007f]/,A=/^[0-9a-f]{64}$/;function _(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function l(t,e){return t.includes(e)}function h(t){return typeof t=="string"&&M.test(t)?t.toLowerCase():void 0}function O(t){if(!_(t))return null;let e={};for(let r of["background","foreground","cursor"]){let o=h(t[r]);o&&(e[r]=o)}let n=t.ansi;if(_(n)){let r={};for(let o of T){let i=h(n[o]);i&&(r[o]=i)}Object.keys(r).length===T.length&&(e.ansi=r)}return Object.keys(e).length>0?e:null}function d(t){let e=typeof t=="string"?t.trim():"";return!e||e.length>128||y.test(e)?null:e}function L(t){if(!_(t))return null;let e=d(t.family);if(!e)return null;let n=Number(t.sizePx),r=Number.isFinite(n)&&n>=4&&n<=96?Math.round(n*10)/10:null,o=typeof t.source=="string"&&/^[a-z0-9-]{1,32}$/.test(t.source)?t.source:null,i=[],g=new Set;for(let f of Array.isArray(t.faces)?t.faces.slice(0,16):[]){if(!_(f))continue;let{style:a,format:c,bytes:s,sha256:E}=f;!l(R,a)||g.has(a)||l(S,c)&&(typeof s!="number"||!Number.isInteger(s)||s<=0||s>16777216||typeof E!="string"||!A.test(E)||(g.add(a),i.push({style:a,format:c,bytes:s,sha256:E})))}let p=[];for(let f of Array.isArray(t.subsets)?t.subsets.slice(0,16):[]){if(!_(f))continue;let a=d(f.family),{scope:c,sha256:s}=f;!a||f.style!=="regular"||l(I,c)&&(typeof s!="string"||!A.test(s)||p.some(E=>E.scope===c)||p.push({family:a,style:"regular",scope:c,sha256:s}))}return{family:e,...r!==null&&{sizePx:r},...o!==null&&{source:o},faces:i,subsets:p}}var P="dibin666/herdr-remote",m=`https://github.com/${P}/releases`,B=`${m}/latest/download/latest.json`,b=`${m}/latest/download/herdr-remote.tgz`;function Y(t){return`${m}/download/herdr-remote-v${t}/herdr-remote-${t}.tgz`}function u(t){return Buffer.isBuffer(t)?t:(typeof t=="string"||t instanceof ArrayBuffer,Buffer.from(t))}function C(t,e,n=Buffer.alloc(0)){if(typeof t!="string"||!t||typeof e!="string"||!e)throw new TypeError("type and streamId must be non-empty strings");let r=u(n),o=Buffer.from(JSON.stringify({type:t,streamId:e}),"utf8");if(o.length>8192)throw new RangeError("stream frame header is too large");let i=Buffer.allocUnsafe(4);return i.writeUInt32BE(o.length,0),Buffer.concat([i,o,r])}function w(t){let e=u(t);if(e.length<4)throw new Error("stream frame is truncated");let n=e.readUInt32BE(0);if(n===0||n>8192||e.length<4+n)throw new Error("stream frame header is invalid");let r;try{r=JSON.parse(e.subarray(4,4+n).toString("utf8"))}catch(o){throw new Error(`stream frame header is not JSON: ${o.message}`)}if(!r||typeof r.type!="string"||typeof r.streamId!="string")throw new Error("stream frame header is missing routing fields");return{version:1,type:r.type,streamId:r.streamId,payload:e.subarray(4+n)}}function X(t,e,n=Buffer.alloc(0)){let r=t;if(t==="output"?r=0:t==="input"&&(r=1),r!==0&&r!==1)throw new TypeError("type must be FRAME_TYPE_OUTPUT (0) or FRAME_TYPE_INPUT (1)");if(!Number.isInteger(e)||e<0||e>65535)throw new RangeError("streamIndex must be an unsigned 16-bit integer (0-65535)");let o=u(n),i=Buffer.allocUnsafe(4+o.length);return i.writeUInt8(255,0),i.writeUInt8(r,1),i.writeUInt16BE(e,2),o.copy(i,4),i}function F(t){let e=u(t);if(e.length<4)throw new Error("v2 stream frame is truncated");if(e.readUInt8(0)!==255)throw new Error("invalid v2 stream frame magic byte");let r=e.readUInt8(1);if(r!==0&&r!==1)throw new Error(`unknown v2 stream frame type: ${r}`);let o=e.readUInt16BE(2);return{version:2,type:r===0?"output":"input",typeCode:r,streamIndex:o,payload:e.subarray(4)}}function k(t){let e=u(t);if(e.length<4)throw new Error("stream frame is truncated");return e[0]===255?F(e):w(e)}var N=/^[\x21-\x7e]+$/;function $(t){if(!Array.isArray(t))return;let e=new Set;for(let n of t){if(e.size>=8)break;if(typeof n!="string")continue;let r=n.replace(/\s+/g,"").toLowerCase();r.length<=32&&N.test(r)&&e.add(r)}return e.size>0?[...e]:void 0}var G="/ws/host";var D={hostHandoff:"host_handoff",idleHeartbeat:"idle_heartbeat",binaryFrameV2:"binary_frame_v2",adminTabs:"admin_tabs",pasteAnyFile:"paste_any_file"};var K="application/octet-stream";function J(t){if(typeof t!="string")return"file";let n=(t.normalize("NFC").split(/[\\/]/).pop()??"").replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^[._]+|[._]+$/g,"");if([...n].length>120){let r=n.lastIndexOf("."),o=r>0&&n.length-r<=16?n.slice(r):"";n=[...n.slice(0,n.length-o.length)].slice(0,120-o.length).join("")+o}return n||"file"}var x={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","image/gif":".gif"},W=Object.keys(x);function q(t){return typeof t=="string"&&Object.hasOwn(x,t)}function Q(t,e){switch(t){case"image/png":return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71;case"image/jpeg":return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255;case"image/webp":return e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80;case"image/gif":return e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56;default:return!1}}export{C as a,X as b,k as c,T as d,R as e,O as f,L as g,$ as h,G as i,D as j,K as k,J as l,x as m,q as n,Q as o,m as p,B as q,b as r,Y as s};
|