@shipstatic/ship 0.2.1 → 0.2.2

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/browser.js CHANGED
@@ -2,7 +2,7 @@ var Ha=Object.create;var ie=Object.defineProperty;var Ga=Object.getOwnPropertyDe
2
2
  `||e===`
3
3
  `&&s[a-1]!=="\r"?`\r
4
4
  `:e);bi=i=>new Proxy(i,{get:(e,a)=>la(e,a),has:(e,a)=>la(e,a)!==void 0}),hi={enableAdditionalHeaders:!1},ce={writable:!1,configurable:!1},gi=class{constructor(i,e,a){if(D(this,ee),D(this,L,`\r
5
- `),D(this,X),D(this,re),D(this,Y,"-".repeat(2)),D(this,I,new TextEncoder),D(this,Z),D(this,Q),D(this,pe),!da(i))throw new TypeError("Expected first argument to be a FormData instance.");let s;if(pa(e)?a=e:s=e,s||(s=`form-data-encoder-${ui()}`),typeof s!="string")throw new TypeError("Expected boundary argument to be a string.");if(a&&!pa(a))throw new TypeError("Expected options argument to be an object.");V(this,Q,Array.from(i.entries())),V(this,pe,{...hi,...a}),V(this,X,A(this,I).encode(A(this,L))),V(this,re,A(this,X).byteLength),this.boundary=s,this.contentType=`multipart/form-data; boundary=${this.boundary}`,V(this,Z,A(this,I).encode(`${A(this,Y)}${this.boundary}${A(this,Y)}${A(this,L).repeat(2)}`));let r={"Content-Type":this.contentType},u=Ce(this,ee,va).call(this);u&&(this.contentLength=u,r["Content-Length"]=u),this.headers=bi(Object.freeze(r)),Object.defineProperties(this,{boundary:ce,contentType:ce,contentLength:ce,headers:ce})}*values(){for(let[i,e]of A(this,Q)){let a=N(e)?e:A(this,I).encode(xa(e));yield Ce(this,ee,_e).call(this,i,a),yield a,yield A(this,X)}yield A(this,Z)}async*encode(){for(let i of this.values())N(i)?yield*vi(i.stream()):yield*ma(i)}[Symbol.iterator](){return this.values()}[Symbol.asyncIterator](){return this.encode()}};L=new WeakMap;X=new WeakMap;re=new WeakMap;Y=new WeakMap;I=new WeakMap;Z=new WeakMap;Q=new WeakMap;pe=new WeakMap;ee=new WeakSet;_e=function(i,e){let a="";if(a+=`${A(this,Y)}${this.boundary}${A(this,L)}`,a+=`Content-Disposition: form-data; name="${ca(i)}"`,N(e)&&(a+=`; filename="${ca(e.name)}"${A(this,L)}`,a+=`Content-Type: ${e.type||"application/octet-stream"}`),A(this,pe).enableAdditionalHeaders===!0){let s=N(e)?e.size:e.byteLength;s!=null&&!isNaN(s)&&(a+=`${A(this,L)}Content-Length: ${s}`)}return A(this,I).encode(`${a}${A(this,L).repeat(2)}`)};va=function(){let i=0;for(let[e,a]of A(this,Q)){let s=N(a)?a:A(this,I).encode(xa(a)),r=N(s)?s.size:s.byteLength;if(r==null||isNaN(r))return;i+=Ce(this,ee,_e).call(this,e,s).byteLength,i+=r,i+=A(this,re)}return String(i+A(this,Z).byteLength)}});var Ca=O((Sa,Fa)=>{"use strict";(function(i){if(typeof Sa=="object")Fa.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var e;try{e=window}catch{e=self}e.SparkMD5=i()}})(function(i){"use strict";var e=function(l,p){return l+p&4294967295},a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(l,p,o,n,c,t){return p=e(e(p,l),e(n,t)),e(p<<c|p>>>32-c,o)}function r(l,p){var o=l[0],n=l[1],c=l[2],t=l[3];o+=(n&c|~n&t)+p[0]-680876936|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[1]-389564586|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[2]+606105819|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[3]-1044525330|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&t)+p[4]-176418897|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[5]+1200080426|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[6]-1473231341|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[7]-45705983|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&t)+p[8]+1770035416|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[9]-1958414417|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[10]-42063|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[11]-1990404162|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&t)+p[12]+1804603682|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[13]-40341101|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[14]-1502002290|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[15]+1236535329|0,n=(n<<22|n>>>10)+c|0,o+=(n&t|c&~t)+p[1]-165796510|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[6]-1069501632|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[11]+643717713|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[0]-373897302|0,n=(n<<20|n>>>12)+c|0,o+=(n&t|c&~t)+p[5]-701558691|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[10]+38016083|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[15]-660478335|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[4]-405537848|0,n=(n<<20|n>>>12)+c|0,o+=(n&t|c&~t)+p[9]+568446438|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[14]-1019803690|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[3]-187363961|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[8]+1163531501|0,n=(n<<20|n>>>12)+c|0,o+=(n&t|c&~t)+p[13]-1444681467|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[2]-51403784|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[7]+1735328473|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[12]-1926607734|0,n=(n<<20|n>>>12)+c|0,o+=(n^c^t)+p[5]-378558|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[8]-2022574463|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[11]+1839030562|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[14]-35309556|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^t)+p[1]-1530992060|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[4]+1272893353|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[7]-155497632|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[10]-1094730640|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^t)+p[13]+681279174|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[0]-358537222|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[3]-722521979|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[6]+76029189|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^t)+p[9]-640364487|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[12]-421815835|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[15]+530742520|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[2]-995338651|0,n=(n<<23|n>>>9)+c|0,o+=(c^(n|~t))+p[0]-198630844|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[7]+1126891415|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[14]-1416354905|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[5]-57434055|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~t))+p[12]+1700485571|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[3]-1894986606|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[10]-1051523|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[1]-2054922799|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~t))+p[8]+1873313359|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[15]-30611744|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[6]-1560198380|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[13]+1309151649|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~t))+p[4]-145523070|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[11]-1120210379|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[2]+718787259|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[9]-343485551|0,n=(n<<21|n>>>11)+c|0,l[0]=o+l[0]|0,l[1]=n+l[1]|0,l[2]=c+l[2]|0,l[3]=t+l[3]|0}function u(l){var p=[],o;for(o=0;o<64;o+=4)p[o>>2]=l.charCodeAt(o)+(l.charCodeAt(o+1)<<8)+(l.charCodeAt(o+2)<<16)+(l.charCodeAt(o+3)<<24);return p}function m(l){var p=[],o;for(o=0;o<64;o+=4)p[o>>2]=l[o]+(l[o+1]<<8)+(l[o+2]<<16)+(l[o+3]<<24);return p}function d(l){var p=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,t,F,E,U;for(n=64;n<=p;n+=64)r(o,u(l.substring(n-64,n)));for(l=l.substring(n-64),c=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)t[n>>2]|=l.charCodeAt(n)<<(n%4<<3);if(t[n>>2]|=128<<(n%4<<3),n>55)for(r(o,t),n=0;n<16;n+=1)t[n]=0;return F=p*8,F=F.toString(16).match(/(.*?)(.{0,8})$/),E=parseInt(F[2],16),U=parseInt(F[1],16)||0,t[14]=E,t[15]=U,r(o,t),o}function x(l){var p=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,t,F,E,U;for(n=64;n<=p;n+=64)r(o,m(l.subarray(n-64,n)));for(l=n-64<p?l.subarray(n-64):new Uint8Array(0),c=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)t[n>>2]|=l[n]<<(n%4<<3);if(t[n>>2]|=128<<(n%4<<3),n>55)for(r(o,t),n=0;n<16;n+=1)t[n]=0;return F=p*8,F=F.toString(16).match(/(.*?)(.{0,8})$/),E=parseInt(F[2],16),U=parseInt(F[1],16)||0,t[14]=E,t[15]=U,r(o,t),o}function w(l){var p="",o;for(o=0;o<4;o+=1)p+=a[l>>o*8+4&15]+a[l>>o*8&15];return p}function h(l){var p;for(p=0;p<l.length;p+=1)l[p]=w(l[p]);return l.join("")}h(d("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(e=function(l,p){var o=(l&65535)+(p&65535),n=(l>>16)+(p>>16)+(o>>16);return n<<16|o&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function l(p,o){return p=p|0||0,p<0?Math.max(p+o,0):Math.min(p,o)}ArrayBuffer.prototype.slice=function(p,o){var n=this.byteLength,c=l(p,n),t=n,F,E,U,Oe;return o!==i&&(t=l(o,n)),c>t?new ArrayBuffer(0):(F=t-c,E=new ArrayBuffer(F),U=new Uint8Array(E),Oe=new Uint8Array(this,c,F),U.set(Oe),E)}})();function v(l){return/[\u0080-\uFFFF]/.test(l)&&(l=unescape(encodeURIComponent(l))),l}function S(l,p){var o=l.length,n=new ArrayBuffer(o),c=new Uint8Array(n),t;for(t=0;t<o;t+=1)c[t]=l.charCodeAt(t);return p?c:n}function j(l){return String.fromCharCode.apply(null,new Uint8Array(l))}function P(l,p,o){var n=new Uint8Array(l.byteLength+p.byteLength);return n.set(new Uint8Array(l)),n.set(new Uint8Array(p),l.byteLength),o?n:n.buffer}function R(l){var p=[],o=l.length,n;for(n=0;n<o-1;n+=2)p.push(parseInt(l.substr(n,2),16));return String.fromCharCode.apply(String,p)}function y(){this.reset()}return y.prototype.append=function(l){return this.appendBinary(v(l)),this},y.prototype.appendBinary=function(l){this._buff+=l,this._length+=l.length;var p=this._buff.length,o;for(o=64;o<=p;o+=64)r(this._hash,u(this._buff.substring(o-64,o)));return this._buff=this._buff.substring(o-64),this},y.prototype.end=function(l){var p=this._buff,o=p.length,n,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t;for(n=0;n<o;n+=1)c[n>>2]|=p.charCodeAt(n)<<(n%4<<3);return this._finish(c,o),t=h(this._hash),l&&(t=R(t)),this.reset(),t},y.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},y.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},y.prototype.setState=function(l){return this._buff=l.buff,this._length=l.length,this._hash=l.hash,this},y.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},y.prototype._finish=function(l,p){var o=p,n,c,t;if(l[o>>2]|=128<<(o%4<<3),o>55)for(r(this._hash,l),o=0;o<16;o+=1)l[o]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(n[2],16),t=parseInt(n[1],16)||0,l[14]=c,l[15]=t,r(this._hash,l)},y.hash=function(l,p){return y.hashBinary(v(l),p)},y.hashBinary=function(l,p){var o=d(l),n=h(o);return p?R(n):n},y.ArrayBuffer=function(){this.reset()},y.ArrayBuffer.prototype.append=function(l){var p=P(this._buff.buffer,l,!0),o=p.length,n;for(this._length+=l.byteLength,n=64;n<=o;n+=64)r(this._hash,m(p.subarray(n-64,n)));return this._buff=n-64<o?new Uint8Array(p.buffer.slice(n-64)):new Uint8Array(0),this},y.ArrayBuffer.prototype.end=function(l){var p=this._buff,o=p.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c,t;for(c=0;c<o;c+=1)n[c>>2]|=p[c]<<(c%4<<3);return this._finish(n,o),t=h(this._hash),l&&(t=R(t)),this.reset(),t},y.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},y.ArrayBuffer.prototype.getState=function(){var l=y.prototype.getState.call(this);return l.buff=j(l.buff),l},y.ArrayBuffer.prototype.setState=function(l){return l.buff=S(l.buff,!0),y.prototype.setState.call(this,l)},y.ArrayBuffer.prototype.destroy=y.prototype.destroy,y.ArrayBuffer.prototype._finish=y.prototype._finish,y.ArrayBuffer.hash=function(l,p){var o=x(new Uint8Array(l)),n=h(o);return p?R(n):n},y})});var De=O((an,Pa)=>{"use strict";Pa.exports={}});async function zi(i){let e=(await Promise.resolve().then(()=>W(Ca(),1))).default;return new Promise((a,s)=>{let u=Math.ceil(i.size/2097152),m=0,d=new e.ArrayBuffer,x=new FileReader,w=()=>{let h=m*2097152,v=Math.min(h+2097152,i.size);x.readAsArrayBuffer(i.slice(h,v))};x.onload=h=>{let v=h.target?.result;if(!v){s(f.business("Failed to read file chunk"));return}d.append(v),m++,m<u?w():a({md5:d.end()})},x.onerror=()=>{s(f.business("Failed to calculate MD5: FileReader error"))},w()})}async function Si(i){let e=await Promise.resolve().then(()=>W(De(),1));if(Buffer.isBuffer(i)){let s=e.createHash("md5");return s.update(i),{md5:s.digest("hex")}}let a=await Promise.resolve().then(()=>W(De(),1));return new Promise((s,r)=>{let u=e.createHash("md5"),m=a.createReadStream(i);m.on("error",d=>r(f.business(`Failed to read file for MD5: ${d.message}`))),m.on("data",d=>u.update(d)),m.on("end",()=>s({md5:u.digest("hex")}))})}async function xe(i){let e=G();if(e==="browser"){if(!(i instanceof Blob))throw f.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return zi(i)}if(e==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw f.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Si(i)}throw f.business("Unknown or unsupported execution environment for MD5 calculation.")}var ve=_(()=>{"use strict";J();$()});var Ua={};ne(Ua,{loadConfig:()=>Ra,setConfig:()=>be});async function Ra(i){return{}}function be(i){Object.assign(Ci,i)}var Ci,he=_(()=>{"use strict";Ci={}});function $a(i){return _i.test(i)}var Pi,_i,La=_(()=>{"use strict";Pi=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],_i=new RegExp(Pi.join("|"))});function Oa(i){return!i||i.length===0?[]:i.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let s=a[a.length-1];if($a(s))return!1;let r=a.slice(0,-1);for(let u of r)if(Ti.some(m=>u.toLowerCase()===m.toLowerCase()))return!1;return!0})}var Ti,qe=_(()=>{"use strict";La();Ti=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function ge(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ba=_(()=>{"use strict"});function Ia(i,e={}){if(e.flatten===!1)return i.map(s=>({path:ge(s),name:Re(s)}));let a=Ei(i);return i.map(s=>{let r=ge(s);if(a){let u=a.endsWith("/")?a:`${a}/`;r.startsWith(u)&&(r=r.substring(u.length))}return r||(r=Re(s)),{path:r,name:Re(s)}})}function Ei(i){if(!i.length)return"";let a=i.map(u=>ge(u)).map(u=>u.split("/")),s=[],r=Math.min(...a.map(u=>u.length));for(let u=0;u<r-1;u++){let m=a[0][u];if(a.every(d=>d[u]===m))s.push(m);else break}return s.join("/")}function Re(i){return i.split(/[/\\]/).pop()||i}var Ue=_(()=>{"use strict";Ba()});var Ma={};ne(Ma,{processFilesForBrowser:()=>Na});async function Na(i,e={}){let{getENV:a}=await Promise.resolve().then(()=>(J(),oa));if(a()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let s=Array.isArray(i)?i:Array.from(i),r=s.map(v=>v.webkitRelativePath||v.name),u=Ia(r,{flatten:e.pathDetect!==!1}),m=[];for(let v=0;v<s.length;v++){let S=s[v],j=u[v].path;if(j.includes("..")||j.includes("\0"))throw f.business(`Security error: Unsafe file path "${j}" for file: ${S.name}`);m.push({file:S,relativePath:j})}let d=m.map(v=>v.relativePath),x=Oa(d),w=new Set(x),h=[];for(let v of m){if(!w.has(v.relativePath))continue;let{md5:S}=await xe(v.file);h.push({content:v.file,path:v.relativePath,size:v.file.size,md5:S})}return h}var $e=_(()=>{"use strict";ve();$();qe();Ue()});var me=W(ea(),1);$();J();var le="/deployments",ha="/ping",ae="/aliases",yi="/config",wi="/account",ki="/spa-check";function ji(i){return typeof i=="string"?me.lookup(i)||"application/octet-stream":me.lookup(i.name)||i.type||"application/octet-stream"}async function Ai(i){let e=[];for await(let a of i)e.push(a);return e}var b,ga,Te,C,ya,wa,ka,ja,Ee,ue,de=class{constructor(e){se(this,b);this.apiUrl=e.apiUrl||te,this.apiKey=e.apiKey??"",this.deployToken=e.deployToken??""}async ping(){return(await g(this,b,C).call(this,`${this.apiUrl}${ha}`,{method:"GET"},"Ping"))?.success||!1}async getPingResponse(){return await g(this,b,C).call(this,`${this.apiUrl}${ha}`,{method:"GET"},"Ping")}async getConfig(){return await g(this,b,C).call(this,`${this.apiUrl}${yi}`,{method:"GET"},"Config")}async deploy(e,a={}){g(this,b,ya).call(this,e);let{apiUrl:s=this.apiUrl,signal:r,apiKey:u,deployToken:m}=a,{requestBody:d,requestHeaders:x}=await g(this,b,wa).call(this,e),w={};m?w={Authorization:`Bearer ${m}`}:u&&(w={Authorization:`Bearer ${u}`});let h={method:"POST",body:d,headers:{...x,...w},signal:r||null};return await g(this,b,C).call(this,`${s}${le}`,h,"Deploy")}async listDeployments(){return await g(this,b,C).call(this,`${this.apiUrl}${le}`,{method:"GET"},"List Deployments")}async getDeployment(e){return await g(this,b,C).call(this,`${this.apiUrl}${le}/${e}`,{method:"GET"},"Get Deployment")}async removeDeployment(e){await g(this,b,C).call(this,`${this.apiUrl}${le}/${e}`,{method:"DELETE"},"Remove Deployment")}async setAlias(e,a){try{let s=await g(this,b,Te).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({deployment:a})},"Set Alias");return s.ok||await g(this,b,Ee).call(this,s,"Set Alias"),{...await s.json(),isCreate:s.status===201}}catch(s){g(this,b,ue).call(this,s,"Set Alias")}}async getAlias(e){return await g(this,b,C).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}`,{method:"GET"},"Get Alias")}async listAliases(){return await g(this,b,C).call(this,`${this.apiUrl}${ae}`,{method:"GET"},"List Aliases")}async removeAlias(e){await g(this,b,C).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove Alias")}async checkAlias(e){return await g(this,b,C).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}/dns-check`,{method:"POST"},"Check Alias")}async getAccount(){return await g(this,b,C).call(this,`${this.apiUrl}${wi}`,{method:"GET"},"Get Account")}async createApiKey(){return await g(this,b,C).call(this,`${this.apiUrl}/key`,{method:"POST"},"Create API Key")}async checkSPA(e){let a=e.find(x=>x.path==="index.html"||x.path==="/index.html");if(!a)return!1;let s=100*1024;if(a.size>s)return!1;let r;if(typeof Buffer<"u"&&Buffer.isBuffer(a.content))r=a.content.toString("utf-8");else if(typeof Blob<"u"&&a.content instanceof Blob)r=await a.content.text();else if(typeof File<"u"&&a.content instanceof File)r=await a.content.text();else return!1;let m={files:e.map(x=>x.path),index:r};return(await g(this,b,C).call(this,`${this.apiUrl}${ki}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)},"SPA Check")).isSPA}};b=new WeakSet,ga=function(e={}){let a={...e};return this.deployToken?a.Authorization=`Bearer ${this.deployToken}`:this.apiKey&&(a.Authorization=`Bearer ${this.apiKey}`),a},Te=async function(e,a={},s){let r=g(this,b,ga).call(this,a.headers),u={...a,headers:r};try{return await fetch(e,u)}catch(m){throw g(this,b,ue).call(this,m,s),m}},C=async function(e,a={},s){try{let r=await g(this,b,Te).call(this,e,a,s);return r.ok||await g(this,b,Ee).call(this,r,s),r.headers.get("Content-Length")==="0"||r.status===204?void 0:await r.json()}catch(r){throw r instanceof f||g(this,b,ue).call(this,r,s),r}},ya=function(e){if(!e.length)throw f.business("No files to deploy.");for(let a of e)if(!a.md5)throw f.file(`MD5 checksum missing for file: ${a.path}`,a.path)},wa=async function(e){let a,s={};if(G()==="browser")a=g(this,b,ka).call(this,e);else if(G()==="node"){let{body:r,headers:u}=await g(this,b,ja).call(this,e);a=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),s=u}else throw f.business("Unknown or unsupported execution environment");return{requestBody:a,requestHeaders:s}},ka=function(e){let a=new FormData,s=[];for(let r=0;r<e.length;r++){let u=e[r],m;if(u.content instanceof File||u.content instanceof Blob)m=u.content;else throw f.file(`Unsupported file.content type for browser FormData: ${u.path}`,u.path);let d=ji(m instanceof File?m:u.path),x=new File([m],u.path,{type:d});a.append("files[]",x),s.push(u.md5)}return a.append("checksums",JSON.stringify(s)),a},ja=async function(e){let{FormData:a,File:s}=await import("formdata-node"),{FormDataEncoder:r}=await Promise.resolve().then(()=>(ba(),fa)),u=await Promise.resolve().then(()=>W(we(),1)),m=new a,d=[];for(let S=0;S<e.length;S++){let j=e[S],P=me.lookup(j.path)||"application/octet-stream",R;if(Buffer.isBuffer(j.content))R=new s([j.content],j.path,{type:P});else if(typeof Blob<"u"&&j.content instanceof Blob)R=new s([j.content],j.path,{type:P});else throw f.file(`Unsupported file.content type for Node.js FormData: ${j.path}`,j.path);let y=j.path.startsWith("/")?j.path:"/"+j.path;m.append("files[]",R,y),d.push(j.md5)}m.append("checksums",JSON.stringify(d));let x=new r(m),w=await Ai(x.encode()),h=Buffer.concat(w.map(S=>Buffer.from(S))),v={"Content-Type":x.contentType,"Content-Length":Buffer.byteLength(h).toString()};return{body:h,headers:v}},Ee=async function(e,a){let s={};try{let r=e.headers.get("content-type");r&&r.includes("application/json")?s=await e.json():s={message:await e.text()}}catch{s={message:"Failed to parse error response"}}if(s.error||s.code||s.message){let r=s.message||s.error||`${a} failed due to API error`;throw e.status===401?f.authentication(r):f.api(r,e.status,s.code,s)}throw e.status===401?f.authentication(`Authentication failed for ${a}`):f.api(`${a} failed due to API error`,e.status,void 0,s)},ue=function(e,a){throw e.name==="AbortError"?f.cancelled(`${a} operation was cancelled.`):e instanceof TypeError&&e.message.includes("fetch")?f.network(`${a} failed due to network error: ${e.message}`,e):e instanceof f?e:f.business(`An unexpected error occurred during ${a}: ${e.message||"Unknown error"}`)};$();function Aa(i={},e={}){let a={apiUrl:i.apiUrl||e.apiUrl||te,apiKey:i.apiKey!==void 0?i.apiKey:e.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:e.deployToken},s={apiUrl:a.apiUrl};return a.apiKey!==void 0&&(s.apiKey=a.apiKey),a.deployToken!==void 0&&(s.deployToken=a.deployToken),s}function za(i,e){let a={...i};return a.apiUrl===void 0&&e.apiUrl!==void 0&&(a.apiUrl=e.apiUrl),a.apiKey===void 0&&e.apiKey!==void 0&&(a.apiKey=e.apiKey),a.deployToken===void 0&&e.deployToken!==void 0&&(a.deployToken=e.deployToken),a.timeout===void 0&&e.timeout!==void 0&&(a.timeout=e.timeout),a.maxConcurrency===void 0&&e.maxConcurrency!==void 0&&(a.maxConcurrency=e.maxConcurrency),a.onProgress===void 0&&e.onProgress!==void 0&&(a.onProgress=e.onProgress),a.onProgressStats===void 0&&e.onProgressStats!==void 0&&(a.onProgressStats=e.onProgressStats),a}$();ve();async function Fi(){let e=JSON.stringify({rewrites:[{source:"/(.*)",destination:"/index.html"}]},null,2),a;typeof Buffer<"u"?a=Buffer.from(e,"utf-8"):a=new Blob([e],{type:"application/json"});let{md5:s}=await xe(a);return{path:Se,content:a,size:e.length,md5:s}}async function _a(i,e,a){if(a.spaDetect===!1||i.some(s=>s.path===Se))return i;try{if(await e.checkSPA(i)){let r=await Fi();return[...i,r]}}catch(s){console.warn("SPA detection failed, continuing without auto-config:",s)}return i}function Ta(i,e,a,s){return{create:async(r,u={})=>{a&&await a();let m=e?za(u,e):u,d=i();if(!s)throw new Error("processInput function is not provided.");let x=await s(r,m);return x=await _a(x,d,m),await d.deploy(x,m)},list:async()=>(a&&await a(),i().listDeployments()),remove:async r=>{a&&await a(),await i().removeDeployment(r)},get:async r=>(a&&await a(),i().getDeployment(r))}}function Ea(i,e){return{set:async(a,s)=>(e&&await e(),i().setAlias(a,s)),get:async a=>(e&&await e(),i().getAlias(a)),list:async()=>(e&&await e(),i().listAliases()),remove:async a=>{e&&await e(),await i().removeAlias(a)},check:async a=>(e&&await e(),i().checkAlias(a))}}function Da(i,e){return{get:async()=>(e&&await e(),i().getAccount())}}function qa(i,e){return{create:async()=>(e&&await e(),i().createApiKey())}}var fe=class{constructor(e={}){this.initPromise=null;this.clientOptions=e;let a=this.resolveInitialConfig(e);this.http=new de({...e,...a});let s=()=>this.ensureInitialized(),r=()=>this.http;this._deployments=Ta(r,this.clientOptions,s,(u,m)=>this.processInput(u,m)),this._aliases=Ea(r,s),this._account=Da(r,s),this._keys=qa(r,s)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(e,a){return this.deployments.create(e,a)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get aliases(){return this._aliases}get account(){return this._account}get keys(){return this._keys}};he();$();ve();function vn(i,e,a,s=!0){let r=i===1?e:a;return s?`${i} ${r}`:r}qe();Ue();J();$();he();$e();var ye,Ka,Le=class extends fe{constructor(a={}){super(a);se(this,ye)}resolveInitialConfig(a){return Aa(a,{})}async loadFullConfig(){try{let{loadConfig:a}=await Promise.resolve().then(()=>(he(),Ua)),s=await a(this.clientOptions.configFile);be({apiUrl:this.clientOptions.apiUrl,deployToken:this.clientOptions.deployToken,apiKey:this.clientOptions.apiKey})}catch(a){throw this.initPromise=null,a}}async processInput(a,s){if(!g(this,ye,Ka).call(this,a))throw f.business("Invalid input type for browser environment. Expected File[], FileList, or HTMLInputElement.");let r=a instanceof HTMLInputElement?Array.from(a.files):a,{processFilesForBrowser:u}=await Promise.resolve().then(()=>($e(),Ma));return u(r,s)}};ye=new WeakSet,Ka=function(a){return Array.isArray(a)?a.length===0||a.every(s=>s instanceof File):a&&typeof a=="object"&&"length"in a&&typeof a.length=="number"?"item"in a||a.constructor?.name==="FileList":!!(a&&typeof a=="object"&&"files"in a)};var Mn=Le;export{Ae as API_KEY_HEX_LENGTH,K as API_KEY_PREFIX,aa as API_KEY_TOTAL_LENGTH,de as ApiHttp,te as DEFAULT_API,Se as DEPLOYMENT_CONFIG_FILENAME,ze as DEPLOY_TOKEN_HEX_LENGTH,H as DEPLOY_TOKEN_PREFIX,ia as DEPLOY_TOKEN_TOTAL_LENGTH,k as ErrorType,Ti as JUNK_DIRECTORIES,Le as Ship,f as ShipError,ri as ShipErrorType,na as UploadStatus,pi as __setTestEnvironment,xe as calculateMD5,Da as createAccountResource,Ea as createAliasResource,Ta as createDeploymentResource,qa as createKeysResource,Mn as default,Oa as filterJunk,Hi as generateAliasUrl,Ki as generateDeploymentUrl,G as getENV,Ra as loadConfig,za as mergeDeployOptions,Ia as optimizeDeployPaths,vn as pluralize,Na as processFilesForBrowser,Aa as resolveConfig,Oi as serverConfig,be as setConfig,Bi as validateApiKey,Ni as validateApiUrl,Ii as validateDeployToken,Mi as validateSubdomain};
5
+ `),D(this,X),D(this,re),D(this,Y,"-".repeat(2)),D(this,I,new TextEncoder),D(this,Z),D(this,Q),D(this,pe),!da(i))throw new TypeError("Expected first argument to be a FormData instance.");let s;if(pa(e)?a=e:s=e,s||(s=`form-data-encoder-${ui()}`),typeof s!="string")throw new TypeError("Expected boundary argument to be a string.");if(a&&!pa(a))throw new TypeError("Expected options argument to be an object.");V(this,Q,Array.from(i.entries())),V(this,pe,{...hi,...a}),V(this,X,A(this,I).encode(A(this,L))),V(this,re,A(this,X).byteLength),this.boundary=s,this.contentType=`multipart/form-data; boundary=${this.boundary}`,V(this,Z,A(this,I).encode(`${A(this,Y)}${this.boundary}${A(this,Y)}${A(this,L).repeat(2)}`));let r={"Content-Type":this.contentType},u=Ce(this,ee,va).call(this);u&&(this.contentLength=u,r["Content-Length"]=u),this.headers=bi(Object.freeze(r)),Object.defineProperties(this,{boundary:ce,contentType:ce,contentLength:ce,headers:ce})}*values(){for(let[i,e]of A(this,Q)){let a=N(e)?e:A(this,I).encode(xa(e));yield Ce(this,ee,_e).call(this,i,a),yield a,yield A(this,X)}yield A(this,Z)}async*encode(){for(let i of this.values())N(i)?yield*vi(i.stream()):yield*ma(i)}[Symbol.iterator](){return this.values()}[Symbol.asyncIterator](){return this.encode()}};L=new WeakMap;X=new WeakMap;re=new WeakMap;Y=new WeakMap;I=new WeakMap;Z=new WeakMap;Q=new WeakMap;pe=new WeakMap;ee=new WeakSet;_e=function(i,e){let a="";if(a+=`${A(this,Y)}${this.boundary}${A(this,L)}`,a+=`Content-Disposition: form-data; name="${ca(i)}"`,N(e)&&(a+=`; filename="${ca(e.name)}"${A(this,L)}`,a+=`Content-Type: ${e.type||"application/octet-stream"}`),A(this,pe).enableAdditionalHeaders===!0){let s=N(e)?e.size:e.byteLength;s!=null&&!isNaN(s)&&(a+=`${A(this,L)}Content-Length: ${s}`)}return A(this,I).encode(`${a}${A(this,L).repeat(2)}`)};va=function(){let i=0;for(let[e,a]of A(this,Q)){let s=N(a)?a:A(this,I).encode(xa(a)),r=N(s)?s.size:s.byteLength;if(r==null||isNaN(r))return;i+=Ce(this,ee,_e).call(this,e,s).byteLength,i+=r,i+=A(this,re)}return String(i+A(this,Z).byteLength)}});var Ca=O((Sa,Fa)=>{"use strict";(function(i){if(typeof Sa=="object")Fa.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var e;try{e=window}catch{e=self}e.SparkMD5=i()}})(function(i){"use strict";var e=function(l,p){return l+p&4294967295},a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(l,p,o,n,c,t){return p=e(e(p,l),e(n,t)),e(p<<c|p>>>32-c,o)}function r(l,p){var o=l[0],n=l[1],c=l[2],t=l[3];o+=(n&c|~n&t)+p[0]-680876936|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[1]-389564586|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[2]+606105819|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[3]-1044525330|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&t)+p[4]-176418897|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[5]+1200080426|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[6]-1473231341|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[7]-45705983|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&t)+p[8]+1770035416|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[9]-1958414417|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[10]-42063|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[11]-1990404162|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&t)+p[12]+1804603682|0,o=(o<<7|o>>>25)+n|0,t+=(o&n|~o&c)+p[13]-40341101|0,t=(t<<12|t>>>20)+o|0,c+=(t&o|~t&n)+p[14]-1502002290|0,c=(c<<17|c>>>15)+t|0,n+=(c&t|~c&o)+p[15]+1236535329|0,n=(n<<22|n>>>10)+c|0,o+=(n&t|c&~t)+p[1]-165796510|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[6]-1069501632|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[11]+643717713|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[0]-373897302|0,n=(n<<20|n>>>12)+c|0,o+=(n&t|c&~t)+p[5]-701558691|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[10]+38016083|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[15]-660478335|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[4]-405537848|0,n=(n<<20|n>>>12)+c|0,o+=(n&t|c&~t)+p[9]+568446438|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[14]-1019803690|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[3]-187363961|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[8]+1163531501|0,n=(n<<20|n>>>12)+c|0,o+=(n&t|c&~t)+p[13]-1444681467|0,o=(o<<5|o>>>27)+n|0,t+=(o&c|n&~c)+p[2]-51403784|0,t=(t<<9|t>>>23)+o|0,c+=(t&n|o&~n)+p[7]+1735328473|0,c=(c<<14|c>>>18)+t|0,n+=(c&o|t&~o)+p[12]-1926607734|0,n=(n<<20|n>>>12)+c|0,o+=(n^c^t)+p[5]-378558|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[8]-2022574463|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[11]+1839030562|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[14]-35309556|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^t)+p[1]-1530992060|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[4]+1272893353|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[7]-155497632|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[10]-1094730640|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^t)+p[13]+681279174|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[0]-358537222|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[3]-722521979|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[6]+76029189|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^t)+p[9]-640364487|0,o=(o<<4|o>>>28)+n|0,t+=(o^n^c)+p[12]-421815835|0,t=(t<<11|t>>>21)+o|0,c+=(t^o^n)+p[15]+530742520|0,c=(c<<16|c>>>16)+t|0,n+=(c^t^o)+p[2]-995338651|0,n=(n<<23|n>>>9)+c|0,o+=(c^(n|~t))+p[0]-198630844|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[7]+1126891415|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[14]-1416354905|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[5]-57434055|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~t))+p[12]+1700485571|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[3]-1894986606|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[10]-1051523|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[1]-2054922799|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~t))+p[8]+1873313359|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[15]-30611744|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[6]-1560198380|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[13]+1309151649|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~t))+p[4]-145523070|0,o=(o<<6|o>>>26)+n|0,t+=(n^(o|~c))+p[11]-1120210379|0,t=(t<<10|t>>>22)+o|0,c+=(o^(t|~n))+p[2]+718787259|0,c=(c<<15|c>>>17)+t|0,n+=(t^(c|~o))+p[9]-343485551|0,n=(n<<21|n>>>11)+c|0,l[0]=o+l[0]|0,l[1]=n+l[1]|0,l[2]=c+l[2]|0,l[3]=t+l[3]|0}function u(l){var p=[],o;for(o=0;o<64;o+=4)p[o>>2]=l.charCodeAt(o)+(l.charCodeAt(o+1)<<8)+(l.charCodeAt(o+2)<<16)+(l.charCodeAt(o+3)<<24);return p}function m(l){var p=[],o;for(o=0;o<64;o+=4)p[o>>2]=l[o]+(l[o+1]<<8)+(l[o+2]<<16)+(l[o+3]<<24);return p}function d(l){var p=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,t,F,E,U;for(n=64;n<=p;n+=64)r(o,u(l.substring(n-64,n)));for(l=l.substring(n-64),c=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)t[n>>2]|=l.charCodeAt(n)<<(n%4<<3);if(t[n>>2]|=128<<(n%4<<3),n>55)for(r(o,t),n=0;n<16;n+=1)t[n]=0;return F=p*8,F=F.toString(16).match(/(.*?)(.{0,8})$/),E=parseInt(F[2],16),U=parseInt(F[1],16)||0,t[14]=E,t[15]=U,r(o,t),o}function x(l){var p=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,t,F,E,U;for(n=64;n<=p;n+=64)r(o,m(l.subarray(n-64,n)));for(l=n-64<p?l.subarray(n-64):new Uint8Array(0),c=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)t[n>>2]|=l[n]<<(n%4<<3);if(t[n>>2]|=128<<(n%4<<3),n>55)for(r(o,t),n=0;n<16;n+=1)t[n]=0;return F=p*8,F=F.toString(16).match(/(.*?)(.{0,8})$/),E=parseInt(F[2],16),U=parseInt(F[1],16)||0,t[14]=E,t[15]=U,r(o,t),o}function w(l){var p="",o;for(o=0;o<4;o+=1)p+=a[l>>o*8+4&15]+a[l>>o*8&15];return p}function h(l){var p;for(p=0;p<l.length;p+=1)l[p]=w(l[p]);return l.join("")}h(d("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(e=function(l,p){var o=(l&65535)+(p&65535),n=(l>>16)+(p>>16)+(o>>16);return n<<16|o&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function l(p,o){return p=p|0||0,p<0?Math.max(p+o,0):Math.min(p,o)}ArrayBuffer.prototype.slice=function(p,o){var n=this.byteLength,c=l(p,n),t=n,F,E,U,Oe;return o!==i&&(t=l(o,n)),c>t?new ArrayBuffer(0):(F=t-c,E=new ArrayBuffer(F),U=new Uint8Array(E),Oe=new Uint8Array(this,c,F),U.set(Oe),E)}})();function v(l){return/[\u0080-\uFFFF]/.test(l)&&(l=unescape(encodeURIComponent(l))),l}function S(l,p){var o=l.length,n=new ArrayBuffer(o),c=new Uint8Array(n),t;for(t=0;t<o;t+=1)c[t]=l.charCodeAt(t);return p?c:n}function j(l){return String.fromCharCode.apply(null,new Uint8Array(l))}function P(l,p,o){var n=new Uint8Array(l.byteLength+p.byteLength);return n.set(new Uint8Array(l)),n.set(new Uint8Array(p),l.byteLength),o?n:n.buffer}function R(l){var p=[],o=l.length,n;for(n=0;n<o-1;n+=2)p.push(parseInt(l.substr(n,2),16));return String.fromCharCode.apply(String,p)}function y(){this.reset()}return y.prototype.append=function(l){return this.appendBinary(v(l)),this},y.prototype.appendBinary=function(l){this._buff+=l,this._length+=l.length;var p=this._buff.length,o;for(o=64;o<=p;o+=64)r(this._hash,u(this._buff.substring(o-64,o)));return this._buff=this._buff.substring(o-64),this},y.prototype.end=function(l){var p=this._buff,o=p.length,n,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t;for(n=0;n<o;n+=1)c[n>>2]|=p.charCodeAt(n)<<(n%4<<3);return this._finish(c,o),t=h(this._hash),l&&(t=R(t)),this.reset(),t},y.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},y.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},y.prototype.setState=function(l){return this._buff=l.buff,this._length=l.length,this._hash=l.hash,this},y.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},y.prototype._finish=function(l,p){var o=p,n,c,t;if(l[o>>2]|=128<<(o%4<<3),o>55)for(r(this._hash,l),o=0;o<16;o+=1)l[o]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(n[2],16),t=parseInt(n[1],16)||0,l[14]=c,l[15]=t,r(this._hash,l)},y.hash=function(l,p){return y.hashBinary(v(l),p)},y.hashBinary=function(l,p){var o=d(l),n=h(o);return p?R(n):n},y.ArrayBuffer=function(){this.reset()},y.ArrayBuffer.prototype.append=function(l){var p=P(this._buff.buffer,l,!0),o=p.length,n;for(this._length+=l.byteLength,n=64;n<=o;n+=64)r(this._hash,m(p.subarray(n-64,n)));return this._buff=n-64<o?new Uint8Array(p.buffer.slice(n-64)):new Uint8Array(0),this},y.ArrayBuffer.prototype.end=function(l){var p=this._buff,o=p.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c,t;for(c=0;c<o;c+=1)n[c>>2]|=p[c]<<(c%4<<3);return this._finish(n,o),t=h(this._hash),l&&(t=R(t)),this.reset(),t},y.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},y.ArrayBuffer.prototype.getState=function(){var l=y.prototype.getState.call(this);return l.buff=j(l.buff),l},y.ArrayBuffer.prototype.setState=function(l){return l.buff=S(l.buff,!0),y.prototype.setState.call(this,l)},y.ArrayBuffer.prototype.destroy=y.prototype.destroy,y.ArrayBuffer.prototype._finish=y.prototype._finish,y.ArrayBuffer.hash=function(l,p){var o=x(new Uint8Array(l)),n=h(o);return p?R(n):n},y})});var De=O((an,Pa)=>{"use strict";Pa.exports={}});async function zi(i){let e=(await Promise.resolve().then(()=>W(Ca(),1))).default;return new Promise((a,s)=>{let u=Math.ceil(i.size/2097152),m=0,d=new e.ArrayBuffer,x=new FileReader,w=()=>{let h=m*2097152,v=Math.min(h+2097152,i.size);x.readAsArrayBuffer(i.slice(h,v))};x.onload=h=>{let v=h.target?.result;if(!v){s(f.business("Failed to read file chunk"));return}d.append(v),m++,m<u?w():a({md5:d.end()})},x.onerror=()=>{s(f.business("Failed to calculate MD5: FileReader error"))},w()})}async function Si(i){let e=await Promise.resolve().then(()=>W(De(),1));if(Buffer.isBuffer(i)){let s=e.createHash("md5");return s.update(i),{md5:s.digest("hex")}}let a=await Promise.resolve().then(()=>W(De(),1));return new Promise((s,r)=>{let u=e.createHash("md5"),m=a.createReadStream(i);m.on("error",d=>r(f.business(`Failed to read file for MD5: ${d.message}`))),m.on("data",d=>u.update(d)),m.on("end",()=>s({md5:u.digest("hex")}))})}async function xe(i){let e=G();if(e==="browser"){if(!(i instanceof Blob))throw f.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return zi(i)}if(e==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw f.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Si(i)}throw f.business("Unknown or unsupported execution environment for MD5 calculation.")}var ve=_(()=>{"use strict";J();$()});var Ua={};ne(Ua,{loadConfig:()=>Ra,setConfig:()=>be});async function Ra(i){return{}}function be(i){Object.assign(Ci,i)}var Ci,he=_(()=>{"use strict";Ci={}});function $a(i){return _i.test(i)}var Pi,_i,La=_(()=>{"use strict";Pi=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],_i=new RegExp(Pi.join("|"))});function Oa(i){return!i||i.length===0?[]:i.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let s=a[a.length-1];if($a(s))return!1;let r=a.slice(0,-1);for(let u of r)if(Ti.some(m=>u.toLowerCase()===m.toLowerCase()))return!1;return!0})}var Ti,qe=_(()=>{"use strict";La();Ti=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function ge(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ba=_(()=>{"use strict"});function Ia(i,e={}){if(e.flatten===!1)return i.map(s=>({path:ge(s),name:Re(s)}));let a=Ei(i);return i.map(s=>{let r=ge(s);if(a){let u=a.endsWith("/")?a:`${a}/`;r.startsWith(u)&&(r=r.substring(u.length))}return r||(r=Re(s)),{path:r,name:Re(s)}})}function Ei(i){if(!i.length)return"";let a=i.map(u=>ge(u)).map(u=>u.split("/")),s=[],r=Math.min(...a.map(u=>u.length));for(let u=0;u<r-1;u++){let m=a[0][u];if(a.every(d=>d[u]===m))s.push(m);else break}return s.join("/")}function Re(i){return i.split(/[/\\]/).pop()||i}var Ue=_(()=>{"use strict";Ba()});var Ma={};ne(Ma,{processFilesForBrowser:()=>Na});async function Na(i,e={}){let{getENV:a}=await Promise.resolve().then(()=>(J(),oa));if(a()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let s=Array.isArray(i)?i:Array.from(i),r=s.map(v=>v.webkitRelativePath||v.name),u=Ia(r,{flatten:e.pathDetect!==!1}),m=[];for(let v=0;v<s.length;v++){let S=s[v],j=u[v].path;if(j.includes("..")||j.includes("\0"))throw f.business(`Security error: Unsafe file path "${j}" for file: ${S.name}`);m.push({file:S,relativePath:j})}let d=m.map(v=>v.relativePath),x=Oa(d),w=new Set(x),h=[];for(let v of m){if(!w.has(v.relativePath))continue;let{md5:S}=await xe(v.file);h.push({content:v.file,path:v.relativePath,size:v.file.size,md5:S})}return h}var $e=_(()=>{"use strict";ve();$();qe();Ue()});var me=W(ea(),1);$();J();var le="/deployments",ha="/ping",ae="/aliases",yi="/config",wi="/account",ki="/spa-check";function ji(i){return typeof i=="string"?me.lookup(i)||"application/octet-stream":me.lookup(i.name)||i.type||"application/octet-stream"}async function Ai(i){let e=[];for await(let a of i)e.push(a);return e}var b,ga,Te,C,ya,wa,ka,ja,Ee,ue,de=class{constructor(e){se(this,b);this.apiUrl=e.apiUrl||te,this.apiKey=e.apiKey??"",this.deployToken=e.deployToken??""}async ping(){return(await g(this,b,C).call(this,`${this.apiUrl}${ha}`,{method:"GET"},"Ping"))?.success||!1}async getPingResponse(){return await g(this,b,C).call(this,`${this.apiUrl}${ha}`,{method:"GET"},"Ping")}async getConfig(){return await g(this,b,C).call(this,`${this.apiUrl}${yi}`,{method:"GET"},"Config")}async deploy(e,a={}){g(this,b,ya).call(this,e);let{apiUrl:s=this.apiUrl,signal:r,apiKey:u,deployToken:m}=a,{requestBody:d,requestHeaders:x}=await g(this,b,wa).call(this,e),w={};m?w={Authorization:`Bearer ${m}`}:u&&(w={Authorization:`Bearer ${u}`});let h={method:"POST",body:d,headers:{...x,...w},signal:r||null};return await g(this,b,C).call(this,`${s}${le}`,h,"Deploy")}async listDeployments(){return await g(this,b,C).call(this,`${this.apiUrl}${le}`,{method:"GET"},"List Deployments")}async getDeployment(e){return await g(this,b,C).call(this,`${this.apiUrl}${le}/${e}`,{method:"GET"},"Get Deployment")}async removeDeployment(e){await g(this,b,C).call(this,`${this.apiUrl}${le}/${e}`,{method:"DELETE"},"Remove Deployment")}async setAlias(e,a){try{let s=await g(this,b,Te).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({deployment:a})},"Set Alias");return s.ok||await g(this,b,Ee).call(this,s,"Set Alias"),{...await s.json(),isCreate:s.status===201}}catch(s){g(this,b,ue).call(this,s,"Set Alias")}}async getAlias(e){return await g(this,b,C).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}`,{method:"GET"},"Get Alias")}async listAliases(){return await g(this,b,C).call(this,`${this.apiUrl}${ae}`,{method:"GET"},"List Aliases")}async removeAlias(e){await g(this,b,C).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove Alias")}async checkAlias(e){return await g(this,b,C).call(this,`${this.apiUrl}${ae}/${encodeURIComponent(e)}/dns-check`,{method:"POST"},"Check Alias")}async getAccount(){return await g(this,b,C).call(this,`${this.apiUrl}${wi}`,{method:"GET"},"Get Account")}async createApiKey(){return await g(this,b,C).call(this,`${this.apiUrl}/key`,{method:"POST"},"Create API Key")}async checkSPA(e){let a=e.find(x=>x.path==="index.html"||x.path==="/index.html");if(!a)return!1;let s=100*1024;if(a.size>s)return!1;let r;if(typeof Buffer<"u"&&Buffer.isBuffer(a.content))r=a.content.toString("utf-8");else if(typeof Blob<"u"&&a.content instanceof Blob)r=await a.content.text();else if(typeof File<"u"&&a.content instanceof File)r=await a.content.text();else return!1;let m={files:e.map(x=>x.path),index:r};return(await g(this,b,C).call(this,`${this.apiUrl}${ki}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)},"SPA Check")).isSPA}};b=new WeakSet,ga=function(e={}){let a={...e};return this.deployToken?a.Authorization=`Bearer ${this.deployToken}`:this.apiKey&&(a.Authorization=`Bearer ${this.apiKey}`),a},Te=async function(e,a={},s){let r=g(this,b,ga).call(this,a.headers),u={...a,headers:r};try{return await fetch(e,u)}catch(m){throw g(this,b,ue).call(this,m,s),m}},C=async function(e,a={},s){try{let r=await g(this,b,Te).call(this,e,a,s);return r.ok||await g(this,b,Ee).call(this,r,s),r.headers.get("Content-Length")==="0"||r.status===204?void 0:await r.json()}catch(r){throw r instanceof f||g(this,b,ue).call(this,r,s),r}},ya=function(e){if(!e.length)throw f.business("No files to deploy.");for(let a of e)if(!a.md5)throw f.file(`MD5 checksum missing for file: ${a.path}`,a.path)},wa=async function(e){let a,s={};if(G()==="browser")a=g(this,b,ka).call(this,e);else if(G()==="node"){let{body:r,headers:u}=await g(this,b,ja).call(this,e);a=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),s=u}else throw f.business("Unknown or unsupported execution environment");return{requestBody:a,requestHeaders:s}},ka=function(e){let a=new FormData,s=[];for(let r=0;r<e.length;r++){let u=e[r],m;if(u.content instanceof File||u.content instanceof Blob)m=u.content;else throw f.file(`Unsupported file.content type for browser FormData: ${u.path}`,u.path);let d=ji(m instanceof File?m:u.path),x=new File([m],u.path,{type:d});a.append("files[]",x),s.push(u.md5)}return a.append("checksums",JSON.stringify(s)),a},ja=async function(e){let{FormData:a,File:s}=await import("formdata-node"),{FormDataEncoder:r}=await Promise.resolve().then(()=>(ba(),fa)),u=await Promise.resolve().then(()=>W(we(),1)),m=new a,d=[];for(let S=0;S<e.length;S++){let j=e[S],P=me.lookup(j.path)||"application/octet-stream",R;if(Buffer.isBuffer(j.content))R=new s([j.content],j.path,{type:P});else if(typeof Blob<"u"&&j.content instanceof Blob)R=new s([j.content],j.path,{type:P});else throw f.file(`Unsupported file.content type for Node.js FormData: ${j.path}`,j.path);let y=j.path.startsWith("/")?j.path:"/"+j.path;m.append("files[]",R,y),d.push(j.md5)}m.append("checksums",JSON.stringify(d));let x=new r(m),w=await Ai(x.encode()),h=Buffer.concat(w.map(S=>Buffer.from(S))),v={"Content-Type":x.contentType,"Content-Length":Buffer.byteLength(h).toString()};return{body:h,headers:v}},Ee=async function(e,a){let s={};try{let r=e.headers.get("content-type");r&&r.includes("application/json")?s=await e.json():s={message:await e.text()}}catch{s={message:"Failed to parse error response"}}if(s.error||s.code||s.message){let r=s.message||s.error||`${a} failed due to API error`;throw e.status===401?f.authentication(r):f.api(r,e.status,s.code,s)}throw e.status===401?f.authentication(`Authentication failed for ${a}`):f.api(`${a} failed due to API error`,e.status,void 0,s)},ue=function(e,a){throw e.name==="AbortError"?f.cancelled(`${a} operation was cancelled.`):e instanceof TypeError&&e.message.includes("fetch")?f.network(`${a} failed due to network error: ${e.message}`,e):e instanceof f?e:f.business(`An unexpected error occurred during ${a}: ${e.message||"Unknown error"}`)};$();function Aa(i={},e={}){let a={apiUrl:i.apiUrl||e.apiUrl||te,apiKey:i.apiKey!==void 0?i.apiKey:e.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:e.deployToken},s={apiUrl:a.apiUrl};return a.apiKey!==void 0&&(s.apiKey=a.apiKey),a.deployToken!==void 0&&(s.deployToken=a.deployToken),s}function za(i,e){let a={...i};return a.apiUrl===void 0&&e.apiUrl!==void 0&&(a.apiUrl=e.apiUrl),a.apiKey===void 0&&e.apiKey!==void 0&&(a.apiKey=e.apiKey),a.deployToken===void 0&&e.deployToken!==void 0&&(a.deployToken=e.deployToken),a.timeout===void 0&&e.timeout!==void 0&&(a.timeout=e.timeout),a.maxConcurrency===void 0&&e.maxConcurrency!==void 0&&(a.maxConcurrency=e.maxConcurrency),a.onProgress===void 0&&e.onProgress!==void 0&&(a.onProgress=e.onProgress),a.onProgressStats===void 0&&e.onProgressStats!==void 0&&(a.onProgressStats=e.onProgressStats),a}$();ve();async function Fi(){let e=JSON.stringify({rewrites:[{source:"/(.*)",destination:"/index.html"}]},null,2),a;typeof Buffer<"u"?a=Buffer.from(e,"utf-8"):a=new Blob([e],{type:"application/json"});let{md5:s}=await xe(a);return{path:Se,content:a,size:e.length,md5:s}}async function _a(i,e,a){if(a.spaDetect===!1||i.some(s=>s.path===Se))return i;try{if(await e.checkSPA(i)){let r=await Fi();return[...i,r]}}catch{}return i}function Ta(i,e,a,s){return{create:async(r,u={})=>{a&&await a();let m=e?za(u,e):u,d=i();if(!s)throw new Error("processInput function is not provided.");let x=await s(r,m);return x=await _a(x,d,m),await d.deploy(x,m)},list:async()=>(a&&await a(),i().listDeployments()),remove:async r=>{a&&await a(),await i().removeDeployment(r)},get:async r=>(a&&await a(),i().getDeployment(r))}}function Ea(i,e){return{set:async(a,s)=>(e&&await e(),i().setAlias(a,s)),get:async a=>(e&&await e(),i().getAlias(a)),list:async()=>(e&&await e(),i().listAliases()),remove:async a=>{e&&await e(),await i().removeAlias(a)},check:async a=>(e&&await e(),i().checkAlias(a))}}function Da(i,e){return{get:async()=>(e&&await e(),i().getAccount())}}function qa(i,e){return{create:async()=>(e&&await e(),i().createApiKey())}}var fe=class{constructor(e={}){this.initPromise=null;this.clientOptions=e;let a=this.resolveInitialConfig(e);this.http=new de({...e,...a});let s=()=>this.ensureInitialized(),r=()=>this.http;this._deployments=Ta(r,this.clientOptions,s,(u,m)=>this.processInput(u,m)),this._aliases=Ea(r,s),this._account=Da(r,s),this._keys=qa(r,s)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(e,a){return this.deployments.create(e,a)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get aliases(){return this._aliases}get account(){return this._account}get keys(){return this._keys}};he();$();ve();function vn(i,e,a,s=!0){let r=i===1?e:a;return s?`${i} ${r}`:r}qe();Ue();J();$();he();$e();var ye,Ka,Le=class extends fe{constructor(a={}){super(a);se(this,ye)}resolveInitialConfig(a){return Aa(a,{})}async loadFullConfig(){try{let{loadConfig:a}=await Promise.resolve().then(()=>(he(),Ua)),s=await a(this.clientOptions.configFile);be({apiUrl:this.clientOptions.apiUrl,deployToken:this.clientOptions.deployToken,apiKey:this.clientOptions.apiKey})}catch(a){throw this.initPromise=null,a}}async processInput(a,s){if(!g(this,ye,Ka).call(this,a))throw f.business("Invalid input type for browser environment. Expected File[], FileList, or HTMLInputElement.");let r=a instanceof HTMLInputElement?Array.from(a.files):a,{processFilesForBrowser:u}=await Promise.resolve().then(()=>($e(),Ma));return u(r,s)}};ye=new WeakSet,Ka=function(a){return Array.isArray(a)?a.length===0||a.every(s=>s instanceof File):a&&typeof a=="object"&&"length"in a&&typeof a.length=="number"?"item"in a||a.constructor?.name==="FileList":!!(a&&typeof a=="object"&&"files"in a)};var Mn=Le;export{Ae as API_KEY_HEX_LENGTH,K as API_KEY_PREFIX,aa as API_KEY_TOTAL_LENGTH,de as ApiHttp,te as DEFAULT_API,Se as DEPLOYMENT_CONFIG_FILENAME,ze as DEPLOY_TOKEN_HEX_LENGTH,H as DEPLOY_TOKEN_PREFIX,ia as DEPLOY_TOKEN_TOTAL_LENGTH,k as ErrorType,Ti as JUNK_DIRECTORIES,Le as Ship,f as ShipError,ri as ShipErrorType,na as UploadStatus,pi as __setTestEnvironment,xe as calculateMD5,Da as createAccountResource,Ea as createAliasResource,Ta as createDeploymentResource,qa as createKeysResource,Mn as default,Oa as filterJunk,Hi as generateAliasUrl,Ki as generateDeploymentUrl,G as getENV,Ra as loadConfig,za as mergeDeployOptions,Ia as optimizeDeployPaths,vn as pluralize,Na as processFilesForBrowser,Aa as resolveConfig,Oi as serverConfig,be as setConfig,Bi as validateApiKey,Ni as validateApiUrl,Ii as validateDeployToken,Mi as validateSubdomain};
6
6
  /*! Bundled license information:
7
7
 
8
8
  mime-db/index.js: