@leviyuan/lodestar 0.18.12 → 0.18.14

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.
@@ -114,7 +114,7 @@ try {
114
114
  if ($pointer -ne [IntPtr]::Zero) { [void][LodestarProxy]::GlobalFree($pointer) }
115
115
  }
116
116
  }
117
- `;async function L6(){if(process.platform==="win32")return M6(JSON.parse(await V0("powershell.exe",["-NoProfile","-NonInteractive","-Command",Z6],15000)));if(process.platform==="darwin")return w6(await V0("/usr/sbin/scutil",["--proxy"]));if(process.platform==="linux"){let A=I2(process.env.XDG_CONFIG_HOME||I2(J6(),".config"),"kioslaverc");try{let B=W6(await U6(A,"utf8"));if(B&&(!process.env.XDG_CURRENT_DESKTOP||/kde/i.test(process.env.XDG_CURRENT_DESKTOP)))return B}catch(B){if(B?.code!=="ENOENT")throw B}let Q;try{Q=await V0("gsettings",["list-schemas"])}catch(B){if(B?.code==="ENOENT")return{};throw B}if(!Q.split(/\r?\n/).includes("org.gnome.system.proxy"))return{};return V6(await V0("gsettings",["list-recursively","org.gnome.system.proxy"]))}return{}}function R6(A=L6,Q=process.env,B=Date.now){let I;return async(C)=>{if(Z0(C)||FU(C,bC(Q,"NO_PROXY"))||bC(Q,C.protocol==="https:"?"HTTPS_PROXY":"HTTP_PROXY")||bC(Q,"ALL_PROXY"))return E2(C,Q);if(!I||I.until<=B()){let g=A().catch((F)=>{if(I?.value===g)I=void 0;if(F instanceof Error&&F.message.startsWith("network proxy:"))throw F;let Y=F instanceof Error?F.code??F.name:"unknown error";throw Error(`network proxy: failed to read ${process.platform} system proxy settings (${Y})`,{cause:F})});I={until:B()+30000,value:g}}return E2(C,Q,await I.value)}}var g2=R6();var df=new pf({keepAlive:!0}),nf=new lf({keepAlive:!0}),C8;function af(A,Q){if(!Q)return A.protocol==="https:"?nf:df;return A.protocol==="https:"?new g8.HttpsProxyAgent(Q):new E8.HttpProxyAgent(Q)}async function of(A,Q,B){if(typeof Bun<"u"){let F=A.protocol==="https:"?"HTTPS_PROXY":"HTTP_PROXY";if(!B&&(process.env[F.toLowerCase()]||process.env[F])){let Y=await Promise.resolve().then(() => AI(B8(),1));return C8??=new Y.Agent,await Y.fetch(A,{...Q,redirect:"manual",dispatcher:C8})}return globalThis.fetch(A.href,{...Q,redirect:"manual",...B?{proxy:B}:{}})}let I=new Request(A,{...Q,redirect:"manual",duplex:"half"}),C=await sF(A,{method:I.method,headers:Object.fromEntries(I.headers),body:I.body?I8.fromWeb(I.body):void 0,signal:I.signal,agent:af(A,B),redirect:"manual"}),g=I.method==="HEAD"||[204,205,304].includes(C.status)||!C.body?null:I8.toWeb(C.body);return new Response(g,{status:C.status,statusText:C.statusText,headers:[...C.headers]})}async function sf(A,Q,B,I=g2){let C=new URL(A),g={...Q};for(let F=0;;F++){if(!["http:","https:"].includes(C.protocol))throw Error(`network: unsupported URL protocol ${C.protocol}`);if(B&&!Z0(C))throw Error("network: local request must remain on loopback");g.signal?.throwIfAborted();let Y=B?void 0:await I(C),J=await of(C,g,Y),N=J.headers.get("location");if(![301,302,303,307,308].includes(J.status)||!N||Q.redirect==="manual")return J;if(await J.body?.cancel(),Q.redirect==="error")throw Error("network: redirect rejected");if(F>=20)throw Error("network: too many redirects");let G=new URL(N,C),M=new Headers(g.headers);if(G.origin!==C.origin)for(let W of["authorization","proxy-authorization","cookie","host"])M.delete(W);let w=(g.method??"GET").toUpperCase();if(J.status===303&&w!=="HEAD"||[301,302].includes(J.status)&&w==="POST"){g={...g,method:"GET",body:void 0};for(let W of["content-type","content-length","content-encoding"])M.delete(W)}else if(g.body instanceof ReadableStream)throw Error("network: cannot replay a streamed body after redirect");g.headers=M,C=G}}function F8(A,Q={}){return sf(A,Q,!1)}import{createHash as bb,randomUUID as mb}from"node:crypto";import{existsSync as IH,readFileSync as CH}from"node:fs";import{mkdir as EH,mkdtemp as cb,readFile as gH,rename as FH,rm as JF,writeFile as DH}from"node:fs/promises";import{join as nQ,isAbsolute as ub}from"node:path";import{fileURLToPath as pb,pathToFileURL as pl}from"node:url";var s8=AI(o8(),1);import{execFile as $b}from"node:child_process";var Tb="https://registry.npmjs.org";class AY extends Error{}function jb(A){if(!Number.isSafeInteger(A)||A<=0)return Promise.reject(Error(`Invalid npm installer PID: ${A}`));return new Promise((Q,B)=>{$b("taskkill",["/PID",String(A),"/T","/F"],{windowsHide:!0,timeout:1e4},(I,C,g)=>{if(I)B(Error(`taskkill npm installer PID ${A} failed: ${I.message}
117
+ `;async function L6(){if(process.platform==="win32")return M6(JSON.parse(await V0("powershell.exe",["-NoProfile","-NonInteractive","-Command",Z6],15000)));if(process.platform==="darwin")return w6(await V0("/usr/sbin/scutil",["--proxy"]));if(process.platform==="linux"){let A=I2(process.env.XDG_CONFIG_HOME||I2(J6(),".config"),"kioslaverc");try{let B=W6(await U6(A,"utf8"));if(B&&(!process.env.XDG_CURRENT_DESKTOP||/kde/i.test(process.env.XDG_CURRENT_DESKTOP)))return B}catch(B){if(B?.code!=="ENOENT")throw B}let Q;try{Q=await V0("gsettings",["list-schemas"])}catch(B){if(B?.code==="ENOENT")return{};throw B}if(!Q.split(/\r?\n/).includes("org.gnome.system.proxy"))return{};return V6(await V0("gsettings",["list-recursively","org.gnome.system.proxy"]))}return{}}function R6(A=L6,Q=process.env,B=Date.now){let I;return async(C)=>{if(Z0(C)||FU(C,bC(Q,"NO_PROXY"))||bC(Q,C.protocol==="https:"?"HTTPS_PROXY":"HTTP_PROXY")||bC(Q,"ALL_PROXY"))return E2(C,Q);if(!I||I.until<=B()){let g=A().catch((F)=>{if(I?.value===g)I=void 0;if(F instanceof Error&&F.message.startsWith("network proxy:"))throw F;let Y=F instanceof Error?F.code??F.name:"unknown error";throw Error(`network proxy: failed to read ${process.platform} system proxy settings (${Y})`,{cause:F})});I={until:B()+30000,value:g}}return E2(C,Q,await I.value)}}var g2=R6();var df=new pf({keepAlive:!0}),nf=new lf({keepAlive:!0}),C8;function af(A,Q){if(!Q)return A.protocol==="https:"?nf:df;return A.protocol==="https:"?new g8.HttpsProxyAgent(Q):new E8.HttpProxyAgent(Q)}async function of(A,Q,B){if(typeof Bun<"u"){let F=A.protocol==="https:"?"HTTPS_PROXY":"HTTP_PROXY";if(!B&&(process.env[F.toLowerCase()]||process.env[F])){let Y=await Promise.resolve().then(() => AI(B8(),1));return C8??=new Y.Agent,await Y.fetch(A,{...Q,redirect:"manual",dispatcher:C8})}return globalThis.fetch(A.href,{...Q,redirect:"manual",...B?{proxy:B}:{}})}let I=new Request(A,{...Q,redirect:"manual",duplex:"half"});if(I.body&&!I.headers.has("content-length")&&!I.headers.has("transfer-encoding"))I.headers.set("transfer-encoding","chunked");let C=await sF(A,{method:I.method,headers:Object.fromEntries(I.headers),body:I.body?I8.fromWeb(I.body):void 0,signal:I.signal,agent:af(A,B),redirect:"manual"}),g=I.method==="HEAD"||[204,205,304].includes(C.status)||!C.body?null:I8.toWeb(C.body);return new Response(g,{status:C.status,statusText:C.statusText,headers:[...C.headers]})}async function sf(A,Q,B,I=g2){let C=new URL(A),g={...Q};for(let F=0;;F++){if(!["http:","https:"].includes(C.protocol))throw Error(`network: unsupported URL protocol ${C.protocol}`);if(B&&!Z0(C))throw Error("network: local request must remain on loopback");g.signal?.throwIfAborted();let Y=B?void 0:await I(C),J=await of(C,g,Y),N=J.headers.get("location");if(![301,302,303,307,308].includes(J.status)||!N||Q.redirect==="manual")return J;if(await J.body?.cancel(),Q.redirect==="error")throw Error("network: redirect rejected");if(F>=20)throw Error("network: too many redirects");let G=new URL(N,C),M=new Headers(g.headers);if(G.origin!==C.origin)for(let W of["authorization","proxy-authorization","cookie","host"])M.delete(W);let w=(g.method??"GET").toUpperCase();if(J.status===303&&w!=="HEAD"||[301,302].includes(J.status)&&w==="POST"){g={...g,method:"GET",body:void 0};for(let W of["content-type","content-length","content-encoding"])M.delete(W)}else if(g.body instanceof ReadableStream)throw Error("network: cannot replay a streamed body after redirect");g.headers=M,C=G}}function F8(A,Q={}){return sf(A,Q,!1)}import{createHash as bb,randomUUID as mb}from"node:crypto";import{existsSync as IH,readFileSync as CH}from"node:fs";import{mkdir as EH,mkdtemp as cb,readFile as gH,rename as FH,rm as JF,writeFile as DH}from"node:fs/promises";import{join as nQ,isAbsolute as ub}from"node:path";import{fileURLToPath as pb,pathToFileURL as pl}from"node:url";var s8=AI(o8(),1);import{execFile as $b}from"node:child_process";var Tb="https://registry.npmjs.org";class AY extends Error{}function jb(A){if(!Number.isSafeInteger(A)||A<=0)return Promise.reject(Error(`Invalid npm installer PID: ${A}`));return new Promise((Q,B)=>{$b("taskkill",["/PID",String(A),"/T","/F"],{windowsHide:!0,timeout:1e4},(I,C,g)=>{if(I)B(Error(`taskkill npm installer PID ${A} failed: ${I.message}
118
118
  ${C}${g}`));else Q()})})}async function pG(A,Q,B={}){Q?.throwIfAborted();let I=B.platform??process.platform,C=B.timeoutMs??300000,g=B.terminationTimeoutMs??1e4;return await new Promise((F,Y)=>{let J=(B.spawn??s8.spawn)("npm",["install","--prefix",A,"--include=optional","--no-fund","--no-audit",`--registry=${Tb}`],{cwd:A,stdio:["ignore","pipe","pipe"],shell:!1,windowsHide:!0}),N="",G,M,w=!1,W=!1,L,K=(q)=>{N=(N+q.toString()).slice(-16384)};J.stdout.on("data",K),J.stderr.on("data",K);let Z=(q)=>{if(w)return;if(w=!0,clearTimeout(T),L)clearTimeout(L);if(Q?.removeEventListener("abort",_),q)Y(q);else F()},R=(q)=>new AY(`${G?.message??"Agent runtime install failed"}; npm installer PID ${J.pid??"MISS"} termination unconfirmed: ${q}; partial directory retained: ${A}
119
119
  ${N}`),O=(q)=>{if(w||W||M)return;G??=Error(q),L=setTimeout(()=>Z(R(`stdio did not close within ${g}ms`)),g),M=Promise.resolve().then(async()=>{if(W)throw Error("installer closed before process-tree termination started");if(!J.pid)throw Error("installer PID unavailable");if(I==="win32")await(B.terminateWindows??jb)(J.pid);else if(!J.kill("SIGTERM"))throw Error("npm installer rejected SIGTERM")}),M.catch((x)=>Z(R(x instanceof Error?x.message:String(x))))},_=()=>O("Agent runtime install aborted"),T=setTimeout(()=>O(`Agent runtime install timed out after ${C}ms`),C);if(Q?.addEventListener("abort",_,{once:!0}),J.on("error",(q)=>{if(G??=q,!J.pid)Z(Error(`${q.message}
120
120
  ${N}`))}),J.once("close",async(q,x)=>{W=!0,clearTimeout(T),Q?.removeEventListener("abort",_);try{await M}catch(i){Z(R(i instanceof Error?i.message:String(i)));return}if(G||q!==0)Z(Error(`${G?.message??`npm install exited code=${q} signal=${x}`}