20 lines
109 KiB
JavaScript
20 lines
109 KiB
JavaScript
var Va=Object.defineProperty;var n=(i,o)=>Va(i,"name",{value:o,configurable:!0});import ft from"node:http";import Qa from"node:https";import Ye from"node:zlib";import ie,{PassThrough as Qt,pipeline as Ge}from"node:stream";import{Buffer as D}from"node:buffer";import{types as Yt,promisify as Ya,deprecate as Gt}from"node:util";import{c as Co,g as Ga}from"./shared/node-fetch-native.DfbY2q-x.mjs";import{format as Za}from"node:url";import{isIP as Ka}from"node:net";import{statSync as Po,createReadStream as Ja,promises as Xa}from"node:fs";import{basename as es}from"node:path";function ts(i){if(!/^data:/i.test(i))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');i=i.replace(/\r?\n/g,"");const o=i.indexOf(",");if(o===-1||o<=4)throw new TypeError("malformed data: URI");const a=i.substring(5,o).split(";");let l="",u=!1;const m=a[0]||"text/plain";let h=m;for(let A=1;A<a.length;A++)a[A]==="base64"?u=!0:a[A]&&(h+=`;${a[A]}`,a[A].indexOf("charset=")===0&&(l=a[A].substring(8)));!a[0]&&!l.length&&(h+=";charset=US-ASCII",l="US-ASCII");const S=u?"base64":"ascii",E=unescape(i.substring(o+1)),w=Buffer.from(E,S);return w.type=m,w.typeFull=h,w.charset=l,w}n(ts,"dataUriToBuffer");var Eo={},ct={exports:{}};/**
|
|||
|
|
* @license
|
||
|
|
* web-streams-polyfill v3.3.3
|
||
|
|
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
||
|
|
* This code is released under the MIT license.
|
||
|
|
* SPDX-License-Identifier: MIT
|
||
|
|
*/var rs=ct.exports,vo;function ns(){return vo||(vo=1,function(i,o){(function(a,l){l(o)})(rs,function(a){function l(){}n(l,"noop");function u(e){return typeof e=="object"&&e!==null||typeof e=="function"}n(u,"typeIsObject");const m=l;function h(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch{}}n(h,"setFunctionName");const S=Promise,E=Promise.prototype.then,w=Promise.reject.bind(S);function A(e){return new S(e)}n(A,"newPromise");function T(e){return A(t=>t(e))}n(T,"promiseResolvedWith");function b(e){return w(e)}n(b,"promiseRejectedWith");function q(e,t,r){return E.call(e,t,r)}n(q,"PerformPromiseThen");function g(e,t,r){q(q(e,t,r),void 0,m)}n(g,"uponPromise");function V(e,t){g(e,t)}n(V,"uponFulfillment");function I(e,t){g(e,void 0,t)}n(I,"uponRejection");function F(e,t,r){return q(e,t,r)}n(F,"transformPromiseWith");function Q(e){q(e,void 0,m)}n(Q,"setPromiseIsHandledToTrue");let se=n(e=>{if(typeof queueMicrotask=="function")se=queueMicrotask;else{const t=T(void 0);se=n(r=>q(t,r),"_queueMicrotask")}return se(e)},"_queueMicrotask");function O(e,t,r){if(typeof e!="function")throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}n(O,"reflectCall");function z(e,t,r){try{return T(O(e,t,r))}catch(s){return b(s)}}n(z,"promiseCall");const $=16384;class M{static{n(this,"SimpleQueue")}constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(t){const r=this._back;let s=r;r._elements.length===$-1&&(s={_elements:[],_next:void 0}),r._elements.push(t),s!==r&&(this._back=s,r._next=s),++this._size}shift(){const t=this._front;let r=t;const s=this._cursor;let f=s+1;const c=t._elements,d=c[s];return f===$&&(r=t._next,f=0),--this._size,this._cursor=f,t!==r&&(this._front=r),c[s]=void 0,d}forEach(t){let r=this._cursor,s=this._front,f=s._elements;for(;(r!==f.length||s._next!==void 0)&&!(r===f.length&&(s=s._next,f=s._elements,r=0,f.length===0));)t(f[r]),++r}peek(){const t=this._front,r=this._cursor;return t._elements[r]}}const pt=Symbol("[[AbortSteps]]"),an=Symbol("[[ErrorSteps]]"),ar=Symbol("[[CancelSteps]]"),sr=Symbol("[[PullSteps]]"),ur=Symbol("[[ReleaseSteps]]");function sn(e,t){e._ownerReadableStream=t,t._reader=e,t._state==="readable"?fr(e):t._state==="closed"?ri(e):un(e,t._storedError)}n(sn,"ReadableStreamReaderGenericInitialize");function lr(e,t){const r=e._ownerReadableStream;return X(r,t)}n(lr,"ReadableStreamReaderGenericCancel");function ue(e){const t=e._ownerReadableStream;t._state==="readable"?cr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):ni(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),t._readableStreamController[ur](),t._reader=void 0,e._ownerReadableStream=void 0}n(ue,"ReadableStreamReaderGenericRelease");function yt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}n(yt,"readerLockException");function fr(e){e._closedPromise=A((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}n(fr,"defaultReaderClosedPromiseInitialize");function un(e,t){fr(e),cr(e,t)}n(un,"defaultReaderClosedPromiseInitializeAsRejected");function ri(e){fr(e),ln(e)}n(ri,"defaultReaderClosedPromiseInitializeAsResolved");function cr(e,t){e._closedPromise_reject!==void 0&&(Q(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}n(cr,"defaultReaderClosedPromiseReject");function ni(e,t){un(e,t)}n(ni,"defaultReaderClosedPromiseResetToRejected");function ln(e){e._closedPromise_resolve!==void 0&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}n(ln,"defaultReaderClosedPromiseResolve");const fn=Number.isFinite||function(e){return typeof e=="number"&&isFinite(e)},oi=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function ii(e){return typeof e=="object"||typeof e=="function"}n(ii,"isDictionary");function ne(e,t){if(e!==void 0&&!ii(e))throw
|
||
|
|
`)).replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),"e$1"),Fe=n((i,o,a)=>{if(o.length<a)throw new TypeError(`Failed to execute '${i}' on 'FormData': ${a} arguments required, but only ${o.length} present.`)},"x");const Zt=class{static{n(this,"FormData")}#e=[];constructor(...o){if(o.length)throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.")}get[dt](){return"FormData"}[as](){return this.entries()}static[ss](o){return o&&typeof o=="object"&&o[dt]==="FormData"&&!us.some(a=>typeof o[a]!="function")}append(...o){Fe("append",arguments,2),this.#e.push(qo(...o))}delete(o){Fe("delete",arguments,1),o+="",this.#e=this.#e.filter(([a])=>a!==o)}get(o){Fe("get",arguments,1),o+="";for(var a=this.#e,l=a.length,u=0;u<l;u++)if(a[u][0]===o)return a[u][1];return null}getAll(o,a){return Fe("getAll",arguments,1),a=[],o+="",this.#e.forEach(l=>l[0]===o&&a.push(l[1])),a}has(o){return Fe("has",arguments,1),o+="",this.#e.some(a=>a[0]===o)}forEach(o,a){Fe("forEach",arguments,1);for(var[l,u]of this)o.call(a,u,l,this)}set(...o){Fe("set",arguments,2);var a=[],l=!0;o=qo(...o),this.#e.forEach(u=>{u[0]===o[0]?l&&(l=!a.push(o)):a.push(u)}),l&&a.push(o),this.#e=a}*entries(){yield*this.#e}*keys(){for(var[o]of this)yield o}*values(){for(var[,o]of this)yield o}};function ls(i,o=Ze){var a=`${ko()}${ko()}`.replace(/\./g,"").slice(-28).padStart(32,"-"),l=[],u=`--${a}\r
|
||
|
|
Content-Disposition: form-data; name="`;return i.forEach((m,h)=>typeof m=="string"?l.push(u+Gr(h)+`"\r
|
||
|
|
\r
|
||
|
|
${m.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
|
||
|
|
`)}\r
|
||
|
|
`):l.push(u+Gr(h)+`"; filename="${Gr(m.name,1)}"\r
|
||
|
|
Content-Type: ${m.type||"application/octet-stream"}\r
|
||
|
|
\r
|
||
|
|
`,m,`\r
|
||
|
|
`)),l.push(`--${a}--`),new o(l,{type:"multipart/form-data; boundary="+a})}n(ls,"formDataToBlob");class Kt extends Error{static{n(this,"FetchBaseError")}constructor(o,a){super(o),Error.captureStackTrace(this,this.constructor),this.type=a}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}class te extends Kt{static{n(this,"FetchError")}constructor(o,a,l){super(o,a),l&&(this.code=this.errno=l.code,this.erroredSysCall=l.syscall)}}const Jt=Symbol.toStringTag,Oo=n(i=>typeof i=="object"&&typeof i.append=="function"&&typeof i.delete=="function"&&typeof i.get=="function"&&typeof i.getAll=="function"&&typeof i.has=="function"&&typeof i.set=="function"&&typeof i.sort=="function"&&i[Jt]==="URLSearchParams","isURLSearchParameters"),Xt=n(i=>i&&typeof i=="object"&&typeof i.arrayBuffer=="function"&&typeof i.type=="string"&&typeof i.stream=="function"&&typeof i.constructor=="function"&&/^(Blob|File)$/.test(i[Jt]),"isBlob"),fs=n(i=>typeof i=="object"&&(i[Jt]==="AbortSignal"||i[Jt]==="EventTarget"),"isAbortSignal"),cs=n((i,o)=>{const a=new URL(o).hostname,l=new URL(i).hostname;return a===l||a.endsWith(`.${l}`)},"isDomainOrSubdomain"),ds=n((i,o)=>{const a=new URL(o).protocol,l=new URL(i).protocol;return a===l},"isSameProtocol"),hs=Ya(ie.pipeline),N=Symbol("Body internals");class ht{static{n(this,"Body")}constructor(o,{size:a=0}={}){let l=null;o===null?o=null:Oo(o)?o=D.from(o.toString()):Xt(o)||D.isBuffer(o)||(Yt.isAnyArrayBuffer(o)?o=D.from(o):ArrayBuffer.isView(o)?o=D.from(o.buffer,o.byteOffset,o.byteLength):o instanceof ie||(o instanceof Zt?(o=ls(o),l=o.type.split("=")[1]):o=D.from(String(o))));let u=o;D.isBuffer(o)?u=ie.Readable.from(o):Xt(o)&&(u=ie.Readable.from(o.stream())),this[N]={body:o,stream:u,boundary:l,disturbed:!1,error:null},this.size=a,o instanceof ie&&o.on("error",m=>{const h=m instanceof Kt?m:new te(`Invalid response body while trying to fetch ${this.url}: ${m.message}`,"system",m);this[N].error=h})}get body(){return this[N].stream}get bodyUsed(){return this[N].disturbed}async arrayBuffer(){const{buffer:o,byteOffset:a,byteLength:l}=await Zr(this);return o.slice(a,a+l)}async formData(){const o=this.headers.get("content-type");if(o.startsWith("application/x-www-form-urlencoded")){const l=new Zt,u=new URLSearchParams(await this.text());for(const[m,h]of u)l.append(m,h);return l}const{toFormData:a}=await import("./chunks/multipart-parser.mjs");return a(this.body,o)}async blob(){const o=this.headers&&this.headers.get("content-type")||this[N].body&&this[N].body.type||"",a=await this.arrayBuffer();return new Ze([a],{type:o})}async json(){const o=await this.text();return JSON.parse(o)}async text(){const o=await Zr(this);return new TextDecoder().decode(o)}buffer(){return Zr(this)}}ht.prototype.buffer=Gt(ht.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer"),Object.defineProperties(ht.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:Gt(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});async function Zr(i){if(i[N].disturbed)throw new TypeError(`body used already for: ${i.url}`);if(i[N].disturbed=!0,i[N].error)throw i[N].error;const{body:o}=i;if(o===null)return D.alloc(0);if(!(o instanceof ie))return D.alloc(0);const a=[];let l=0;try{for await(const u of o){if(i.size>0&&l+u.length>i.size){const m=new te(`content size at ${i.url} over limit: ${i.size}`,"max-size");throw o.destroy(m),m}l+=u.length,a.push(u)}}catch(u){throw u instanceof Kt?u:new te(`Invalid response body while trying to fetch ${i.url}: ${u.message}`,"system",u)}if(o.readableEnded===!0||o._readableState.ended===!0)try{return a.every(u=>typeof u=="string")?D.from(a.join("")):D.concat(a,l)}catch(u){throw new te(`Could not create Buffer from response body for ${i.url}: ${u.message}`,"system",u)}else throw new te(`Premature close of server response while trying to fetch ${i
|
||
|
|
\r
|
||
|
|
`);let l=!1,u=!1,m;i.on("response",h=>{const{headers:S}=h;l=S["transfer-encoding"]==="chunked"&&!S["content-length"]}),i.on("socket",h=>{const S=n(()=>{if(l&&!u){const w=new Error("Premature close");w.code="ERR_STREAM_PREMATURE_CLOSE",o(w)}},"onSocketClose"),E=n(w=>{u=D.compare(w.slice(-5),a)===0,!u&&m&&(u=D.compare(m.slice(-3),a.slice(0,3))===0&&D.compare(w.slice(-2),a.slice(3))===0),m=w},"onData");h.prependListener("close",S),h.on("data",E),i.on("close",()=>{h.removeListener("close",S),h.removeListener("data",E)})})}n(Fs,"fixResponseChunkedTransferBadEnding");const Uo=new WeakMap,rn=new WeakMap;function k(i){const o=Uo.get(i);return console.assert(o!=null,"'this' is expected an Event object, but got",i),o}n(k,"pd");function xo(i){if(i.passiveListener!=null){typeof console<"u"&&typeof console.error=="function"&&console.error("Unable to preventDefault inside passive event listener invocation.",i.passiveListener);return}i.event.cancelable&&(i.canceled=!0,typeof i.event.preventDefault=="function"&&i.event.preventDefault())}n(xo,"setCancelFlag");function Je(i,o){Uo.set(this,{eventTarget:i,event:o,eventPhase:2,currentTarget:i,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:o.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const a=Object.keys(o);for(let l=0;l<a.length;++l){const u=a[l];u in this||Object.defineProperty(this,u,No(u))}}n(Je,"Event"),Je.prototype={get type(){return k(this).event.type},get target(){return k(this).eventTarget},get currentTarget(){return k(this).currentTarget},composedPath(){const i=k(this).currentTarget;return i==null?[]:[i]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return k(this).eventPhase},stopPropagation(){const i=k(this);i.stopped=!0,typeof i.event.stopPropagation=="function"&&i.event.stopPropagation()},stopImmediatePropagation(){const i=k(this);i.stopped=!0,i.immediateStopped=!0,typeof i.event.stopImmediatePropagation=="function"&&i.event.stopImmediatePropagation()},get bubbles(){return!!k(this).event.bubbles},get cancelable(){return!!k(this).event.cancelable},preventDefault(){xo(k(this))},get defaultPrevented(){return k(this).canceled},get composed(){return!!k(this).event.composed},get timeStamp(){return k(this).timeStamp},get srcElement(){return k(this).eventTarget},get cancelBubble(){return k(this).stopped},set cancelBubble(i){if(!i)return;const o=k(this);o.stopped=!0,typeof o.event.cancelBubble=="boolean"&&(o.event.cancelBubble=!0)},get returnValue(){return!k(this).canceled},set returnValue(i){i||xo(k(this))},initEvent(){}},Object.defineProperty(Je.prototype,"constructor",{value:Je,configurable:!0,writable:!0}),typeof window<"u"&&typeof window.Event<"u"&&(Object.setPrototypeOf(Je.prototype,window.Event.prototype),rn.set(window.Event.prototype,Je));function No(i){return{get(){return k(this).event[i]},set(o){k(this).event[i]=o},configurable:!0,enumerable:!0}}n(No,"defineRedirectDescriptor");function zs(i){return{value(){const o=k(this).event;return o[i].apply(o,arguments)},configurable:!0,enumerable:!0}}n(zs,"defineCallDescriptor");function js(i,o){const a=Object.keys(o);if(a.length===0)return i;function l(u,m){i.call(this,u,m)}n(l,"CustomEvent"),l.prototype=Object.create(i.prototype,{constructor:{value:l,configurable:!0,writable:!0}});for(let u=0;u<a.length;++u){const m=a[u];if(!(m in i.prototype)){const S=typeof Object.getOwnPropertyDescriptor(o,m).value=="function";Object.defineProperty(l.prototype,m,S?zs(m):No(m))}}return l}n(js,"defineWrapper");function Ho(i){if(i==null||i===Object.prototype)return Je;let o=rn.get(i);return o==null&&(o=js(Ho(Object.getPrototypeOf(i)),i),rn.set(i,o)),o}n(Ho,"getWrapper");function Ls(i,o){const a=Ho(Object.getPrototypeOf(o));return new a(i,o)}n(Ls,"wrapEvent");function Ds(i){return k(i).immediateStopped}n(Ds,"isStopped");function $s(i,o){k(i).eventPhase=o}n($s,"setEventPhase");function Ms(i,o){k(i).currentTarget=o}n(Ms,"setCurrentTarget");function Vo(i,o){k(i).passiveListener=o}n(Vo,"setPassiveListener"
|