@shipstatic/ship 0.8.6 → 0.8.7
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 +4 -0
- package/SKILL.md +173 -98
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +23 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -329,6 +329,10 @@ import type {
|
|
|
329
329
|
} from '@shipstatic/types';
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
+
## AI Agents
|
|
333
|
+
|
|
334
|
+
This package includes a [SKILL.md](./SKILL.md) file — a portable skill definition that AI agents (Claude Code, Codex, OpenClaw, etc.) use to deploy sites with `ship` autonomously.
|
|
335
|
+
|
|
332
336
|
---
|
|
333
337
|
|
|
334
338
|
Part of the [ShipStatic](https://shipstatic.com) platform.
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ship
|
|
3
|
-
description:
|
|
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. Install globally via npm: npm install -g @shipstatic/ship"
|
|
4
5
|
metadata:
|
|
5
6
|
openclaw:
|
|
6
7
|
requires:
|
|
@@ -14,180 +15,254 @@ metadata:
|
|
|
14
15
|
bins: [ship]
|
|
15
16
|
---
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
Deploy static sites. No account, no config — just ship it.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
## Deploy
|
|
20
21
|
|
|
21
22
|
```bash
|
|
22
|
-
ship ./dist
|
|
23
|
-
ship ./dist --json # Parse: {"deployment": "...", "claim": "https://..."}
|
|
24
|
-
ship ./dist -q # Outputs only: happy-cat-abc1234.shipstatic.com
|
|
25
|
-
ship ./dist --label v1.0 --label latest # Labels (repeatable)
|
|
23
|
+
ship ./dist
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
Site is live. Output includes the URL and a claim link.
|
|
27
|
+
|
|
28
|
+
Pass a build output directory (e.g. `./dist`, `./build`, `./out`) or a single file. Ship strips the directory prefix for clean URLs — `dist/assets/app.js` serves at `/assets/app.js`. A single file keeps its name: `ship page.html` deploys as `/page.html`. Deploying a project root (contains `package.json`, `node_modules`) is rejected — build first, then deploy the output.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Without credentials, deployments are public and expire in 3 days. **Always show the user both the deployment URL and the claim link** — the claim link lets them keep the site permanently.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
The deployment ID **is** the URL hostname. Use the full ID (e.g. `happy-cat-abc1234.shipstatic.com`) as the argument to all other commands. The site lives at `https://<deployment>`.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
### Parsing output
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
ship
|
|
38
|
-
ship --api-key <key> ... # Per-command
|
|
39
|
-
export SHIP_API_KEY=<key> # Environment variable
|
|
37
|
+
ship ./dist --json
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"deployment": "happy-cat-abc1234.shipstatic.com",
|
|
43
|
+
"files": 12,
|
|
44
|
+
"size": 348160,
|
|
45
|
+
"status": "success",
|
|
46
|
+
"config": false,
|
|
47
|
+
"labels": [],
|
|
48
|
+
"via": "cli",
|
|
49
|
+
"created": 1743552000,
|
|
50
|
+
"expires": 1743811200,
|
|
51
|
+
"claim": "https://my.shipstatic.com/claim/abc123"
|
|
52
|
+
}
|
|
53
|
+
```
|
|
43
54
|
|
|
44
|
-
|
|
55
|
+
`claim` and `expires` only appear without credentials. With an API key, deployments are permanent.
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
### Piping
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| `--json` | Raw JSON on stdout | Parsing output programmatically |
|
|
52
|
-
| `-q` | Key identifier only | Piping between commands |
|
|
59
|
+
```bash
|
|
60
|
+
ship ./dist -q # → happy-cat-abc1234.shipstatic.com
|
|
61
|
+
```
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
`-q` outputs only the identifier — use it when piping or scripting.
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
### Labels
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
```bash
|
|
68
|
+
ship ./dist --label v1.0 --label production
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Labels **replace all existing**, not append. Include current labels to keep them.
|
|
72
|
+
|
|
73
|
+
### SPA routing
|
|
74
|
+
|
|
75
|
+
Ship auto-detects single-page apps from `index.html` content and configures client-side routing rewrites — all paths serve `index.html`. No action needed. Skipped if a `ship.json` config is already included in the deployment. Disable with `--no-spa-detect`.
|
|
76
|
+
|
|
77
|
+
## Authentication
|
|
78
|
+
|
|
79
|
+
Deploy works without credentials. Everything else requires an API key.
|
|
80
|
+
|
|
81
|
+
| Needs API key | No auth needed |
|
|
82
|
+
|---------------|----------------|
|
|
83
|
+
| Permanent deploys, domains, tokens, account | Deploy (public, 3-day TTL) |
|
|
59
84
|
|
|
60
85
|
```bash
|
|
61
|
-
|
|
62
|
-
ship
|
|
63
|
-
ship
|
|
64
|
-
ship ./dist --label v1.0 --label latest # Labels (repeatable, replaces all existing)
|
|
86
|
+
export SHIP_API_KEY=<key> # Environment variable (best for automation)
|
|
87
|
+
ship --api-key <key> ... # Per-command override
|
|
88
|
+
ship config # Interactive setup → ~/.shiprc (requires TTY)
|
|
65
89
|
```
|
|
66
90
|
|
|
67
|
-
|
|
91
|
+
Deploy tokens (`--deploy-token`) are single-use — consumed after one successful deploy. For CI/CD one-shot workflows.
|
|
92
|
+
|
|
93
|
+
Free API key: https://my.shipstatic.com/api-key
|
|
68
94
|
|
|
69
|
-
## Custom
|
|
95
|
+
## Custom Domains
|
|
96
|
+
|
|
97
|
+
Requires an API key. Full workflow:
|
|
70
98
|
|
|
71
99
|
```bash
|
|
72
|
-
# 1.
|
|
100
|
+
# 1. Validate
|
|
73
101
|
ship domains validate www.example.com
|
|
74
102
|
|
|
75
|
-
# 2. Deploy
|
|
103
|
+
# 2. Deploy + link in one pipe
|
|
76
104
|
ship ./dist -q | ship domains set www.example.com
|
|
77
105
|
|
|
78
|
-
# 3.
|
|
106
|
+
# 3. Show DNS records to the user
|
|
79
107
|
ship domains records www.example.com
|
|
80
108
|
|
|
81
|
-
# 4. After user configures DNS
|
|
109
|
+
# 4. After user configures DNS → verify
|
|
82
110
|
ship domains verify www.example.com
|
|
83
111
|
```
|
|
84
112
|
|
|
85
|
-
|
|
113
|
+
Step 2 auto-prints DNS records and a setup link in text mode. With `--json`, call `domains records` separately.
|
|
114
|
+
|
|
115
|
+
Verification is async — DNS propagation takes minutes to hours. Check status with `ship domains get <name> --json` and look for `"status": "success"`.
|
|
116
|
+
|
|
117
|
+
### Domain types
|
|
118
|
+
|
|
119
|
+
| Type | Example | DNS needed | Goes live |
|
|
120
|
+
|------|---------|------------|-----------|
|
|
121
|
+
| Internal | `my-site.shipstatic.com` | No | Instantly |
|
|
122
|
+
| Custom | `www.example.com` | CNAME + A | After DNS verified |
|
|
123
|
+
|
|
124
|
+
**No apex domains.** Always `www.example.com`, not `example.com`. The A record only redirects apex to www.
|
|
125
|
+
|
|
126
|
+
### Upsert operations
|
|
127
|
+
|
|
128
|
+
`domains set` creates if new, updates if exists:
|
|
86
129
|
|
|
87
|
-
Additional setup helpers (external domains only):
|
|
88
130
|
```bash
|
|
89
|
-
ship domains
|
|
90
|
-
ship domains
|
|
131
|
+
ship domains set www.example.com # Reserve (no deployment yet)
|
|
132
|
+
ship domains set www.example.com <deployment> # Link to deployment
|
|
133
|
+
ship domains set www.example.com <other-dep> # Switch (instant rollback)
|
|
134
|
+
ship domains set www.example.com --label prod # Update labels
|
|
91
135
|
```
|
|
92
136
|
|
|
93
|
-
|
|
137
|
+
Reads deployment from stdin when piped: `ship ./dist -q | ship domains set www.example.com`
|
|
94
138
|
|
|
95
|
-
|
|
96
|
-
|------|---------|-------------|--------|
|
|
97
|
-
| Internal subdomain | `my-site.shipstatic.com` | No | Instant (`success`) |
|
|
98
|
-
| Custom subdomain | `www.example.com` | Yes (CNAME + A) | Starts `pending` until DNS verified |
|
|
139
|
+
**No unlinking.** Once linked, switch deployments or delete the domain. Setting deployment to null returns 400.
|
|
99
140
|
|
|
100
|
-
|
|
141
|
+
### Parsing domain output
|
|
101
142
|
|
|
102
|
-
|
|
143
|
+
```bash
|
|
144
|
+
ship domains set www.example.com <dep> --json
|
|
145
|
+
```
|
|
103
146
|
|
|
104
|
-
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"domain": "www.example.com",
|
|
150
|
+
"deployment": "happy-cat-abc1234.shipstatic.com",
|
|
151
|
+
"status": "pending",
|
|
152
|
+
"labels": [],
|
|
153
|
+
"created": 1743552000,
|
|
154
|
+
"linked": 1743552000,
|
|
155
|
+
"links": 1
|
|
156
|
+
}
|
|
157
|
+
```
|
|
105
158
|
|
|
106
159
|
```bash
|
|
107
|
-
ship domains
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
160
|
+
ship domains records www.example.com --json
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"domain": "www.example.com",
|
|
166
|
+
"apex": "example.com",
|
|
167
|
+
"records": [
|
|
168
|
+
{"type": "A", "name": "@", "value": "76.76.21.21"},
|
|
169
|
+
{"type": "CNAME", "name": "www", "value": "cname.shipstatic.com"}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
111
172
|
```
|
|
112
173
|
|
|
113
|
-
|
|
174
|
+
### DNS helpers (custom domains only)
|
|
175
|
+
|
|
114
176
|
```bash
|
|
115
|
-
ship
|
|
177
|
+
ship domains dns www.example.com # Provider name
|
|
178
|
+
ship domains share www.example.com # Shareable setup link
|
|
179
|
+
ship domains records www.example.com -q # TYPE NAME VALUE (one per line)
|
|
116
180
|
```
|
|
117
181
|
|
|
118
|
-
|
|
182
|
+
### Validation
|
|
183
|
+
|
|
184
|
+
Exit codes as the answer:
|
|
185
|
+
|
|
119
186
|
```bash
|
|
120
187
|
ship domains validate www.example.com -q && echo "valid" || echo "invalid"
|
|
121
|
-
# valid → exit 0, outputs normalized name
|
|
122
|
-
# invalid → exit 1, no output
|
|
123
188
|
```
|
|
124
189
|
|
|
125
|
-
|
|
190
|
+
Exit 0 = valid (outputs normalized name). Exit 1 = invalid (no output).
|
|
191
|
+
|
|
192
|
+
## Output Modes
|
|
193
|
+
|
|
194
|
+
Every command supports three modes:
|
|
195
|
+
|
|
196
|
+
| Flag | Output | When to use |
|
|
197
|
+
|------|--------|-------------|
|
|
198
|
+
| *(default)* | Human-readable | Showing results to the user |
|
|
199
|
+
| `--json` | JSON on stdout | Parsing programmatically |
|
|
200
|
+
| `-q` | Identifier only | Piping between commands |
|
|
201
|
+
|
|
202
|
+
Errors go to stderr in all modes. Exit 0 = success, 1 = error.
|
|
126
203
|
|
|
127
|
-
|
|
128
|
-
- **`records` quiet mode** outputs one record per line, space-separated: `TYPE NAME VALUE`. Parseable with awk: `ship domains records <name> -q | awk '{print $3}'` extracts values.
|
|
129
|
-
- **`domains list` text mode** does not show domain status. Use `--json` to see which domains are `pending` vs `success`.
|
|
204
|
+
List commands return `{"<resource>s": [...], "cursor": null, "total": N}`. `domains list` text mode omits status — use `--json` to see `pending` vs `success`.
|
|
130
205
|
|
|
131
|
-
##
|
|
206
|
+
## Commands
|
|
132
207
|
|
|
133
208
|
### Deployments
|
|
134
209
|
|
|
135
210
|
```bash
|
|
136
|
-
ship ./dist #
|
|
137
|
-
ship deployments upload <path> #
|
|
138
|
-
ship deployments list # List all
|
|
139
|
-
ship deployments get <deployment> #
|
|
211
|
+
ship ./dist # Deploy (shortcut)
|
|
212
|
+
ship deployments upload <path> # Deploy (explicit)
|
|
213
|
+
ship deployments list # List all
|
|
214
|
+
ship deployments get <deployment> # Details
|
|
140
215
|
ship deployments set <deployment> # Update labels (--label)
|
|
141
|
-
ship deployments remove <deployment> # Delete
|
|
216
|
+
ship deployments remove <deployment> # Delete (async)
|
|
142
217
|
```
|
|
143
218
|
|
|
144
219
|
### Domains
|
|
145
220
|
|
|
146
221
|
```bash
|
|
147
|
-
ship domains list # List all
|
|
148
|
-
ship domains get <name> #
|
|
149
|
-
ship domains set <name> [deployment] # Create, link, or update
|
|
150
|
-
ship domains validate <name> #
|
|
151
|
-
ship domains records <name> # Required DNS records
|
|
152
|
-
ship domains dns <name> # DNS provider lookup
|
|
153
|
-
ship domains share <name> # Shareable setup link
|
|
154
|
-
ship domains verify <name> # Trigger DNS verification
|
|
155
|
-
ship domains remove <name> # Delete
|
|
222
|
+
ship domains list # List all
|
|
223
|
+
ship domains get <name> # Details
|
|
224
|
+
ship domains set <name> [deployment] # Create, link, or update
|
|
225
|
+
ship domains validate <name> # Check validity (exit code)
|
|
226
|
+
ship domains records <name> # Required DNS records
|
|
227
|
+
ship domains dns <name> # DNS provider lookup
|
|
228
|
+
ship domains share <name> # Shareable setup link
|
|
229
|
+
ship domains verify <name> # Trigger DNS verification
|
|
230
|
+
ship domains remove <name> # Delete
|
|
156
231
|
```
|
|
157
232
|
|
|
158
233
|
### Account & Tokens
|
|
159
234
|
|
|
160
235
|
```bash
|
|
161
236
|
ship whoami # Account info
|
|
162
|
-
ship ping #
|
|
163
|
-
ship tokens create #
|
|
237
|
+
ship ping # Connectivity check
|
|
238
|
+
ship tokens create # New deploy token (shown once)
|
|
164
239
|
ship tokens create --ttl 3600 # With expiry (seconds)
|
|
165
|
-
ship tokens list # List tokens
|
|
166
|
-
ship tokens remove <token> #
|
|
240
|
+
ship tokens list # List tokens
|
|
241
|
+
ship tokens remove <token> # Revoke
|
|
167
242
|
```
|
|
168
243
|
|
|
169
|
-
##
|
|
244
|
+
## Flags
|
|
170
245
|
|
|
171
246
|
| Flag | Purpose |
|
|
172
247
|
|------|---------|
|
|
173
248
|
| `--json` | JSON output |
|
|
174
|
-
| `-q, --quiet` |
|
|
249
|
+
| `-q, --quiet` | Identifier only |
|
|
175
250
|
| `--api-key <key>` | API key for this command |
|
|
176
251
|
| `--deploy-token <token>` | Single-use deploy token |
|
|
177
|
-
| `--label <label>` | Set label (repeatable, replaces all
|
|
178
|
-
| `--no-path-detect` |
|
|
179
|
-
| `--no-spa-detect` |
|
|
180
|
-
| `--no-color` |
|
|
181
|
-
| `--config <file>` | Custom config
|
|
182
|
-
|
|
183
|
-
##
|
|
184
|
-
|
|
185
|
-
|
|
|
186
|
-
|
|
187
|
-
| `too many requests` |
|
|
188
|
-
| `authentication failed` |
|
|
189
|
-
| `not found` |
|
|
190
|
-
| `path does not exist` |
|
|
191
|
-
| `invalid domain name` |
|
|
192
|
-
| `DNS information is only available for external domains` |
|
|
193
|
-
| `DNS verification already requested recently` | Rate limited | Wait
|
|
252
|
+
| `--label <label>` | Set label (repeatable, replaces all) |
|
|
253
|
+
| `--no-path-detect` | Skip build output auto-detection |
|
|
254
|
+
| `--no-spa-detect` | Skip SPA rewrite auto-configuration |
|
|
255
|
+
| `--no-color` | Disable colors |
|
|
256
|
+
| `--config <file>` | Custom config path |
|
|
257
|
+
|
|
258
|
+
## Errors
|
|
259
|
+
|
|
260
|
+
| Message | Cause | Fix |
|
|
261
|
+
|---------|-------|-----|
|
|
262
|
+
| `too many requests` | Rate limited | Wait, or set an API key |
|
|
263
|
+
| `authentication failed` | Bad credentials | Check key/token |
|
|
264
|
+
| `not found` | No such resource | Verify the ID/name |
|
|
265
|
+
| `path does not exist` | Bad deploy path | Check file/directory |
|
|
266
|
+
| `invalid domain name` | Not a subdomain | Use `www.example.com`, not `example.com` |
|
|
267
|
+
| `DNS information is only available for external domains` | DNS op on internal domain | Only custom domains need DNS |
|
|
268
|
+
| `DNS verification already requested recently` | Rate limited | Wait |
|
package/dist/browser.d.ts
CHANGED
|
@@ -677,7 +677,7 @@ declare function getCurrentConfig(): ConfigResponse;
|
|
|
677
677
|
* - **Server-processed** (build/prerender): Source files destined for server-side build.
|
|
678
678
|
* Junk filtering and MD5 checksums only — the build service validates the output.
|
|
679
679
|
*
|
|
680
|
-
* Both modes share: environment check → extract paths →
|
|
680
|
+
* Both modes share: environment check → extract paths → optimize paths → filter junk → MD5.
|
|
681
681
|
*/
|
|
682
682
|
|
|
683
683
|
/**
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ze=Object.create;var U=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Ge=(i,r,e)=>r in i?U(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var C=(i,r)=>()=>(i&&(r=i(i=0)),r);var de=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),qe=(i,r)=>{for(var e in r)U(i,e,{get:r[e],enumerable:!0})},Ye=(i,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of He(r))!je.call(i,u)&&u!==e&&U(i,u,{get:()=>r[u],enumerable:!(a=Ke(r,u))||a.enumerable});return i};var Y=(i,r,e)=>(e=i!=null?ze(Ve(i)):{},Ye(r||!i||!i.__esModule?U(e,"default",{value:i,enumerable:!0}):e,i));var L=(i,r,e)=>Ge(i,typeof r!="symbol"?r+"":r,e);function Q(i){return i!==null&&typeof i=="object"&&"name"in i&&i.name==="ShipError"&&"status"in i}function B(i){let r=i.lastIndexOf(".");if(r===-1||r===i.length-1)return!1;let e=i.slice(r+1).toLowerCase();return Je.has(e)}function ge(i){return We.test(i)}function k(i){return i.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Xe.has(e))}function dt(i){if(!i.startsWith(I))throw m.validation(`API key must start with "${I}"`);if(i.length!==me)throw m.validation(`API key must be ${me} characters total (${I} + ${W} hex chars)`);let r=i.slice(I.length);if(!/^[a-f0-9]{64}$/i.test(r))throw m.validation(`API key must contain ${W} hexadecimal characters after "${I}" prefix`)}function mt(i){if(!i.startsWith(F))throw m.validation(`Deploy token must start with "${F}"`);if(i.length!==ye)throw m.validation(`Deploy token must be ${ye} characters total (${F} + ${X} hex chars)`);let r=i.slice(F.length);if(!/^[a-f0-9]{64}$/i.test(r))throw m.validation(`Deploy token must contain ${X} hexadecimal characters after "${F}" prefix`)}function yt(i){try{let r=new URL(i);if(!["http:","https:"].includes(r.protocol))throw m.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw m.validation("API URL must not contain a path");if(r.search||r.hash)throw m.validation("API URL must not contain query parameters or fragments")}catch(r){throw Q(r)?r:m.validation("API URL must be a valid URL")}}function gt(i){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(i)}function Ae(i,r){return i.endsWith(`.${r}`)}function At(i,r){return!Ae(i,r)}function Dt(i,r){return Ae(i,r)?i.slice(0,-(r.length+1)):null}function St(i){return`https://${i}`}function bt(i){return`https://${i}`}function wt(i){return!i||i.length===0?null:JSON.stringify(i)}function Rt(i){if(!i)return[];try{let r=JSON.parse(i);return Array.isArray(r)?r:[]}catch{return[]}}var pt,ut,ct,S,J,m,Je,We,Xe,I,W,me,ft,F,X,ye,ht,Z,M,E,Et,vt,w=C(()=>{"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"};(function(i){i.Validation="validation_failed",i.NotFound="not_found",i.RateLimit="rate_limit_exceeded",i.Authentication="authentication_failed",i.Business="business_logic_error",i.Api="internal_server_error",i.Network="network_error",i.Cancelled="operation_cancelled",i.File="file_error",i.Config="config_error"})(S||(S={}));J={client:new Set([S.Business,S.Config,S.File,S.Validation]),network:new Set([S.Network]),auth:new Set([S.Authentication])},m=class i extends Error{constructor(e,a,u,f){super(a);L(this,"type");L(this,"status");L(this,"details");this.type=e,this.status=u,this.details=f,this.name="ShipError"}toResponse(){let e=this.type===S.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:e}}static fromResponse(e){return new i(e.error,e.message,e.status,e.details)}static validation(e,a){return new i(S.Validation,e,400,a)}static notFound(e,a){let u=a?`${e} ${a} not found`:`${e} not found`;return new i(S.NotFound,u,404)}static rateLimit(e="Too many requests"){return new i(S.RateLimit,e,429)}static authentication(e="Authentication required",a){return new i(S.Authentication,e,401,a)}static business(e,a=400){return new i(S.Business,e,a)}static network(e,a){return new i(S.Network,e,void 0,{cause:a})}static cancelled(e){return new i(S.Cancelled,e)}static file(e,a){return new i(S.File,e,void 0,{filePath:a})}static config(e,a){return new i(S.Config,e,void 0,a)}static api(e,a=500){return new i(S.Api,e,a)}static database(e,a=500){return new i(S.Api,e,a)}static storage(e,a=500){return new i(S.Api,e,a)}get filePath(){return this.details?.filePath}isClientError(){return J.client.has(this.type)}isNetworkError(){return J.network.has(this.type)}isAuthError(){return J.auth.has(this.type)}isValidationError(){return this.type===S.Validation}isFileError(){return this.type===S.File}isConfigError(){return this.type===S.Config}isType(e){return this.type===e}};Je=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#?%\\<>"]/;Xe=new Set(["node_modules","package.json"]);I="ship-",W=64,me=I.length+W,ft=4,F="token-",X=64,ye=F.length+X,ht={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},Z="ship.json";M="https://api.shipstatic.com",E={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};Et={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},vt=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/});function te(i){ee=i}function O(){if(ee===null)throw m.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return ee}var ee,_=C(()=>{"use strict";w();ee=null});function Ut(i){ne=i}function Ze(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function H(){return ne||Ze()}var ne,V=C(()=>{"use strict";ne=null});var ve=de((be,Ee)=>{"use strict";(function(i){if(typeof be=="object")Ee.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var r;try{r=window}catch{r=self}r.SparkMD5=i()}})(function(i){"use strict";var r=function(p,l){return p+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(p,l,n,t,s,o){return l=r(r(l,p),r(t,o)),r(l<<s|l>>>32-s,n)}function u(p,l){var n=p[0],t=p[1],s=p[2],o=p[3];n+=(t&s|~t&o)+l[0]-680876936|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[1]-389564586|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[2]+606105819|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[3]-1044525330|0,t=(t<<22|t>>>10)+s|0,n+=(t&s|~t&o)+l[4]-176418897|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[5]+1200080426|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[7]-45705983|0,t=(t<<22|t>>>10)+s|0,n+=(t&s|~t&o)+l[8]+1770035416|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[9]-1958414417|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[10]-42063|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[11]-1990404162|0,t=(t<<22|t>>>10)+s|0,n+=(t&s|~t&o)+l[12]+1804603682|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[13]-40341101|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[15]+1236535329|0,t=(t<<22|t>>>10)+s|0,n+=(t&o|s&~o)+l[1]-165796510|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[6]-1069501632|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[11]+643717713|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[0]-373897302|0,t=(t<<20|t>>>12)+s|0,n+=(t&o|s&~o)+l[5]-701558691|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[10]+38016083|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[15]-660478335|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[4]-405537848|0,t=(t<<20|t>>>12)+s|0,n+=(t&o|s&~o)+l[9]+568446438|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[14]-1019803690|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[3]-187363961|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[8]+1163531501|0,t=(t<<20|t>>>12)+s|0,n+=(t&o|s&~o)+l[13]-1444681467|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[2]-51403784|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[12]-1926607734|0,t=(t<<20|t>>>12)+s|0,n+=(t^s^o)+l[5]-378558|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[8]-2022574463|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[14]-35309556|0,t=(t<<23|t>>>9)+s|0,n+=(t^s^o)+l[1]-1530992060|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[4]+1272893353|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[7]-155497632|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[10]-1094730640|0,t=(t<<23|t>>>9)+s|0,n+=(t^s^o)+l[13]+681279174|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[0]-358537222|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[3]-722521979|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[6]+76029189|0,t=(t<<23|t>>>9)+s|0,n+=(t^s^o)+l[9]-640364487|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[12]-421815835|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[15]+530742520|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[2]-995338651|0,t=(t<<23|t>>>9)+s|0,n+=(s^(t|~o))+l[0]-198630844|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[7]+1126891415|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[5]-57434055|0,t=(t<<21|t>>>11)+s|0,n+=(s^(t|~o))+l[12]+1700485571|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[3]-1894986606|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[10]-1051523|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[1]-2054922799|0,t=(t<<21|t>>>11)+s|0,n+=(s^(t|~o))+l[8]+1873313359|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[15]-30611744|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[13]+1309151649|0,t=(t<<21|t>>>11)+s|0,n+=(s^(t|~o))+l[4]-145523070|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[11]-1120210379|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[2]+718787259|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[9]-343485551|0,t=(t<<21|t>>>11)+s|0,p[0]=n+p[0]|0,p[1]=t+p[1]|0,p[2]=s+p[2]|0,p[3]=o+p[3]|0}function f(p){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=p.charCodeAt(n)+(p.charCodeAt(n+1)<<8)+(p.charCodeAt(n+2)<<16)+(p.charCodeAt(n+3)<<24);return l}function h(p){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=p[n]+(p[n+1]<<8)+(p[n+2]<<16)+(p[n+3]<<24);return l}function y(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,v,x,T;for(t=64;t<=l;t+=64)u(n,f(p.substring(t-64,t)));for(p=p.substring(t-64),s=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<s;t+=1)o[t>>2]|=p.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(n,o),t=0;t<16;t+=1)o[t]=0;return v=l*8,v=v.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(v[2],16),T=parseInt(v[1],16)||0,o[14]=x,o[15]=T,u(n,o),n}function c(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,v,x,T;for(t=64;t<=l;t+=64)u(n,h(p.subarray(t-64,t)));for(p=t-64<l?p.subarray(t-64):new Uint8Array(0),s=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<s;t+=1)o[t>>2]|=p[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(n,o),t=0;t<16;t+=1)o[t]=0;return v=l*8,v=v.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(v[2],16),T=parseInt(v[1],16)||0,o[14]=x,o[15]=T,u(n,o),n}function g(p){var l="",n;for(n=0;n<4;n+=1)l+=e[p>>n*8+4&15]+e[p>>n*8&15];return l}function d(p){var l;for(l=0;l<p.length;l+=1)p[l]=g(p[l]);return p.join("")}d(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(r=function(p,l){var n=(p&65535)+(l&65535),t=(p>>16)+(l>>16)+(n>>16);return t<<16|n&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function p(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,s=p(l,t),o=t,v,x,T,he;return n!==i&&(o=p(n,t)),s>o?new ArrayBuffer(0):(v=o-s,x=new ArrayBuffer(v),T=new Uint8Array(x),he=new Uint8Array(this,s,v),T.set(he),x)}})();function A(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function R(p,l){var n=p.length,t=new ArrayBuffer(n),s=new Uint8Array(t),o;for(o=0;o<n;o+=1)s[o]=p.charCodeAt(o);return l?s:t}function P(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function Me(p,l,n){var t=new Uint8Array(p.byteLength+l.byteLength);return t.set(new Uint8Array(p)),t.set(new Uint8Array(l),p.byteLength),n?t:t.buffer}function N(p){var l=[],n=p.length,t;for(t=0;t<n-1;t+=2)l.push(parseInt(p.substr(t,2),16));return String.fromCharCode.apply(String,l)}function D(){this.reset()}return D.prototype.append=function(p){return this.appendBinary(A(p)),this},D.prototype.appendBinary=function(p){this._buff+=p,this._length+=p.length;var l=this._buff.length,n;for(n=64;n<=l;n+=64)u(this._hash,f(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},D.prototype.end=function(p){var l=this._buff,n=l.length,t,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(t=0;t<n;t+=1)s[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(s,n),o=d(this._hash),p&&(o=N(o)),this.reset(),o},D.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},D.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},D.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},D.prototype._finish=function(p,l){var n=l,t,s,o;if(p[n>>2]|=128<<(n%4<<3),n>55)for(u(this._hash,p),n=0;n<16;n+=1)p[n]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(t[2],16),o=parseInt(t[1],16)||0,p[14]=s,p[15]=o,u(this._hash,p)},D.hash=function(p,l){return D.hashBinary(A(p),l)},D.hashBinary=function(p,l){var n=y(p),t=d(n);return l?N(t):t},D.ArrayBuffer=function(){this.reset()},D.ArrayBuffer.prototype.append=function(p){var l=Me(this._buff.buffer,p,!0),n=l.length,t;for(this._length+=p.byteLength,t=64;t<=n;t+=64)u(this._hash,h(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},D.ArrayBuffer.prototype.end=function(p){var l=this._buff,n=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,o;for(s=0;s<n;s+=1)t[s>>2]|=l[s]<<(s%4<<3);return this._finish(t,n),o=d(this._hash),p&&(o=N(o)),this.reset(),o},D.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.ArrayBuffer.prototype.getState=function(){var p=D.prototype.getState.call(this);return p.buff=P(p.buff),p},D.ArrayBuffer.prototype.setState=function(p){return p.buff=R(p.buff,!0),D.prototype.setState.call(this,p)},D.ArrayBuffer.prototype.destroy=D.prototype.destroy,D.ArrayBuffer.prototype._finish=D.prototype._finish,D.ArrayBuffer.hash=function(p,l){var n=c(new Uint8Array(p)),t=d(n);return l?N(t):t},D})});var re=de((Bt,we)=>{"use strict";we.exports={}});async function et(i){let r=(await Promise.resolve().then(()=>Y(ve(),1))).default;return new Promise((e,a)=>{let f=Math.ceil(i.size/2097152),h=0,y=new r.ArrayBuffer,c=new FileReader,g=()=>{let d=h*2097152,A=Math.min(d+2097152,i.size);c.readAsArrayBuffer(i.slice(d,A))};c.onload=d=>{let A=d.target?.result;if(!A){a(m.business("Failed to read file chunk"));return}y.append(A),h++,h<f?g():e({md5:y.end()})},c.onerror=()=>{a(m.business("Failed to calculate MD5: FileReader error"))},g()})}async function tt(i){let r=await Promise.resolve().then(()=>Y(re(),1));if(Buffer.isBuffer(i)){let a=r.createHash("md5");return a.update(i),{md5:a.digest("hex")}}let e=await Promise.resolve().then(()=>Y(re(),1));return new Promise((a,u)=>{let f=r.createHash("md5"),h=e.createReadStream(i);h.on("error",y=>u(m.business(`Failed to read file for MD5: ${y.message}`))),h.on("data",y=>f.update(y)),h.on("end",()=>a({md5:f.digest("hex")}))})}async function $(i){let r=H();if(r==="browser"){if(!(i instanceof Blob))throw m.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return et(i)}if(r==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw m.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return tt(i)}throw m.business("Unknown or unsupported execution environment for MD5 calculation.")}var j=C(()=>{"use strict";V();w()});function Pe(i){return it.test(i)}var rt,it,Oe=C(()=>{"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 _e(i,r){if(!i||i.length===0)return[];if(!r?.allowUnbuilt&&i.find(a=>a&&k(a)))throw m.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return i.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let u=a[a.length-1];if(Pe(u))return!1;for(let h of a)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let f=a.slice(0,-1);for(let h of f)if(ot.some(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var ot,ie=C(()=>{"use strict";Oe();w();ot=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function q(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var $e=C(()=>{"use strict"});function Ne(i,r={}){if(r.flatten===!1)return i.map(a=>({path:q(a),name:oe(a)}));let e=st(i);return i.map(a=>{let u=q(a);if(e){let f=e.endsWith("/")?e:`${e}/`;u.startsWith(f)&&(u=u.substring(f.length))}return u||(u=oe(a)),{path:u,name:oe(a)}})}function st(i){if(!i.length)return"";let e=i.map(f=>q(f)).map(f=>f.split("/")),a=[],u=Math.min(...e.map(f=>f.length));for(let f=0;f<u-1;f++){let h=e[0][f];if(e.every(y=>y[f]===h))a.push(h);else break}return a.join("/")}function oe(i){return i.split(/[/\\]/).pop()||i}var se=C(()=>{"use strict";$e()});function ae(i,r=1){if(i===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],u=Math.floor(Math.log(i)/Math.log(e));return parseFloat((i/Math.pow(e,u)).toFixed(r))+" "+a[u]}function le(i){if(ge(i))return{valid:!1,reason:"File name contains unsafe characters"};if(i.startsWith(" ")||i.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(i.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let r=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=i.split("/").pop()||i;return r.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:i.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function hn(i,r){let e=[],a=[],u=[];if(i.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 i)if(k(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:i.map(g=>({...g,status:E.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(i.length>r.maxFilesCount){let c={file:`(${i.length} files)`,message:`File count (${i.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(c),{files:i.map(g=>({...g,status:E.VALIDATION_FAILED,statusMessage:c.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let f=0;for(let c of i){let g=E.READY,d="Ready for upload",A=c.name?le(c.name):{valid:!1,reason:"File name cannot be empty"};if(c.status===E.PROCESSING_ERROR)g=E.VALIDATION_FAILED,d=c.statusMessage||"File failed during processing",e.push({file:c.name,message:d});else if(c.size===0){g=E.EXCLUDED,d="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:c.name,message:d}),u.push({...c,status:g,statusMessage:d});continue}else c.size<0?(g=E.VALIDATION_FAILED,d="File size must be positive",e.push({file:c.name,message:d})):!c.name||c.name.trim().length===0?(g=E.VALIDATION_FAILED,d="File name cannot be empty",e.push({file:c.name||"(empty)",message:d})):c.name.includes("\0")?(g=E.VALIDATION_FAILED,d="File name contains invalid characters (null byte)",e.push({file:c.name,message:d})):A.valid?B(c.name)?(g=E.VALIDATION_FAILED,d=`File extension not allowed: "${c.name}"`,e.push({file:c.name,message:d})):c.size>r.maxFileSize?(g=E.VALIDATION_FAILED,d=`File size (${ae(c.size)}) exceeds limit of ${ae(r.maxFileSize)}`,e.push({file:c.name,message:d})):(f+=c.size,f>r.maxTotalSize&&(g=E.VALIDATION_FAILED,d=`Total size would exceed limit of ${ae(r.maxTotalSize)}`,e.push({file:c.name,message:d}))):(g=E.VALIDATION_FAILED,d=A.reason||"Invalid file name",e.push({file:c.name,message:d}));u.push({...c,status:g,statusMessage:d})}e.length>0&&(u=u.map(c=>c.status===E.EXCLUDED?c:{...c,status:E.VALIDATION_FAILED,statusMessage:c.status===E.VALIDATION_FAILED?c.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?u.filter(c=>c.status===E.READY):[],y=e.length===0;return{files:u,validFiles:h,errors:e,warnings:a,canDeploy:y}}function at(i){return i.filter(r=>r.status===E.READY)}function dn(i){return at(i).length>0}var pe=C(()=>{"use strict";w()});function Ue(i,r){if(i.includes("\0")||i.includes("/../")||i.startsWith("../")||i.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${i}" for file: ${r}`)}function Le(i,r){let e=le(i);if(!e.valid)throw m.business(e.reason||"Invalid file name");if(B(i))throw m.business(`File extension not allowed: "${r}"`)}var ue=C(()=>{"use strict";w();pe()});var ke={};qe(ke,{processFilesForBrowser:()=>Be});async function Be(i,r={}){if(H()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");let e=i.map(d=>d.webkitRelativePath||d.name),a=r.build||r.prerender,u=new Set(_e(e,{allowUnbuilt:a})),f=[];for(let d=0;d<i.length;d++)u.has(e[d])&&f.push({file:i[d],rawPath:e[d]});if(f.length===0)return[];let h=Ne(f.map(d=>d.rawPath),{flatten:r.pathDetect!==!1});if(a){let d=[];for(let A=0;A<f.length;A++){let{file:R}=f[A];if(R.size===0)continue;let{md5:P}=await $(R);d.push({path:h[A].path,content:R,size:R.size,md5:P})}return d}let y=O(),c=[],g=0;for(let d=0;d<f.length;d++){let{file:A}=f[d],R=h[d].path;if(Ue(R,A.name),A.size===0)continue;if(Le(R,A.name),A.size>y.maxFileSize)throw m.business(`File ${A.name} is too large. Maximum allowed size is ${y.maxFileSize/(1024*1024)}MB.`);if(g+=A.size,g>y.maxTotalSize)throw m.business(`Total deploy size is too large. Maximum allowed is ${y.maxTotalSize/(1024*1024)}MB.`);let{md5:P}=await $(A);c.push({path:R,content:A,size:A.size,md5:P})}if(c.length>y.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${y.maxFilesCount} files.`);return c}var ce=C(()=>{"use strict";j();w();V();ie();se();ue();_()});w();var z=class{constructor(){this.handlers=new Map}on(r,e){this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r).add(e)}off(r,e){let a=this.handlers.get(r);a&&(a.delete(e),a.size===0&&this.handlers.delete(r))}emit(r,...e){let a=this.handlers.get(r);if(!a)return;let u=Array.from(a);for(let f of u)try{f(...e)}catch(h){a.delete(f),r!=="error"&&setTimeout(()=>{h instanceof Error?this.emit("error",h,String(r)):this.emit("error",new Error(String(h)),String(r))},0)}}transfer(r){this.handlers.forEach((e,a)=>{e.forEach(u=>{r.on(a,u)})})}clear(){this.handlers.clear()}};var b={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Qe=3e4,K=class extends z{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||M,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??Qe,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||b.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,a,u){let f=this.mergeHeaders(a.headers),{signal:h,cleanup:y}=this.createTimeoutSignal(a.signal),c={...a,headers:f,credentials:this.useCredentials&&!f.Authorization?"include":void 0,signal:h};this.emit("request",e,c);try{let g=await fetch(e,c);return y(),g.ok||await this.handleResponseError(g,u),this.emit("response",this.safeClone(g),e),{data:await this.parseResponse(this.safeClone(g)),status:g.status}}catch(g){y();let d=g instanceof Error?g:new Error(String(g));this.emit("error",d,e),this.handleFetchError(g,u)}}async request(e,a,u){let{data:f}=await this.executeRequest(e,a,u);return f}async requestWithStatus(e,a,u){return this.executeRequest(e,a,u)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let a=new AbortController,u=setTimeout(()=>a.abort(),this.timeout);if(e){let f=()=>a.abort();e.addEventListener("abort",f),e.aborted&&a.abort()}return{signal:a.signal,cleanup:()=>clearTimeout(u)}}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 handleResponseError(e,a){let u={};try{if(e.headers.get("content-type")?.includes("application/json")){let y=await e.json();if(y&&typeof y=="object"){let c=y;typeof c.message=="string"&&(u.message=c.message),typeof c.error=="string"&&(u.error=c.error)}}else u={message:await e.text()}}catch{u={message:"Failed to parse error response"}}let f=u.message||u.error||`${a} failed`;throw e.status===401?m.authentication(f):m.api(f,e.status)}handleFetchError(e,a){throw Q(e)?e:e instanceof Error&&e.name==="AbortError"?m.cancelled(`${a} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?m.network(`${a} failed: ${e.message}`,e):e instanceof Error?m.business(`${a} failed: ${e.message}`):m.business(`${a} failed: Unknown error`)}async deploy(e,a={}){if(!e.length)throw m.business("No files to deploy");for(let c of e)if(!c.md5)throw m.file(`MD5 checksum missing for file: ${c.path}`,c.path);let u=a.build||a.prerender?{build:a.build,prerender:a.prerender}:void 0,{body:f,headers:h}=await this.createDeployBody(e,a.labels,a.via,u),y={};return a.deployToken?y.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(y.Authorization=`Bearer ${a.apiKey}`),a.caller&&(y["X-Caller"]=a.caller),this.request(`${a.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:f,headers:{...h,...y},signal:a.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${b.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${b.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){return this.request(`${this.apiUrl}${b.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:a})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${b.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,u){let f={};a&&(f.deployment=a),u!==void 0&&(f.labels=u);let{data:h,status:y}=await this.requestWithStatus(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...h,isCreate:y===201}}async listDomains(){return this.request(`${this.apiUrl}${b.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${b.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let u={};return e!==void 0&&(u.ttl=e),a!==void 0&&(u.labels=a),this.request(`${this.apiUrl}${b.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${b.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${b.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${b.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${b.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${b.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${b.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let u=e.find(g=>g.path==="index.html"||g.path==="/index.html");if(!u||u.size>100*1024)return!1;let f;if(typeof Buffer<"u"&&Buffer.isBuffer(u.content))f=u.content.toString("utf-8");else if(typeof Blob<"u"&&u.content instanceof Blob)f=await u.content.text();else if(typeof File<"u"&&u.content instanceof File)f=await u.content.text();else return!1;let h={"Content-Type":"application/json"};a.deployToken?h.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(h.Authorization=`Bearer ${a.apiKey}`);let y={files:e.map(g=>g.path),index:f};return(await this.request(`${this.apiUrl}${b.SPA_CHECK}`,{method:"POST",headers:h,body:JSON.stringify(y)},"SPA check")).isSPA}};w();_();w();w();function De(i={},r={}){let e={apiUrl:i.apiUrl||r.apiUrl||M,apiKey:i.apiKey!==void 0?i.apiKey:r.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:r.deployToken},a={apiUrl:e.apiUrl};return e.apiKey!==void 0&&(a.apiKey=e.apiKey),e.deployToken!==void 0&&(a.deployToken=e.deployToken),a}function Se(i,r){let e={...i};return e.apiUrl===void 0&&r.apiUrl!==void 0&&(e.apiUrl=r.apiUrl),e.apiKey===void 0&&r.apiKey!==void 0&&(e.apiKey=r.apiKey),e.deployToken===void 0&&r.deployToken!==void 0&&(e.deployToken=r.deployToken),e.timeout===void 0&&r.timeout!==void 0&&(e.timeout=r.timeout),e.maxConcurrency===void 0&&r.maxConcurrency!==void 0&&(e.maxConcurrency=r.maxConcurrency),e.onProgress===void 0&&r.onProgress!==void 0&&(e.onProgress=r.onProgress),e.caller===void 0&&r.caller!==void 0&&(e.caller=r.caller),e}w();j();async function nt(){let r=JSON.stringify({rewrites:[{source:"/(.*)",destination:"/index.html"}]},null,2),e;typeof Buffer<"u"?e=Buffer.from(r,"utf-8"):e=new Blob([r],{type:"application/json"});let{md5:a}=await $(e);return{path:Z,content:e,size:r.length,md5:a}}async function Re(i,r,e){if(e.spaDetect===!1||e.build||e.prerender||i.some(a=>a.path===Z))return i;try{if(await r.checkSPA(i,e)){let u=await nt();return[...i,u]}}catch{}return i}function Ce(i){let{getApi:r,ensureInit:e,processInput:a,clientDefaults:u,hasAuth:f}=i;return{upload:async(h,y={})=>{await e();let c=u?Se(y,u):y;if(f&&!f()&&!c.deployToken&&!c.apiKey)try{let A=r(),{secret:R}=await A.fetchAgentToken();c.deployToken=R}catch{throw m.authentication("Too many requests; try again later or configure a free API key with 'ship config'")}if(!a)throw m.config("processInput function is not provided.");let g=r(),d=await a(h,c);return d=await Re(d,g,c),g.deploy(d,c)},list:async()=>(await e(),r().listDeployments()),get:async h=>(await e(),r().getDeployment(h)),set:async(h,y)=>(await e(),r().updateDeploymentLabels(h,y.labels)),remove:async h=>{await e(),await r().removeDeployment(h)}}}function xe(i){let{getApi:r,ensureInit:e}=i;return{set:async(a,u={})=>(await e(),r().setDomain(a,u.deployment,u.labels)),list:async()=>(await e(),r().listDomains()),get:async a=>(await e(),r().getDomain(a)),remove:async a=>{await e(),await r().removeDomain(a)},verify:async a=>(await e(),r().verifyDomain(a)),validate:async a=>(await e(),r().validateDomain(a)),dns:async a=>(await e(),r().getDomainDns(a)),records:async a=>(await e(),r().getDomainRecords(a)),share:async a=>(await e(),r().getDomainShare(a))}}function Te(i){let{getApi:r,ensureInit:e}=i;return{get:async()=>(await e(),r().getAccount())}}function Ie(i){let{getApi:r,ensureInit:e}=i;return{create:async(a={})=>(await e(),r().createToken(a.ttl,a.labels)),list:async()=>(await e(),r().listTokens()),remove:async a=>{await e(),await r().removeToken(a)}}}var G=class{constructor(r={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=r,r.deployToken?this.auth={type:"token",value:r.deployToken}:r.apiKey&&(this.auth={type:"apiKey",value:r.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let e=this.resolveInitialConfig(r);this.http=new K({...r,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let a={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=Ce({...a,processInput:(u,f)=>this.processInput(u,f),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=xe(a),this._account=Te(a),this._tokens=Ie(a)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(r,e){return this.deployments.upload(r,e)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=O(),this._config)}on(r,e){this.http.on(r,e)}off(r,e){this.http.off(r,e)}setHeaders(r){this.customHeaders=r,this.http.setGlobalHeaders(r)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(r){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(r)}catch(e){console.warn("Event transfer failed during client replacement:",e)}this.http=r,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(r){if(!r||typeof r!="string")throw m.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:r}}setApiKey(r){if(!r||typeof r!="string")throw m.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:r}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};_();w();w();async function Fe(i,r,e,a){let u=new FormData,f=[];for(let h of i){if(!(h.content instanceof File||h.content instanceof Blob))throw m.file(`Unsupported file.content type for browser: ${h.path}`,h.path);if(!h.md5)throw m.file(`File missing md5 checksum: ${h.path}`,h.path);let y=new File([h.content],h.path,{type:"application/octet-stream"});u.append("files[]",y),f.push(h.md5)}return u.append("checksums",JSON.stringify(f)),r&&r.length>0&&u.append("labels",JSON.stringify(r)),e&&u.append("via",e),a?.build&&u.append("build","true"),a?.prerender&&u.append("prerender","true"),{body:u,headers:{}}}j();function nn(i,r,e,a=!0){let u=i===1?r:e;return a?`${i} ${u}`:u}ie();se();V();pe();ue();w();_();ce();var fe=class extends G{constructor(r={}){super(r)}resolveInitialConfig(r){return De(r,{})}async loadFullConfig(){try{let r=await this.http.getConfig();te(r)}catch(r){throw this.initPromise=null,r}}async processInput(r,e){if(!this.isFileArray(r))throw m.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw m.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(ce(),ke));return a(r,e)}isFileArray(r){return Array.isArray(r)&&r.every(e=>e instanceof File)}getDeployBodyCreator(){return Fe}},jn=fe;export{W as API_KEY_HEX_LENGTH,ft as API_KEY_HINT_LENGTH,I as API_KEY_PREFIX,me as API_KEY_TOTAL_LENGTH,ct as AccountPlan,K as ApiHttp,ht as AuthMethod,Je as BLOCKED_EXTENSIONS,M as DEFAULT_API,Z as DEPLOYMENT_CONFIG_FILENAME,X as DEPLOY_TOKEN_HEX_LENGTH,F as DEPLOY_TOKEN_PREFIX,ye as DEPLOY_TOKEN_TOTAL_LENGTH,pt as DeploymentStatus,ut as DomainStatus,S as ErrorType,E as FILE_VALIDATION_STATUS,E as FileValidationStatus,ot as JUNK_DIRECTORIES,Et as LABEL_CONSTRAINTS,vt as LABEL_PATTERN,fe as Ship,m as ShipError,Xe as UNBUILT_PROJECT_MARKERS,We as UNSAFE_FILENAME_CHARS,Ut as __setTestEnvironment,dn as allValidFilesReady,$ as calculateMD5,Te as createAccountResource,Ce as createDeploymentResource,xe as createDomainResource,Ie as createTokenResource,jn as default,Rt as deserializeLabels,Dt as extractSubdomain,_e as filterJunk,ae as formatFileSize,St as generateDeploymentUrl,bt as generateDomainUrl,O as getCurrentConfig,H as getENV,at as getValidFiles,k as hasUnbuiltMarker,ge as hasUnsafeChars,B as isBlockedExtension,At as isCustomDomain,gt as isDeployment,Ae as isPlatformDomain,Q as isShipError,Se as mergeDeployOptions,Ne as optimizeDeployPaths,nn as pluralize,Be as processFilesForBrowser,De as resolveConfig,wt as serializeLabels,te as setPlatformConfig,dt as validateApiKey,yt as validateApiUrl,Le as validateDeployFile,Ue as validateDeployPath,mt as validateDeployToken,le as validateFileName,hn as validateFiles};
|
|
1
|
+
var ze=Object.create;var L=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Ge=(i,r,e)=>r in i?L(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var C=(i,r)=>()=>(i&&(r=i(i=0)),r);var me=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),qe=(i,r)=>{for(var e in r)L(i,e,{get:r[e],enumerable:!0})},Ye=(i,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of He(r))!je.call(i,u)&&u!==e&&L(i,u,{get:()=>r[u],enumerable:!(a=Ke(r,u))||a.enumerable});return i};var J=(i,r,e)=>(e=i!=null?ze(Ve(i)):{},Ye(r||!i||!i.__esModule?L(e,"default",{value:i,enumerable:!0}):e,i));var B=(i,r,e)=>Ge(i,typeof r!="symbol"?r+"":r,e);function Z(i){return i!==null&&typeof i=="object"&&"name"in i&&i.name==="ShipError"&&"status"in i}function k(i){let r=i.lastIndexOf(".");if(r===-1||r===i.length-1)return!1;let e=i.slice(r+1).toLowerCase();return Je.has(e)}function Ae(i){return We.test(i)}function M(i){return i.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Xe.has(e))}function dt(i){if(!i.startsWith(P))throw d.validation(`API key must start with "${P}"`);if(i.length!==ye)throw d.validation(`API key must be ${ye} characters total (${P} + ${X} hex chars)`);let r=i.slice(P.length);if(!/^[a-f0-9]{64}$/i.test(r))throw d.validation(`API key must contain ${X} hexadecimal characters after "${P}" prefix`)}function mt(i){if(!i.startsWith(O))throw d.validation(`Deploy token must start with "${O}"`);if(i.length!==ge)throw d.validation(`Deploy token must be ${ge} characters total (${O} + ${Q} hex chars)`);let r=i.slice(O.length);if(!/^[a-f0-9]{64}$/i.test(r))throw d.validation(`Deploy token must contain ${Q} hexadecimal characters after "${O}" prefix`)}function yt(i){try{let r=new URL(i);if(!["http:","https:"].includes(r.protocol))throw d.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw d.validation("API URL must not contain a path");if(r.search||r.hash)throw d.validation("API URL must not contain query parameters or fragments")}catch(r){throw Z(r)?r:d.validation("API URL must be a valid URL")}}function gt(i){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(i)}function De(i,r){return i.endsWith(`.${r}`)}function At(i,r){return!De(i,r)}function Dt(i,r){return De(i,r)?i.slice(0,-(r.length+1)):null}function St(i){return`https://${i}`}function bt(i){return`https://${i}`}function wt(i){return!i||i.length===0?null:JSON.stringify(i)}function Rt(i){if(!i)return[];try{let r=JSON.parse(i);return Array.isArray(r)?r:[]}catch{return[]}}var pt,ut,ct,S,W,d,Je,We,Xe,P,X,ye,ft,O,Q,ge,ht,ee,z,E,Et,vt,R=C(()=>{"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"};(function(i){i.Validation="validation_failed",i.NotFound="not_found",i.RateLimit="rate_limit_exceeded",i.Authentication="authentication_failed",i.Business="business_logic_error",i.Api="internal_server_error",i.Network="network_error",i.Cancelled="operation_cancelled",i.File="file_error",i.Config="config_error"})(S||(S={}));W={client:new Set([S.Business,S.Config,S.File,S.Validation]),network:new Set([S.Network]),auth:new Set([S.Authentication])},d=class i extends Error{constructor(e,a,u,f){super(a);B(this,"type");B(this,"status");B(this,"details");this.type=e,this.status=u,this.details=f,this.name="ShipError"}toResponse(){let e=this.type===S.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:e}}static fromResponse(e){return new i(e.error,e.message,e.status,e.details)}static validation(e,a){return new i(S.Validation,e,400,a)}static notFound(e,a){let u=a?`${e} ${a} not found`:`${e} not found`;return new i(S.NotFound,u,404)}static rateLimit(e="Too many requests"){return new i(S.RateLimit,e,429)}static authentication(e="Authentication required",a){return new i(S.Authentication,e,401,a)}static business(e,a=400){return new i(S.Business,e,a)}static network(e,a){return new i(S.Network,e,void 0,{cause:a})}static cancelled(e){return new i(S.Cancelled,e)}static file(e,a){return new i(S.File,e,void 0,{filePath:a})}static config(e,a){return new i(S.Config,e,void 0,a)}static api(e,a=500){return new i(S.Api,e,a)}static database(e,a=500){return new i(S.Api,e,a)}static storage(e,a=500){return new i(S.Api,e,a)}get filePath(){return this.details?.filePath}isClientError(){return W.client.has(this.type)}isNetworkError(){return W.network.has(this.type)}isAuthError(){return W.auth.has(this.type)}isValidationError(){return this.type===S.Validation}isFileError(){return this.type===S.File}isConfigError(){return this.type===S.Config}isType(e){return this.type===e}};Je=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#?%\\<>"]/;Xe=new Set(["node_modules","package.json"]);P="ship-",X=64,ye=P.length+X,ft=4,O="token-",Q=64,ge=O.length+Q,ht={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},ee="ship.json";z="https://api.shipstatic.com",E={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};Et={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},vt=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/});function ne(i){te=i}function $(){if(te===null)throw d.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return te}var te,N=C(()=>{"use strict";R();te=null});function Ut(i){re=i}function Ze(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function V(){return re||Ze()}var re,j=C(()=>{"use strict";re=null});var we=me((Ee,ve)=>{"use strict";(function(i){if(typeof Ee=="object")ve.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var r;try{r=window}catch{r=self}r.SparkMD5=i()}})(function(i){"use strict";var r=function(p,l){return p+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(p,l,n,t,s,o){return l=r(r(l,p),r(t,o)),r(l<<s|l>>>32-s,n)}function u(p,l){var n=p[0],t=p[1],s=p[2],o=p[3];n+=(t&s|~t&o)+l[0]-680876936|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[1]-389564586|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[2]+606105819|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[3]-1044525330|0,t=(t<<22|t>>>10)+s|0,n+=(t&s|~t&o)+l[4]-176418897|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[5]+1200080426|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[7]-45705983|0,t=(t<<22|t>>>10)+s|0,n+=(t&s|~t&o)+l[8]+1770035416|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[9]-1958414417|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[10]-42063|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[11]-1990404162|0,t=(t<<22|t>>>10)+s|0,n+=(t&s|~t&o)+l[12]+1804603682|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&s)+l[13]-40341101|0,o=(o<<12|o>>>20)+n|0,s+=(o&n|~o&t)+l[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,t+=(s&o|~s&n)+l[15]+1236535329|0,t=(t<<22|t>>>10)+s|0,n+=(t&o|s&~o)+l[1]-165796510|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[6]-1069501632|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[11]+643717713|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[0]-373897302|0,t=(t<<20|t>>>12)+s|0,n+=(t&o|s&~o)+l[5]-701558691|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[10]+38016083|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[15]-660478335|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[4]-405537848|0,t=(t<<20|t>>>12)+s|0,n+=(t&o|s&~o)+l[9]+568446438|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[14]-1019803690|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[3]-187363961|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[8]+1163531501|0,t=(t<<20|t>>>12)+s|0,n+=(t&o|s&~o)+l[13]-1444681467|0,n=(n<<5|n>>>27)+t|0,o+=(n&s|t&~s)+l[2]-51403784|0,o=(o<<9|o>>>23)+n|0,s+=(o&t|n&~t)+l[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,t+=(s&n|o&~n)+l[12]-1926607734|0,t=(t<<20|t>>>12)+s|0,n+=(t^s^o)+l[5]-378558|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[8]-2022574463|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[14]-35309556|0,t=(t<<23|t>>>9)+s|0,n+=(t^s^o)+l[1]-1530992060|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[4]+1272893353|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[7]-155497632|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[10]-1094730640|0,t=(t<<23|t>>>9)+s|0,n+=(t^s^o)+l[13]+681279174|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[0]-358537222|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[3]-722521979|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[6]+76029189|0,t=(t<<23|t>>>9)+s|0,n+=(t^s^o)+l[9]-640364487|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^s)+l[12]-421815835|0,o=(o<<11|o>>>21)+n|0,s+=(o^n^t)+l[15]+530742520|0,s=(s<<16|s>>>16)+o|0,t+=(s^o^n)+l[2]-995338651|0,t=(t<<23|t>>>9)+s|0,n+=(s^(t|~o))+l[0]-198630844|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[7]+1126891415|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[5]-57434055|0,t=(t<<21|t>>>11)+s|0,n+=(s^(t|~o))+l[12]+1700485571|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[3]-1894986606|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[10]-1051523|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[1]-2054922799|0,t=(t<<21|t>>>11)+s|0,n+=(s^(t|~o))+l[8]+1873313359|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[15]-30611744|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[13]+1309151649|0,t=(t<<21|t>>>11)+s|0,n+=(s^(t|~o))+l[4]-145523070|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~s))+l[11]-1120210379|0,o=(o<<10|o>>>22)+n|0,s+=(n^(o|~t))+l[2]+718787259|0,s=(s<<15|s>>>17)+o|0,t+=(o^(s|~n))+l[9]-343485551|0,t=(t<<21|t>>>11)+s|0,p[0]=n+p[0]|0,p[1]=t+p[1]|0,p[2]=s+p[2]|0,p[3]=o+p[3]|0}function f(p){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=p.charCodeAt(n)+(p.charCodeAt(n+1)<<8)+(p.charCodeAt(n+2)<<16)+(p.charCodeAt(n+3)<<24);return l}function h(p){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=p[n]+(p[n+1]<<8)+(p[n+2]<<16)+(p[n+3]<<24);return l}function m(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,w,T,I;for(t=64;t<=l;t+=64)u(n,f(p.substring(t-64,t)));for(p=p.substring(t-64),s=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<s;t+=1)o[t>>2]|=p.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(n,o),t=0;t<16;t+=1)o[t]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),T=parseInt(w[2],16),I=parseInt(w[1],16)||0,o[14]=T,o[15]=I,u(n,o),n}function c(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,w,T,I;for(t=64;t<=l;t+=64)u(n,h(p.subarray(t-64,t)));for(p=t-64<l?p.subarray(t-64):new Uint8Array(0),s=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<s;t+=1)o[t>>2]|=p[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(n,o),t=0;t<16;t+=1)o[t]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),T=parseInt(w[2],16),I=parseInt(w[1],16)||0,o[14]=T,o[15]=I,u(n,o),n}function y(p){var l="",n;for(n=0;n<4;n+=1)l+=e[p>>n*8+4&15]+e[p>>n*8&15];return l}function g(p){var l;for(l=0;l<p.length;l+=1)p[l]=y(p[l]);return p.join("")}g(m("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(r=function(p,l){var n=(p&65535)+(l&65535),t=(p>>16)+(l>>16)+(n>>16);return t<<16|n&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function p(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,s=p(l,t),o=t,w,T,I,de;return n!==i&&(o=p(n,t)),s>o?new ArrayBuffer(0):(w=o-s,T=new ArrayBuffer(w),I=new Uint8Array(T),de=new Uint8Array(this,s,w),I.set(de),T)}})();function A(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function v(p,l){var n=p.length,t=new ArrayBuffer(n),s=new Uint8Array(t),o;for(o=0;o<n;o+=1)s[o]=p.charCodeAt(o);return l?s:t}function x(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function _(p,l,n){var t=new Uint8Array(p.byteLength+l.byteLength);return t.set(new Uint8Array(p)),t.set(new Uint8Array(l),p.byteLength),n?t:t.buffer}function F(p){var l=[],n=p.length,t;for(t=0;t<n-1;t+=2)l.push(parseInt(p.substr(t,2),16));return String.fromCharCode.apply(String,l)}function D(){this.reset()}return D.prototype.append=function(p){return this.appendBinary(A(p)),this},D.prototype.appendBinary=function(p){this._buff+=p,this._length+=p.length;var l=this._buff.length,n;for(n=64;n<=l;n+=64)u(this._hash,f(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},D.prototype.end=function(p){var l=this._buff,n=l.length,t,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(t=0;t<n;t+=1)s[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(s,n),o=g(this._hash),p&&(o=F(o)),this.reset(),o},D.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},D.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},D.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},D.prototype._finish=function(p,l){var n=l,t,s,o;if(p[n>>2]|=128<<(n%4<<3),n>55)for(u(this._hash,p),n=0;n<16;n+=1)p[n]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(t[2],16),o=parseInt(t[1],16)||0,p[14]=s,p[15]=o,u(this._hash,p)},D.hash=function(p,l){return D.hashBinary(A(p),l)},D.hashBinary=function(p,l){var n=m(p),t=g(n);return l?F(t):t},D.ArrayBuffer=function(){this.reset()},D.ArrayBuffer.prototype.append=function(p){var l=_(this._buff.buffer,p,!0),n=l.length,t;for(this._length+=p.byteLength,t=64;t<=n;t+=64)u(this._hash,h(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},D.ArrayBuffer.prototype.end=function(p){var l=this._buff,n=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,o;for(s=0;s<n;s+=1)t[s>>2]|=l[s]<<(s%4<<3);return this._finish(t,n),o=g(this._hash),p&&(o=F(o)),this.reset(),o},D.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.ArrayBuffer.prototype.getState=function(){var p=D.prototype.getState.call(this);return p.buff=x(p.buff),p},D.ArrayBuffer.prototype.setState=function(p){return p.buff=v(p.buff,!0),D.prototype.setState.call(this,p)},D.ArrayBuffer.prototype.destroy=D.prototype.destroy,D.ArrayBuffer.prototype._finish=D.prototype._finish,D.ArrayBuffer.hash=function(p,l){var n=c(new Uint8Array(p)),t=g(n);return l?F(t):t},D})});var ie=me((Bt,Re)=>{"use strict";Re.exports={}});async function et(i){let r=(await Promise.resolve().then(()=>J(we(),1))).default;return new Promise((e,a)=>{let f=Math.ceil(i.size/2097152),h=0,m=new r.ArrayBuffer,c=new FileReader,y=()=>{let g=h*2097152,A=Math.min(g+2097152,i.size);c.readAsArrayBuffer(i.slice(g,A))};c.onload=g=>{let A=g.target?.result;if(!A){a(d.business("Failed to read file chunk"));return}m.append(A),h++,h<f?y():e({md5:m.end()})},c.onerror=()=>{a(d.business("Failed to calculate MD5: FileReader error"))},y()})}async function tt(i){let r=await Promise.resolve().then(()=>J(ie(),1));if(Buffer.isBuffer(i)){let a=r.createHash("md5");return a.update(i),{md5:a.digest("hex")}}let e=await Promise.resolve().then(()=>J(ie(),1));return new Promise((a,u)=>{let f=r.createHash("md5"),h=e.createReadStream(i);h.on("error",m=>u(d.business(`Failed to read file for MD5: ${m.message}`))),h.on("data",m=>f.update(m)),h.on("end",()=>a({md5:f.digest("hex")}))})}async function U(i){let r=V();if(r==="browser"){if(!(i instanceof Blob))throw d.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return et(i)}if(r==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw d.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return tt(i)}throw d.business("Unknown or unsupported execution environment for MD5 calculation.")}var G=C(()=>{"use strict";j();R()});function Oe(i){return it.test(i)}var rt,it,_e=C(()=>{"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 $e(i,r){if(!i||i.length===0)return[];if(!r?.allowUnbuilt&&i.find(a=>a&&M(a)))throw d.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return i.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let u=a[a.length-1];if(Oe(u))return!1;for(let h of a)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let f=a.slice(0,-1);for(let h of f)if(ot.some(m=>h.toLowerCase()===m.toLowerCase()))return!1;return!0})}var ot,oe=C(()=>{"use strict";_e();R();ot=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Y(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ne=C(()=>{"use strict"});function Ue(i,r={}){if(r.flatten===!1)return i.map(a=>({path:Y(a),name:se(a)}));let e=st(i);return i.map(a=>{let u=Y(a);if(e){let f=e.endsWith("/")?e:`${e}/`;u.startsWith(f)&&(u=u.substring(f.length))}return u||(u=se(a)),{path:u,name:se(a)}})}function st(i){if(!i.length)return"";let e=i.map(f=>Y(f)).map(f=>f.split("/")),a=[],u=Math.min(...e.map(f=>f.length));for(let f=0;f<u-1;f++){let h=e[0][f];if(e.every(m=>m[f]===h))a.push(h);else break}return a.join("/")}function se(i){return i.split(/[/\\]/).pop()||i}var ae=C(()=>{"use strict";Ne()});function le(i,r=1){if(i===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],u=Math.floor(Math.log(i)/Math.log(e));return parseFloat((i/Math.pow(e,u)).toFixed(r))+" "+a[u]}function pe(i){if(Ae(i))return{valid:!1,reason:"File name contains unsafe characters"};if(i.startsWith(" ")||i.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(i.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let r=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=i.split("/").pop()||i;return r.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:i.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function hn(i,r){let e=[],a=[],u=[];if(i.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 i)if(M(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:i.map(y=>({...y,status:E.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(i.length>r.maxFilesCount){let c={file:`(${i.length} files)`,message:`File count (${i.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(c),{files:i.map(y=>({...y,status:E.VALIDATION_FAILED,statusMessage:c.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let f=0;for(let c of i){let y=E.READY,g="Ready for upload",A=c.name?pe(c.name):{valid:!1,reason:"File name cannot be empty"};if(c.status===E.PROCESSING_ERROR)y=E.VALIDATION_FAILED,g=c.statusMessage||"File failed during processing",e.push({file:c.name,message:g});else if(c.size===0){y=E.EXCLUDED,g="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:c.name,message:g}),u.push({...c,status:y,statusMessage:g});continue}else c.size<0?(y=E.VALIDATION_FAILED,g="File size must be positive",e.push({file:c.name,message:g})):!c.name||c.name.trim().length===0?(y=E.VALIDATION_FAILED,g="File name cannot be empty",e.push({file:c.name||"(empty)",message:g})):c.name.includes("\0")?(y=E.VALIDATION_FAILED,g="File name contains invalid characters (null byte)",e.push({file:c.name,message:g})):A.valid?k(c.name)?(y=E.VALIDATION_FAILED,g=`File extension not allowed: "${c.name}"`,e.push({file:c.name,message:g})):c.size>r.maxFileSize?(y=E.VALIDATION_FAILED,g=`File size (${le(c.size)}) exceeds limit of ${le(r.maxFileSize)}`,e.push({file:c.name,message:g})):(f+=c.size,f>r.maxTotalSize&&(y=E.VALIDATION_FAILED,g=`Total size would exceed limit of ${le(r.maxTotalSize)}`,e.push({file:c.name,message:g}))):(y=E.VALIDATION_FAILED,g=A.reason||"Invalid file name",e.push({file:c.name,message:g}));u.push({...c,status:y,statusMessage:g})}e.length>0&&(u=u.map(c=>c.status===E.EXCLUDED?c:{...c,status:E.VALIDATION_FAILED,statusMessage:c.status===E.VALIDATION_FAILED?c.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?u.filter(c=>c.status===E.READY):[],m=e.length===0;return{files:u,validFiles:h,errors:e,warnings:a,canDeploy:m}}function at(i){return i.filter(r=>r.status===E.READY)}function dn(i){return at(i).length>0}var ue=C(()=>{"use strict";R()});function Le(i,r){if(i.includes("\0")||i.includes("/../")||i.startsWith("../")||i.endsWith("/.."))throw d.business(`Security error: Unsafe file path "${i}" for file: ${r}`)}function Be(i,r){let e=pe(i);if(!e.valid)throw d.business(e.reason||"Invalid file name");if(k(i))throw d.business(`File extension not allowed: "${r}"`)}var ce=C(()=>{"use strict";R();ue()});var Me={};qe(Me,{processFilesForBrowser:()=>ke});async function ke(i,r={}){if(V()!=="browser")throw d.business("processFilesForBrowser can only be called in a browser environment.");let e=i.map(A=>A.webkitRelativePath||A.name),a=r.build||r.prerender,u=Ue(e,{flatten:r.pathDetect!==!1}),f=u.map(A=>A.path),h=new Set($e(f,{allowUnbuilt:a})),m=[];for(let A=0;A<i.length;A++)h.has(f[A])&&m.push({file:i[A],deployPath:u[A].path});if(m.length===0)return[];if(a){let A=[];for(let v=0;v<m.length;v++){let{file:x,deployPath:_}=m[v];if(x.size===0)continue;let{md5:F}=await U(x);A.push({path:_,content:x,size:x.size,md5:F})}return A}let c=$(),y=[],g=0;for(let A=0;A<m.length;A++){let{file:v,deployPath:x}=m[A];if(Le(x,v.name),v.size===0)continue;if(Be(x,v.name),v.size>c.maxFileSize)throw d.business(`File ${v.name} is too large. Maximum allowed size is ${c.maxFileSize/(1024*1024)}MB.`);if(g+=v.size,g>c.maxTotalSize)throw d.business(`Total deploy size is too large. Maximum allowed is ${c.maxTotalSize/(1024*1024)}MB.`);let{md5:_}=await U(v);y.push({path:x,content:v,size:v.size,md5:_})}if(y.length>c.maxFilesCount)throw d.business(`Too many files to deploy. Maximum allowed is ${c.maxFilesCount} files.`);return y}var fe=C(()=>{"use strict";G();R();j();oe();ae();ce();N()});R();var K=class{constructor(){this.handlers=new Map}on(r,e){this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r).add(e)}off(r,e){let a=this.handlers.get(r);a&&(a.delete(e),a.size===0&&this.handlers.delete(r))}emit(r,...e){let a=this.handlers.get(r);if(!a)return;let u=Array.from(a);for(let f of u)try{f(...e)}catch(h){a.delete(f),r!=="error"&&setTimeout(()=>{h instanceof Error?this.emit("error",h,String(r)):this.emit("error",new Error(String(h)),String(r))},0)}}transfer(r){this.handlers.forEach((e,a)=>{e.forEach(u=>{r.on(a,u)})})}clear(){this.handlers.clear()}};var b={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Qe=3e4,H=class extends K{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||z,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??Qe,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||b.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,a,u){let f=this.mergeHeaders(a.headers),{signal:h,cleanup:m}=this.createTimeoutSignal(a.signal),c={...a,headers:f,credentials:this.useCredentials&&!f.Authorization?"include":void 0,signal:h};this.emit("request",e,c);try{let y=await fetch(e,c);return m(),y.ok||await this.handleResponseError(y,u),this.emit("response",this.safeClone(y),e),{data:await this.parseResponse(this.safeClone(y)),status:y.status}}catch(y){m();let g=y instanceof Error?y:new Error(String(y));this.emit("error",g,e),this.handleFetchError(y,u)}}async request(e,a,u){let{data:f}=await this.executeRequest(e,a,u);return f}async requestWithStatus(e,a,u){return this.executeRequest(e,a,u)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let a=new AbortController,u=setTimeout(()=>a.abort(),this.timeout);if(e){let f=()=>a.abort();e.addEventListener("abort",f),e.aborted&&a.abort()}return{signal:a.signal,cleanup:()=>clearTimeout(u)}}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 handleResponseError(e,a){let u={};try{if(e.headers.get("content-type")?.includes("application/json")){let m=await e.json();if(m&&typeof m=="object"){let c=m;typeof c.message=="string"&&(u.message=c.message),typeof c.error=="string"&&(u.error=c.error)}}else u={message:await e.text()}}catch{u={message:"Failed to parse error response"}}let f=u.message||u.error||`${a} failed`;throw e.status===401?d.authentication(f):d.api(f,e.status)}handleFetchError(e,a){throw Z(e)?e:e instanceof Error&&e.name==="AbortError"?d.cancelled(`${a} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?d.network(`${a} failed: ${e.message}`,e):e instanceof Error?d.business(`${a} failed: ${e.message}`):d.business(`${a} failed: Unknown error`)}async deploy(e,a={}){if(!e.length)throw d.business("No files to deploy");for(let c of e)if(!c.md5)throw d.file(`MD5 checksum missing for file: ${c.path}`,c.path);let u=a.build||a.prerender?{build:a.build,prerender:a.prerender}:void 0,{body:f,headers:h}=await this.createDeployBody(e,a.labels,a.via,u),m={};return a.deployToken?m.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(m.Authorization=`Bearer ${a.apiKey}`),a.caller&&(m["X-Caller"]=a.caller),this.request(`${a.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:f,headers:{...h,...m},signal:a.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${b.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${b.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){return this.request(`${this.apiUrl}${b.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:a})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${b.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,u){let f={};a&&(f.deployment=a),u!==void 0&&(f.labels=u);let{data:h,status:m}=await this.requestWithStatus(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...h,isCreate:m===201}}async listDomains(){return this.request(`${this.apiUrl}${b.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${b.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${b.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let u={};return e!==void 0&&(u.ttl=e),a!==void 0&&(u.labels=a),this.request(`${this.apiUrl}${b.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${b.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${b.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${b.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${b.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${b.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${b.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let u=e.find(y=>y.path==="index.html"||y.path==="/index.html");if(!u||u.size>100*1024)return!1;let f;if(typeof Buffer<"u"&&Buffer.isBuffer(u.content))f=u.content.toString("utf-8");else if(typeof Blob<"u"&&u.content instanceof Blob)f=await u.content.text();else if(typeof File<"u"&&u.content instanceof File)f=await u.content.text();else return!1;let h={"Content-Type":"application/json"};a.deployToken?h.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(h.Authorization=`Bearer ${a.apiKey}`);let m={files:e.map(y=>y.path),index:f};return(await this.request(`${this.apiUrl}${b.SPA_CHECK}`,{method:"POST",headers:h,body:JSON.stringify(m)},"SPA check")).isSPA}};R();N();R();R();function Se(i={},r={}){let e={apiUrl:i.apiUrl||r.apiUrl||z,apiKey:i.apiKey!==void 0?i.apiKey:r.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:r.deployToken},a={apiUrl:e.apiUrl};return e.apiKey!==void 0&&(a.apiKey=e.apiKey),e.deployToken!==void 0&&(a.deployToken=e.deployToken),a}function be(i,r){let e={...i};return e.apiUrl===void 0&&r.apiUrl!==void 0&&(e.apiUrl=r.apiUrl),e.apiKey===void 0&&r.apiKey!==void 0&&(e.apiKey=r.apiKey),e.deployToken===void 0&&r.deployToken!==void 0&&(e.deployToken=r.deployToken),e.timeout===void 0&&r.timeout!==void 0&&(e.timeout=r.timeout),e.maxConcurrency===void 0&&r.maxConcurrency!==void 0&&(e.maxConcurrency=r.maxConcurrency),e.onProgress===void 0&&r.onProgress!==void 0&&(e.onProgress=r.onProgress),e.caller===void 0&&r.caller!==void 0&&(e.caller=r.caller),e}R();G();async function nt(){let r=JSON.stringify({rewrites:[{source:"/(.*)",destination:"/index.html"}]},null,2),e;typeof Buffer<"u"?e=Buffer.from(r,"utf-8"):e=new Blob([r],{type:"application/json"});let{md5:a}=await U(e);return{path:ee,content:e,size:r.length,md5:a}}async function Ce(i,r,e){if(e.spaDetect===!1||e.build||e.prerender||i.some(a=>a.path===ee))return i;try{if(await r.checkSPA(i,e)){let u=await nt();return[...i,u]}}catch{}return i}function xe(i){let{getApi:r,ensureInit:e,processInput:a,clientDefaults:u,hasAuth:f}=i;return{upload:async(h,m={})=>{await e();let c=u?be(m,u):m;if(f&&!f()&&!c.deployToken&&!c.apiKey)try{let A=r(),{secret:v}=await A.fetchAgentToken();c.deployToken=v}catch{throw d.authentication("Too many requests; try again later or configure a free API key with 'ship config'")}if(!a)throw d.config("processInput function is not provided.");let y=r(),g=await a(h,c);return g=await Ce(g,y,c),y.deploy(g,c)},list:async()=>(await e(),r().listDeployments()),get:async h=>(await e(),r().getDeployment(h)),set:async(h,m)=>(await e(),r().updateDeploymentLabels(h,m.labels)),remove:async h=>{await e(),await r().removeDeployment(h)}}}function Te(i){let{getApi:r,ensureInit:e}=i;return{set:async(a,u={})=>(await e(),r().setDomain(a,u.deployment,u.labels)),list:async()=>(await e(),r().listDomains()),get:async a=>(await e(),r().getDomain(a)),remove:async a=>{await e(),await r().removeDomain(a)},verify:async a=>(await e(),r().verifyDomain(a)),validate:async a=>(await e(),r().validateDomain(a)),dns:async a=>(await e(),r().getDomainDns(a)),records:async a=>(await e(),r().getDomainRecords(a)),share:async a=>(await e(),r().getDomainShare(a))}}function Ie(i){let{getApi:r,ensureInit:e}=i;return{get:async()=>(await e(),r().getAccount())}}function Fe(i){let{getApi:r,ensureInit:e}=i;return{create:async(a={})=>(await e(),r().createToken(a.ttl,a.labels)),list:async()=>(await e(),r().listTokens()),remove:async a=>{await e(),await r().removeToken(a)}}}var q=class{constructor(r={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=r,r.deployToken?this.auth={type:"token",value:r.deployToken}:r.apiKey&&(this.auth={type:"apiKey",value:r.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let e=this.resolveInitialConfig(r);this.http=new H({...r,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let a={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=xe({...a,processInput:(u,f)=>this.processInput(u,f),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=Te(a),this._account=Ie(a),this._tokens=Fe(a)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(r,e){return this.deployments.upload(r,e)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=$(),this._config)}on(r,e){this.http.on(r,e)}off(r,e){this.http.off(r,e)}setHeaders(r){this.customHeaders=r,this.http.setGlobalHeaders(r)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(r){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(r)}catch(e){console.warn("Event transfer failed during client replacement:",e)}this.http=r,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(r){if(!r||typeof r!="string")throw d.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:r}}setApiKey(r){if(!r||typeof r!="string")throw d.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:r}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};N();R();R();async function Pe(i,r,e,a){let u=new FormData,f=[];for(let h of i){if(!(h.content instanceof File||h.content instanceof Blob))throw d.file(`Unsupported file.content type for browser: ${h.path}`,h.path);if(!h.md5)throw d.file(`File missing md5 checksum: ${h.path}`,h.path);let m=new File([h.content],h.path,{type:"application/octet-stream"});u.append("files[]",m),f.push(h.md5)}return u.append("checksums",JSON.stringify(f)),r&&r.length>0&&u.append("labels",JSON.stringify(r)),e&&u.append("via",e),a?.build&&u.append("build","true"),a?.prerender&&u.append("prerender","true"),{body:u,headers:{}}}G();function nn(i,r,e,a=!0){let u=i===1?r:e;return a?`${i} ${u}`:u}oe();ae();j();ue();ce();R();N();fe();var he=class extends q{constructor(r={}){super(r)}resolveInitialConfig(r){return Se(r,{})}async loadFullConfig(){try{let r=await this.http.getConfig();ne(r)}catch(r){throw this.initPromise=null,r}}async processInput(r,e){if(!this.isFileArray(r))throw d.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw d.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(fe(),Me));return a(r,e)}isFileArray(r){return Array.isArray(r)&&r.every(e=>e instanceof File)}getDeployBodyCreator(){return Pe}},jn=he;export{X as API_KEY_HEX_LENGTH,ft as API_KEY_HINT_LENGTH,P as API_KEY_PREFIX,ye as API_KEY_TOTAL_LENGTH,ct as AccountPlan,H as ApiHttp,ht as AuthMethod,Je as BLOCKED_EXTENSIONS,z as DEFAULT_API,ee as DEPLOYMENT_CONFIG_FILENAME,Q as DEPLOY_TOKEN_HEX_LENGTH,O as DEPLOY_TOKEN_PREFIX,ge as DEPLOY_TOKEN_TOTAL_LENGTH,pt as DeploymentStatus,ut as DomainStatus,S as ErrorType,E as FILE_VALIDATION_STATUS,E as FileValidationStatus,ot as JUNK_DIRECTORIES,Et as LABEL_CONSTRAINTS,vt as LABEL_PATTERN,he as Ship,d as ShipError,Xe as UNBUILT_PROJECT_MARKERS,We as UNSAFE_FILENAME_CHARS,Ut as __setTestEnvironment,dn as allValidFilesReady,U as calculateMD5,Ie as createAccountResource,xe as createDeploymentResource,Te as createDomainResource,Fe as createTokenResource,jn as default,Rt as deserializeLabels,Dt as extractSubdomain,$e as filterJunk,le as formatFileSize,St as generateDeploymentUrl,bt as generateDomainUrl,$ as getCurrentConfig,V as getENV,at as getValidFiles,M as hasUnbuiltMarker,Ae as hasUnsafeChars,k as isBlockedExtension,At as isCustomDomain,gt as isDeployment,De as isPlatformDomain,Z as isShipError,be as mergeDeployOptions,Ue as optimizeDeployPaths,nn as pluralize,ke as processFilesForBrowser,Se as resolveConfig,wt as serializeLabels,ne as setPlatformConfig,dt as validateApiKey,yt as validateApiUrl,Be as validateDeployFile,Le as validateDeployPath,mt as validateDeployToken,pe as validateFileName,hn as validateFiles};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|