@shipstatic/ship 0.9.4 → 0.9.6
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 +41 -17
- package/SKILL.md +19 -2
- package/dist/browser.d.ts +8 -3
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +10 -10
- 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 +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
CLI and SDK for [ShipStatic](https://shipstatic.com) — deploy static websites, landing pages, and prototypes instantly from the terminal or code.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Deploy in seconds — no install, no account
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npx @shipstatic/ship ./dist
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Deploy — Free, No Account Needed
|
|
11
|
+
That's it. Your site is live on `*.shipstatic.com`. No sign-up, no config, no global install. Got Node? You're ready.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
ship ./dist
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Your site is live instantly on `*.shipstatic.com`. No API key, no sign-up, no configuration.
|
|
20
|
-
|
|
21
|
-
Deployments without an API key are public and expire in 3 days. The output includes a **claim URL** — visit it to keep the site permanently.
|
|
13
|
+
The output includes a **claim URL** — visit it to keep the site permanently. Anonymous deployments are public and expire in 3 days.
|
|
22
14
|
|
|
23
15
|
```javascript
|
|
24
16
|
import Ship from '@shipstatic/ship';
|
|
@@ -29,6 +21,16 @@ const result = await ship.deploy('./dist');
|
|
|
29
21
|
// result.claim → visit to keep permanently
|
|
30
22
|
```
|
|
31
23
|
|
|
24
|
+
## Install (optional, for repeat use)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g @shipstatic/ship # global CLI — drop the `npx @shipstatic/ship` prefix
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
> As a project dependency: `npm install @shipstatic/ship`
|
|
31
|
+
>
|
|
32
|
+
> Every example in this README uses the bare `ship` command. If you haven't installed it globally, prefix any of them with `npx @shipstatic/ship` (or `npx -y @shipstatic/ship` in non-interactive environments).
|
|
33
|
+
|
|
32
34
|
## All Commands — Free API Key
|
|
33
35
|
|
|
34
36
|
For permanent deployments and full control over your sites and domains, get a free API key from [my.shipstatic.com/api-key](https://my.shipstatic.com/api-key).
|
|
@@ -152,20 +154,40 @@ ship completion uninstall
|
|
|
152
154
|
|
|
153
155
|
### Global Flags
|
|
154
156
|
|
|
157
|
+
Available on every command:
|
|
158
|
+
|
|
155
159
|
| Flag | Description |
|
|
156
160
|
|------|-------------|
|
|
157
161
|
| `--api-key <key>` | API key for authenticated requests |
|
|
158
162
|
| `--deploy-token <token>` | Deploy token for single-use deployments |
|
|
163
|
+
| `--api-url <url>` | API URL override (for development) |
|
|
159
164
|
| `--config <file>` | Custom config file path |
|
|
160
|
-
| `--label <label>` | Add label (repeatable) |
|
|
161
|
-
| `--password <password>` | Password-protect this deployment |
|
|
162
|
-
| `--no-path-detect` | Disable automatic path optimization |
|
|
163
|
-
| `--no-spa-detect` | Disable automatic SPA detection |
|
|
164
|
-
| `--no-color` | Disable colored output |
|
|
165
165
|
| `--json` | Output results in JSON format |
|
|
166
166
|
| `-q, --quiet` | Output only the resource identifier |
|
|
167
|
+
| `--no-color` | Disable colored output |
|
|
168
|
+
| `--help` | Display help for command |
|
|
167
169
|
| `--version` | Show version information |
|
|
168
170
|
|
|
171
|
+
### Deploy Flags
|
|
172
|
+
|
|
173
|
+
Available on `ship <path>` and `ship deployments upload`:
|
|
174
|
+
|
|
175
|
+
| Flag | Description |
|
|
176
|
+
|------|-------------|
|
|
177
|
+
| `--label <label>` | Add label (repeatable) |
|
|
178
|
+
| `--password <password>` | Password-protect this deployment (6–128 chars) |
|
|
179
|
+
| `--no-path-detect` | Disable automatic path optimization |
|
|
180
|
+
| `--no-spa-detect` | Disable automatic SPA detection |
|
|
181
|
+
|
|
182
|
+
### CLI Environment Variables
|
|
183
|
+
|
|
184
|
+
| Var | Purpose |
|
|
185
|
+
|---|---|
|
|
186
|
+
| `SHIP_API_KEY` | Default for `--api-key` |
|
|
187
|
+
| `SHIP_DEPLOY_TOKEN` | Default for `--deploy-token` |
|
|
188
|
+
| `SHIP_API_URL` | Default for `--api-url` |
|
|
189
|
+
| `SHIP_PASSWORD` | Default for `--password` (empty string normalized to absence) |
|
|
190
|
+
|
|
169
191
|
## SDK Reference
|
|
170
192
|
|
|
171
193
|
### Authentication
|
|
@@ -193,11 +215,13 @@ ship.deploy(input, {
|
|
|
193
215
|
password?: string, // Password-protect the deployment (6–128 chars)
|
|
194
216
|
onProgress?: ({ percent }) => void,
|
|
195
217
|
signal?: AbortSignal,
|
|
218
|
+
onCancel?: () => void, // Called if signal aborts
|
|
196
219
|
pathDetect?: boolean, // Auto-optimize paths (default: true)
|
|
197
220
|
spaDetect?: boolean, // Auto-detect SPA (default: true)
|
|
198
221
|
maxConcurrency?: number, // Concurrent uploads (default: 4)
|
|
199
222
|
timeout?: number, // Request timeout in ms
|
|
200
223
|
via?: string, // Client identifier
|
|
224
|
+
apiUrl?: string, // Per-request API URL override
|
|
201
225
|
apiKey?: string, // Per-request API key override
|
|
202
226
|
deployToken?: string, // Per-request deploy token override
|
|
203
227
|
});
|
package/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ship
|
|
3
3
|
description: "Deploy static websites to ShipStatic. Use when the user wants to deploy a site, publish a website, upload to hosting, go live, set up a custom domain, manage deployments, or share a site URL. No account required — instant deployment. CLI (`ship`) and Node.js/browser SDK."
|
|
4
|
-
compatibility: "Node.js >= 20.
|
|
4
|
+
compatibility: "Node.js >= 20. Run via npx (no install) or install globally: npm install -g @shipstatic/ship"
|
|
5
5
|
metadata:
|
|
6
6
|
openclaw:
|
|
7
7
|
requires:
|
|
@@ -17,6 +17,18 @@ metadata:
|
|
|
17
17
|
|
|
18
18
|
Deploy static sites. No account, no config — just ship it.
|
|
19
19
|
|
|
20
|
+
## No-install usage (recommended for agents)
|
|
21
|
+
|
|
22
|
+
You don't need to install anything. Run any command via `npx`:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx -y @shipstatic/ship ./dist # deploy (shortcut)
|
|
26
|
+
npx -y @shipstatic/ship deployments list # any subcommand works the same
|
|
27
|
+
npx -y @shipstatic/ship domains set www.example.com # ...
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`-y` skips the install prompt — important for non-interactive runtimes (CI, sandboxes, agent containers). Every example below uses the bare `ship` command for readability; substitute `npx -y @shipstatic/ship` if it isn't installed globally.
|
|
31
|
+
|
|
20
32
|
## Deploy
|
|
21
33
|
|
|
22
34
|
```bash
|
|
@@ -40,10 +52,12 @@ ship ./dist --json
|
|
|
40
52
|
```json
|
|
41
53
|
{
|
|
42
54
|
"deployment": "happy-cat-abc1234.shipstatic.com",
|
|
55
|
+
"url": "https://happy-cat-abc1234.shipstatic.com",
|
|
43
56
|
"files": 12,
|
|
44
57
|
"size": 348160,
|
|
45
58
|
"status": "success",
|
|
46
59
|
"config": false,
|
|
60
|
+
"password": false,
|
|
47
61
|
"labels": [],
|
|
48
62
|
"via": "cli",
|
|
49
63
|
"created": 1743552000,
|
|
@@ -52,7 +66,7 @@ ship ./dist --json
|
|
|
52
66
|
}
|
|
53
67
|
```
|
|
54
68
|
|
|
55
|
-
`claim`
|
|
69
|
+
`claim` only appears on the initial deploy without credentials. `expires` is `null` for authenticated (permanent) deploys. `config: true` indicates a `ship.json` is present in the deployment; `password: true` indicates the deployment is password-protected.
|
|
56
70
|
|
|
57
71
|
### Piping
|
|
58
72
|
|
|
@@ -156,6 +170,7 @@ ship domains set www.example.com <dep> --json
|
|
|
156
170
|
```json
|
|
157
171
|
{
|
|
158
172
|
"domain": "www.example.com",
|
|
173
|
+
"url": "https://www.example.com",
|
|
159
174
|
"deployment": "happy-cat-abc1234.shipstatic.com",
|
|
160
175
|
"status": "pending",
|
|
161
176
|
"labels": [],
|
|
@@ -274,5 +289,7 @@ ship tokens remove <token> # Revoke
|
|
|
274
289
|
| `not found` | No such resource | Verify the ID/name |
|
|
275
290
|
| `path does not exist` | Bad deploy path | Check file/directory |
|
|
276
291
|
| `invalid domain name` | Not a subdomain | Use `www.example.com`, not `example.com` |
|
|
292
|
+
| `<resource> limit reached` | Plan caps hit (deployments, domains) | Suggest upgrading the plan; do not retry |
|
|
293
|
+
| `Account has been deleted` / `Account terminated` | Account is gone | Stop; the account cannot deploy |
|
|
277
294
|
| `DNS information is only available for external domains` | DNS op on internal domain | Only custom domains need DNS |
|
|
278
295
|
| `DNS verification already requested recently` | Rate limited | Wait |
|
package/dist/browser.d.ts
CHANGED
|
@@ -119,9 +119,14 @@ interface ShipClientOptions {
|
|
|
119
119
|
* Used by orchestrators (e.g. n8n nodes processing many tenants from one
|
|
120
120
|
* worker) so the API's rate-limit bucket keys per caller rather than per
|
|
121
121
|
* shared IP. **Programmatic-only by design** — there is no `--caller`
|
|
122
|
-
* CLI flag because
|
|
123
|
-
*
|
|
124
|
-
*
|
|
122
|
+
* CLI flag because every CLI invocation belongs to one human; a per-tenant
|
|
123
|
+
* rate-limit bucket would defeat the purpose.
|
|
124
|
+
*
|
|
125
|
+
* Distinct from `via` (the client identifier — `'cli'`, `'sdk'`, `'web'`,
|
|
126
|
+
* `'git'`, etc.). `via` is for analytics/origin tracking and is
|
|
127
|
+
* env-overridable via `SHIP_VIA` for integrations that wrap the CLI
|
|
128
|
+
* (GitHub Action, MCP). `caller` is for rate-limit isolation and stays
|
|
129
|
+
* programmatic-only.
|
|
125
130
|
*/
|
|
126
131
|
caller?: string | undefined;
|
|
127
132
|
/**
|
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 Y=(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 Xe.has(e)}function fe(r){return We.test(r)}function H(r){return r.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Je.has(e))}function dt(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 ft(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 ht(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 mt(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 yt(r,i){return!me(r,i)}function gt(r,i){return me(r,i)?r.slice(0,-(i.length+1)):null}function At(r){return`https://${r}`}function Dt(r){return`https://${r}`}function Et(r){return!r||r.length===0?null:JSON.stringify(r)}function St(r){if(!r)return[];try{let i=JSON.parse(r);return Array.isArray(i)?i:[]}catch{return[]}}var lt,pt,ut,D,Q,je,h,Xe,We,Je,F,P,ct,Z,he,G,T,C,ye,$,v=x(()=>{"use strict";lt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},pt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},ut={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},D={Validation:"validation_failed",NotFound:"not_found",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"},Q={client:new Set([D.Business,D.Config,D.File,D.Validation]),network:new Set([D.Network]),auth:new Set([D.Authentication])},je=new Set(Object.values(D).filter(r=>r!==D.Network&&r!==D.Cancelled)),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.type===D.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:e}}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"&&je.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===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 rateLimit(e="Too many requests"){return new r(D.RateLimit,e,429)}static authentication(e="Authentication required",a){return new r(D.Authentication,e,401,a)}static business(e,a=400){return new r(D.Business,e,a)}static network(e,a){return new r(D.Network,e,void 0,a)}static cancelled(e){return new r(D.Cancelled,e)}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){return new r(D.Api,e,a)}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}};Xe=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"]);We=/[\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},ct={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",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]+)*$/;$={MIN_LENGTH:6,MAX_LENGTH:128}});function Nt(r){ee=r}function Qe(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function q(){return ee||Qe()}var ee,j=x(()=>{"use strict";ee=null});var Te=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 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(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=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 te=de(($t,be)=>{"use strict";be.exports={}});async function Ze(r){let i=(await Promise.resolve().then(()=>Y(Te(),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 et(r){let i=await Promise.resolve().then(()=>Y(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(()=>Y(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 Ze(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 et(r)}throw h.business("Unknown or unsupported execution environment for MD5 calculation.")}var X=x(()=>{"use strict";j();v()});function Pe(r){return rt.test(r)}var nt,rt,Le=x(()=>{"use strict";nt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],rt=new RegExp(nt.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(it.some(g=>f.toLowerCase()===g.toLowerCase()))return!1;return!0})}var it,ne=x(()=>{"use strict";Le();v();it=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function J(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:J(a),name:re(a)}));let e=st(r);return r.map(a=>{let p=J(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 st(r){if(!r.length)return"";let e=r.map(d=>J(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 un(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: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",A=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})):A.valid?z(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=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===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 ot(r){return r.filter(i=>i.status===T.READY)}function cn(r){return ot(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 b=0;b<c.length;b++){let{file:R,deployPath:O}=c[b];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:b,deployPath:R}=c[A];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 U(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();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"},Ye=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??Ye,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 tt(){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 tt();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:b}=await A.fetchAgentToken();c.deployToken=b}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 Zt(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}},Mn=ue;export{F as API_KEY,ut as AccountPlan,V as ApiHttp,ct as AuthMethod,Xe as BLOCKED_EXTENSIONS,G as DEFAULT_API,Z as DEPLOYMENT_CONFIG_FILENAME,P as DEPLOY_TOKEN,lt as DeploymentStatus,pt as DomainStatus,D as ErrorType,T as FILE_VALIDATION_STATUS,T as FileValidationStatus,it 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,We as UNSAFE_FILENAME_CHARS,Nt as __setTestEnvironment,cn as allValidFilesReady,U as calculateMD5,xe as createAccountResource,ve as createDeploymentResource,Re as createDomainResource,Ie as createTokenResource,Mn as default,St as deserializeLabels,gt as extractSubdomain,Ce as filterJunk,se as formatFileSize,At as generateDeploymentUrl,Dt as generateDomainUrl,q as getENV,ot as getValidFiles,H as hasUnbuiltMarker,fe as hasUnsafeChars,z as isBlockedExtension,yt as isCustomDomain,mt as isDeployment,me as isPlatformDomain,k as isShipError,De as mergeDeployOptions,Oe as optimizeDeployPaths,Zt as pluralize,Ue as processFilesForBrowser,Ae as resolveConfig,Et as serializeLabels,dt as validateApiKey,ht as validateApiUrl,_e as validateDeployFile,$e as validateDeployPath,ft as validateDeployToken,oe as validateFileName,un as validateFiles};
|
|
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};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|