@shipstatic/ship 2.2.0-beta.4 → 2.2.0-beta.5
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/README.md +19 -0
- package/dist/browser.d.ts +52 -1
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +36 -36
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,6 +230,25 @@ const ship = new Ship({ session: true });
|
|
|
230
230
|
ship.setToken('ship-...');
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
+
### Retries
|
|
234
|
+
|
|
235
|
+
Failed requests are retried automatically: transport failures (including a
|
|
236
|
+
timeout) and 500/502/503/504, twice by default, with full-jitter exponential
|
|
237
|
+
backoff. `maxRetries` is the knob; `0` disables it.
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
const ship = new Ship({ token: 'ship-...', maxRetries: 5 });
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Deliberately never retried: a maintenance 503 (its message says when to come
|
|
244
|
+
back), 429 (the rate limiter has answered), `PUT`/`DELETE` (a repeat can
|
|
245
|
+
misreport a lost success as a failure), anything stopped by a `signal` you
|
|
246
|
+
supplied, and any other non-`GET` without an `Idempotency-Key` — with the key,
|
|
247
|
+
a deploy replays its stored result instead of creating a second one.
|
|
248
|
+
|
|
249
|
+
`timeout` is the ceiling on one ATTEMPT. For a hard overall deadline pass your
|
|
250
|
+
own `signal` (`AbortSignal.timeout(ms)`), which is never retried past.
|
|
251
|
+
|
|
233
252
|
### Deploy Options
|
|
234
253
|
|
|
235
254
|
```typescript
|
package/dist/browser.d.ts
CHANGED
|
@@ -1883,8 +1883,31 @@ interface ShipClientOptions {
|
|
|
1883
1883
|
/**
|
|
1884
1884
|
* Timeout in milliseconds for every API request made by this client
|
|
1885
1885
|
* instance. Defaults to 30 seconds.
|
|
1886
|
+
*
|
|
1887
|
+
* With retries, this is the ceiling on an ATTEMPT rather than on the wall
|
|
1888
|
+
* clock — each attempt is an honest request and deserves the ceiling you
|
|
1889
|
+
* named, and {@link ShipClientOptions.maxRetries} is the lever on the total.
|
|
1890
|
+
* For a hard overall deadline, pass your own `signal`
|
|
1891
|
+
* (`AbortSignal.timeout(ms)`): the client never retries past a signal you
|
|
1892
|
+
* supplied.
|
|
1886
1893
|
*/
|
|
1887
1894
|
timeout?: number | undefined;
|
|
1895
|
+
/**
|
|
1896
|
+
* How many times to retry a failed request. Defaults to 2 (three attempts);
|
|
1897
|
+
* `0` disables retrying entirely.
|
|
1898
|
+
*
|
|
1899
|
+
* Retried: transport failures (including a timeout — nothing was exchanged
|
|
1900
|
+
* either way) and 500/502/503/504, with full-jitter exponential backoff.
|
|
1901
|
+
*
|
|
1902
|
+
* NOT retried, each deliberately: a maintenance 503 (a state, not a fault —
|
|
1903
|
+
* its message says when to come back), 429 (the rate limiter has just
|
|
1904
|
+
* answered), anything stopped by a `signal` you supplied, and any request
|
|
1905
|
+
* that cannot be safely repeated — `PUT`/`DELETE` are excluded outright, and
|
|
1906
|
+
* other non-`GET` methods retry only when they carry an `Idempotency-Key`,
|
|
1907
|
+
* which is what lets a deploy replay its stored result instead of creating a
|
|
1908
|
+
* second one.
|
|
1909
|
+
*/
|
|
1910
|
+
maxRetries?: number | undefined;
|
|
1888
1911
|
/**
|
|
1889
1912
|
* When true, the client authenticates with the first-party cookie session
|
|
1890
1913
|
* (`AuthMethod.SESSION`) — requests are sent with `credentials: 'include'`
|
|
@@ -2009,6 +2032,7 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
2009
2032
|
private readonly session;
|
|
2010
2033
|
private readonly caller;
|
|
2011
2034
|
private readonly timeout;
|
|
2035
|
+
private readonly maxRetries;
|
|
2012
2036
|
private readonly deployTimeout;
|
|
2013
2037
|
private readonly deployBuildTimeout;
|
|
2014
2038
|
private readonly fetch;
|
|
@@ -2022,9 +2046,36 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
2022
2046
|
*/
|
|
2023
2047
|
setGlobalHeaders(headers: Record<string, string>): void;
|
|
2024
2048
|
/**
|
|
2025
|
-
* Execute HTTP request
|
|
2049
|
+
* Execute an HTTP request, retrying the failures that are worth retrying.
|
|
2050
|
+
*
|
|
2051
|
+
* The loop lives here because `attemptOnce` is already the single wrap point
|
|
2052
|
+
* for headers, the timeout signal, the events and error normalization — so
|
|
2053
|
+
* an attempt is a whole request and nothing has to be undone between two.
|
|
2054
|
+
*
|
|
2055
|
+
* **Events stay honest across attempts**: `request` and `error` fire per
|
|
2056
|
+
* attempt, so a consumer counting requests sees what actually went out;
|
|
2057
|
+
* `response` fires once, on the one that worked.
|
|
2058
|
+
*
|
|
2059
|
+
* **The caller's `timeout` governs an ATTEMPT, not the wall clock.** Each
|
|
2060
|
+
* attempt is an honest request and deserves the ceiling the caller named;
|
|
2061
|
+
* `maxRetries` is the lever on the total. A caller who wants a hard overall
|
|
2062
|
+
* deadline passes their own `signal` — see `isRetryable` for why that ends
|
|
2063
|
+
* the loop even when it is a timeout.
|
|
2026
2064
|
*/
|
|
2027
2065
|
private executeRequest;
|
|
2066
|
+
/**
|
|
2067
|
+
* Is this failure worth another attempt?
|
|
2068
|
+
*
|
|
2069
|
+
* Two axes, and both must say yes: what went wrong, and whether the request
|
|
2070
|
+
* is one that may be sent twice.
|
|
2071
|
+
*/
|
|
2072
|
+
private isRetryable;
|
|
2073
|
+
/** Did this request carry the header that makes a repeat safe? */
|
|
2074
|
+
private hasIdempotencyKey;
|
|
2075
|
+
/**
|
|
2076
|
+
* One attempt: headers, timeout signal, events, and error normalization.
|
|
2077
|
+
*/
|
|
2078
|
+
private attemptOnce;
|
|
2028
2079
|
/**
|
|
2029
2080
|
* Simple request - returns data only
|
|
2030
2081
|
*/
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Je=Object.create;var B=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var nt=(t,n,e)=>n in t?B(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var L=(t,n)=>()=>(t&&(n=t(t=0)),n);var ye=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),rt=(t,n)=>{for(var e in n)B(t,e,{get:n[e],enumerable:!0})},it=(t,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of Ze(n))!tt.call(t,p)&&p!==e&&B(t,p,{get:()=>n[p],enumerable:!(a=Qe(n,p))||a.enumerable});return t};var H=(t,n,e)=>(e=t!=null?Je(et(t)):{},it(n||!t||!t.__esModule?B(e,"default",{value:t,enumerable:!0}):e,t));var G=(t,n,e)=>nt(t,typeof n!="symbol"?n+"":n,e);function Ft(t){if(!t||typeof t!="string")return;let n=t.trim().toLowerCase();return Object.values(st).includes(n)?n:void 0}function Ee(t){if(t==null)return;if(typeof t!="string")throw f.validation("Idempotency key must be a string.");let n=t.trim();if(!n)throw f.validation("Idempotency key must not be empty.");if(n.length>z.MAX_LENGTH)throw f.validation(`Idempotency key must be at most ${z.MAX_LENGTH} characters.`);return n}function pt(t){let n=t.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:t instanceof TypeError?!/\burl\b/i.test(t.message):!1}function Ae(t){return t!==null&&typeof t=="object"&&"name"in t&&t.name==="ShipError"&&"status"in t}function ut(t){let n=t.replace(/\\/g,"/").split("/").pop()??"",e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()}function V(t,n){let e=ut(t);return e===null?!1:Array.isArray(n)?n.includes(e):n.has(e)}function De(t){return dt.test(t)}function K(t){return t.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>ft.has(e))}function mt(t){return t.startsWith(Te.PREFIX)?C.API_KEY:t.startsWith(Se.PREFIX)?C.DEPLOY_TOKEN:C.OPAQUE}function Ie(t){let n=t.charCodeAt(0)===65279?t.slice(1):t,e;try{e=JSON.parse(n)}catch(a){throw f.config(`invalid JSON format in config: ${a.message}`,{filePath:N})}if(e===null||typeof e!="object"||Array.isArray(e))throw f.config(`${N} must contain a JSON object`,{filePath:N})}function be(t,n,e){if(!t.startsWith(n.PREFIX))throw f.validation(`${e} must start with "${n.PREFIX}"`);if(t.length!==n.TOTAL_LENGTH)throw f.validation(`${e} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let a=t.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(a))throw f.validation(`${e} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function ht(t){be(t,Te,"API key")}function yt(t){be(t,Se,"Deploy token")}function ee(t){switch(mt(t)){case C.API_KEY:ht(t);return;case C.DEPLOY_TOKEN:yt(t);return;case C.OPAQUE:if(!t)throw f.validation("Token must be a non-empty string")}}function we(t){if(!t||t.length>$.MAX_LENGTH||!$.PATTERN.test(t))throw f.validation(`Caller must be 1-${$.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function Bt(t){try{let n=new URL(t);if(!["http:","https:"].includes(n.protocol))throw f.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw f.validation("API URL must not contain a path");if(n.search||n.hash)throw f.validation("API URL must not contain query parameters or fragments")}catch(n){throw Ae(n)?n:f.validation("API URL must be a valid URL")}}function Ht(t){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(t)}function Pe(t,n){return t.endsWith(`.${n}`)}function Vt(t,n){return!Pe(t,n)}function Kt(t,n){return Pe(t,n)?t.slice(0,-(n.length+1)):null}function jt(t){return`https://${t}`}function Yt(t){return`https://${t}`}function qt(t){return!t||t.length===0?null:JSON.stringify(t)}function Xt(t){if(!t)return[];try{let n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function ne(t){if(t==null)return;if(typeof t!="string")throw f.validation("Password must be a string");let n=t.trim();if(n.length<k.MIN_LENGTH||n.length>k.MAX_LENGTH)throw f.validation(`Password must be between ${k.MIN_LENGTH} and ${k.MAX_LENGTH} characters`);return n}var vt,st,Ot,z,Ct,D,x,E,ot,Z,at,lt,f,ct,$t,dt,ft,Ut,ge,Te,Se,$,C,Mt,N,Re,j,te,Gt,kt,zt,R,F,Le,k,I=L(()=>{"use strict";vt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},st={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},Ot={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},z={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Ct={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},D={DEPLOYMENTS:"/deployments",DEPLOYMENT:t=>`/deployments/${t}`,DEPLOYMENT_CONFIG:t=>`/deployments/${t}/config`,DOMAINS:"/domains",DOMAIN:t=>`/domains/${t}`,DOMAIN_VERIFY:t=>`/domains/${t}/verify`,DOMAIN_DNS:t=>`/domains/${t}/dns`,DOMAIN_RECORDS:t=>`/domains/${t}/records`,DOMAIN_SHARE:t=>`/domains/${t}/share`,DOMAIN_PROPAGATION:t=>`/domains/${t}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:t=>`/tokens/${t}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},x={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},E={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},ot=new Set([E.Network,E.Cancelled,E.File,E.Config]),Z={client:new Set([E.Business,E.Cancelled,E.Config,E.File,E.Forbidden,E.NotFound,E.RateLimit,E.Validation]),network:new Set([E.Network]),auth:new Set([E.Authentication])},at=new Set(Object.values(E).filter(t=>!ot.has(t))),lt=200;f=class t extends Error{constructor(e,a,p,c){super(a);G(this,"type");G(this,"status");G(this,"details");this.type=e,this.status=p,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===E.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(e,a){let p,c,h;try{if(e.headers.get("content-type")?.includes("application/json")){let m=await e.json();if(m&&typeof m=="object"){let T=m;typeof T.message=="string"?p=T.message:typeof T.error=="string"&&(p=T.error),c=T.details,typeof T.error=="string"&&at.has(T.error)&&(h=T.error)}}else{let m=(await e.text()).trim();m&&!m.startsWith("<")&&m.length<=lt&&(p=m)}}catch{}let y=e.headers.get("retry-after");if(y!==null){let g=y.trim(),m=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(m)&&m>=0){let T=c&&typeof c=="object"?c:{};T.retryAfter===void 0&&(c={...T,retryAfter:m})}}p=p||`${a||"Request"} failed with status ${e.status}`;let d=h??(e.status===401?E.Authentication:e.status===403?E.Forbidden:e.status===429?E.RateLimit:E.Api);return new t(d,p,e.status,c)}static fromFetchError(e,a){if(Ae(e))return e;let p=a||"Request",c=e?.name;return c==="AbortError"?t.cancelled(`${p} was cancelled`):c==="TimeoutError"?t.network(`${p} timed out`,{cause:e}):e instanceof Error?pt(e)?t.network(`${p} failed: ${e.message}`,{cause:e}):new t(E.Api,`${p} failed: ${e.message}`):new t(E.Api,`${p} failed: Unknown error`)}static validation(e,a){return new t(E.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new t(E.NotFound,p,404)}static forbidden(e,a){return new t(E.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new t(E.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new t(E.Authentication,e,401,a)}static business(e,a=400,p){return new t(E.Business,e,a,p)}static network(e,a){return new t(E.Network,e,void 0,a)}static cancelled(e,a){return new t(E.Cancelled,e,void 0,a)}static file(e,a){return new t(E.File,e,void 0,a)}static config(e,a){return new t(E.Config,e,void 0,a)}static api(e,a=500,p){return new t(E.Api,e,a,p)}static maintenance(e,a){return new t(E.Maintenance,e,503,a)}isClientError(){return Z.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Z.network.has(this.type)}isAuthError(){return Z.auth.has(this.type)}isType(e){return this.type===e}};ct=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],$t=ct.map(t=>`.${t}`).join(","),dt=/[\x00-\x1f\x7f#?%\\<>"]/;ft=new Set(["node_modules","package.json"]);Ut="/auth",ge={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Te={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Se={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},$={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},C={API_KEY:ge.API_KEY,DEPLOY_TOKEN:ge.TOKEN,OPAQUE:"opaque"};Mt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},N="ship.json",Re={rewrites:[{source:"/(.*)",destination:"/index.html"}]},j={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};te="https://api.shipstatic.com",Gt={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},kt="https://my.shipstatic.com/api-key",zt=4320*60,R={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Le=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;k={MIN_LENGTH:6,MAX_LENGTH:128}});var Oe=ye((Ne,ve)=>{"use strict";(function(t){if(typeof Ne=="object")ve.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var n;try{n=window}catch{n=self}n.SparkMD5=t()}})(function(t){"use strict";var n=function(u,l){return u+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,l,i,r,o,s){return l=n(n(l,u),n(r,s)),n(l<<o|l>>>32-o,i)}function p(u,l){var i=u[0],r=u[1],o=u[2],s=u[3];i+=(r&o|~r&s)+l[0]-680876936|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&r)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,r+=(o&s|~o&i)+l[3]-1044525330|0,r=(r<<22|r>>>10)+o|0,i+=(r&o|~r&s)+l[4]-176418897|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&r)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,r+=(o&s|~o&i)+l[7]-45705983|0,r=(r<<22|r>>>10)+o|0,i+=(r&o|~r&s)+l[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&r)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,r+=(o&s|~o&i)+l[11]-1990404162|0,r=(r<<22|r>>>10)+o|0,i+=(r&o|~r&s)+l[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&r)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,r+=(o&s|~o&i)+l[15]+1236535329|0,r=(r<<22|r>>>10)+o|0,i+=(r&s|o&~s)+l[1]-165796510|0,i=(i<<5|i>>>27)+r|0,s+=(i&o|r&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+i|0,o+=(s&r|i&~r)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,r+=(o&i|s&~i)+l[0]-373897302|0,r=(r<<20|r>>>12)+o|0,i+=(r&s|o&~s)+l[5]-701558691|0,i=(i<<5|i>>>27)+r|0,s+=(i&o|r&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+i|0,o+=(s&r|i&~r)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,r+=(o&i|s&~i)+l[4]-405537848|0,r=(r<<20|r>>>12)+o|0,i+=(r&s|o&~s)+l[9]+568446438|0,i=(i<<5|i>>>27)+r|0,s+=(i&o|r&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+i|0,o+=(s&r|i&~r)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,r+=(o&i|s&~i)+l[8]+1163531501|0,r=(r<<20|r>>>12)+o|0,i+=(r&s|o&~s)+l[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,s+=(i&o|r&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+i|0,o+=(s&r|i&~r)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,r+=(o&i|s&~i)+l[12]-1926607734|0,r=(r<<20|r>>>12)+o|0,i+=(r^o^s)+l[5]-378558|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^r)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,r+=(o^s^i)+l[14]-35309556|0,r=(r<<23|r>>>9)+o|0,i+=(r^o^s)+l[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^r)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,r+=(o^s^i)+l[10]-1094730640|0,r=(r<<23|r>>>9)+o|0,i+=(r^o^s)+l[13]+681279174|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^r)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,r+=(o^s^i)+l[6]+76029189|0,r=(r<<23|r>>>9)+o|0,i+=(r^o^s)+l[9]-640364487|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^r)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,r+=(o^s^i)+l[2]-995338651|0,r=(r<<23|r>>>9)+o|0,i+=(o^(r|~s))+l[0]-198630844|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~r))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,r+=(s^(o|~i))+l[5]-57434055|0,r=(r<<21|r>>>11)+o|0,i+=(o^(r|~s))+l[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~r))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,r+=(s^(o|~i))+l[1]-2054922799|0,r=(r<<21|r>>>11)+o|0,i+=(o^(r|~s))+l[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~r))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,r+=(s^(o|~i))+l[13]+1309151649|0,r=(r<<21|r>>>11)+o|0,i+=(o^(r|~s))+l[4]-145523070|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~r))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,r+=(s^(o|~i))+l[9]-343485551|0,r=(r<<21|r>>>11)+o|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function c(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return l}function h(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return l}function y(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,o,s,w,_,O;for(r=64;r<=l;r+=64)p(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<o;r+=1)s[r>>2]|=u.charCodeAt(r)<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(p(i,s),r=0;r<16;r+=1)s[r]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(w[2],16),O=parseInt(w[1],16)||0,s[14]=_,s[15]=O,p(i,s),i}function d(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,o,s,w,_,O;for(r=64;r<=l;r+=64)p(i,h(u.subarray(r-64,r)));for(u=r-64<l?u.subarray(r-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<o;r+=1)s[r>>2]|=u[r]<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(p(i,s),r=0;r<16;r+=1)s[r]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(w[2],16),O=parseInt(w[1],16)||0,s[14]=_,s[15]=O,p(i,s),i}function g(u){var l="",i;for(i=0;i<4;i+=1)l+=e[u>>i*8+4&15]+e[u>>i*8&15];return l}function m(u){var l;for(l=0;l<u.length;l+=1)u[l]=g(u[l]);return u.join("")}m(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(u,l){var i=(u&65535)+(l&65535),r=(u>>16)+(l>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,i){return l=l|0||0,l<0?Math.max(l+i,0):Math.min(l,i)}ArrayBuffer.prototype.slice=function(l,i){var r=this.byteLength,o=u(l,r),s=r,w,_,O,he;return i!==t&&(s=u(i,r)),o>s?new ArrayBuffer(0):(w=s-o,_=new ArrayBuffer(w),O=new Uint8Array(_),he=new Uint8Array(this,o,w),O.set(he),_)}})();function T(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function S(u,l){var i=u.length,r=new ArrayBuffer(i),o=new Uint8Array(r),s;for(s=0;s<i;s+=1)o[s]=u.charCodeAt(s);return l?o:r}function b(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function P(u,l,i){var r=new Uint8Array(u.byteLength+l.byteLength);return r.set(new Uint8Array(u)),r.set(new Uint8Array(l),u.byteLength),i?r:r.buffer}function v(u){var l=[],i=u.length,r;for(r=0;r<i-1;r+=2)l.push(parseInt(u.substr(r,2),16));return String.fromCharCode.apply(String,l)}function A(){this.reset()}return A.prototype.append=function(u){return this.appendBinary(T(u)),this},A.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,i;for(i=64;i<=l;i+=64)p(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},A.prototype.end=function(u){var l=this._buff,i=l.length,r,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(r=0;r<i;r+=1)o[r>>2]|=l.charCodeAt(r)<<(r%4<<3);return this._finish(o,i),s=m(this._hash),u&&(s=v(s)),this.reset(),s},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.prototype._finish=function(u,l){var i=l,r,o,s;if(u[i>>2]|=128<<(i%4<<3),i>55)for(p(this._hash,u),i=0;i<16;i+=1)u[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(r[2],16),s=parseInt(r[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},A.hash=function(u,l){return A.hashBinary(T(u),l)},A.hashBinary=function(u,l){var i=y(u),r=m(i);return l?v(r):r},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(u){var l=P(this._buff.buffer,u,!0),i=l.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)p(this._hash,h(l.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(l.buffer.slice(r-64)):new Uint8Array(0),this},A.ArrayBuffer.prototype.end=function(u){var l=this._buff,i=l.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<i;o+=1)r[o>>2]|=l[o]<<(o%4<<3);return this._finish(r,i),s=m(this._hash),u&&(s=v(s)),this.reset(),s},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var u=A.prototype.getState.call(this);return u.buff=b(u.buff),u},A.ArrayBuffer.prototype.setState=function(u){return u.buff=S(u.buff,!0),A.prototype.setState.call(this,u)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(u,l){var i=d(new Uint8Array(u)),r=m(i);return l?v(r):r},A})});var X=ye((an,Fe)=>{"use strict";Fe.exports={}});async function Tt(t){let n=(await Promise.resolve().then(()=>H(Oe(),1))).default,e=new n.ArrayBuffer,a=2097152;for(let p=0;p<t.size;p+=a){let c=Math.min(p+a,t.size);e.append(await t.slice(p,c).arrayBuffer())}return{md5:e.end()}}async function St(t){let{createHash:n}=await Promise.resolve().then(()=>H(X(),1)),e=n("md5");return e.update(t),{md5:e.digest("hex")}}async function Rt(t){let{createHash:n}=await Promise.resolve().then(()=>H(X(),1)),{createReadStream:e}=await Promise.resolve().then(()=>H(X(),1));return new Promise((a,p)=>{let c=n("md5"),h=e(t);h.on("error",y=>p(f.file(`Failed to read file for MD5: ${y.message}`,{filePath:t}))),h.on("data",y=>c.update(y)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function M(t){if(t instanceof Blob)return Tt(t);if(typeof Buffer<"u"&&Buffer.isBuffer(t))return St(t);if(typeof t=="string")return Rt(t);throw f.business("Invalid input for MD5 calculation")}var W=L(()=>{"use strict";I()});function Q(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ge=L(()=>{"use strict"});function ke(t,n={}){if(n.flatten===!1)return t.map(a=>({path:Q(a),name:ie(a)}));let e=bt(t);return t.map(a=>{let p=Q(a);if(e){let c=e.endsWith("/")?e:`${e}/`;p.startsWith(c)&&(p=p.substring(c.length))}return p||(p=ie(a)),{path:p,name:ie(a)}})}function bt(t){if(!t.length)return"";let e=t.map(c=>Q(c)).map(c=>c.split("/")),a=[],p=Math.min(...e.map(c=>c.length));for(let c=0;c<p-1;c++){let h=e[0][c];if(e.every(y=>y[c]===h))a.push(h);else break}return a.join("/")}function ie(t){return t.split(/[/\\]/).pop()||t}var se=L(()=>{"use strict";Ge()});function Pn(t){oe=t}function wt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function ze(){return oe||wt()}var oe,ae=L(()=>{"use strict";oe=null});function le(t,n=1){if(t===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/e**p).toFixed(n))} ${a[p]}`}function pe(t){if(De(t))return{valid:!1,reason:"File name contains unsafe characters"};if(t.startsWith(" ")||t.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(t.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=t.split("/").pop()||t;return n.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:t.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function _n(t,n){let e=[],a=[],p=[];if(t.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of t)if(K(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:t.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(t.length>n.maxFilesCount){let d={file:`(${t.length} files)`,message:`File count (${t.length}) exceeds limit of ${n.maxFilesCount}`};return e.push(d),{files:t.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of t){let g=R.READY,m="Ready for upload",T=d.name?pe(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===R.PROCESSING_ERROR)g=R.VALIDATION_FAILED,m=d.statusMessage||"File failed during processing",e.push({file:d.name,message:m});else if(d.size===0){g=R.EXCLUDED,m="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:m}),p.push({...d,status:g,statusMessage:m});continue}else d.size<0?(g=R.VALIDATION_FAILED,m="File size must be positive",e.push({file:d.name,message:m})):!d.name||d.name.trim().length===0?(g=R.VALIDATION_FAILED,m="File name cannot be empty",e.push({file:d.name||"(empty)",message:m})):d.name.includes("\0")?(g=R.VALIDATION_FAILED,m="File name contains invalid characters (null byte)",e.push({file:d.name,message:m})):T.valid?V(d.name,n.blockedExtensions??[])?(g=R.VALIDATION_FAILED,m=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:m})):d.size>n.maxFileSize?(g=R.VALIDATION_FAILED,m=`File size (${le(d.size)}) exceeds limit of ${le(n.maxFileSize)}`,e.push({file:d.name,message:m})):(c+=d.size,c>n.maxTotalSize&&(g=R.VALIDATION_FAILED,m=`Total size would exceed limit of ${le(n.maxTotalSize)}`,e.push({file:d.name,message:m}))):(g=R.VALIDATION_FAILED,m=T.reason||"Invalid file name",e.push({file:d.name,message:m}));p.push({...d,status:g,statusMessage:m})}e.length>0&&(p=p.map(d=>d.status===R.EXCLUDED?d:{...d,status:R.VALIDATION_FAILED,statusMessage:d.status===R.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?p.filter(d=>d.status===R.READY):[],y=e.length===0;return{files:p,validFiles:h,errors:e,warnings:a,canDeploy:y}}function Pt(t){return t.filter(n=>n.status===R.READY)}function Nn(t){return Pt(t).length>0}var ue=L(()=>{"use strict";I()});function Ve(t){return xt.test(t)}var Lt,xt,Ke=L(()=>{"use strict";Lt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],xt=new RegExp(Lt.join("|"))});function je(t,n){if(!t||t.length===0)return[];if(!n?.allowUnbuilt&&t.find(a=>a&&K(a)))throw f.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return t.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let p=a[a.length-1];if(Ve(p))return!1;for(let h of a)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let c=a.slice(0,-1);for(let h of c)if(_t.some(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var _t,ce=L(()=>{"use strict";I();Ke();_t=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ye(t,n){if(t.includes("\0")||t.includes("/../")||t.startsWith("../")||t.endsWith("/.."))throw f.business(`Security error: Unsafe file path "${t}" for file: ${n}`)}function qe(t,n,e){let a=pe(t);if(!a.valid)throw f.business(a.reason||"Invalid file name");if(V(t,e))throw f.business(`File extension not allowed: "${n}"`)}var de=L(()=>{"use strict";I();ue()});var We={};rt(We,{processFilesForBrowser:()=>Xe});async function Xe(t,n={},e){if(ze()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let a=t.map(S=>S.webkitRelativePath||S.name),p=n.build||n.prerender,c=ke(a,{flatten:n.pathDetect!==!1}),h=c.map(S=>S.path),y=new Set(je(h,{allowUnbuilt:p})),d=[];for(let S=0;S<t.length;S++)y.has(h[S])&&d.push({file:t[S],deployPath:c[S].path});if(d.length===0)return[];if(p){let S=[];for(let b=0;b<d.length;b++){let{file:P,deployPath:v}=d[b];if(P.size===0)continue;let{md5:A}=await M(P);S.push({path:v,content:P,size:P.size,md5:A})}return S}if(!e)throw f.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let g=[],m=0,T=e.blockedExtensions??[];for(let S=0;S<d.length;S++){let{file:b,deployPath:P}=d[S];if(Ye(P,b.name),b.size===0)continue;if(qe(P,b.name,T),b.size>e.maxFileSize)throw f.business(`File ${b.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(m+=b.size,m>e.maxTotalSize)throw f.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:v}=await M(b);g.push({path:P,content:b,size:b.size,md5:v})}if(g.length>e.maxFilesCount)throw f.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return g}var fe=L(()=>{"use strict";I();se();ae();ce();W();de()});I();I();I();var Y=class{constructor(){this.handlers=new Map}on(n,e){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(e)}off(n,e){let a=this.handlers.get(n);a&&(a.delete(e),a.size===0&&this.handlers.delete(n))}emit(n,...e){let a=this.handlers.get(n);if(!a)return;let p=Array.from(a);for(let c of p)try{c(...e)}catch(h){a.delete(c),n!=="error"&&setTimeout(()=>{let y=h instanceof Error?h:new Error(String(h));this.emit("error",y,String(n))},0)}}};I();I();function U(t){if(t==null)return;if(t.length===0)return t;if(t.length>F.MAX_COUNT)throw f.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let n=t.map((a,p)=>{if(typeof a!="string")throw f.validation(`Label at index ${p} must be a string`);let c=a.trim().toLowerCase();if(c.length<F.MIN_LENGTH)throw f.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(c.length>F.MAX_LENGTH)throw f.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!Le.test(c))throw f.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return c}),e=[...new Set(n)];if(e.length!==n.length)throw f.validation("Duplicate labels are not allowed");return e}async function xe(t){let n=t.find(p=>p.path===N||p.path===`/${N}`);if(!n)return;let e=n.content,a=typeof e.text=="function"?await e.text():n.content.toString("utf8");Ie(a)}var gt=3e4,_e=3e5,Et=3e5,At=_e+Et,Dt="sdk";function re(t){let n=new URLSearchParams;t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.cursor!==void 0&&n.set("cursor",t.cursor);let e=n.toString();return e?`?${e}`:""}var q=class extends Y{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||te,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??gt,this.deployTimeout=e.timeout??_e,this.deployBuildTimeout=e.timeout??At,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||D.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p,c=this.timeout){let h=()=>{};try{let y=await this.mergeHeaders(a.headers),d=this.createTimeoutSignal(a.signal,c);h=d.cleanup;let g={...a,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",e,g);let m=await this.fetch(e,g);if(h(),!m.ok)throw await f.fromHttpResponse(m,p);return this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(y){h();let d=f.fromFetchError(y,p);throw this.emit("error",d,e),d}}async request(e,a,p,c){let{data:h}=await this.executeRequest(e,a,p,c);return h}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{[$.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e,a=this.timeout){let p=new AbortController,c=setTimeout(()=>p.abort(),a);if(e){let h=()=>p.abort();e.addEventListener("abort",h),e.aborted&&p.abort()}return{signal:p.signal,cleanup:()=>clearTimeout(c)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,a={}){if(!e.length)throw f.business("No files to deploy");for(let g of e)if(!g.md5)throw f.file(`MD5 checksum missing for file: ${g.path}`,{filePath:g.path});ne(a.password);let p=Ee(a.idempotencyKey),c=U(a.labels);await xe(e);let h=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:y,headers:d}=await this.createDeployBody(e,{labels:c,via:a.via??Dt,password:a.password,flags:h,captcha:a.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:y,headers:p?{...d,[z.HEADER]:p}:d,signal:a.signal||null},"Deploy",a.build||a.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(e){return this.request(`${this.apiUrl}${D.DEPLOYMENTS}${re(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${D.DEPLOYMENT(encodeURIComponent(e))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=U(a);return this.request(`${this.apiUrl}${D.DEPLOYMENT(encodeURIComponent(e))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async deleteDeployment(e){return this.request(`${this.apiUrl}${D.DEPLOYMENT(encodeURIComponent(e))}`,{method:"DELETE"},"Delete deployment")}async setDomain(e,a,p){let c=U(p),h={};a&&(h.deployment=a),c!==void 0&&(h.labels=c);let{data:y,status:d}=await this.requestWithStatus(`${this.apiUrl}${D.DOMAIN(encodeURIComponent(e))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"Set domain");return{...y,isCreate:d===201}}async listDomains(e){return this.request(`${this.apiUrl}${D.DOMAINS}${re(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${D.DOMAIN(encodeURIComponent(e))}`,{method:"GET"},"Get domain")}async deleteDomain(e){return this.request(`${this.apiUrl}${D.DOMAIN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${D.DOMAIN_VERIFY(encodeURIComponent(e))}`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${D.DOMAIN_DNS(encodeURIComponent(e))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${D.DOMAIN_RECORDS(encodeURIComponent(e))}`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${D.DOMAIN_SHARE(encodeURIComponent(e))}`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${D.DOMAINS_VALIDATE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=U(a),c={};return e!==void 0&&(c.ttl=e),p!==void 0&&(c.labels=p),this.request(`${this.apiUrl}${D.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(e){return this.request(`${this.apiUrl}${D.TOKENS}${re(e)}`,{method:"GET"},"List tokens")}async deleteToken(e){return this.request(`${this.apiUrl}${D.TOKEN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete token")}async getToken(e){return this.request(`${this.apiUrl}${D.TOKEN(encodeURIComponent(e))}`,{method:"GET"},"Get token")}async getAccount(){return this.request(`${this.apiUrl}${D.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${D.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return this.request(`${this.apiUrl}${D.PING}`,{method:"GET"},"Ping")}async checkSPA(e,a={}){let p=e.find(d=>d.path===j.INDEX_FILE||d.path===`/${j.INDEX_FILE}`);if(!p||p.size>j.MAX_INDEX_BYTES)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))c=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)c=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)c=await p.content.text();else return!1;let h={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${D.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"SPA check")).isSPA}};I();I();W();async function It(){let t=JSON.stringify(Re,null,2),n;typeof Buffer<"u"?n=Buffer.from(t,"utf-8"):n=new Blob([t],{type:"application/json"});let{md5:e}=await M(n);return{path:N,content:n,size:t.length,md5:e}}async function Ce(t,n,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||t.some(a=>a.path===N))return t;try{if(await n.checkSPA(t,e)){let p=await It();return[...t,p]}}catch{}return t}function $e(t){let{getApi:n,ensureInit:e,processInput:a}=t;return{upload:async(p,c={})=>{if(await e(),!a)throw f.config("processInput function is not provided.");let h=n(),y=await a(p,c);return y=await Ce(y,h,c),h.deploy(y,c)},list:async p=>(await e(),n().listDeployments(p)),get:async p=>(await e(),n().getDeployment(p)),set:async(p,c)=>(await e(),n().updateDeploymentLabels(p,c.labels)),delete:async p=>(await e(),n().deleteDeployment(p))}}function Ue(t){let{getApi:n,ensureInit:e}=t;return{set:async(a,p={})=>(await e(),n().setDomain(a,p.deployment,p.labels)),list:async a=>(await e(),n().listDomains(a)),get:async a=>(await e(),n().getDomain(a)),delete:async a=>(await e(),n().deleteDomain(a)),verify:async a=>(await e(),n().verifyDomain(a)),validate:async a=>(await e(),n().validateDomain(a)),dns:async a=>(await e(),n().getDomainDns(a)),records:async a=>(await e(),n().getDomainRecords(a)),share:async a=>(await e(),n().getDomainShare(a))}}function Me(t){let{getApi:n,ensureInit:e}=t;return{get:async()=>(await e(),n().getAccount())}}function Be(t){let{getApi:n,ensureInit:e}=t;return{create:async(a={})=>(await e(),n().createToken(a.ttl,a.labels)),list:async a=>(await e(),n().listTokens(a)),get:async a=>(await e(),n().getToken(a)),delete:async a=>(await e(),n().deleteToken(a))}}var J=class{constructor(n={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(n={...n,apiUrl:n.apiUrl||void 0,token:n.token||void 0,caller:n.caller||void 0},this.clientOptions=n,n.caller!==void 0&&we(n.caller),n.token&&n.session)throw f.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(ee(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new q({...n,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=$e({...e,processInput:(a,p)=>this.processInput(a,p)}),this.domains=Ue(e),this.account=Me(e),this.tokens=Be(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(n){throw this.initPromise=null,n}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(n,e){return this.deployments.upload(n,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,e){this.http.on(n,e)}off(n,e){this.http.off(n,e)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw f.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw f.business("Invalid token provided. Token must be a non-empty string.");ee(n),this.credential=n;return}if(typeof n!="function")throw f.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=n}async getAuthHeaders(){if(this.credential===null)return{};let n=typeof this.credential=="function"?await this.credential():this.credential;if(!n)throw f.authentication("Token provider returned no token.");if(typeof n!="string")throw f.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};I();async function He(t,n={}){let{labels:e,via:a,password:p,flags:c,captcha:h}=n,y=new FormData,d=[];for(let g of t){if(!(g.content instanceof File||g.content instanceof Blob))throw f.file(`Unsupported file.content type for browser: ${g.path}`,{filePath:g.path});if(!g.md5)throw f.file(`File missing md5 checksum: ${g.path}`,{filePath:g.path});let m=new File([g.content],g.path,{type:"application/octet-stream"});y.append(x.FILES,m),d.push(g.md5)}return y.append(x.CHECKSUMS,JSON.stringify(d)),e&&e.length>0&&y.append(x.LABELS,JSON.stringify(e)),a&&y.append(x.VIA,a),p&&y.append(x.PASSWORD,p),c?.build&&y.append(x.BUILD,"true"),c?.prerender&&y.append(x.PRERENDER,"true"),c?.spa&&y.append(x.SPA,"true"),h&&y.append(x.CAPTCHA,h),{body:y,headers:{}}}I();I();se();ae();ue();ce();W();de();function Hn(t,n,e,a=!0){let p=t===1?n:e;return a?`${t} ${p}`:p}fe();var me=class extends J{async deploy(n,e){return super.deploy(n,e)}async processInput(n,e){if(!Array.isArray(n)||!n.every(p=>p instanceof File))throw f.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw f.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(fe(),We));return a(n,e,this.platformLimits??void 0)}getDeployBodyCreator(){return He}},ur=me;export{Te as API_KEY,D as API_PATHS,Ut as AUTH_BASE_PATH,Ct as AccountPlan,q as ApiHttp,ge as AuthMethod,$ as CALLER,te as DEFAULT_API,N as DEPLOYMENT_CONFIG_FILENAME,x as DEPLOY_FIELDS,Se as DEPLOY_TOKEN,vt as DeploymentStatus,st as DeploymentVia,Ot as DomainStatus,E as ErrorType,R as FILE_VALIDATION_STATUS,R as FileValidationStatus,z as IDEMPOTENCY_KEY_CONSTRAINTS,_t as JUNK_DIRECTORIES,F as LABEL_CONSTRAINTS,Le as LABEL_PATTERN,kt as MY_API_KEY_URL,Mt as OAuthScope,k as PASSWORD_CONSTRAINTS,zt as PUBLIC_DEPLOYMENT_TTL_SECONDS,Gt as SHIP_ENV,j as SPA_CHECK_CONSTRAINTS,Re as SPA_DEFAULT_CONFIG,me as Ship,f as ShipError,C as TokenKind,ft as UNBUILT_PROJECT_MARKERS,dt as UNSAFE_FILENAME_CHARS,$t as WEB_FILE_ACCEPT,Pn as __setTestEnvironment,Nn as allValidFilesReady,Ie as assertShipJsonSyntax,M as calculateMD5,mt as classifyToken,Me as createAccountResource,$e as createDeploymentResource,Ue as createDomainResource,Be as createTokenResource,ur as default,Xt as deserializeLabels,Kt as extractSubdomain,je as filterJunk,le as formatFileSize,jt as generateDeploymentUrl,Yt as generateDomainUrl,ze as getENV,Pt as getValidFiles,K as hasUnbuiltMarker,De as hasUnsafeChars,V as isBlockedExtension,Vt as isCustomDomain,Ht as isDeployment,Pe as isPlatformDomain,Ae as isShipError,Ft as normalizeVia,ke as optimizeDeployPaths,Hn as pluralize,Xe as processFilesForBrowser,qt as serializeLabels,ht as validateApiKey,Bt as validateApiUrl,we as validateCaller,qe as validateDeployFile,Ye as validateDeployPath,yt as validateDeployToken,pe as validateFileName,_n as validateFiles,Ee as validateIdempotencyKey,ne as validatePassword,ee as validateToken};
|
|
1
|
+
var Je=Object.create;var H=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var nt=(t,n,e)=>n in t?H(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var P=(t,n)=>()=>(t&&(n=t(t=0)),n);var ye=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),rt=(t,n)=>{for(var e in n)H(t,e,{get:n[e],enumerable:!0})},it=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of Ze(n))!tt.call(t,l)&&l!==e&&H(t,l,{get:()=>n[l],enumerable:!(o=Qe(n,l))||o.enumerable});return t};var G=(t,n,e)=>(e=t!=null?Je(et(t)):{},it(n||!t||!t.__esModule?H(e,"default",{value:t,enumerable:!0}):e,t));var k=(t,n,e)=>nt(t,typeof n!="symbol"?n+"":n,e);function Bt(t){if(!t||typeof t!="string")return;let n=t.trim().toLowerCase();return Object.values(st).includes(n)?n:void 0}function Ee(t){if(t==null)return;if(typeof t!="string")throw m.validation("Idempotency key must be a string.");let n=t.trim();if(!n)throw m.validation("Idempotency key must not be empty.");if(n.length>U.MAX_LENGTH)throw m.validation(`Idempotency key must be at most ${U.MAX_LENGTH} characters.`);return n}function pt(t){let n=t.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:t instanceof TypeError?!/\burl\b/i.test(t.message):!1}function Ae(t){return t!==null&&typeof t=="object"&&"name"in t&&t.name==="ShipError"&&"status"in t}function ut(t){let n=t.replace(/\\/g,"/").split("/").pop()??"",e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()}function V(t,n){let e=ut(t);return e===null?!1:Array.isArray(n)?n.includes(e):n.has(e)}function De(t){return dt.test(t)}function K(t){return t.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>ft.has(e))}function mt(t){return t.startsWith(Te.PREFIX)?C.API_KEY:t.startsWith(Se.PREFIX)?C.DEPLOY_TOKEN:C.OPAQUE}function be(t){let n=t.charCodeAt(0)===65279?t.slice(1):t,e;try{e=JSON.parse(n)}catch(o){throw m.config(`invalid JSON format in config: ${o.message}`,{filePath:x})}if(e===null||typeof e!="object"||Array.isArray(e))throw m.config(`${x} must contain a JSON object`,{filePath:x})}function Ie(t,n,e){if(!t.startsWith(n.PREFIX))throw m.validation(`${e} must start with "${n.PREFIX}"`);if(t.length!==n.TOTAL_LENGTH)throw m.validation(`${e} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let o=t.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(o))throw m.validation(`${e} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function ht(t){Ie(t,Te,"API key")}function yt(t){Ie(t,Se,"Deploy token")}function ee(t){switch(mt(t)){case C.API_KEY:ht(t);return;case C.DEPLOY_TOKEN:yt(t);return;case C.OPAQUE:if(!t)throw m.validation("Token must be a non-empty string")}}function we(t){if(!t||t.length>$.MAX_LENGTH||!$.PATTERN.test(t))throw m.validation(`Caller must be 1-${$.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function Vt(t){try{let n=new URL(t);if(!["http:","https:"].includes(n.protocol))throw m.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw m.validation("API URL must not contain a path");if(n.search||n.hash)throw m.validation("API URL must not contain query parameters or fragments")}catch(n){throw Ae(n)?n:m.validation("API URL must be a valid URL")}}function Kt(t){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(t)}function Le(t,n){return t.endsWith(`.${n}`)}function Xt(t,n){return!Le(t,n)}function Wt(t,n){return Le(t,n)?t.slice(0,-(n.length+1)):null}function Jt(t){return`https://${t}`}function Qt(t){return`https://${t}`}function Zt(t){return!t||t.length===0?null:JSON.stringify(t)}function en(t){if(!t)return[];try{let n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function ne(t){if(t==null)return;if(typeof t!="string")throw m.validation("Password must be a string");let n=t.trim();if(n.length<z.MIN_LENGTH||n.length>z.MAX_LENGTH)throw m.validation(`Password must be between ${z.MIN_LENGTH} and ${z.MAX_LENGTH} characters`);return n}var Ut,st,Mt,U,Ht,T,_,E,ot,Z,at,lt,m,ct,Gt,dt,ft,kt,ge,Te,Se,$,C,zt,x,Re,Y,te,Yt,jt,qt,R,F,Pe,z,b=P(()=>{"use strict";Ut={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},st={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},Mt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},U={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Ht={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:t=>`/deployments/${t}`,DEPLOYMENT_CONFIG:t=>`/deployments/${t}/config`,DOMAINS:"/domains",DOMAIN:t=>`/domains/${t}`,DOMAIN_VERIFY:t=>`/domains/${t}/verify`,DOMAIN_DNS:t=>`/domains/${t}/dns`,DOMAIN_RECORDS:t=>`/domains/${t}/records`,DOMAIN_SHARE:t=>`/domains/${t}/share`,DOMAIN_PROPAGATION:t=>`/domains/${t}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:t=>`/tokens/${t}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},_={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},E={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},ot=new Set([E.Network,E.Cancelled,E.File,E.Config]),Z={client:new Set([E.Business,E.Cancelled,E.Config,E.File,E.Forbidden,E.NotFound,E.RateLimit,E.Validation]),network:new Set([E.Network]),auth:new Set([E.Authentication])},at=new Set(Object.values(E).filter(t=>!ot.has(t))),lt=200;m=class t extends Error{constructor(e,o,l,c){super(o);k(this,"type");k(this,"status");k(this,"details");this.type=e,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,o=this.type===E.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:o}}static async fromHttpResponse(e,o){let l,c,f;try{if(e.headers.get("content-type")?.includes("application/json")){let h=await e.json();if(h&&typeof h=="object"){let D=h;typeof D.message=="string"?l=D.message:typeof D.error=="string"&&(l=D.error),c=D.details,typeof D.error=="string"&&at.has(D.error)&&(f=D.error)}}else{let h=(await e.text()).trim();h&&!h.startsWith("<")&&h.length<=lt&&(l=h)}}catch{}let y=e.headers.get("retry-after");if(y!==null){let g=y.trim(),h=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(h)&&h>=0){let D=c&&typeof c=="object"?c:{};D.retryAfter===void 0&&(c={...D,retryAfter:h})}}l=l||`${o||"Request"} failed with status ${e.status}`;let d=f??(e.status===401?E.Authentication:e.status===403?E.Forbidden:e.status===429?E.RateLimit:E.Api);return new t(d,l,e.status,c)}static fromFetchError(e,o){if(Ae(e))return e;let l=o||"Request",c=e?.name;return c==="AbortError"?t.cancelled(`${l} was cancelled`):c==="TimeoutError"?t.network(`${l} timed out`,{cause:e}):e instanceof Error?pt(e)?t.network(`${l} failed: ${e.message}`,{cause:e}):new t(E.Api,`${l} failed: ${e.message}`):new t(E.Api,`${l} failed: Unknown error`)}static validation(e,o){return new t(E.Validation,e,400,o)}static notFound(e,o){let l=o?`${e} ${o} not found`:`${e} not found`;return new t(E.NotFound,l,404)}static forbidden(e,o){return new t(E.Forbidden,e,403,o)}static rateLimit(e="Too many requests",o){return new t(E.RateLimit,e,429,o)}static authentication(e="Authentication required",o){return new t(E.Authentication,e,401,o)}static business(e,o=400,l){return new t(E.Business,e,o,l)}static network(e,o){return new t(E.Network,e,void 0,o)}static cancelled(e,o){return new t(E.Cancelled,e,void 0,o)}static file(e,o){return new t(E.File,e,void 0,o)}static config(e,o){return new t(E.Config,e,void 0,o)}static api(e,o=500,l){return new t(E.Api,e,o,l)}static maintenance(e,o){return new t(E.Maintenance,e,503,o)}isClientError(){return Z.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Z.network.has(this.type)}isAuthError(){return Z.auth.has(this.type)}isType(e){return this.type===e}};ct=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],Gt=ct.map(t=>`.${t}`).join(","),dt=/[\x00-\x1f\x7f#?%\\<>"]/;ft=new Set(["node_modules","package.json"]);kt="/auth",ge={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Te={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Se={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},$={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},C={API_KEY:ge.API_KEY,DEPLOY_TOKEN:ge.TOKEN,OPAQUE:"opaque"};zt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},x="ship.json",Re={rewrites:[{source:"/(.*)",destination:"/index.html"}]},Y={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};te="https://api.shipstatic.com",Yt={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},jt="https://my.shipstatic.com/api-key",qt=4320*60,R={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Pe=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;z={MIN_LENGTH:6,MAX_LENGTH:128}});var Oe=ye((xe,Ne)=>{"use strict";(function(t){if(typeof xe=="object")Ne.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var n;try{n=window}catch{n=self}n.SparkMD5=t()}})(function(t){"use strict";var n=function(u,p){return u+p&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(u,p,i,r,a,s){return p=n(n(p,u),n(r,s)),n(p<<a|p>>>32-a,i)}function l(u,p){var i=u[0],r=u[1],a=u[2],s=u[3];i+=(r&a|~r&s)+p[0]-680876936|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[1]-389564586|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[2]+606105819|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[3]-1044525330|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[4]-176418897|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[5]+1200080426|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[6]-1473231341|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[7]-45705983|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[9]-1958414417|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[10]-42063|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[11]-1990404162|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[13]-40341101|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[14]-1502002290|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[15]+1236535329|0,r=(r<<22|r>>>10)+a|0,i+=(r&s|a&~s)+p[1]-165796510|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[6]-1069501632|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[11]+643717713|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[0]-373897302|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[5]-701558691|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[10]+38016083|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[15]-660478335|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[4]-405537848|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[9]+568446438|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[14]-1019803690|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[3]-187363961|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[8]+1163531501|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[2]-51403784|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[7]+1735328473|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[12]-1926607734|0,r=(r<<20|r>>>12)+a|0,i+=(r^a^s)+p[5]-378558|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[8]-2022574463|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[11]+1839030562|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[14]-35309556|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[4]+1272893353|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[7]-155497632|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[10]-1094730640|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[13]+681279174|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[0]-358537222|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[3]-722521979|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[6]+76029189|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[9]-640364487|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[12]-421815835|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[15]+530742520|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[2]-995338651|0,r=(r<<23|r>>>9)+a|0,i+=(a^(r|~s))+p[0]-198630844|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[7]+1126891415|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[14]-1416354905|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[5]-57434055|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[3]-1894986606|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[10]-1051523|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[1]-2054922799|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[15]-30611744|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[6]-1560198380|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[13]+1309151649|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[4]-145523070|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[11]-1120210379|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[2]+718787259|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[9]-343485551|0,r=(r<<21|r>>>11)+a|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=a+u[2]|0,u[3]=s+u[3]|0}function c(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return p}function f(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return p}function y(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,w,v,O;for(r=64;r<=p;r+=64)l(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),a=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)s[r>>2]|=u.charCodeAt(r)<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(l(i,s),r=0;r<16;r+=1)s[r]=0;return w=p*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(w[2],16),O=parseInt(w[1],16)||0,s[14]=v,s[15]=O,l(i,s),i}function d(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,w,v,O;for(r=64;r<=p;r+=64)l(i,f(u.subarray(r-64,r)));for(u=r-64<p?u.subarray(r-64):new Uint8Array(0),a=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)s[r>>2]|=u[r]<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(l(i,s),r=0;r<16;r+=1)s[r]=0;return w=p*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(w[2],16),O=parseInt(w[1],16)||0,s[14]=v,s[15]=O,l(i,s),i}function g(u){var p="",i;for(i=0;i<4;i+=1)p+=e[u>>i*8+4&15]+e[u>>i*8&15];return p}function h(u){var p;for(p=0;p<u.length;p+=1)u[p]=g(u[p]);return u.join("")}h(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(u,p){var i=(u&65535)+(p&65535),r=(u>>16)+(p>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(p,i){return p=p|0||0,p<0?Math.max(p+i,0):Math.min(p,i)}ArrayBuffer.prototype.slice=function(p,i){var r=this.byteLength,a=u(p,r),s=r,w,v,O,he;return i!==t&&(s=u(i,r)),a>s?new ArrayBuffer(0):(w=s-a,v=new ArrayBuffer(w),O=new Uint8Array(v),he=new Uint8Array(this,a,w),O.set(he),v)}})();function D(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function S(u,p){var i=u.length,r=new ArrayBuffer(i),a=new Uint8Array(r),s;for(s=0;s<i;s+=1)a[s]=u.charCodeAt(s);return p?a:r}function I(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function L(u,p,i){var r=new Uint8Array(u.byteLength+p.byteLength);return r.set(new Uint8Array(u)),r.set(new Uint8Array(p),u.byteLength),i?r:r.buffer}function N(u){var p=[],i=u.length,r;for(r=0;r<i-1;r+=2)p.push(parseInt(u.substr(r,2),16));return String.fromCharCode.apply(String,p)}function A(){this.reset()}return A.prototype.append=function(u){return this.appendBinary(D(u)),this},A.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var p=this._buff.length,i;for(i=64;i<=p;i+=64)l(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},A.prototype.end=function(u){var p=this._buff,i=p.length,r,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(r=0;r<i;r+=1)a[r>>2]|=p.charCodeAt(r)<<(r%4<<3);return this._finish(a,i),s=h(this._hash),u&&(s=N(s)),this.reset(),s},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.prototype._finish=function(u,p){var i=p,r,a,s;if(u[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,u),i=0;i<16;i+=1)u[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),s=parseInt(r[1],16)||0,u[14]=a,u[15]=s,l(this._hash,u)},A.hash=function(u,p){return A.hashBinary(D(u),p)},A.hashBinary=function(u,p){var i=y(u),r=h(i);return p?N(r):r},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(u){var p=L(this._buff.buffer,u,!0),i=p.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)l(this._hash,f(p.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(p.buffer.slice(r-64)):new Uint8Array(0),this},A.ArrayBuffer.prototype.end=function(u){var p=this._buff,i=p.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,s;for(a=0;a<i;a+=1)r[a>>2]|=p[a]<<(a%4<<3);return this._finish(r,i),s=h(this._hash),u&&(s=N(s)),this.reset(),s},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var u=A.prototype.getState.call(this);return u.buff=I(u.buff),u},A.ArrayBuffer.prototype.setState=function(u){return u.buff=S(u.buff,!0),A.prototype.setState.call(this,u)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(u,p){var i=d(new Uint8Array(u)),r=h(i);return p?N(r):r},A})});var X=ye((dn,Fe)=>{"use strict";Fe.exports={}});async function wt(t){let n=(await Promise.resolve().then(()=>G(Oe(),1))).default,e=new n.ArrayBuffer,o=2097152;for(let l=0;l<t.size;l+=o){let c=Math.min(l+o,t.size);e.append(await t.slice(l,c).arrayBuffer())}return{md5:e.end()}}async function Lt(t){let{createHash:n}=await Promise.resolve().then(()=>G(X(),1)),e=n("md5");return e.update(t),{md5:e.digest("hex")}}async function Pt(t){let{createHash:n}=await Promise.resolve().then(()=>G(X(),1)),{createReadStream:e}=await Promise.resolve().then(()=>G(X(),1));return new Promise((o,l)=>{let c=n("md5"),f=e(t);f.on("error",y=>l(m.file(`Failed to read file for MD5: ${y.message}`,{filePath:t}))),f.on("data",y=>c.update(y)),f.on("end",()=>o({md5:c.digest("hex")}))})}async function B(t){if(t instanceof Blob)return wt(t);if(typeof Buffer<"u"&&Buffer.isBuffer(t))return Lt(t);if(typeof t=="string")return Pt(t);throw m.business("Invalid input for MD5 calculation")}var W=P(()=>{"use strict";b()});function Q(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ge=P(()=>{"use strict"});function ke(t,n={}){if(n.flatten===!1)return t.map(o=>({path:Q(o),name:ie(o)}));let e=vt(t);return t.map(o=>{let l=Q(o);if(e){let c=e.endsWith("/")?e:`${e}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=ie(o)),{path:l,name:ie(o)}})}function vt(t){if(!t.length)return"";let e=t.map(c=>Q(c)).map(c=>c.split("/")),o=[],l=Math.min(...e.map(c=>c.length));for(let c=0;c<l-1;c++){let f=e[0][c];if(e.every(y=>y[c]===f))o.push(f);else break}return o.join("/")}function ie(t){return t.split(/[/\\]/).pop()||t}var se=P(()=>{"use strict";Ge()});function Nn(t){oe=t}function xt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function ze(){return oe||xt()}var oe,ae=P(()=>{"use strict";oe=null});function le(t,n=1){if(t===0)return"0 Bytes";let e=1024,o=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/e**l).toFixed(n))} ${o[l]}`}function pe(t){if(De(t))return{valid:!1,reason:"File name contains unsafe characters"};if(t.startsWith(" ")||t.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(t.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=t.split("/").pop()||t;return n.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:t.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Cn(t,n){let e=[],o=[],l=[];if(t.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of t)if(K(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:t.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(t.length>n.maxFilesCount){let d={file:`(${t.length} files)`,message:`File count (${t.length}) exceeds limit of ${n.maxFilesCount}`};return e.push(d),{files:t.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of t){let g=R.READY,h="Ready for upload",D=d.name?pe(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===R.PROCESSING_ERROR)g=R.VALIDATION_FAILED,h=d.statusMessage||"File failed during processing",e.push({file:d.name,message:h});else if(d.size===0){g=R.EXCLUDED,h="File is empty (0 bytes) and cannot be deployed due to storage limitations",o.push({file:d.name,message:h}),l.push({...d,status:g,statusMessage:h});continue}else d.size<0?(g=R.VALIDATION_FAILED,h="File size must be positive",e.push({file:d.name,message:h})):!d.name||d.name.trim().length===0?(g=R.VALIDATION_FAILED,h="File name cannot be empty",e.push({file:d.name||"(empty)",message:h})):d.name.includes("\0")?(g=R.VALIDATION_FAILED,h="File name contains invalid characters (null byte)",e.push({file:d.name,message:h})):D.valid?V(d.name,n.blockedExtensions??[])?(g=R.VALIDATION_FAILED,h=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:h})):d.size>n.maxFileSize?(g=R.VALIDATION_FAILED,h=`File size (${le(d.size)}) exceeds limit of ${le(n.maxFileSize)}`,e.push({file:d.name,message:h})):(c+=d.size,c>n.maxTotalSize&&(g=R.VALIDATION_FAILED,h=`Total size would exceed limit of ${le(n.maxTotalSize)}`,e.push({file:d.name,message:h}))):(g=R.VALIDATION_FAILED,h=D.reason||"Invalid file name",e.push({file:d.name,message:h}));l.push({...d,status:g,statusMessage:h})}e.length>0&&(l=l.map(d=>d.status===R.EXCLUDED?d:{...d,status:R.VALIDATION_FAILED,statusMessage:d.status===R.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let f=e.length===0?l.filter(d=>d.status===R.READY):[],y=e.length===0;return{files:l,validFiles:f,errors:e,warnings:o,canDeploy:y}}function Nt(t){return t.filter(n=>n.status===R.READY)}function $n(t){return Nt(t).length>0}var ue=P(()=>{"use strict";b()});function Ve(t){return Ft.test(t)}var Ot,Ft,Ke=P(()=>{"use strict";Ot=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Ft=new RegExp(Ot.join("|"))});function Ye(t,n){if(!t||t.length===0)return[];if(!n?.allowUnbuilt&&t.find(o=>o&&K(o)))throw m.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return t.filter(e=>{if(!e)return!1;let o=e.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let l=o[o.length-1];if(Ve(l))return!1;for(let f of o)if(f!==".well-known"&&(f.startsWith(".")||f.length>255))return!1;let c=o.slice(0,-1);for(let f of c)if(Ct.some(y=>f.toLowerCase()===y.toLowerCase()))return!1;return!0})}var Ct,ce=P(()=>{"use strict";b();Ke();Ct=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function je(t,n){if(t.includes("\0")||t.includes("/../")||t.startsWith("../")||t.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${t}" for file: ${n}`)}function qe(t,n,e){let o=pe(t);if(!o.valid)throw m.business(o.reason||"Invalid file name");if(V(t,e))throw m.business(`File extension not allowed: "${n}"`)}var de=P(()=>{"use strict";b();ue()});var We={};rt(We,{processFilesForBrowser:()=>Xe});async function Xe(t,n={},e){if(ze()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");let o=t.map(S=>S.webkitRelativePath||S.name),l=n.build||n.prerender,c=ke(o,{flatten:n.pathDetect!==!1}),f=c.map(S=>S.path),y=new Set(Ye(f,{allowUnbuilt:l})),d=[];for(let S=0;S<t.length;S++)y.has(f[S])&&d.push({file:t[S],deployPath:c[S].path});if(d.length===0)return[];if(l){let S=[];for(let I=0;I<d.length;I++){let{file:L,deployPath:N}=d[I];if(L.size===0)continue;let{md5:A}=await B(L);S.push({path:N,content:L,size:L.size,md5:A})}return S}if(!e)throw m.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let g=[],h=0,D=e.blockedExtensions??[];for(let S=0;S<d.length;S++){let{file:I,deployPath:L}=d[S];if(je(L,I.name),I.size===0)continue;if(qe(L,I.name,D),I.size>e.maxFileSize)throw m.business(`File ${I.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(h+=I.size,h>e.maxTotalSize)throw m.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:N}=await B(I);g.push({path:L,content:I,size:I.size,md5:N})}if(g.length>e.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return g}var fe=P(()=>{"use strict";b();se();ae();ce();W();de()});b();b();b();var j=class{constructor(){this.handlers=new Map}on(n,e){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(e)}off(n,e){let o=this.handlers.get(n);o&&(o.delete(e),o.size===0&&this.handlers.delete(n))}emit(n,...e){let o=this.handlers.get(n);if(!o)return;let l=Array.from(o);for(let c of l)try{c(...e)}catch(f){o.delete(c),n!=="error"&&setTimeout(()=>{let y=f instanceof Error?f:new Error(String(f));this.emit("error",y,String(n))},0)}}};b();b();function M(t){if(t==null)return;if(t.length===0)return t;if(t.length>F.MAX_COUNT)throw m.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let n=t.map((o,l)=>{if(typeof o!="string")throw m.validation(`Label at index ${l} must be a string`);let c=o.trim().toLowerCase();if(c.length<F.MIN_LENGTH)throw m.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(c.length>F.MAX_LENGTH)throw m.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!Pe.test(c))throw m.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return c}),e=[...new Set(n)];if(e.length!==n.length)throw m.validation("Duplicate labels are not allowed");return e}async function _e(t){let n=t.find(l=>l.path===x||l.path===`/${x}`);if(!n)return;let e=n.content,o=typeof e.text=="function"?await e.text():n.content.toString("utf8");be(o)}var gt=3e4,Et=2,At=300,Dt=2e3,Tt=new Set([500,502,503,504]);function St(t,n){return new Promise((e,o)=>{if(n?.aborted){o(n.reason);return}let l=()=>{clearTimeout(f),n?.removeEventListener("abort",c)},c=()=>{l(),o(n?.reason)},f=setTimeout(()=>{l(),e()},t);n?.addEventListener("abort",c)})}var ve=3e5,Rt=3e5,bt=ve+Rt,It="sdk";function re(t){let n=new URLSearchParams;t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.cursor!==void 0&&n.set("cursor",t.cursor);let e=n.toString();return e?`?${e}`:""}var q=class extends j{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||te,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??gt,this.maxRetries=Math.max(0,e.maxRetries??Et),this.deployTimeout=e.timeout??ve,this.deployBuildTimeout=e.timeout??bt,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||T.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,o,l,c=this.timeout){for(let f=0;;f++)try{return await this.attemptOnce(e,o,l,c)}catch(y){let d=m.fromFetchError(y,l);if(f>=this.maxRetries||!this.isRetryable(d,o))throw d;let g=Math.min(Dt,At*2**f);try{await St(Math.random()*g,o.signal)}catch(h){let D=m.fromFetchError(h,l);throw this.emit("error",D,e),D}}}isRetryable(e,o){if(o.signal?.aborted||e.isType(E.Maintenance)||e.isType(E.Cancelled)||!(e.isNetworkError()||e.status!==void 0&&Tt.has(e.status)))return!1;let c=(o.method??"GET").toUpperCase();return c==="GET"||c==="HEAD"?!0:c==="PUT"||c==="DELETE"?!1:this.hasIdempotencyKey(o.headers)}hasIdempotencyKey(e){if(!e)return!1;let o=U.HEADER.toLowerCase(),l=!1,c=f=>{f.toLowerCase()===o&&(l=!0)};if(e instanceof Headers)e.forEach((f,y)=>{c(y)});else if(Array.isArray(e))for(let[f]of e)c(f);else for(let f of Object.keys(e))c(f);return l}async attemptOnce(e,o,l,c=this.timeout){let f=()=>{};try{let y=await this.mergeHeaders(o.headers),d=this.createTimeoutSignal(o.signal,c);f=d.cleanup;let g={...o,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",e,g);let h=await this.fetch(e,g);if(f(),!h.ok)throw await m.fromHttpResponse(h,l);return this.emit("response",this.safeClone(h),e),{data:await this.parseResponse(this.safeClone(h)),status:h.status}}catch(y){f();let d=m.fromFetchError(y,l);throw this.emit("error",d,e),d}}async request(e,o,l,c){let{data:f}=await this.executeRequest(e,o,l,c);return f}async requestWithStatus(e,o,l){return this.executeRequest(e,o,l)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{[$.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e,o=this.timeout){let l=new AbortController,c=setTimeout(()=>l.abort(new DOMException(`Timed out after ${o}ms`,"TimeoutError")),o),f=e?()=>l.abort(e.reason):void 0;return e&&f&&(e.addEventListener("abort",f),e.aborted&&l.abort(e.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(c),e&&f&&e.removeEventListener("abort",f)}}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,o={}){if(!e.length)throw m.business("No files to deploy");for(let g of e)if(!g.md5)throw m.file(`MD5 checksum missing for file: ${g.path}`,{filePath:g.path});ne(o.password);let l=Ee(o.idempotencyKey),c=M(o.labels);await _e(e);let f=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:y,headers:d}=await this.createDeployBody(e,{labels:c,via:o.via??It,password:o.password,flags:f,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:y,headers:l?{...d,[U.HEADER]:l}:d,signal:o.signal||null},"Deploy",o.build||o.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(e){return this.request(`${this.apiUrl}${T.DEPLOYMENTS}${re(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,o){let l=M(o);return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:l})},"Update deployment labels")}async deleteDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"DELETE"},"Delete deployment")}async setDomain(e,o,l){let c=M(l),f={};o&&(f.deployment=o),c!==void 0&&(f.labels=c);let{data:y,status:d}=await this.requestWithStatus(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...y,isCreate:d===201}}async listDomains(e){return this.request(`${this.apiUrl}${T.DOMAINS}${re(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"GET"},"Get domain")}async deleteDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN_VERIFY(encodeURIComponent(e))}`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${T.DOMAIN_DNS(encodeURIComponent(e))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${T.DOMAIN_RECORDS(encodeURIComponent(e))}`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${T.DOMAIN_SHARE(encodeURIComponent(e))}`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${T.DOMAINS_VALIDATE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,o){let l=M(o),c={};return e!==void 0&&(c.ttl=e),l!==void 0&&(c.labels=l),this.request(`${this.apiUrl}${T.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(e){return this.request(`${this.apiUrl}${T.TOKENS}${re(e)}`,{method:"GET"},"List tokens")}async deleteToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete token")}async getToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"GET"},"Get token")}async getAccount(){return this.request(`${this.apiUrl}${T.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${T.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return this.request(`${this.apiUrl}${T.PING}`,{method:"GET"},"Ping")}async checkSPA(e,o={}){let l=e.find(d=>d.path===Y.INDEX_FILE||d.path===`/${Y.INDEX_FILE}`);if(!l||l.size>Y.MAX_INDEX_BYTES)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(l.content))c=l.content.toString("utf-8");else if(typeof Blob<"u"&&l.content instanceof Blob)c=await l.content.text();else if(typeof File<"u"&&l.content instanceof File)c=await l.content.text();else return!1;let f={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${T.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"SPA check")).isSPA}};b();b();W();async function _t(){let t=JSON.stringify(Re,null,2),n;typeof Buffer<"u"?n=Buffer.from(t,"utf-8"):n=new Blob([t],{type:"application/json"});let{md5:e}=await B(n);return{path:x,content:n,size:t.length,md5:e}}async function Ce(t,n,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||t.some(o=>o.path===x))return t;try{if(await n.checkSPA(t,e)){let l=await _t();return[...t,l]}}catch{}return t}function $e(t){let{getApi:n,ensureInit:e,processInput:o}=t;return{upload:async(l,c={})=>{if(await e(),!o)throw m.config("processInput function is not provided.");let f=n(),y=await o(l,c);return y=await Ce(y,f,c),f.deploy(y,c)},list:async l=>(await e(),n().listDeployments(l)),get:async l=>(await e(),n().getDeployment(l)),set:async(l,c)=>(await e(),n().updateDeploymentLabels(l,c.labels)),delete:async l=>(await e(),n().deleteDeployment(l))}}function Ue(t){let{getApi:n,ensureInit:e}=t;return{set:async(o,l={})=>(await e(),n().setDomain(o,l.deployment,l.labels)),list:async o=>(await e(),n().listDomains(o)),get:async o=>(await e(),n().getDomain(o)),delete:async o=>(await e(),n().deleteDomain(o)),verify:async o=>(await e(),n().verifyDomain(o)),validate:async o=>(await e(),n().validateDomain(o)),dns:async o=>(await e(),n().getDomainDns(o)),records:async o=>(await e(),n().getDomainRecords(o)),share:async o=>(await e(),n().getDomainShare(o))}}function Me(t){let{getApi:n,ensureInit:e}=t;return{get:async()=>(await e(),n().getAccount())}}function Be(t){let{getApi:n,ensureInit:e}=t;return{create:async(o={})=>(await e(),n().createToken(o.ttl,o.labels)),list:async o=>(await e(),n().listTokens(o)),get:async o=>(await e(),n().getToken(o)),delete:async o=>(await e(),n().deleteToken(o))}}var J=class{constructor(n={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(n={...n,apiUrl:n.apiUrl||void 0,token:n.token||void 0,caller:n.caller||void 0},this.clientOptions=n,n.caller!==void 0&&we(n.caller),n.token&&n.session)throw m.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(ee(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new q({...n,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=$e({...e,processInput:(o,l)=>this.processInput(o,l)}),this.domains=Ue(e),this.account=Me(e),this.tokens=Be(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(n){throw this.initPromise=null,n}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(n,e){return this.deployments.upload(n,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,e){this.http.on(n,e)}off(n,e){this.http.off(n,e)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw m.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw m.business("Invalid token provided. Token must be a non-empty string.");ee(n),this.credential=n;return}if(typeof n!="function")throw m.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=n}async getAuthHeaders(){if(this.credential===null)return{};let n=typeof this.credential=="function"?await this.credential():this.credential;if(!n)throw m.authentication("Token provider returned no token.");if(typeof n!="string")throw m.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};b();async function He(t,n={}){let{labels:e,via:o,password:l,flags:c,captcha:f}=n,y=new FormData,d=[];for(let g of t){if(!(g.content instanceof File||g.content instanceof Blob))throw m.file(`Unsupported file.content type for browser: ${g.path}`,{filePath:g.path});if(!g.md5)throw m.file(`File missing md5 checksum: ${g.path}`,{filePath:g.path});let h=new File([g.content],g.path,{type:"application/octet-stream"});y.append(_.FILES,h),d.push(g.md5)}return y.append(_.CHECKSUMS,JSON.stringify(d)),e&&e.length>0&&y.append(_.LABELS,JSON.stringify(e)),o&&y.append(_.VIA,o),l&&y.append(_.PASSWORD,l),c?.build&&y.append(_.BUILD,"true"),c?.prerender&&y.append(_.PRERENDER,"true"),c?.spa&&y.append(_.SPA,"true"),f&&y.append(_.CAPTCHA,f),{body:y,headers:{}}}b();b();se();ae();ue();ce();W();de();function Kn(t,n,e,o=!0){let l=t===1?n:e;return o?`${t} ${l}`:l}fe();var me=class extends J{async deploy(n,e){return super.deploy(n,e)}async processInput(n,e){if(!Array.isArray(n)||!n.every(l=>l instanceof File))throw m.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw m.business("No files to deploy.");let{processFilesForBrowser:o}=await Promise.resolve().then(()=>(fe(),We));return o(n,e,this.platformLimits??void 0)}getDeployBodyCreator(){return He}},hr=me;export{Te as API_KEY,T as API_PATHS,kt as AUTH_BASE_PATH,Ht as AccountPlan,q as ApiHttp,ge as AuthMethod,$ as CALLER,te as DEFAULT_API,x as DEPLOYMENT_CONFIG_FILENAME,_ as DEPLOY_FIELDS,Se as DEPLOY_TOKEN,Ut as DeploymentStatus,st as DeploymentVia,Mt as DomainStatus,E as ErrorType,R as FILE_VALIDATION_STATUS,R as FileValidationStatus,U as IDEMPOTENCY_KEY_CONSTRAINTS,Ct as JUNK_DIRECTORIES,F as LABEL_CONSTRAINTS,Pe as LABEL_PATTERN,jt as MY_API_KEY_URL,zt as OAuthScope,z as PASSWORD_CONSTRAINTS,qt as PUBLIC_DEPLOYMENT_TTL_SECONDS,Yt as SHIP_ENV,Y as SPA_CHECK_CONSTRAINTS,Re as SPA_DEFAULT_CONFIG,me as Ship,m as ShipError,C as TokenKind,ft as UNBUILT_PROJECT_MARKERS,dt as UNSAFE_FILENAME_CHARS,Gt as WEB_FILE_ACCEPT,Nn as __setTestEnvironment,$n as allValidFilesReady,be as assertShipJsonSyntax,B as calculateMD5,mt as classifyToken,Me as createAccountResource,$e as createDeploymentResource,Ue as createDomainResource,Be as createTokenResource,hr as default,en as deserializeLabels,Wt as extractSubdomain,Ye as filterJunk,le as formatFileSize,Jt as generateDeploymentUrl,Qt as generateDomainUrl,ze as getENV,Nt as getValidFiles,K as hasUnbuiltMarker,De as hasUnsafeChars,V as isBlockedExtension,Xt as isCustomDomain,Kt as isDeployment,Le as isPlatformDomain,Ae as isShipError,Bt as normalizeVia,ke as optimizeDeployPaths,Kn as pluralize,Xe as processFilesForBrowser,Zt as serializeLabels,ht as validateApiKey,Vt as validateApiUrl,we as validateCaller,qe as validateDeployFile,je as validateDeployPath,yt as validateDeployToken,pe as validateFileName,Cn as validateFiles,Ee as validateIdempotencyKey,ne as validatePassword,ee as validateToken};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|