@shipstatic/ship 0.9.6 → 1.0.1
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 +25 -3
- package/SKILL.md +2 -2
- package/dist/browser.d.ts +13 -5
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +27 -27
- package/dist/cli.cjs.map +1 -1
- package/dist/completions/ship.fish +1 -1
- package/dist/completions/ship.zsh +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -159,7 +159,7 @@ Available on every command:
|
|
|
159
159
|
| Flag | Description |
|
|
160
160
|
|------|-------------|
|
|
161
161
|
| `--api-key <key>` | API key for authenticated requests |
|
|
162
|
-
| `--deploy-token <token>` | Deploy token for
|
|
162
|
+
| `--deploy-token <token>` | Deploy token for authenticated deployments |
|
|
163
163
|
| `--api-url <url>` | API URL override (for development) |
|
|
164
164
|
| `--config <file>` | Custom config file path |
|
|
165
165
|
| `--json` | Output results in JSON format |
|
|
@@ -199,7 +199,7 @@ const ship = new Ship();
|
|
|
199
199
|
// API key — permanent, full access
|
|
200
200
|
const ship = new Ship({ apiKey: 'ship-...' });
|
|
201
201
|
|
|
202
|
-
// Deploy token —
|
|
202
|
+
// Deploy token — scoped to deploys, optional TTL, revocable
|
|
203
203
|
const ship = new Ship({ deployToken: 'token-...' });
|
|
204
204
|
|
|
205
205
|
// Set credentials after construction
|
|
@@ -229,7 +229,7 @@ ship.deploy(input, {
|
|
|
229
229
|
|
|
230
230
|
#### Password protection
|
|
231
231
|
|
|
232
|
-
Pass `password` (6–128 characters
|
|
232
|
+
Pass `password` (6–128 characters) to gate the deployment behind a prompt. Visitors are asked for the password before they can view the site, including on any custom domains pointing at it. To remove protection, redeploy without a password.
|
|
233
233
|
|
|
234
234
|
```bash
|
|
235
235
|
ship --password 'your-passphrase' ./dist
|
|
@@ -266,6 +266,28 @@ ship.on('error', (error, url) => {});
|
|
|
266
266
|
ship.off('request', handler);
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
+
### Custom fetch
|
|
270
|
+
|
|
271
|
+
Pass `fetch` to override the transport function used for every API call. Defaults to `globalThis.fetch`. Useful for wrapping requests with tracing, retries, or request signing, and for injecting a Cloudflare service-binding `Fetcher` from a Worker so calls reach a sibling Worker in-process instead of through the public hostname.
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import type { Fetch } from '@shipstatic/ship';
|
|
275
|
+
|
|
276
|
+
const traced: Fetch = (input, init) =>
|
|
277
|
+
globalThis.fetch(input, { ...init, headers: { ...init?.headers, 'X-Trace-Id': 'abc-123' } });
|
|
278
|
+
|
|
279
|
+
const ship = new Ship({ fetch: traced });
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
// Cloudflare Worker with a service binding to the API.
|
|
284
|
+
// Any parseable apiUrl works — service bindings dispatch by binding identity, not hostname.
|
|
285
|
+
const ship = new Ship({
|
|
286
|
+
apiUrl: 'https://api',
|
|
287
|
+
fetch: env.API.fetch.bind(env.API),
|
|
288
|
+
});
|
|
289
|
+
```
|
|
290
|
+
|
|
269
291
|
### Error Handling
|
|
270
292
|
|
|
271
293
|
```javascript
|
package/SKILL.md
CHANGED
|
@@ -91,7 +91,7 @@ ship ./dist --password "hunter22" # protect deployment
|
|
|
91
91
|
SHIP_PASSWORD="hunter22" ship ./dist # via env var
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
Visitors get an unlock page until they enter the password. Length: 6–128 characters. Set per-deployment at upload time — cannot be added or changed later (deploy a new version to rotate). Works on both internal (`*.shipstatic.com`) and custom domains.
|
|
94
|
+
Visitors get an unlock page until they enter the password. Length: 6–128 characters. Set per-deployment at upload time — cannot be added or changed later (deploy a new version to rotate). Works on both internal (`*.shipstatic.com`) and custom domains. **Always show the password to the user** if you set one — they need it to view the site.
|
|
95
95
|
|
|
96
96
|
### SPA routing
|
|
97
97
|
|
|
@@ -111,7 +111,7 @@ ship --api-key <key> ... # Per-command override
|
|
|
111
111
|
ship config # Interactive setup → ~/.shiprc (requires TTY)
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
Deploy tokens (`--deploy-token`) are
|
|
114
|
+
Deploy tokens (`--deploy-token`) are scoped, revocable deploy credentials. Set a short TTL for one-shot CI/CD workflows.
|
|
115
115
|
|
|
116
116
|
Free API key: https://my.shipstatic.com/api-key
|
|
117
117
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ interface DeployBodyContext {
|
|
|
76
76
|
* Implemented differently for Node.js and Browser.
|
|
77
77
|
*/
|
|
78
78
|
type DeployBodyCreator = (files: StaticFile[], context?: DeployBodyContext) => Promise<DeployBody>;
|
|
79
|
+
/** Standard `fetch` signature — the type of the `fetch` client option. */
|
|
80
|
+
type Fetch = typeof fetch;
|
|
79
81
|
/**
|
|
80
82
|
* Options for configuring a `Ship` instance.
|
|
81
83
|
* Sets default API host, authentication credentials, progress callbacks, concurrency, and timeouts for the client.
|
|
@@ -85,7 +87,7 @@ interface ShipClientOptions {
|
|
|
85
87
|
apiUrl?: string | undefined;
|
|
86
88
|
/** API key for authenticated deployments (format: ship-<64-char-hex>, total 69 chars). */
|
|
87
89
|
apiKey?: string | undefined;
|
|
88
|
-
/** Deploy token for
|
|
90
|
+
/** Deploy token for authenticated deployments (format: token-<64-char-hex>, total 70 chars). */
|
|
89
91
|
deployToken?: string | undefined;
|
|
90
92
|
/**
|
|
91
93
|
* Default callback for deploy progress for deploys made with this client.
|
|
@@ -112,6 +114,14 @@ interface ShipClientOptions {
|
|
|
112
114
|
* to proceed with cookie-based credentials.
|
|
113
115
|
*/
|
|
114
116
|
useCredentials?: boolean | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Custom `fetch` implementation. Defaults to `globalThis.fetch`.
|
|
119
|
+
*
|
|
120
|
+
* Use to inject a Cloudflare service-binding `Fetcher`
|
|
121
|
+
* (`env.API.fetch.bind(env.API)`) for Worker-to-Worker calls, to wrap
|
|
122
|
+
* requests with tracing/retries/signing, or to mock in tests.
|
|
123
|
+
*/
|
|
124
|
+
fetch?: Fetch | undefined;
|
|
115
125
|
/**
|
|
116
126
|
* Default caller identifier for multi-tenant deployments.
|
|
117
127
|
* Alphanumeric characters, dots, underscores, and hyphens allowed (max 128 chars).
|
|
@@ -195,6 +205,7 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
195
205
|
private readonly getAuthHeadersCallback;
|
|
196
206
|
private readonly useCredentials;
|
|
197
207
|
private readonly timeout;
|
|
208
|
+
private readonly fetch;
|
|
198
209
|
private readonly createDeployBody;
|
|
199
210
|
private readonly deployEndpoint;
|
|
200
211
|
private globalHeaders;
|
|
@@ -397,9 +408,6 @@ declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults:
|
|
|
397
408
|
interface MD5Result {
|
|
398
409
|
md5: string;
|
|
399
410
|
}
|
|
400
|
-
/**
|
|
401
|
-
* Unified MD5 calculation that delegates to environment-specific handlers
|
|
402
|
-
*/
|
|
403
411
|
declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>;
|
|
404
412
|
|
|
405
413
|
/**
|
|
@@ -703,4 +711,4 @@ declare class Ship extends Ship$1 {
|
|
|
703
711
|
protected getDeployBodyCreator(): DeployBodyCreator;
|
|
704
712
|
}
|
|
705
713
|
|
|
706
|
-
export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeploymentOptions, type DeploymentResourceContext, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ResourceContext, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getENV, getValidFiles, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, validateDeployFile, validateDeployPath, validateFileName, validateFiles };
|
|
714
|
+
export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeploymentOptions, type DeploymentResourceContext, type ExecutionEnvironment, type Fetch, JUNK_DIRECTORIES, type MD5Result, type ResourceContext, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getENV, getValidFiles, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, validateDeployFile, validateDeployPath, validateFileName, validateFiles };
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Me=Object.create;var B=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ke=(r,i,e)=>i in r?B(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var x=(r,i)=>()=>(r&&(i=r(r=0)),i);var de=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports),Ve=(r,i)=>{for(var e in i)B(r,e,{get:i[e],enumerable:!0})},qe=(r,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of ze(i))!Ge.call(r,p)&&p!==e&&B(r,p,{get:()=>i[p],enumerable:!(a=ke(i,p))||a.enumerable});return r};var J=(r,i,e)=>(e=r!=null?Me(He(r)):{},qe(i||!r||!r.__esModule?B(e,"default",{value:r,enumerable:!0}):e,r));var M=(r,i,e)=>Ke(r,typeof i!="symbol"?i+"":i,e);function k(r){return r!==null&&typeof r=="object"&&"name"in r&&r.name==="ShipError"&&"status"in r}function z(r){let i=r.lastIndexOf(".");if(i===-1||i===r.length-1)return!1;let e=r.slice(i+1).toLowerCase();return We.has(e)}function fe(r){return Ye.test(r)}function H(r){return r.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Je.has(e))}function ft(r){if(!r.startsWith(F.PREFIX))throw h.validation(`API key must start with "${F.PREFIX}"`);if(r.length!==F.TOTAL_LENGTH)throw h.validation(`API key must be ${F.TOTAL_LENGTH} characters total (${F.PREFIX} + ${F.HEX_LENGTH} hex chars)`);let i=r.slice(F.PREFIX.length);if(!/^[a-f0-9]{64}$/i.test(i))throw h.validation(`API key must contain ${F.HEX_LENGTH} hexadecimal characters after "${F.PREFIX}" prefix`)}function ht(r){if(!r.startsWith(P.PREFIX))throw h.validation(`Deploy token must start with "${P.PREFIX}"`);if(r.length!==P.TOTAL_LENGTH)throw h.validation(`Deploy token must be ${P.TOTAL_LENGTH} characters total (${P.PREFIX} + ${P.HEX_LENGTH} hex chars)`);let i=r.slice(P.PREFIX.length);if(!/^[a-f0-9]{64}$/i.test(i))throw h.validation(`Deploy token must contain ${P.HEX_LENGTH} hexadecimal characters after "${P.PREFIX}" prefix`)}function mt(r){try{let i=new URL(r);if(!["http:","https:"].includes(i.protocol))throw h.validation("API URL must use http:// or https:// protocol");if(i.pathname!=="/"&&i.pathname!=="")throw h.validation("API URL must not contain a path");if(i.search||i.hash)throw h.validation("API URL must not contain query parameters or fragments")}catch(i){throw k(i)?i:h.validation("API URL must be a valid URL")}}function yt(r){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(r)}function me(r,i){return r.endsWith(`.${i}`)}function gt(r,i){return!me(r,i)}function At(r,i){return me(r,i)?r.slice(0,-(i.length+1)):null}function Dt(r){return`https://${r}`}function Et(r){return`https://${r}`}function St(r){return!r||r.length===0?null:JSON.stringify(r)}function bt(r){if(!r)return[];try{let i=JSON.parse(r);return Array.isArray(i)?i:[]}catch{return[]}}var pt,ut,ct,D,je,Q,Xe,h,We,Ye,Je,F,P,dt,Z,he,G,b,C,ye,$,v=x(()=>{"use strict";pt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},ut={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},ct={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},D={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},je=new Set([D.Network,D.Cancelled,D.File,D.Config]),Q={client:new Set([D.Business,D.Config,D.File,D.Forbidden,D.Validation]),network:new Set([D.Network]),auth:new Set([D.Authentication])},Xe=new Set(Object.values(D).filter(r=>!je.has(r))),h=class r extends Error{constructor(e,a,p,d){super(a);M(this,"type");M(this,"status");M(this,"details");this.type=e,this.status=p,this.details=d,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===D.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,d,f;try{if(e.headers.get("content-type")?.includes("application/json")){let m=await e.json();if(m&&typeof m=="object"){let y=m;typeof y.message=="string"?p=y.message:typeof y.error=="string"&&(p=y.error),d=y.details,typeof y.error=="string"&&Xe.has(y.error)&&(f=y.error)}}else{let m=await e.text();m&&(p=m)}}catch{}p=p||`${a||"Request"} failed with status ${e.status}`;let g=f??(e.status===401?D.Authentication:e.status===403?D.Forbidden:e.status===429?D.RateLimit:D.Api);return new r(g,p,e.status,d)}static fromFetchError(e,a){if(k(e))return e;let p=a||"Request";return e instanceof Error?e.name==="AbortError"?r.cancelled(`${p} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?r.network(`${p} failed: ${e.message}`,{cause:e}):new r(D.Api,`${p} failed: ${e.message}`):new r(D.Api,`${p} failed: Unknown error`)}static validation(e,a){return new r(D.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new r(D.NotFound,p,404)}static forbidden(e,a){return new r(D.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new r(D.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new r(D.Authentication,e,401,a)}static business(e,a=400,p){return new r(D.Business,e,a,p)}static network(e,a){return new r(D.Network,e,void 0,a)}static cancelled(e,a){return new r(D.Cancelled,e,void 0,a)}static file(e,a){return new r(D.File,e,void 0,a)}static config(e,a){return new r(D.Config,e,void 0,a)}static api(e,a=500,p){return new r(D.Api,e,a,p)}isClientError(){return Q.client.has(this.type)}isNetworkError(){return Q.network.has(this.type)}isAuthError(){return Q.auth.has(this.type)}isType(e){return this.type===e}};We=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Ye=/[\x00-\x1f\x7f#?%\\<>"]/;Je=new Set(["node_modules","package.json"]);F={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},P={PREFIX:"token-",HEX_LENGTH:64,TOTAL_LENGTH:70},dt={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},Z="ship.json",he={rewrites:[{source:"/(.*)",destination:"/index.html"}]};G="https://api.shipstatic.com",b={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};C={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ye=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;$={MIN_LENGTH:6,MAX_LENGTH:128}});function Ot(r){ee=r}function Ze(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function q(){return ee||Ze()}var ee,j=x(()=>{"use strict";ee=null});var be=de((Ee,Se)=>{"use strict";(function(r){if(typeof Ee=="object")Se.exports=r();else if(typeof define=="function"&&define.amd)define(r);else{var i;try{i=window}catch{i=self}i.SparkMD5=r()}})(function(r){"use strict";var i=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,n,t,o,s){return l=i(i(l,u),i(t,s)),i(l<<o|l>>>32-o,n)}function p(u,l){var n=u[0],t=u[1],o=u[2],s=u[3];n+=(t&o|~t&s)+l[0]-680876936|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[3]-1044525330|0,t=(t<<22|t>>>10)+o|0,n+=(t&o|~t&s)+l[4]-176418897|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[7]-45705983|0,t=(t<<22|t>>>10)+o|0,n+=(t&o|~t&s)+l[8]+1770035416|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[11]-1990404162|0,t=(t<<22|t>>>10)+o|0,n+=(t&o|~t&s)+l[12]+1804603682|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[15]+1236535329|0,t=(t<<22|t>>>10)+o|0,n+=(t&s|o&~s)+l[1]-165796510|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[0]-373897302|0,t=(t<<20|t>>>12)+o|0,n+=(t&s|o&~s)+l[5]-701558691|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[4]-405537848|0,t=(t<<20|t>>>12)+o|0,n+=(t&s|o&~s)+l[9]+568446438|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[8]+1163531501|0,t=(t<<20|t>>>12)+o|0,n+=(t&s|o&~s)+l[13]-1444681467|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[12]-1926607734|0,t=(t<<20|t>>>12)+o|0,n+=(t^o^s)+l[5]-378558|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[14]-35309556|0,t=(t<<23|t>>>9)+o|0,n+=(t^o^s)+l[1]-1530992060|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[10]-1094730640|0,t=(t<<23|t>>>9)+o|0,n+=(t^o^s)+l[13]+681279174|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[6]+76029189|0,t=(t<<23|t>>>9)+o|0,n+=(t^o^s)+l[9]-640364487|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[2]-995338651|0,t=(t<<23|t>>>9)+o|0,n+=(o^(t|~s))+l[0]-198630844|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[5]-57434055|0,t=(t<<21|t>>>11)+o|0,n+=(o^(t|~s))+l[12]+1700485571|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[1]-2054922799|0,t=(t<<21|t>>>11)+o|0,n+=(o^(t|~s))+l[8]+1873313359|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[13]+1309151649|0,t=(t<<21|t>>>11)+o|0,n+=(o^(t|~s))+l[4]-145523070|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[9]-343485551|0,t=(t<<21|t>>>11)+o|0,u[0]=n+u[0]|0,u[1]=t+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function d(u){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=u.charCodeAt(n)+(u.charCodeAt(n+1)<<8)+(u.charCodeAt(n+2)<<16)+(u.charCodeAt(n+3)<<24);return l}function f(u){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=u[n]+(u[n+1]<<8)+(u[n+2]<<16)+(u[n+3]<<24);return l}function g(u){var l=u.length,n=[1732584193,-271733879,-1732584194,271733878],t,o,s,w,I,L;for(t=64;t<=l;t+=64)p(n,d(u.substring(t-64,t)));for(u=u.substring(t-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(n,s),t=0;t<16;t+=1)s[t]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(w[2],16),L=parseInt(w[1],16)||0,s[14]=I,s[15]=L,p(n,s),n}function c(u){var l=u.length,n=[1732584193,-271733879,-1732584194,271733878],t,o,s,w,I,L;for(t=64;t<=l;t+=64)p(n,f(u.subarray(t-64,t)));for(u=t-64<l?u.subarray(t-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(n,s),t=0;t<16;t+=1)s[t]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(w[2],16),L=parseInt(w[1],16)||0,s[14]=I,s[15]=L,p(n,s),n}function m(u){var l="",n;for(n=0;n<4;n+=1)l+=e[u>>n*8+4&15]+e[u>>n*8&15];return l}function y(u){var l;for(l=0;l<u.length;l+=1)u[l]=m(u[l]);return u.join("")}y(g("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(i=function(u,l){var n=(u&65535)+(l&65535),t=(u>>16)+(l>>16)+(n>>16);return t<<16|n&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,n){return l=l|0||0,l<0?Math.max(l+n,0):Math.min(l,n)}ArrayBuffer.prototype.slice=function(l,n){var t=this.byteLength,o=u(l,t),s=t,w,I,L,ce;return n!==r&&(s=u(n,t)),o>s?new ArrayBuffer(0):(w=s-o,I=new ArrayBuffer(w),L=new Uint8Array(I),ce=new Uint8Array(this,o,w),L.set(ce),I)}})();function A(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function T(u,l){var n=u.length,t=new ArrayBuffer(n),o=new Uint8Array(t),s;for(s=0;s<n;s+=1)o[s]=u.charCodeAt(s);return l?o:t}function R(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function O(u,l,n){var t=new Uint8Array(u.byteLength+l.byteLength);return t.set(new Uint8Array(u)),t.set(new Uint8Array(l),u.byteLength),n?t:t.buffer}function N(u){var l=[],n=u.length,t;for(t=0;t<n-1;t+=2)l.push(parseInt(u.substr(t,2),16));return String.fromCharCode.apply(String,l)}function E(){this.reset()}return E.prototype.append=function(u){return this.appendBinary(A(u)),this},E.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,n;for(n=64;n<=l;n+=64)p(this._hash,d(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},E.prototype.end=function(u){var l=this._buff,n=l.length,t,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(t=0;t<n;t+=1)o[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(o,n),s=y(this._hash),u&&(s=N(s)),this.reset(),s},E.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},E.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},E.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},E.prototype._finish=function(u,l){var n=l,t,o,s;if(u[n>>2]|=128<<(n%4<<3),n>55)for(p(this._hash,u),n=0;n<16;n+=1)u[n]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(t[2],16),s=parseInt(t[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},E.hash=function(u,l){return E.hashBinary(A(u),l)},E.hashBinary=function(u,l){var n=g(u),t=y(n);return l?N(t):t},E.ArrayBuffer=function(){this.reset()},E.ArrayBuffer.prototype.append=function(u){var l=O(this._buff.buffer,u,!0),n=l.length,t;for(this._length+=u.byteLength,t=64;t<=n;t+=64)p(this._hash,f(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},E.ArrayBuffer.prototype.end=function(u){var l=this._buff,n=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<n;o+=1)t[o>>2]|=l[o]<<(o%4<<3);return this._finish(t,n),s=y(this._hash),u&&(s=N(s)),this.reset(),s},E.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.ArrayBuffer.prototype.getState=function(){var u=E.prototype.getState.call(this);return u.buff=R(u.buff),u},E.ArrayBuffer.prototype.setState=function(u){return u.buff=T(u.buff,!0),E.prototype.setState.call(this,u)},E.ArrayBuffer.prototype.destroy=E.prototype.destroy,E.ArrayBuffer.prototype._finish=E.prototype._finish,E.ArrayBuffer.hash=function(u,l){var n=c(new Uint8Array(u)),t=y(n);return l?N(t):t},E})});var te=de((_t,Te)=>{"use strict";Te.exports={}});async function et(r){let i=(await Promise.resolve().then(()=>J(be(),1))).default;return new Promise((e,a)=>{let d=Math.ceil(r.size/2097152),f=0,g=new i.ArrayBuffer,c=new FileReader,m=()=>{let y=f*2097152,A=Math.min(y+2097152,r.size);c.readAsArrayBuffer(r.slice(y,A))};c.onload=y=>{let A=y.target?.result;if(!A){a(h.business("Failed to read file chunk"));return}g.append(A),f++,f<d?m():e({md5:g.end()})},c.onerror=()=>{a(h.business("Failed to calculate MD5: FileReader error"))},m()})}async function tt(r){let i=await Promise.resolve().then(()=>J(te(),1));if(Buffer.isBuffer(r)){let a=i.createHash("md5");return a.update(r),{md5:a.digest("hex")}}let e=await Promise.resolve().then(()=>J(te(),1));return new Promise((a,p)=>{let d=i.createHash("md5"),f=e.createReadStream(r);f.on("error",g=>p(h.business(`Failed to read file for MD5: ${g.message}`))),f.on("data",g=>d.update(g)),f.on("end",()=>a({md5:d.digest("hex")}))})}async function U(r){let i=q();if(i==="browser"){if(!(r instanceof Blob))throw h.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return et(r)}if(i==="node"){if(!(Buffer.isBuffer(r)||typeof r=="string"))throw h.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return tt(r)}throw h.business("Unknown or unsupported execution environment for MD5 calculation.")}var X=x(()=>{"use strict";j();v()});function Pe(r){return it.test(r)}var rt,it,Le=x(()=>{"use strict";rt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],it=new RegExp(rt.join("|"))});function Ce(r,i){if(!r||r.length===0)return[];if(!i?.allowUnbuilt&&r.find(a=>a&&H(a)))throw h.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return r.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(Pe(p))return!1;for(let f of a)if(f!==".well-known"&&(f.startsWith(".")||f.length>255))return!1;let d=a.slice(0,-1);for(let f of d)if(st.some(g=>f.toLowerCase()===g.toLowerCase()))return!1;return!0})}var st,ne=x(()=>{"use strict";Le();v();st=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Y(r){return r.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ne=x(()=>{"use strict"});function Oe(r,i={}){if(i.flatten===!1)return r.map(a=>({path:Y(a),name:re(a)}));let e=ot(r);return r.map(a=>{let p=Y(a);if(e){let d=e.endsWith("/")?e:`${e}/`;p.startsWith(d)&&(p=p.substring(d.length))}return p||(p=re(a)),{path:p,name:re(a)}})}function ot(r){if(!r.length)return"";let e=r.map(d=>Y(d)).map(d=>d.split("/")),a=[],p=Math.min(...e.map(d=>d.length));for(let d=0;d<p-1;d++){let f=e[0][d];if(e.every(g=>g[d]===f))a.push(f);else break}return a.join("/")}function re(r){return r.split(/[/\\]/).pop()||r}var ie=x(()=>{"use strict";Ne()});function se(r,i=1){if(r===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(r)/Math.log(e));return parseFloat((r/Math.pow(e,p)).toFixed(i))+" "+a[p]}function oe(r){if(fe(r))return{valid:!1,reason:"File name contains unsafe characters"};if(r.startsWith(" ")||r.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(r.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let i=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=r.split("/").pop()||r;return i.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:r.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function cn(r,i){let e=[],a=[],p=[];if(r.length===0){let c={file:"(no files)",message:"At least one file must be provided"};return e.push(c),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let c of r)if(H(c.name))return e.push({file:c.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:r.map(m=>({...m,status:b.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(r.length>i.maxFilesCount){let c={file:`(${r.length} files)`,message:`File count (${r.length}) exceeds limit of ${i.maxFilesCount}`};return e.push(c),{files:r.map(m=>({...m,status:b.VALIDATION_FAILED,statusMessage:c.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let d=0;for(let c of r){let m=b.READY,y="Ready for upload",A=c.name?oe(c.name):{valid:!1,reason:"File name cannot be empty"};if(c.status===b.PROCESSING_ERROR)m=b.VALIDATION_FAILED,y=c.statusMessage||"File failed during processing",e.push({file:c.name,message:y});else if(c.size===0){m=b.EXCLUDED,y="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:c.name,message:y}),p.push({...c,status:m,statusMessage:y});continue}else c.size<0?(m=b.VALIDATION_FAILED,y="File size must be positive",e.push({file:c.name,message:y})):!c.name||c.name.trim().length===0?(m=b.VALIDATION_FAILED,y="File name cannot be empty",e.push({file:c.name||"(empty)",message:y})):c.name.includes("\0")?(m=b.VALIDATION_FAILED,y="File name contains invalid characters (null byte)",e.push({file:c.name,message:y})):A.valid?z(c.name)?(m=b.VALIDATION_FAILED,y=`File extension not allowed: "${c.name}"`,e.push({file:c.name,message:y})):c.size>i.maxFileSize?(m=b.VALIDATION_FAILED,y=`File size (${se(c.size)}) exceeds limit of ${se(i.maxFileSize)}`,e.push({file:c.name,message:y})):(d+=c.size,d>i.maxTotalSize&&(m=b.VALIDATION_FAILED,y=`Total size would exceed limit of ${se(i.maxTotalSize)}`,e.push({file:c.name,message:y}))):(m=b.VALIDATION_FAILED,y=A.reason||"Invalid file name",e.push({file:c.name,message:y}));p.push({...c,status:m,statusMessage:y})}e.length>0&&(p=p.map(c=>c.status===b.EXCLUDED?c:{...c,status:b.VALIDATION_FAILED,statusMessage:c.status===b.VALIDATION_FAILED?c.statusMessage:"Deployment failed due to validation errors in bundle"}));let f=e.length===0?p.filter(c=>c.status===b.READY):[],g=e.length===0;return{files:p,validFiles:f,errors:e,warnings:a,canDeploy:g}}function at(r){return r.filter(i=>i.status===b.READY)}function dn(r){return at(r).length>0}var ae=x(()=>{"use strict";v()});function $e(r,i){if(r.includes("\0")||r.includes("/../")||r.startsWith("../")||r.endsWith("/.."))throw h.business(`Security error: Unsafe file path "${r}" for file: ${i}`)}function _e(r,i){let e=oe(r);if(!e.valid)throw h.business(e.reason||"Invalid file name");if(z(r))throw h.business(`File extension not allowed: "${i}"`)}var le=x(()=>{"use strict";v();ae()});var Be={};Ve(Be,{processFilesForBrowser:()=>Ue});async function Ue(r,i={},e){if(q()!=="browser")throw h.business("processFilesForBrowser can only be called in a browser environment.");let a=r.map(A=>A.webkitRelativePath||A.name),p=i.build||i.prerender,d=Oe(a,{flatten:i.pathDetect!==!1}),f=d.map(A=>A.path),g=new Set(Ce(f,{allowUnbuilt:p})),c=[];for(let A=0;A<r.length;A++)g.has(f[A])&&c.push({file:r[A],deployPath:d[A].path});if(c.length===0)return[];if(p){let A=[];for(let T=0;T<c.length;T++){let{file:R,deployPath:O}=c[T];if(R.size===0)continue;let{md5:N}=await U(R);A.push({path:O,content:R,size:R.size,md5:N})}return A}if(!e)throw h.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let m=[],y=0;for(let A=0;A<c.length;A++){let{file:T,deployPath:R}=c[A];if($e(R,T.name),T.size===0)continue;if(_e(R,T.name),T.size>e.maxFileSize)throw h.business(`File ${T.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(y+=T.size,y>e.maxTotalSize)throw h.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:O}=await U(T);m.push({path:R,content:T,size:T.size,md5:O})}if(m.length>e.maxFilesCount)throw h.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return m}var pe=x(()=>{"use strict";X();v();j();ne();ie();le()});v();v();var K=class{constructor(){this.handlers=new Map}on(i,e){this.handlers.has(i)||this.handlers.set(i,new Set),this.handlers.get(i).add(e)}off(i,e){let a=this.handlers.get(i);a&&(a.delete(e),a.size===0&&this.handlers.delete(i))}emit(i,...e){let a=this.handlers.get(i);if(!a)return;let p=Array.from(a);for(let d of p)try{d(...e)}catch(f){a.delete(d),i!=="error"&&setTimeout(()=>{let g=f instanceof Error?f:new Error(String(f));this.emit("error",g,String(i))},0)}}};v();function ge(r){if(r!=null){if(typeof r!="string")throw h.validation("Password must be a string");if(r.length<$.MIN_LENGTH||r.length>$.MAX_LENGTH)throw h.validation(`Password must be between ${$.MIN_LENGTH} and ${$.MAX_LENGTH} characters`)}}function _(r){if(r==null)return;if(r.length===0)return r;if(r.length>C.MAX_COUNT)throw h.validation(`Maximum ${C.MAX_COUNT} labels allowed`);let i=r.map((a,p)=>{if(typeof a!="string")throw h.validation(`Label at index ${p} must be a string`);let d=a.trim().toLowerCase();if(d.length<C.MIN_LENGTH)throw h.validation(`Labels must be at least ${C.MIN_LENGTH} characters long`);if(d.length>C.MAX_LENGTH)throw h.validation(`Labels must be no more than ${C.MAX_LENGTH} characters long`);if(!ye.test(d))throw h.validation(`Labels must start and end with alphanumeric characters, with optional separators (${C.SEPARATORS}) between segments`);return d}),e=[...new Set(i)];if(e.length!==i.length)throw h.validation("Duplicate labels are not allowed");return e}var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},Qe=3e4,V=class extends K{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||G,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??Qe,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||S.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p){let d=this.mergeHeaders(a.headers),{signal:f,cleanup:g}=this.createTimeoutSignal(a.signal),c={...a,headers:d,credentials:this.useCredentials&&!d.Authorization?"include":void 0,signal:f};this.emit("request",e,c);try{let m=await fetch(e,c);if(g(),!m.ok)throw await h.fromHttpResponse(m,p);return this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(m){g();let y=h.fromFetchError(m,p);throw this.emit("error",y,e),y}}async request(e,a,p){let{data:d}=await this.executeRequest(e,a,p);return d}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let a=new AbortController,p=setTimeout(()=>a.abort(),this.timeout);if(e){let d=()=>a.abort();e.addEventListener("abort",d),e.aborted&&a.abort()}return{signal:a.signal,cleanup:()=>clearTimeout(p)}}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 h.business("No files to deploy");for(let m of e)if(!m.md5)throw h.file(`MD5 checksum missing for file: ${m.path}`,{filePath:m.path});ge(a.password);let p=_(a.labels),d=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:f,headers:g}=await this.createDeployBody(e,{labels:p,via:a.via,password:a.password,flags:d}),c={};return a.deployToken?c.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(c.Authorization=`Bearer ${a.apiKey}`),a.caller&&(c["X-Caller"]=a.caller),this.request(`${a.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:f,headers:{...g,...c},signal:a.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=_(a);return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,p){let d=_(p),f={};a&&(f.deployment=a),d!==void 0&&(f.labels=d);let{data:g,status:c}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...g,isCreate:c===201}}async listDomains(){return this.request(`${this.apiUrl}${S.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=_(a),d={};return e!==void 0&&(d.ttl=e),p!==void 0&&(d.labels=p),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${S.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${S.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${S.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${S.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let p=e.find(m=>m.path==="index.html"||m.path==="/index.html");if(!p||p.size>100*1024)return!1;let d;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))d=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)d=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)d=await p.content.text();else return!1;let f={"Content-Type":"application/json"};a.deployToken?f.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(f.Authorization=`Bearer ${a.apiKey}`);let g={files:e.map(m=>m.path),index:d};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:f,body:JSON.stringify(g)},"SPA check")).isSPA}};v();function Ae(r={}){let i={apiUrl:r.apiUrl||G};return r.apiKey!==void 0&&(i.apiKey=r.apiKey),r.deployToken!==void 0&&(i.deployToken=r.deployToken),i}function De(r,i){let e={...r};return e.apiUrl===void 0&&i.apiUrl!==void 0&&(e.apiUrl=i.apiUrl),e.apiKey===void 0&&i.apiKey!==void 0&&(e.apiKey=i.apiKey),e.deployToken===void 0&&i.deployToken!==void 0&&(e.deployToken=i.deployToken),e.timeout===void 0&&i.timeout!==void 0&&(e.timeout=i.timeout),e.maxConcurrency===void 0&&i.maxConcurrency!==void 0&&(e.maxConcurrency=i.maxConcurrency),e.onProgress===void 0&&i.onProgress!==void 0&&(e.onProgress=i.onProgress),e.caller===void 0&&i.caller!==void 0&&(e.caller=i.caller),e}v();v();X();async function nt(){let r=JSON.stringify(he,null,2),i;typeof Buffer<"u"?i=Buffer.from(r,"utf-8"):i=new Blob([r],{type:"application/json"});let{md5:e}=await U(i);return{path:Z,content:i,size:r.length,md5:e}}async function we(r,i,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||r.some(a=>a.path===Z))return r;try{if(await i.checkSPA(r,e)){let p=await nt();return[...r,p]}}catch{}return r}function ve(r){let{getApi:i,ensureInit:e,processInput:a,clientDefaults:p,hasAuth:d}=r;return{upload:async(f,g={})=>{await e();let c=p?De(g,p):g;if(d&&!d()&&!c.deployToken&&!c.apiKey)try{let A=i(),{secret:T}=await A.fetchAgentToken();c.deployToken=T}catch(A){throw k(A)&&A.type===D.RateLimit?h.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):A}if(!a)throw h.config("processInput function is not provided.");let m=i(),y=await a(f,c);return y=await we(y,m,c),m.deploy(y,c)},list:async()=>(await e(),i().listDeployments()),get:async f=>(await e(),i().getDeployment(f)),set:async(f,g)=>(await e(),i().updateDeploymentLabels(f,g.labels)),remove:async f=>{await e(),await i().removeDeployment(f)}}}function Re(r){let{getApi:i,ensureInit:e}=r;return{set:async(a,p={})=>(await e(),i().setDomain(a,p.deployment,p.labels)),list:async()=>(await e(),i().listDomains()),get:async a=>(await e(),i().getDomain(a)),remove:async a=>{await e(),await i().removeDomain(a)},verify:async a=>(await e(),i().verifyDomain(a)),validate:async a=>(await e(),i().validateDomain(a)),dns:async a=>(await e(),i().getDomainDns(a)),records:async a=>(await e(),i().getDomainRecords(a)),share:async a=>(await e(),i().getDomainShare(a))}}function xe(r){let{getApi:i,ensureInit:e}=r;return{get:async()=>(await e(),i().getAccount())}}function Ie(r){let{getApi:i,ensureInit:e}=r;return{create:async(a={})=>(await e(),i().createToken(a.ttl,a.labels)),list:async()=>(await e(),i().listTokens()),remove:async a=>{await e(),await i().removeToken(a)}}}var W=class{constructor(i={}){this.initPromise=null;this.platformLimits=null;this.auth=null;i={...i,apiUrl:i.apiUrl||void 0,apiKey:i.apiKey||void 0,deployToken:i.deployToken||void 0},this.clientOptions=i,i.deployToken?this.auth={type:"token",value:i.deployToken}:i.apiKey&&(this.auth={type:"apiKey",value:i.apiKey}),this.http=new V({...i,...Ae(i),getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=ve({...e,processInput:(a,p)=>this.processInput(a,p),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this.domains=Re(e),this.account=xe(e),this.tokens=Ie(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(i){throw this.initPromise=null,i}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(i,e){return this.deployments.upload(i,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(i,e){this.http.on(i,e)}off(i,e){this.http.off(i,e)}setHeaders(i){this.http.setGlobalHeaders(i)}clearHeaders(){this.http.setGlobalHeaders({})}setDeployToken(i){if(!i||typeof i!="string")throw h.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:i}}setApiKey(i){if(!i||typeof i!="string")throw h.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:i}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};v();v();async function Fe(r,i={}){let{labels:e,via:a,password:p,flags:d}=i,f=new FormData,g=[];for(let c of r){if(!(c.content instanceof File||c.content instanceof Blob))throw h.file(`Unsupported file.content type for browser: ${c.path}`,{filePath:c.path});if(!c.md5)throw h.file(`File missing md5 checksum: ${c.path}`,{filePath:c.path});let m=new File([c.content],c.path,{type:"application/octet-stream"});f.append("files[]",m),g.push(c.md5)}return f.append("checksums",JSON.stringify(g)),e&&e.length>0&&f.append("labels",JSON.stringify(e)),a&&f.append("via",a),p&&f.append("password",p),d?.build&&f.append("build","true"),d?.prerender&&f.append("prerender","true"),d?.spa&&f.append("spa","true"),{body:f,headers:{}}}X();function en(r,i,e,a=!0){let p=r===1?i:e;return a?`${r} ${p}`:p}ne();ie();j();ae();le();v();pe();var ue=class extends W{async deploy(i,e){return super.deploy(i,e)}async processInput(i,e){if(!Array.isArray(i)||!i.every(p=>p instanceof File))throw h.business("Invalid input type for browser environment. Expected File[].");if(i.length===0)throw h.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(pe(),Be));return a(i,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Fe}},kn=ue;export{F as API_KEY,ct as AccountPlan,V as ApiHttp,dt as AuthMethod,We as BLOCKED_EXTENSIONS,G as DEFAULT_API,Z as DEPLOYMENT_CONFIG_FILENAME,P as DEPLOY_TOKEN,pt as DeploymentStatus,ut as DomainStatus,D as ErrorType,b as FILE_VALIDATION_STATUS,b as FileValidationStatus,st as JUNK_DIRECTORIES,C as LABEL_CONSTRAINTS,ye as LABEL_PATTERN,$ as PASSWORD_CONSTRAINTS,he as SPA_DEFAULT_CONFIG,ue as Ship,h as ShipError,Je as UNBUILT_PROJECT_MARKERS,Ye as UNSAFE_FILENAME_CHARS,Ot as __setTestEnvironment,dn as allValidFilesReady,U as calculateMD5,xe as createAccountResource,ve as createDeploymentResource,Re as createDomainResource,Ie as createTokenResource,kn as default,bt as deserializeLabels,At as extractSubdomain,Ce as filterJunk,se as formatFileSize,Dt as generateDeploymentUrl,Et as generateDomainUrl,q as getENV,at as getValidFiles,H as hasUnbuiltMarker,fe as hasUnsafeChars,z as isBlockedExtension,gt as isCustomDomain,yt as isDeployment,me as isPlatformDomain,k as isShipError,De as mergeDeployOptions,Oe as optimizeDeployPaths,en as pluralize,Ue as processFilesForBrowser,Ae as resolveConfig,St as serializeLabels,ft as validateApiKey,mt as validateApiUrl,_e as validateDeployFile,$e as validateDeployPath,ht as validateDeployToken,oe as validateFileName,cn as validateFiles};
|
|
1
|
+
var Me=Object.create;var U=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ke=(r,i,e)=>i in r?U(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var x=(r,i)=>()=>(r&&(i=r(r=0)),i);var de=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports),qe=(r,i)=>{for(var e in i)U(r,e,{get:i[e],enumerable:!0})},Ve=(r,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of ze(i))!Ge.call(r,p)&&p!==e&&U(r,p,{get:()=>i[p],enumerable:!(a=He(i,p))||a.enumerable});return r};var B=(r,i,e)=>(e=r!=null?Me(ke(r)):{},Ve(i||!r||!r.__esModule?U(e,"default",{value:r,enumerable:!0}):e,r));var M=(r,i,e)=>Ke(r,typeof i!="symbol"?i+"":i,e);function z(r){return r!==null&&typeof r=="object"&&"name"in r&&r.name==="ShipError"&&"status"in r}function k(r){let i=r.lastIndexOf(".");if(i===-1||i===r.length-1)return!1;let e=r.slice(i+1).toLowerCase();return We.has(e)}function fe(r){return Ye.test(r)}function G(r){return r.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Je.has(e))}function ht(r){if(!r.startsWith(F.PREFIX))throw h.validation(`API key must start with "${F.PREFIX}"`);if(r.length!==F.TOTAL_LENGTH)throw h.validation(`API key must be ${F.TOTAL_LENGTH} characters total (${F.PREFIX} + ${F.HEX_LENGTH} hex chars)`);let i=r.slice(F.PREFIX.length);if(!/^[a-f0-9]{64}$/i.test(i))throw h.validation(`API key must contain ${F.HEX_LENGTH} hexadecimal characters after "${F.PREFIX}" prefix`)}function mt(r){if(!r.startsWith(P.PREFIX))throw h.validation(`Deploy token must start with "${P.PREFIX}"`);if(r.length!==P.TOTAL_LENGTH)throw h.validation(`Deploy token must be ${P.TOTAL_LENGTH} characters total (${P.PREFIX} + ${P.HEX_LENGTH} hex chars)`);let i=r.slice(P.PREFIX.length);if(!/^[a-f0-9]{64}$/i.test(i))throw h.validation(`Deploy token must contain ${P.HEX_LENGTH} hexadecimal characters after "${P.PREFIX}" prefix`)}function yt(r){try{let i=new URL(r);if(!["http:","https:"].includes(i.protocol))throw h.validation("API URL must use http:// or https:// protocol");if(i.pathname!=="/"&&i.pathname!=="")throw h.validation("API URL must not contain a path");if(i.search||i.hash)throw h.validation("API URL must not contain query parameters or fragments")}catch(i){throw z(i)?i:h.validation("API URL must be a valid URL")}}function gt(r){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(r)}function me(r,i){return r.endsWith(`.${i}`)}function At(r,i){return!me(r,i)}function Dt(r,i){return me(r,i)?r.slice(0,-(i.length+1)):null}function Et(r){return`https://${r}`}function St(r){return`https://${r}`}function Tt(r){return!r||r.length===0?null:JSON.stringify(r)}function bt(r){if(!r)return[];try{let i=JSON.parse(r);return Array.isArray(i)?i:[]}catch{return[]}}function Z(r){if(r==null)return;if(typeof r!="string")throw h.validation("Password must be a string");let i=r.trim();if(i.length<H.MIN_LENGTH||i.length>H.MAX_LENGTH)throw h.validation(`Password must be between ${H.MIN_LENGTH} and ${H.MAX_LENGTH} characters`);return i}var ut,ct,dt,A,je,J,Xe,h,We,Ye,Je,F,P,ft,Q,he,K,T,C,ye,H,w=x(()=>{"use strict";ut={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},ct={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},dt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},A={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},je=new Set([A.Network,A.Cancelled,A.File,A.Config]),J={client:new Set([A.Business,A.Config,A.File,A.Forbidden,A.Validation]),network:new Set([A.Network]),auth:new Set([A.Authentication])},Xe=new Set(Object.values(A).filter(r=>!je.has(r))),h=class r extends Error{constructor(e,a,p,d){super(a);M(this,"type");M(this,"status");M(this,"details");this.type=e,this.status=p,this.details=d,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===A.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,d,f;try{if(e.headers.get("content-type")?.includes("application/json")){let m=await e.json();if(m&&typeof m=="object"){let y=m;typeof y.message=="string"?p=y.message:typeof y.error=="string"&&(p=y.error),d=y.details,typeof y.error=="string"&&Xe.has(y.error)&&(f=y.error)}}else{let m=await e.text();m&&(p=m)}}catch{}p=p||`${a||"Request"} failed with status ${e.status}`;let g=f??(e.status===401?A.Authentication:e.status===403?A.Forbidden:e.status===429?A.RateLimit:A.Api);return new r(g,p,e.status,d)}static fromFetchError(e,a){if(z(e))return e;let p=a||"Request";return e instanceof Error?e.name==="AbortError"?r.cancelled(`${p} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?r.network(`${p} failed: ${e.message}`,{cause:e}):new r(A.Api,`${p} failed: ${e.message}`):new r(A.Api,`${p} failed: Unknown error`)}static validation(e,a){return new r(A.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new r(A.NotFound,p,404)}static forbidden(e,a){return new r(A.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new r(A.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new r(A.Authentication,e,401,a)}static business(e,a=400,p){return new r(A.Business,e,a,p)}static network(e,a){return new r(A.Network,e,void 0,a)}static cancelled(e,a){return new r(A.Cancelled,e,void 0,a)}static file(e,a){return new r(A.File,e,void 0,a)}static config(e,a){return new r(A.Config,e,void 0,a)}static api(e,a=500,p){return new r(A.Api,e,a,p)}isClientError(){return J.client.has(this.type)}isNetworkError(){return J.network.has(this.type)}isAuthError(){return J.auth.has(this.type)}isType(e){return this.type===e}};We=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Ye=/[\x00-\x1f\x7f#?%\\<>"]/;Je=new Set(["node_modules","package.json"]);F={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},P={PREFIX:"token-",HEX_LENGTH:64,TOTAL_LENGTH:70},ft={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},Q="ship.json",he={rewrites:[{source:"/(.*)",destination:"/index.html"}]};K="https://api.shipstatic.com",T={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};C={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ye=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;H={MIN_LENGTH:6,MAX_LENGTH:128}});var Se=de((De,Ee)=>{"use strict";(function(r){if(typeof De=="object")Ee.exports=r();else if(typeof define=="function"&&define.amd)define(r);else{var i;try{i=window}catch{i=self}i.SparkMD5=r()}})(function(r){"use strict";var i=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,n,t,o,s){return l=i(i(l,u),i(t,s)),i(l<<o|l>>>32-o,n)}function p(u,l){var n=u[0],t=u[1],o=u[2],s=u[3];n+=(t&o|~t&s)+l[0]-680876936|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[3]-1044525330|0,t=(t<<22|t>>>10)+o|0,n+=(t&o|~t&s)+l[4]-176418897|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[7]-45705983|0,t=(t<<22|t>>>10)+o|0,n+=(t&o|~t&s)+l[8]+1770035416|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[11]-1990404162|0,t=(t<<22|t>>>10)+o|0,n+=(t&o|~t&s)+l[12]+1804603682|0,n=(n<<7|n>>>25)+t|0,s+=(n&t|~n&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+n|0,o+=(s&n|~s&t)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,t+=(o&s|~o&n)+l[15]+1236535329|0,t=(t<<22|t>>>10)+o|0,n+=(t&s|o&~s)+l[1]-165796510|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[0]-373897302|0,t=(t<<20|t>>>12)+o|0,n+=(t&s|o&~s)+l[5]-701558691|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[4]-405537848|0,t=(t<<20|t>>>12)+o|0,n+=(t&s|o&~s)+l[9]+568446438|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[8]+1163531501|0,t=(t<<20|t>>>12)+o|0,n+=(t&s|o&~s)+l[13]-1444681467|0,n=(n<<5|n>>>27)+t|0,s+=(n&o|t&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+n|0,o+=(s&t|n&~t)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,t+=(o&n|s&~n)+l[12]-1926607734|0,t=(t<<20|t>>>12)+o|0,n+=(t^o^s)+l[5]-378558|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[14]-35309556|0,t=(t<<23|t>>>9)+o|0,n+=(t^o^s)+l[1]-1530992060|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[10]-1094730640|0,t=(t<<23|t>>>9)+o|0,n+=(t^o^s)+l[13]+681279174|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[6]+76029189|0,t=(t<<23|t>>>9)+o|0,n+=(t^o^s)+l[9]-640364487|0,n=(n<<4|n>>>28)+t|0,s+=(n^t^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+n|0,o+=(s^n^t)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,t+=(o^s^n)+l[2]-995338651|0,t=(t<<23|t>>>9)+o|0,n+=(o^(t|~s))+l[0]-198630844|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[5]-57434055|0,t=(t<<21|t>>>11)+o|0,n+=(o^(t|~s))+l[12]+1700485571|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[1]-2054922799|0,t=(t<<21|t>>>11)+o|0,n+=(o^(t|~s))+l[8]+1873313359|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[13]+1309151649|0,t=(t<<21|t>>>11)+o|0,n+=(o^(t|~s))+l[4]-145523070|0,n=(n<<6|n>>>26)+t|0,s+=(t^(n|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+n|0,o+=(n^(s|~t))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,t+=(s^(o|~n))+l[9]-343485551|0,t=(t<<21|t>>>11)+o|0,u[0]=n+u[0]|0,u[1]=t+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function d(u){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=u.charCodeAt(n)+(u.charCodeAt(n+1)<<8)+(u.charCodeAt(n+2)<<16)+(u.charCodeAt(n+3)<<24);return l}function f(u){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=u[n]+(u[n+1]<<8)+(u[n+2]<<16)+(u[n+3]<<24);return l}function g(u){var l=u.length,n=[1732584193,-271733879,-1732584194,271733878],t,o,s,v,I,L;for(t=64;t<=l;t+=64)p(n,d(u.substring(t-64,t)));for(u=u.substring(t-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(n,s),t=0;t<16;t+=1)s[t]=0;return v=l*8,v=v.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(v[2],16),L=parseInt(v[1],16)||0,s[14]=I,s[15]=L,p(n,s),n}function c(u){var l=u.length,n=[1732584193,-271733879,-1732584194,271733878],t,o,s,v,I,L;for(t=64;t<=l;t+=64)p(n,f(u.subarray(t-64,t)));for(u=t-64<l?u.subarray(t-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)s[t>>2]|=u[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(p(n,s),t=0;t<16;t+=1)s[t]=0;return v=l*8,v=v.toString(16).match(/(.*?)(.{0,8})$/),I=parseInt(v[2],16),L=parseInt(v[1],16)||0,s[14]=I,s[15]=L,p(n,s),n}function m(u){var l="",n;for(n=0;n<4;n+=1)l+=e[u>>n*8+4&15]+e[u>>n*8&15];return l}function y(u){var l;for(l=0;l<u.length;l+=1)u[l]=m(u[l]);return u.join("")}y(g("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(i=function(u,l){var n=(u&65535)+(l&65535),t=(u>>16)+(l>>16)+(n>>16);return t<<16|n&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,n){return l=l|0||0,l<0?Math.max(l+n,0):Math.min(l,n)}ArrayBuffer.prototype.slice=function(l,n){var t=this.byteLength,o=u(l,t),s=t,v,I,L,ce;return n!==r&&(s=u(n,t)),o>s?new ArrayBuffer(0):(v=s-o,I=new ArrayBuffer(v),L=new Uint8Array(I),ce=new Uint8Array(this,o,v),L.set(ce),I)}})();function D(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function b(u,l){var n=u.length,t=new ArrayBuffer(n),o=new Uint8Array(t),s;for(s=0;s<n;s+=1)o[s]=u.charCodeAt(s);return l?o:t}function R(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function O(u,l,n){var t=new Uint8Array(u.byteLength+l.byteLength);return t.set(new Uint8Array(u)),t.set(new Uint8Array(l),u.byteLength),n?t:t.buffer}function N(u){var l=[],n=u.length,t;for(t=0;t<n-1;t+=2)l.push(parseInt(u.substr(t,2),16));return String.fromCharCode.apply(String,l)}function E(){this.reset()}return E.prototype.append=function(u){return this.appendBinary(D(u)),this},E.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,n;for(n=64;n<=l;n+=64)p(this._hash,d(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},E.prototype.end=function(u){var l=this._buff,n=l.length,t,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(t=0;t<n;t+=1)o[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(o,n),s=y(this._hash),u&&(s=N(s)),this.reset(),s},E.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},E.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},E.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},E.prototype._finish=function(u,l){var n=l,t,o,s;if(u[n>>2]|=128<<(n%4<<3),n>55)for(p(this._hash,u),n=0;n<16;n+=1)u[n]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(t[2],16),s=parseInt(t[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},E.hash=function(u,l){return E.hashBinary(D(u),l)},E.hashBinary=function(u,l){var n=g(u),t=y(n);return l?N(t):t},E.ArrayBuffer=function(){this.reset()},E.ArrayBuffer.prototype.append=function(u){var l=O(this._buff.buffer,u,!0),n=l.length,t;for(this._length+=u.byteLength,t=64;t<=n;t+=64)p(this._hash,f(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},E.ArrayBuffer.prototype.end=function(u){var l=this._buff,n=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<n;o+=1)t[o>>2]|=l[o]<<(o%4<<3);return this._finish(t,n),s=y(this._hash),u&&(s=N(s)),this.reset(),s},E.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.ArrayBuffer.prototype.getState=function(){var u=E.prototype.getState.call(this);return u.buff=R(u.buff),u},E.ArrayBuffer.prototype.setState=function(u){return u.buff=b(u.buff,!0),E.prototype.setState.call(this,u)},E.ArrayBuffer.prototype.destroy=E.prototype.destroy,E.ArrayBuffer.prototype._finish=E.prototype._finish,E.ArrayBuffer.hash=function(u,l){var n=c(new Uint8Array(u)),t=y(n);return l?N(t):t},E})});var j=de((_t,Te)=>{"use strict";Te.exports={}});async function Ze(r){let i=(await Promise.resolve().then(()=>B(Se(),1))).default,e=new i.ArrayBuffer,a=2097152;for(let p=0;p<r.size;p+=a){let d=Math.min(p+a,r.size);e.append(await r.slice(p,d).arrayBuffer())}return{md5:e.end()}}async function et(r){let{createHash:i}=await Promise.resolve().then(()=>B(j(),1)),e=i("md5");return e.update(r),{md5:e.digest("hex")}}async function tt(r){let{createHash:i}=await Promise.resolve().then(()=>B(j(),1)),{createReadStream:e}=await Promise.resolve().then(()=>B(j(),1));return new Promise((a,p)=>{let d=i("md5"),f=e(r);f.on("error",g=>p(h.business(`Failed to read file for MD5: ${g.message}`))),f.on("data",g=>d.update(g)),f.on("end",()=>a({md5:d.digest("hex")}))})}async function _(r){if(r instanceof Blob)return Ze(r);if(typeof Buffer<"u"&&Buffer.isBuffer(r))return et(r);if(typeof r=="string")return tt(r);throw h.business("Invalid input for MD5 calculation")}var X=x(()=>{"use strict";w()});function Fe(r){return it.test(r)}var rt,it,Pe=x(()=>{"use strict";rt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],it=new RegExp(rt.join("|"))});function Le(r,i){if(!r||r.length===0)return[];if(!i?.allowUnbuilt&&r.find(a=>a&&G(a)))throw h.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return r.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(Fe(p))return!1;for(let f of a)if(f!==".well-known"&&(f.startsWith(".")||f.length>255))return!1;let d=a.slice(0,-1);for(let f of d)if(st.some(g=>f.toLowerCase()===g.toLowerCase()))return!1;return!0})}var st,ee=x(()=>{"use strict";Pe();w();st=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Y(r){return r.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ce=x(()=>{"use strict"});function Ne(r,i={}){if(i.flatten===!1)return r.map(a=>({path:Y(a),name:te(a)}));let e=ot(r);return r.map(a=>{let p=Y(a);if(e){let d=e.endsWith("/")?e:`${e}/`;p.startsWith(d)&&(p=p.substring(d.length))}return p||(p=te(a)),{path:p,name:te(a)}})}function ot(r){if(!r.length)return"";let e=r.map(d=>Y(d)).map(d=>d.split("/")),a=[],p=Math.min(...e.map(d=>d.length));for(let d=0;d<p-1;d++){let f=e[0][d];if(e.every(g=>g[d]===f))a.push(f);else break}return a.join("/")}function te(r){return r.split(/[/\\]/).pop()||r}var ne=x(()=>{"use strict";Ce()});function pn(r){re=r}function at(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function Oe(){return re||at()}var re,ie=x(()=>{"use strict";re=null});function se(r,i=1){if(r===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(r)/Math.log(e));return parseFloat((r/Math.pow(e,p)).toFixed(i))+" "+a[p]}function oe(r){if(fe(r))return{valid:!1,reason:"File name contains unsafe characters"};if(r.startsWith(" ")||r.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(r.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let i=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=r.split("/").pop()||r;return i.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:r.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function dn(r,i){let e=[],a=[],p=[];if(r.length===0){let c={file:"(no files)",message:"At least one file must be provided"};return e.push(c),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let c of r)if(G(c.name))return e.push({file:c.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:r.map(m=>({...m,status:T.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(r.length>i.maxFilesCount){let c={file:`(${r.length} files)`,message:`File count (${r.length}) exceeds limit of ${i.maxFilesCount}`};return e.push(c),{files:r.map(m=>({...m,status:T.VALIDATION_FAILED,statusMessage:c.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let d=0;for(let c of r){let m=T.READY,y="Ready for upload",D=c.name?oe(c.name):{valid:!1,reason:"File name cannot be empty"};if(c.status===T.PROCESSING_ERROR)m=T.VALIDATION_FAILED,y=c.statusMessage||"File failed during processing",e.push({file:c.name,message:y});else if(c.size===0){m=T.EXCLUDED,y="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:c.name,message:y}),p.push({...c,status:m,statusMessage:y});continue}else c.size<0?(m=T.VALIDATION_FAILED,y="File size must be positive",e.push({file:c.name,message:y})):!c.name||c.name.trim().length===0?(m=T.VALIDATION_FAILED,y="File name cannot be empty",e.push({file:c.name||"(empty)",message:y})):c.name.includes("\0")?(m=T.VALIDATION_FAILED,y="File name contains invalid characters (null byte)",e.push({file:c.name,message:y})):D.valid?k(c.name)?(m=T.VALIDATION_FAILED,y=`File extension not allowed: "${c.name}"`,e.push({file:c.name,message:y})):c.size>i.maxFileSize?(m=T.VALIDATION_FAILED,y=`File size (${se(c.size)}) exceeds limit of ${se(i.maxFileSize)}`,e.push({file:c.name,message:y})):(d+=c.size,d>i.maxTotalSize&&(m=T.VALIDATION_FAILED,y=`Total size would exceed limit of ${se(i.maxTotalSize)}`,e.push({file:c.name,message:y}))):(m=T.VALIDATION_FAILED,y=D.reason||"Invalid file name",e.push({file:c.name,message:y}));p.push({...c,status:m,statusMessage:y})}e.length>0&&(p=p.map(c=>c.status===T.EXCLUDED?c:{...c,status:T.VALIDATION_FAILED,statusMessage:c.status===T.VALIDATION_FAILED?c.statusMessage:"Deployment failed due to validation errors in bundle"}));let f=e.length===0?p.filter(c=>c.status===T.READY):[],g=e.length===0;return{files:p,validFiles:f,errors:e,warnings:a,canDeploy:g}}function lt(r){return r.filter(i=>i.status===T.READY)}function fn(r){return lt(r).length>0}var ae=x(()=>{"use strict";w()});function $e(r,i){if(r.includes("\0")||r.includes("/../")||r.startsWith("../")||r.endsWith("/.."))throw h.business(`Security error: Unsafe file path "${r}" for file: ${i}`)}function _e(r,i){let e=oe(r);if(!e.valid)throw h.business(e.reason||"Invalid file name");if(k(r))throw h.business(`File extension not allowed: "${i}"`)}var le=x(()=>{"use strict";w();ae()});var Be={};qe(Be,{processFilesForBrowser:()=>Ue});async function Ue(r,i={},e){if(Oe()!=="browser")throw h.business("processFilesForBrowser can only be called in a browser environment.");let a=r.map(D=>D.webkitRelativePath||D.name),p=i.build||i.prerender,d=Ne(a,{flatten:i.pathDetect!==!1}),f=d.map(D=>D.path),g=new Set(Le(f,{allowUnbuilt:p})),c=[];for(let D=0;D<r.length;D++)g.has(f[D])&&c.push({file:r[D],deployPath:d[D].path});if(c.length===0)return[];if(p){let D=[];for(let b=0;b<c.length;b++){let{file:R,deployPath:O}=c[b];if(R.size===0)continue;let{md5:N}=await _(R);D.push({path:O,content:R,size:R.size,md5:N})}return D}if(!e)throw h.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let m=[],y=0;for(let D=0;D<c.length;D++){let{file:b,deployPath:R}=c[D];if($e(R,b.name),b.size===0)continue;if(_e(R,b.name),b.size>e.maxFileSize)throw h.business(`File ${b.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(y+=b.size,y>e.maxTotalSize)throw h.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:O}=await _(b);m.push({path:R,content:b,size:b.size,md5:O})}if(m.length>e.maxFilesCount)throw h.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return m}var pe=x(()=>{"use strict";X();w();ie();ee();ne();le()});w();w();var q=class{constructor(){this.handlers=new Map}on(i,e){this.handlers.has(i)||this.handlers.set(i,new Set),this.handlers.get(i).add(e)}off(i,e){let a=this.handlers.get(i);a&&(a.delete(e),a.size===0&&this.handlers.delete(i))}emit(i,...e){let a=this.handlers.get(i);if(!a)return;let p=Array.from(a);for(let d of p)try{d(...e)}catch(f){a.delete(d),i!=="error"&&setTimeout(()=>{let g=f instanceof Error?f:new Error(String(f));this.emit("error",g,String(i))},0)}}};w();w();function $(r){if(r==null)return;if(r.length===0)return r;if(r.length>C.MAX_COUNT)throw h.validation(`Maximum ${C.MAX_COUNT} labels allowed`);let i=r.map((a,p)=>{if(typeof a!="string")throw h.validation(`Label at index ${p} must be a string`);let d=a.trim().toLowerCase();if(d.length<C.MIN_LENGTH)throw h.validation(`Labels must be at least ${C.MIN_LENGTH} characters long`);if(d.length>C.MAX_LENGTH)throw h.validation(`Labels must be no more than ${C.MAX_LENGTH} characters long`);if(!ye.test(d))throw h.validation(`Labels must start and end with alphanumeric characters, with optional separators (${C.SEPARATORS}) between segments`);return d}),e=[...new Set(i)];if(e.length!==i.length)throw h.validation("Duplicate labels are not allowed");return e}var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},Qe=3e4,V=class extends q{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||K,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??Qe,this.fetch=e.fetch??globalThis.fetch,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||S.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p){let d=this.mergeHeaders(a.headers),{signal:f,cleanup:g}=this.createTimeoutSignal(a.signal),c={...a,headers:d,credentials:this.useCredentials&&!d.Authorization?"include":void 0,signal:f};this.emit("request",e,c);try{let m=await this.fetch(e,c);if(g(),!m.ok)throw await h.fromHttpResponse(m,p);return this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(m){g();let y=h.fromFetchError(m,p);throw this.emit("error",y,e),y}}async request(e,a,p){let{data:d}=await this.executeRequest(e,a,p);return d}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let a=new AbortController,p=setTimeout(()=>a.abort(),this.timeout);if(e){let d=()=>a.abort();e.addEventListener("abort",d),e.aborted&&a.abort()}return{signal:a.signal,cleanup:()=>clearTimeout(p)}}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 h.business("No files to deploy");for(let m of e)if(!m.md5)throw h.file(`MD5 checksum missing for file: ${m.path}`,{filePath:m.path});Z(a.password);let p=$(a.labels),d=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:f,headers:g}=await this.createDeployBody(e,{labels:p,via:a.via,password:a.password,flags:d}),c={};return a.deployToken?c.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(c.Authorization=`Bearer ${a.apiKey}`),a.caller&&(c["X-Caller"]=a.caller),this.request(`${a.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:f,headers:{...g,...c},signal:a.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=$(a);return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,p){let d=$(p),f={};a&&(f.deployment=a),d!==void 0&&(f.labels=d);let{data:g,status:c}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...g,isCreate:c===201}}async listDomains(){return this.request(`${this.apiUrl}${S.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${S.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=$(a),d={};return e!==void 0&&(d.ttl=e),p!==void 0&&(d.labels=p),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${S.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${S.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${S.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${S.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let p=e.find(m=>m.path==="index.html"||m.path==="/index.html");if(!p||p.size>100*1024)return!1;let d;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))d=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)d=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)d=await p.content.text();else return!1;let f={"Content-Type":"application/json"};a.deployToken?f.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(f.Authorization=`Bearer ${a.apiKey}`);let g={files:e.map(m=>m.path),index:d};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:f,body:JSON.stringify(g)},"SPA check")).isSPA}};w();function ge(r={}){let i={apiUrl:r.apiUrl||K};return r.apiKey!==void 0&&(i.apiKey=r.apiKey),r.deployToken!==void 0&&(i.deployToken=r.deployToken),i}function Ae(r,i){let e={...r};return e.apiUrl===void 0&&i.apiUrl!==void 0&&(e.apiUrl=i.apiUrl),e.apiKey===void 0&&i.apiKey!==void 0&&(e.apiKey=i.apiKey),e.deployToken===void 0&&i.deployToken!==void 0&&(e.deployToken=i.deployToken),e.timeout===void 0&&i.timeout!==void 0&&(e.timeout=i.timeout),e.maxConcurrency===void 0&&i.maxConcurrency!==void 0&&(e.maxConcurrency=i.maxConcurrency),e.onProgress===void 0&&i.onProgress!==void 0&&(e.onProgress=i.onProgress),e.caller===void 0&&i.caller!==void 0&&(e.caller=i.caller),e}w();w();X();async function nt(){let r=JSON.stringify(he,null,2),i;typeof Buffer<"u"?i=Buffer.from(r,"utf-8"):i=new Blob([r],{type:"application/json"});let{md5:e}=await _(i);return{path:Q,content:i,size:r.length,md5:e}}async function be(r,i,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||r.some(a=>a.path===Q))return r;try{if(await i.checkSPA(r,e)){let p=await nt();return[...r,p]}}catch{}return r}function we(r){let{getApi:i,ensureInit:e,processInput:a,clientDefaults:p,hasAuth:d}=r;return{upload:async(f,g={})=>{await e();let c=p?Ae(g,p):g;if(d&&!d()&&!c.deployToken&&!c.apiKey)try{let D=i(),{secret:b}=await D.fetchAgentToken();c.deployToken=b}catch(D){throw z(D)&&D.type===A.RateLimit?h.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):D}if(!a)throw h.config("processInput function is not provided.");let m=i(),y=await a(f,c);return y=await be(y,m,c),m.deploy(y,c)},list:async()=>(await e(),i().listDeployments()),get:async f=>(await e(),i().getDeployment(f)),set:async(f,g)=>(await e(),i().updateDeploymentLabels(f,g.labels)),remove:async f=>{await e(),await i().removeDeployment(f)}}}function ve(r){let{getApi:i,ensureInit:e}=r;return{set:async(a,p={})=>(await e(),i().setDomain(a,p.deployment,p.labels)),list:async()=>(await e(),i().listDomains()),get:async a=>(await e(),i().getDomain(a)),remove:async a=>{await e(),await i().removeDomain(a)},verify:async a=>(await e(),i().verifyDomain(a)),validate:async a=>(await e(),i().validateDomain(a)),dns:async a=>(await e(),i().getDomainDns(a)),records:async a=>(await e(),i().getDomainRecords(a)),share:async a=>(await e(),i().getDomainShare(a))}}function Re(r){let{getApi:i,ensureInit:e}=r;return{get:async()=>(await e(),i().getAccount())}}function xe(r){let{getApi:i,ensureInit:e}=r;return{create:async(a={})=>(await e(),i().createToken(a.ttl,a.labels)),list:async()=>(await e(),i().listTokens()),remove:async a=>{await e(),await i().removeToken(a)}}}var W=class{constructor(i={}){this.initPromise=null;this.platformLimits=null;this.auth=null;i={...i,apiUrl:i.apiUrl||void 0,apiKey:i.apiKey||void 0,deployToken:i.deployToken||void 0},this.clientOptions=i,i.deployToken?this.auth={type:"token",value:i.deployToken}:i.apiKey&&(this.auth={type:"apiKey",value:i.apiKey}),this.http=new V({...i,...ge(i),getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=we({...e,processInput:(a,p)=>this.processInput(a,p),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this.domains=ve(e),this.account=Re(e),this.tokens=xe(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(i){throw this.initPromise=null,i}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(i,e){return this.deployments.upload(i,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(i,e){this.http.on(i,e)}off(i,e){this.http.off(i,e)}setHeaders(i){this.http.setGlobalHeaders(i)}clearHeaders(){this.http.setGlobalHeaders({})}setDeployToken(i){if(!i||typeof i!="string")throw h.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:i}}setApiKey(i){if(!i||typeof i!="string")throw h.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:i}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};w();w();async function Ie(r,i={}){let{labels:e,via:a,password:p,flags:d}=i,f=new FormData,g=[];for(let c of r){if(!(c.content instanceof File||c.content instanceof Blob))throw h.file(`Unsupported file.content type for browser: ${c.path}`,{filePath:c.path});if(!c.md5)throw h.file(`File missing md5 checksum: ${c.path}`,{filePath:c.path});let m=new File([c.content],c.path,{type:"application/octet-stream"});f.append("files[]",m),g.push(c.md5)}return f.append("checksums",JSON.stringify(g)),e&&e.length>0&&f.append("labels",JSON.stringify(e)),a&&f.append("via",a),p&&f.append("password",p),d?.build&&f.append("build","true"),d?.prerender&&f.append("prerender","true"),d?.spa&&f.append("spa","true"),{body:f,headers:{}}}X();function Zt(r,i,e,a=!0){let p=r===1?i:e;return a?`${r} ${p}`:p}ee();ne();ie();ae();le();w();pe();var ue=class extends W{async deploy(i,e){return super.deploy(i,e)}async processInput(i,e){if(!Array.isArray(i)||!i.every(p=>p instanceof File))throw h.business("Invalid input type for browser environment. Expected File[].");if(i.length===0)throw h.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(pe(),Be));return a(i,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Ie}},zn=ue;export{F as API_KEY,dt as AccountPlan,V as ApiHttp,ft as AuthMethod,We as BLOCKED_EXTENSIONS,K as DEFAULT_API,Q as DEPLOYMENT_CONFIG_FILENAME,P as DEPLOY_TOKEN,ut as DeploymentStatus,ct as DomainStatus,A as ErrorType,T as FILE_VALIDATION_STATUS,T as FileValidationStatus,st as JUNK_DIRECTORIES,C as LABEL_CONSTRAINTS,ye as LABEL_PATTERN,H as PASSWORD_CONSTRAINTS,he as SPA_DEFAULT_CONFIG,ue as Ship,h as ShipError,Je as UNBUILT_PROJECT_MARKERS,Ye as UNSAFE_FILENAME_CHARS,pn as __setTestEnvironment,fn as allValidFilesReady,_ as calculateMD5,Re as createAccountResource,we as createDeploymentResource,ve as createDomainResource,xe as createTokenResource,zn as default,bt as deserializeLabels,Dt as extractSubdomain,Le as filterJunk,se as formatFileSize,Et as generateDeploymentUrl,St as generateDomainUrl,Oe as getENV,lt as getValidFiles,G as hasUnbuiltMarker,fe as hasUnsafeChars,k as isBlockedExtension,At as isCustomDomain,gt as isDeployment,me as isPlatformDomain,z as isShipError,Ae as mergeDeployOptions,Ne as optimizeDeployPaths,Zt as pluralize,Ue as processFilesForBrowser,ge as resolveConfig,Tt as serializeLabels,ht as validateApiKey,yt as validateApiUrl,_e as validateDeployFile,$e as validateDeployPath,mt as validateDeployToken,oe as validateFileName,dn as validateFiles,Z as validatePassword};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|