@shipstatic/ship 0.7.13 → 0.7.15
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 +2 -2
- package/SKILL.md +83 -0
- package/dist/browser.d.ts +11 -10
- 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 +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @shipstatic/ship
|
|
2
2
|
|
|
3
|
-
Universal SDK and CLI for deploying static files to
|
|
3
|
+
Universal SDK and CLI for deploying static files to ShipStatic.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -318,4 +318,4 @@ import type {
|
|
|
318
318
|
|
|
319
319
|
---
|
|
320
320
|
|
|
321
|
-
Part of the [
|
|
321
|
+
Part of the [ShipStatic](https://shipstatic.com) platform.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ship
|
|
3
|
+
description: Deploy static sites to ShipStatic. Use when the user wants to deploy a website, upload files, manage deployments, set up domains, or publish static files to shipstatic.com.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
Requires Node.js >= 20.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @shipstatic/ship
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Authenticate
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
ship config
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Enter your API key when prompted. Get one at https://my.shipstatic.com/settings
|
|
21
|
+
|
|
22
|
+
Alternative: `export SHIP_API_KEY=ship-...` or pass `--api-key ship-...` per command.
|
|
23
|
+
|
|
24
|
+
## Workflow 1 — Deploy
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
ship ./dist
|
|
28
|
+
ship ./dist --label production --label v1.0
|
|
29
|
+
ship ./dist --json # Returns {"deployment": "<id>", "url": "https://..."}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Workflow 2 — Reserve a Domain
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Pre-flight check
|
|
36
|
+
ship domains validate www.example.com
|
|
37
|
+
|
|
38
|
+
# Reserve (no deployment linked yet)
|
|
39
|
+
ship domains set www.example.com
|
|
40
|
+
|
|
41
|
+
# Or reserve an internal subdomain (instant, no DNS)
|
|
42
|
+
ship domains set my-site
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Internal domains (`my-site.shipstatic.com`) are free and instant. Custom domains require DNS configuration — the CLI prints the required records.
|
|
46
|
+
|
|
47
|
+
**Apex domains are not supported.** Always use a subdomain: `www.example.com`, not `example.com`.
|
|
48
|
+
|
|
49
|
+
## Workflow 3 — Link Domain to Deployment
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Link domain to a deployment
|
|
53
|
+
ship domains set www.example.com <deployment-id>
|
|
54
|
+
|
|
55
|
+
# Switch to a different deployment (instant rollback)
|
|
56
|
+
ship domains set www.example.com <other-deployment-id>
|
|
57
|
+
|
|
58
|
+
# For custom domains: verify DNS after configuring records
|
|
59
|
+
ship domains verify www.example.com
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Reference
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Deployments
|
|
66
|
+
ship deployments list
|
|
67
|
+
ship deployments get <id>
|
|
68
|
+
ship deployments set <id> --label production
|
|
69
|
+
ship deployments remove <id>
|
|
70
|
+
|
|
71
|
+
# Domains
|
|
72
|
+
ship domains list
|
|
73
|
+
ship domains get <name>
|
|
74
|
+
ship domains validate <name>
|
|
75
|
+
ship domains verify <name>
|
|
76
|
+
ship domains remove <name>
|
|
77
|
+
|
|
78
|
+
# Account
|
|
79
|
+
ship whoami
|
|
80
|
+
ship ping
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Use `--json` on any command for machine-readable output.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _shipstatic_types from '@shipstatic/types';
|
|
2
|
-
import { ProgressInfo, StaticFile, Domain, Deployment, DeploymentListResponse, DomainListResponse, DomainDnsResponse, DomainRecordsResponse, DomainValidateResponse, TokenCreateResponse, TokenListResponse, Account, ConfigResponse, ResolvedConfig, DeployInput, AccountResource, DeploymentResource, DomainResource, TokenResource, ValidatableFile, FileValidationResult } from '@shipstatic/types';
|
|
2
|
+
import { DeploymentUploadOptions, ProgressInfo, StaticFile, Domain, Deployment, DeploymentListResponse, DomainListResponse, DomainDnsResponse, DomainRecordsResponse, DomainValidateResponse, TokenCreateResponse, TokenListResponse, Account, ConfigResponse, ResolvedConfig, DeployInput, AccountResource, DeploymentResource, DomainResource, TokenResource, ValidatableFile, FileValidationResult } from '@shipstatic/types';
|
|
3
3
|
export * from '@shipstatic/types';
|
|
4
4
|
export { Account, AccountResource, DEFAULT_API, DeployInput, Deployment, DeploymentResource, Domain, DomainResource, ErrorType, FileValidationStatus as FILE_VALIDATION_STATUS, PingResponse, ResolvedConfig, ShipError, StaticFile, TokenResource } from '@shipstatic/types';
|
|
5
5
|
|
|
@@ -18,15 +18,14 @@ type DomainSetResult = Domain & {
|
|
|
18
18
|
isCreate: boolean;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Universal deploy options for both Node.js and Browser environments
|
|
21
|
+
* Universal deploy options for both Node.js and Browser environments.
|
|
22
|
+
* Extends the API contract (DeploymentUploadOptions) with SDK-specific options.
|
|
22
23
|
*/
|
|
23
|
-
interface DeploymentOptions {
|
|
24
|
+
interface DeploymentOptions extends DeploymentUploadOptions {
|
|
24
25
|
/** The API URL to use for this specific deploy. Overrides client's default. */
|
|
25
26
|
apiUrl?: string;
|
|
26
27
|
/** An AbortSignal to allow cancellation of the deploy operation. */
|
|
27
28
|
signal?: AbortSignal;
|
|
28
|
-
/** An optional subdomain to suggest for the deployment. Availability is subject to the API. */
|
|
29
|
-
subdomain?: string;
|
|
30
29
|
/** Callback invoked if the deploy is cancelled via the AbortSignal. */
|
|
31
30
|
onCancel?: () => void;
|
|
32
31
|
/** Maximum number of concurrent operations. */
|
|
@@ -41,12 +40,8 @@ interface DeploymentOptions {
|
|
|
41
40
|
pathDetect?: boolean;
|
|
42
41
|
/** Whether to auto-detect SPAs and generate ship.json configuration. Defaults to true. */
|
|
43
42
|
spaDetect?: boolean;
|
|
44
|
-
/** Optional array of labels for categorization and filtering (lowercase, alphanumeric with separators). */
|
|
45
|
-
labels?: string[];
|
|
46
43
|
/** Callback for deploy progress with detailed statistics. */
|
|
47
44
|
onProgress?: (info: ProgressInfo) => void;
|
|
48
|
-
/** Client/tool identifier for this deployment (e.g., 'sdk', 'cli', 'web'). Alphanumeric only. */
|
|
49
|
-
via?: string;
|
|
50
45
|
/** Caller identifier for multi-tenant deployments (alphanumeric, dot, underscore, hyphen). */
|
|
51
46
|
caller?: string;
|
|
52
47
|
}
|
|
@@ -107,6 +102,11 @@ interface ShipClientOptions {
|
|
|
107
102
|
* Alphanumeric characters, dots, underscores, and hyphens allowed (max 128 chars).
|
|
108
103
|
*/
|
|
109
104
|
caller?: string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Override the deploy endpoint path. Defaults to '/deployments'.
|
|
107
|
+
* Used by first-party clients to target alternative upload routes (e.g., '/upload').
|
|
108
|
+
*/
|
|
109
|
+
deployEndpoint?: string | undefined;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Event map for Ship SDK events
|
|
@@ -174,6 +174,7 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
174
174
|
private readonly getAuthHeadersCallback;
|
|
175
175
|
private readonly timeout;
|
|
176
176
|
private readonly createDeployBody;
|
|
177
|
+
private readonly deployEndpoint;
|
|
177
178
|
private globalHeaders;
|
|
178
179
|
constructor(options: ApiHttpOptions);
|
|
179
180
|
/**
|
|
@@ -694,7 +695,7 @@ declare function processFilesForBrowser(browserFiles: File[], options?: Deployme
|
|
|
694
695
|
* // Deploy with token obtained from server
|
|
695
696
|
* const ship = new Ship({
|
|
696
697
|
* deployToken: "token-xxxx",
|
|
697
|
-
* apiUrl: "https://api.shipstatic.
|
|
698
|
+
* apiUrl: "https://api.shipstatic.com"
|
|
698
699
|
* });
|
|
699
700
|
*
|
|
700
701
|
* // Deploy files from input element
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ze=Object.create;var O=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Ge=(i,r,e)=>r in i?O(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var x=(i,r)=>()=>(i&&(r=i(i=0)),r);var he=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),qe=(i,r)=>{for(var e in r)O(i,e,{get:r[e],enumerable:!0})},Ye=(i,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of Ke(r))!je.call(i,u)&&u!==e&&O(i,u,{get:()=>r[u],enumerable:!(a=He(r,u))||a.enumerable});return i};var q=(i,r,e)=>(e=i!=null?ze(Ve(i)):{},Ye(r||!i||!i.__esModule?O(e,"default",{value:i,enumerable:!0}):e,i));var $=(i,r,e)=>Ge(i,typeof r!="symbol"?r+"":r,e);function X(i){return i!==null&&typeof i=="object"&&"name"in i&&i.name==="ShipError"&&"status"in i}function N(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 ye(i){return We.test(i)}function L(i){return i.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Xe.has(e))}function dt(i){if(!i.startsWith(T))throw h.validation(`API key must start with "${T}"`);if(i.length!==de)throw h.validation(`API key must be ${de} characters total (${T} + ${J} hex chars)`);let r=i.slice(T.length);if(!/^[a-f0-9]{64}$/i.test(r))throw h.validation(`API key must contain ${J} hexadecimal characters after "${T}" prefix`)}function mt(i){if(!i.startsWith(I))throw h.validation(`Deploy token must start with "${I}"`);if(i.length!==me)throw h.validation(`Deploy token must be ${me} characters total (${I} + ${W} hex chars)`);let r=i.slice(I.length);if(!/^[a-f0-9]{64}$/i.test(r))throw h.validation(`Deploy token must contain ${W} hexadecimal characters after "${I}" prefix`)}function yt(i){try{let r=new URL(i);if(!["http:","https:"].includes(r.protocol))throw h.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw h.validation("API URL must not contain a path");if(r.search||r.hash)throw h.validation("API URL must not contain query parameters or fragments")}catch(r){throw X(r)?r:h.validation("API URL must be a valid URL")}}function gt(i){return/^[a-z]+-[a-z]+-[a-z0-9]{7}$/i.test(i)}function ge(i,r){return i.endsWith(`.${r}`)}function At(i,r){return!ge(i,r)}function Dt(i,r){return ge(i,r)?i.slice(0,-(r.length+1)):null}function St(i,r){return`https://${i}.${r||"shipstatic.com"}`}function Et(i){return`https://${i}`}function bt(i){return!i||i.length===0?null:JSON.stringify(i)}function xt(i){if(!i)return[];try{let r=JSON.parse(i);return Array.isArray(r)?r:[]}catch{return[]}}var pt,ut,ct,D,Y,h,Je,We,Xe,T,J,de,ft,I,W,me,ht,Q,U,E,vt,wt,w=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"};(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"})(D||(D={}));Y={client:new Set([D.Business,D.Config,D.File,D.Validation]),network:new Set([D.Network]),auth:new Set([D.Authentication])},h=class i extends Error{constructor(e,a,u,c){super(a);$(this,"type");$(this,"status");$(this,"details");this.type=e,this.status=u,this.details=c,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 fromResponse(e){return new i(e.error,e.message,e.status,e.details)}static validation(e,a){return new i(D.Validation,e,400,a)}static notFound(e,a){let u=a?`${e} ${a} not found`:`${e} not found`;return new i(D.NotFound,u,404)}static rateLimit(e="Too many requests"){return new i(D.RateLimit,e,429)}static authentication(e="Authentication required",a){return new i(D.Authentication,e,401,a)}static business(e,a=400){return new i(D.Business,e,a)}static network(e,a){return new i(D.Network,e,void 0,{cause:a})}static cancelled(e){return new i(D.Cancelled,e)}static file(e,a){return new i(D.File,e,void 0,{filePath:a})}static config(e,a){return new i(D.Config,e,void 0,a)}static api(e,a=500){return new i(D.Api,e,a)}static database(e,a=500){return new i(D.Api,e,a)}static storage(e,a=500){return new i(D.Api,e,a)}get filePath(){return this.details?.filePath}isClientError(){return Y.client.has(this.type)}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isValidationError(){return this.type===D.Validation}isFileError(){return this.type===D.File}isConfigError(){return this.type===D.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"]);T="ship-",J=64,de=T.length+J,ft=4,I="token-",W=64,me=I.length+W,ht={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},Q="ship.json";U="https://api.shipstatic.com",E={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};vt={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},wt=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/});function ee(i){Z=i}function F(){if(Z===null)throw h.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Z}var Z,P=x(()=>{"use strict";w();Z=null});function Lt(i){te=i}function Ze(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function k(){return te||Ze()}var te,z=x(()=>{"use strict";te=null});var ve=he((Se,Ee)=>{"use strict";(function(i){if(typeof Se=="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 c(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 d(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 g(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,v,R,C;for(t=64;t<=l;t+=64)u(n,c(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})$/),R=parseInt(v[2],16),C=parseInt(v[1],16)||0,o[14]=R,o[15]=C,u(n,o),n}function f(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,v,R,C;for(t=64;t<=l;t+=64)u(n,d(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})$/),R=parseInt(v[2],16),C=parseInt(v[1],16)||0,o[14]=R,o[15]=C,u(n,o),n}function m(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 y(p){var l;for(l=0;l<p.length;l+=1)p[l]=m(p[l]);return p.join("")}y(g("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,R,C,fe;return n!==i&&(o=p(n,t)),s>o?new ArrayBuffer(0):(v=o-s,R=new ArrayBuffer(v),C=new Uint8Array(R),fe=new Uint8Array(this,s,v),C.set(fe),R)}})();function b(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function G(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 Me(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function ke(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 _(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 A(){this.reset()}return A.prototype.append=function(p){return this.appendBinary(b(p)),this},A.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,c(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},A.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=y(this._hash),p&&(o=_(o)),this.reset(),o},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.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)},A.hash=function(p,l){return A.hashBinary(b(p),l)},A.hashBinary=function(p,l){var n=g(p),t=y(n);return l?_(t):t},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(p){var l=ke(this._buff.buffer,p,!0),n=l.length,t;for(this._length+=p.byteLength,t=64;t<=n;t+=64)u(this._hash,d(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},A.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=y(this._hash),p&&(o=_(o)),this.reset(),o},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var p=A.prototype.getState.call(this);return p.buff=Me(p.buff),p},A.ArrayBuffer.prototype.setState=function(p){return p.buff=G(p.buff,!0),A.prototype.setState.call(this,p)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(p,l){var n=f(new Uint8Array(p)),t=y(n);return l?_(t):t},A})});var ne=he((Bt,we)=>{"use strict";we.exports={}});async function et(i){let r=(await Promise.resolve().then(()=>q(ve(),1))).default;return new Promise((e,a)=>{let c=Math.ceil(i.size/2097152),d=0,g=new r.ArrayBuffer,f=new FileReader,m=()=>{let y=d*2097152,b=Math.min(y+2097152,i.size);f.readAsArrayBuffer(i.slice(y,b))};f.onload=y=>{let b=y.target?.result;if(!b){a(h.business("Failed to read file chunk"));return}g.append(b),d++,d<c?m():e({md5:g.end()})},f.onerror=()=>{a(h.business("Failed to calculate MD5: FileReader error"))},m()})}async function tt(i){let r=await Promise.resolve().then(()=>q(ne(),1));if(Buffer.isBuffer(i)){let a=r.createHash("md5");return a.update(i),{md5:a.digest("hex")}}let e=await Promise.resolve().then(()=>q(ne(),1));return new Promise((a,u)=>{let c=r.createHash("md5"),d=e.createReadStream(i);d.on("error",g=>u(h.business(`Failed to read file for MD5: ${g.message}`))),d.on("data",g=>c.update(g)),d.on("end",()=>a({md5:c.digest("hex")}))})}async function H(i){let r=k();if(r==="browser"){if(!(i instanceof Blob))throw h.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 h.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return tt(i)}throw h.business("Unknown or unsupported execution environment for MD5 calculation.")}var K=x(()=>{"use strict";z();w()});function Fe(i){return it.test(i)}var rt,it,Pe=x(()=>{"use strict";rt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],it=new RegExp(rt.join("|"))});function _e(i){if(!i||i.length===0)return[];if(i.find(e=>e&&L(e)))throw h.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(Fe(u))return!1;for(let d of a)if(d!==".well-known"&&(d.startsWith(".")||d.length>255))return!1;let c=a.slice(0,-1);for(let d of c)if(ot.some(g=>d.toLowerCase()===g.toLowerCase()))return!1;return!0})}var ot,re=x(()=>{"use strict";Pe();w();ot=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function j(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Oe=x(()=>{"use strict"});function $e(i,r={}){if(r.flatten===!1)return i.map(a=>({path:j(a),name:ie(a)}));let e=st(i);return i.map(a=>{let u=j(a);if(e){let c=e.endsWith("/")?e:`${e}/`;u.startsWith(c)&&(u=u.substring(c.length))}return u||(u=ie(a)),{path:u,name:ie(a)}})}function st(i){if(!i.length)return"";let e=i.map(c=>j(c)).map(c=>c.split("/")),a=[],u=Math.min(...e.map(c=>c.length));for(let c=0;c<u-1;c++){let d=e[0][c];if(e.every(g=>g[c]===d))a.push(d);else break}return a.join("/")}function ie(i){return i.split(/[/\\]/).pop()||i}var oe=x(()=>{"use strict";Oe()});function se(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 ae(i){if(ye(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 f={file:"(no files)",message:"At least one file must be provided"};return e.push(f),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let f of i)if(L(f.name))return e.push({file:f.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:i.map(m=>({...m,status:E.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(i.length>r.maxFilesCount){let f={file:`(${i.length} files)`,message:`File count (${i.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(f),{files:i.map(m=>({...m,status:E.VALIDATION_FAILED,statusMessage:f.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let f of i){let m=E.READY,y="Ready for upload",b=f.name?ae(f.name):{valid:!1,reason:"File name cannot be empty"};if(f.status===E.PROCESSING_ERROR)m=E.VALIDATION_FAILED,y=f.statusMessage||"File failed during processing",e.push({file:f.name,message:y});else if(f.size===0){m=E.EXCLUDED,y="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:f.name,message:y}),u.push({...f,status:m,statusMessage:y});continue}else f.size<0?(m=E.VALIDATION_FAILED,y="File size must be positive",e.push({file:f.name,message:y})):!f.name||f.name.trim().length===0?(m=E.VALIDATION_FAILED,y="File name cannot be empty",e.push({file:f.name||"(empty)",message:y})):f.name.includes("\0")?(m=E.VALIDATION_FAILED,y="File name contains invalid characters (null byte)",e.push({file:f.name,message:y})):b.valid?N(f.name)?(m=E.VALIDATION_FAILED,y=`File extension not allowed: "${f.name}"`,e.push({file:f.name,message:y})):f.size>r.maxFileSize?(m=E.VALIDATION_FAILED,y=`File size (${se(f.size)}) exceeds limit of ${se(r.maxFileSize)}`,e.push({file:f.name,message:y})):(c+=f.size,c>r.maxTotalSize&&(m=E.VALIDATION_FAILED,y=`Total size would exceed limit of ${se(r.maxTotalSize)}`,e.push({file:f.name,message:y}))):(m=E.VALIDATION_FAILED,y=b.reason||"Invalid file name",e.push({file:f.name,message:y}));u.push({...f,status:m,statusMessage:y})}e.length>0&&(u=u.map(f=>f.status===E.EXCLUDED?f:{...f,status:E.VALIDATION_FAILED,statusMessage:f.status===E.VALIDATION_FAILED?f.statusMessage:"Deployment failed due to validation errors in bundle"}));let d=e.length===0?u.filter(f=>f.status===E.READY):[],g=e.length===0;return{files:u,validFiles:d,errors:e,warnings:a,canDeploy:g}}function at(i){return i.filter(r=>r.status===E.READY)}function dn(i){return at(i).length>0}var le=x(()=>{"use strict";w()});function Ne(i,r){if(i.includes("\0")||i.includes("/../")||i.startsWith("../")||i.endsWith("/.."))throw h.business(`Security error: Unsafe file path "${i}" for file: ${r}`)}function Le(i,r){let e=ae(i);if(!e.valid)throw h.business(e.reason||"Invalid file name");if(N(i))throw h.business(`File extension not allowed: "${r}"`)}var pe=x(()=>{"use strict";w();le()});var Be={};qe(Be,{processFilesForBrowser:()=>Ue});async function Ue(i,r={}){if(k()!=="browser")throw h.business("processFilesForBrowser can only be called in a browser environment.");let e=i.map(m=>m.webkitRelativePath||m.name),a=new Set(_e(e)),u=[];for(let m=0;m<i.length;m++)a.has(e[m])&&u.push({file:i[m],rawPath:e[m]});if(u.length===0)return[];let c=$e(u.map(m=>m.rawPath),{flatten:r.pathDetect!==!1}),d=F(),g=[],f=0;for(let m=0;m<u.length;m++){let{file:y}=u[m],b=c[m].path;if(Ne(b,y.name),y.size===0)continue;if(Le(b,y.name),y.size>d.maxFileSize)throw h.business(`File ${y.name} is too large. Maximum allowed size is ${d.maxFileSize/(1024*1024)}MB.`);if(f+=y.size,f>d.maxTotalSize)throw h.business(`Total deploy size is too large. Maximum allowed is ${d.maxTotalSize/(1024*1024)}MB.`);let{md5:G}=await H(y);g.push({path:b,content:y,size:y.size,md5:G})}if(g.length>d.maxFilesCount)throw h.business(`Too many files to deploy. Maximum allowed is ${d.maxFilesCount} files.`);return g}var ue=x(()=>{"use strict";K();w();z();re();oe();pe();P()});w();var B=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 c of u)try{c(...e)}catch(d){a.delete(c),r!=="error"&&setTimeout(()=>{d instanceof Error?this.emit("error",d,String(r)):this.emit("error",new Error(String(d)),String(r))},0)}}transfer(r){this.handlers.forEach((e,a)=>{e.forEach(u=>{r.on(a,u)})})}clear(){this.handlers.clear()}};var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Qe=3e4,M=class extends B{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||U,this.getAuthHeadersCallback=e.getAuthHeaders,this.timeout=e.timeout??Qe,this.createDeployBody=e.createDeployBody}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,a,u){let c=this.mergeHeaders(a.headers),{signal:d,cleanup:g}=this.createTimeoutSignal(a.signal),f={...a,headers:c,credentials:c.Authorization?void 0:"include",signal:d};this.emit("request",e,f);try{let m=await fetch(e,f);return g(),m.ok||await this.handleResponseError(m,u),this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(m){g();let y=m instanceof Error?m:new Error(String(m));this.emit("error",y,e),this.handleFetchError(m,u)}}async request(e,a,u){let{data:c}=await this.executeRequest(e,a,u);return c}async requestWithStatus(e,a,u){return this.executeRequest(e,a,u)}mergeHeaders(e={}){return{...this.globalHeaders,...e,...this.getAuthHeadersCallback()}}createTimeoutSignal(e){let a=new AbortController,u=setTimeout(()=>a.abort(),this.timeout);if(e){let c=()=>a.abort();e.addEventListener("abort",c),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 g=await e.json();if(g&&typeof g=="object"){let f=g;typeof f.message=="string"&&(u.message=f.message),typeof f.error=="string"&&(u.error=f.error)}}else u={message:await e.text()}}catch{u={message:"Failed to parse error response"}}let c=u.message||u.error||`${a} failed`;throw e.status===401?h.authentication(c):h.api(c,e.status)}handleFetchError(e,a){throw X(e)?e:e instanceof Error&&e.name==="AbortError"?h.cancelled(`${a} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?h.network(`${a} failed: ${e.message}`,e):e instanceof Error?h.business(`${a} failed: ${e.message}`):h.business(`${a} failed: Unknown error`)}async deploy(e,a={}){if(!e.length)throw h.business("No files to deploy");for(let g of e)if(!g.md5)throw h.file(`MD5 checksum missing for file: ${g.path}`,g.path);let{body:u,headers:c}=await this.createDeployBody(e,a.labels,a.via),d={};return a.deployToken?d.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(d.Authorization=`Bearer ${a.apiKey}`),a.caller&&(d["X-Caller"]=a.caller),this.request(`${a.apiUrl||this.apiUrl}${S.DEPLOYMENTS}`,{method:"POST",body:u,headers:{...c,...d},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){return this.request(`${this.apiUrl}${S.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}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,u){let c={};a&&(c.deployment=a),u!==void 0&&(c.labels=u);let{data:d,status:g}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Set domain");return{...d,isCreate:g===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 u={};return e!==void 0&&(u.ttl=e),a!==void 0&&(u.labels=a),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"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 getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${S.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e){let a=e.find(g=>g.path==="index.html"||g.path==="/index.html");if(!a||a.size>100*1024)return!1;let u;if(typeof Buffer<"u"&&Buffer.isBuffer(a.content))u=a.content.toString("utf-8");else if(typeof Blob<"u"&&a.content instanceof Blob)u=await a.content.text();else if(typeof File<"u"&&a.content instanceof File)u=await a.content.text();else return!1;let c={files:e.map(g=>g.path),index:u};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"SPA check")).isSPA}};w();P();w();w();function Ae(i={},r={}){let e={apiUrl:i.apiUrl||r.apiUrl||U,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 De(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();K();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 H(e);return{path:Q,content:e,size:r.length,md5:a}}async function be(i,r,e){if(e.spaDetect===!1||i.some(a=>a.path===Q))return i;try{if(await r.checkSPA(i)){let u=await nt();return[...i,u]}}catch{}return i}function xe(i){let{getApi:r,ensureInit:e,processInput:a,clientDefaults:u,hasAuth:c}=i;return{upload:async(d,g={})=>{await e();let f=u?De(g,u):g;if(c&&!c()&&!f.deployToken&&!f.apiKey)throw h.authentication("Authentication credentials are required for deployment. Please call setDeployToken() or setApiKey() first, or pass credentials in the deployment options.");if(!a)throw h.config("processInput function is not provided.");let m=r(),y=await a(d,f);return y=await be(y,m,f),m.deploy(y,f)},list:async()=>(await e(),r().listDeployments()),get:async d=>(await e(),r().getDeployment(d)),set:async(d,g)=>(await e(),r().updateDeploymentLabels(d,g.labels)),remove:async d=>{await e(),await r().removeDeployment(d)}}}function Re(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 Ce(i){let{getApi:r,ensureInit:e}=i;return{get:async()=>(await e(),r().getAccount())}}function Te(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 V=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 M({...r,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let a={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=xe({...a,processInput:(u,c)=>this.processInput(u,c),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=Re(a),this._account=Ce(a),this._tokens=Te(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=F(),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 h.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 h.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}};P();w();w();async function Ie(i,r,e){let a=new FormData,u=[];for(let c of i){if(!(c.content instanceof File||c.content instanceof Blob))throw h.file(`Unsupported file.content type for browser: ${c.path}`,c.path);if(!c.md5)throw h.file(`File missing md5 checksum: ${c.path}`,c.path);let d=new File([c.content],c.path,{type:"application/octet-stream"});a.append("files[]",d),u.push(c.md5)}return a.append("checksums",JSON.stringify(u)),r&&r.length>0&&a.append("labels",JSON.stringify(r)),e&&a.append("via",e),{body:a,headers:{}}}K();function nn(i,r,e,a=!0){let u=i===1?r:e;return a?`${i} ${u}`:u}re();oe();z();le();pe();w();P();ue();var ce=class extends V{constructor(r={}){super(r)}resolveInitialConfig(r){return Ae(r,{})}async loadFullConfig(){try{let r=await this.http.getConfig();ee(r)}catch(r){throw this.initPromise=null,r}}async processInput(r,e){if(!this.isFileArray(r))throw h.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw h.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(ue(),Be));return a(r,e)}isFileArray(r){return Array.isArray(r)&&r.every(e=>e instanceof File)}getDeployBodyCreator(){return Ie}},jn=ce;export{J as API_KEY_HEX_LENGTH,ft as API_KEY_HINT_LENGTH,T as API_KEY_PREFIX,de as API_KEY_TOTAL_LENGTH,ct as AccountPlan,M as ApiHttp,ht as AuthMethod,Je as BLOCKED_EXTENSIONS,U as DEFAULT_API,Q as DEPLOYMENT_CONFIG_FILENAME,W as DEPLOY_TOKEN_HEX_LENGTH,I as DEPLOY_TOKEN_PREFIX,me as DEPLOY_TOKEN_TOTAL_LENGTH,pt as DeploymentStatus,ut as DomainStatus,D as ErrorType,E as FILE_VALIDATION_STATUS,E as FileValidationStatus,ot as JUNK_DIRECTORIES,vt as LABEL_CONSTRAINTS,wt as LABEL_PATTERN,ce as Ship,h as ShipError,Xe as UNBUILT_PROJECT_MARKERS,We as UNSAFE_FILENAME_CHARS,Lt as __setTestEnvironment,dn as allValidFilesReady,H as calculateMD5,Ce as createAccountResource,xe as createDeploymentResource,Re as createDomainResource,Te as createTokenResource,jn as default,xt as deserializeLabels,Dt as extractSubdomain,_e as filterJunk,se as formatFileSize,St as generateDeploymentUrl,Et as generateDomainUrl,F as getCurrentConfig,k as getENV,at as getValidFiles,L as hasUnbuiltMarker,ye as hasUnsafeChars,N as isBlockedExtension,At as isCustomDomain,gt as isDeployment,ge as isPlatformDomain,X as isShipError,De as mergeDeployOptions,$e as optimizeDeployPaths,nn as pluralize,Ue as processFilesForBrowser,Ae as resolveConfig,bt as serializeLabels,ee as setPlatformConfig,dt as validateApiKey,yt as validateApiUrl,Le as validateDeployFile,Ne as validateDeployPath,mt as validateDeployToken,ae as validateFileName,hn as validateFiles};
|
|
1
|
+
var ze=Object.create;var O=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Ge=(i,r,e)=>r in i?O(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var x=(i,r)=>()=>(i&&(r=i(i=0)),r);var he=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),qe=(i,r)=>{for(var e in r)O(i,e,{get:r[e],enumerable:!0})},Ye=(i,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of Ke(r))!je.call(i,u)&&u!==e&&O(i,u,{get:()=>r[u],enumerable:!(a=He(r,u))||a.enumerable});return i};var q=(i,r,e)=>(e=i!=null?ze(Ve(i)):{},Ye(r||!i||!i.__esModule?O(e,"default",{value:i,enumerable:!0}):e,i));var $=(i,r,e)=>Ge(i,typeof r!="symbol"?r+"":r,e);function X(i){return i!==null&&typeof i=="object"&&"name"in i&&i.name==="ShipError"&&"status"in i}function N(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 ye(i){return We.test(i)}function L(i){return i.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Xe.has(e))}function dt(i){if(!i.startsWith(T))throw h.validation(`API key must start with "${T}"`);if(i.length!==de)throw h.validation(`API key must be ${de} characters total (${T} + ${J} hex chars)`);let r=i.slice(T.length);if(!/^[a-f0-9]{64}$/i.test(r))throw h.validation(`API key must contain ${J} hexadecimal characters after "${T}" prefix`)}function mt(i){if(!i.startsWith(I))throw h.validation(`Deploy token must start with "${I}"`);if(i.length!==me)throw h.validation(`Deploy token must be ${me} characters total (${I} + ${W} hex chars)`);let r=i.slice(I.length);if(!/^[a-f0-9]{64}$/i.test(r))throw h.validation(`Deploy token must contain ${W} hexadecimal characters after "${I}" prefix`)}function yt(i){try{let r=new URL(i);if(!["http:","https:"].includes(r.protocol))throw h.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw h.validation("API URL must not contain a path");if(r.search||r.hash)throw h.validation("API URL must not contain query parameters or fragments")}catch(r){throw X(r)?r:h.validation("API URL must be a valid URL")}}function gt(i){return/^[a-z]+-[a-z]+-[a-z0-9]{7}$/i.test(i)}function ge(i,r){return i.endsWith(`.${r}`)}function At(i,r){return!ge(i,r)}function Dt(i,r){return ge(i,r)?i.slice(0,-(r.length+1)):null}function St(i,r){return`https://${i}.${r||"shipstatic.com"}`}function Et(i){return`https://${i}`}function bt(i){return!i||i.length===0?null:JSON.stringify(i)}function xt(i){if(!i)return[];try{let r=JSON.parse(i);return Array.isArray(r)?r:[]}catch{return[]}}var pt,ut,ct,D,Y,h,Je,We,Xe,T,J,de,ft,I,W,me,ht,Q,U,E,vt,wt,w=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"};(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"})(D||(D={}));Y={client:new Set([D.Business,D.Config,D.File,D.Validation]),network:new Set([D.Network]),auth:new Set([D.Authentication])},h=class i extends Error{constructor(e,a,u,c){super(a);$(this,"type");$(this,"status");$(this,"details");this.type=e,this.status=u,this.details=c,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 fromResponse(e){return new i(e.error,e.message,e.status,e.details)}static validation(e,a){return new i(D.Validation,e,400,a)}static notFound(e,a){let u=a?`${e} ${a} not found`:`${e} not found`;return new i(D.NotFound,u,404)}static rateLimit(e="Too many requests"){return new i(D.RateLimit,e,429)}static authentication(e="Authentication required",a){return new i(D.Authentication,e,401,a)}static business(e,a=400){return new i(D.Business,e,a)}static network(e,a){return new i(D.Network,e,void 0,{cause:a})}static cancelled(e){return new i(D.Cancelled,e)}static file(e,a){return new i(D.File,e,void 0,{filePath:a})}static config(e,a){return new i(D.Config,e,void 0,a)}static api(e,a=500){return new i(D.Api,e,a)}static database(e,a=500){return new i(D.Api,e,a)}static storage(e,a=500){return new i(D.Api,e,a)}get filePath(){return this.details?.filePath}isClientError(){return Y.client.has(this.type)}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isValidationError(){return this.type===D.Validation}isFileError(){return this.type===D.File}isConfigError(){return this.type===D.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"]);T="ship-",J=64,de=T.length+J,ft=4,I="token-",W=64,me=I.length+W,ht={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},Q="ship.json";U="https://api.shipstatic.com",E={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};vt={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},wt=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/});function ee(i){Z=i}function F(){if(Z===null)throw h.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Z}var Z,P=x(()=>{"use strict";w();Z=null});function Lt(i){te=i}function Ze(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function k(){return te||Ze()}var te,z=x(()=>{"use strict";te=null});var ve=he((Se,Ee)=>{"use strict";(function(i){if(typeof Se=="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 c(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 d(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 g(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,v,R,C;for(t=64;t<=l;t+=64)u(n,c(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})$/),R=parseInt(v[2],16),C=parseInt(v[1],16)||0,o[14]=R,o[15]=C,u(n,o),n}function f(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,s,o,v,R,C;for(t=64;t<=l;t+=64)u(n,d(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})$/),R=parseInt(v[2],16),C=parseInt(v[1],16)||0,o[14]=R,o[15]=C,u(n,o),n}function m(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 y(p){var l;for(l=0;l<p.length;l+=1)p[l]=m(p[l]);return p.join("")}y(g("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,R,C,fe;return n!==i&&(o=p(n,t)),s>o?new ArrayBuffer(0):(v=o-s,R=new ArrayBuffer(v),C=new Uint8Array(R),fe=new Uint8Array(this,s,v),C.set(fe),R)}})();function b(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function G(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 Me(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function ke(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 _(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 A(){this.reset()}return A.prototype.append=function(p){return this.appendBinary(b(p)),this},A.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,c(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},A.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=y(this._hash),p&&(o=_(o)),this.reset(),o},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.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)},A.hash=function(p,l){return A.hashBinary(b(p),l)},A.hashBinary=function(p,l){var n=g(p),t=y(n);return l?_(t):t},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(p){var l=ke(this._buff.buffer,p,!0),n=l.length,t;for(this._length+=p.byteLength,t=64;t<=n;t+=64)u(this._hash,d(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},A.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=y(this._hash),p&&(o=_(o)),this.reset(),o},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var p=A.prototype.getState.call(this);return p.buff=Me(p.buff),p},A.ArrayBuffer.prototype.setState=function(p){return p.buff=G(p.buff,!0),A.prototype.setState.call(this,p)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(p,l){var n=f(new Uint8Array(p)),t=y(n);return l?_(t):t},A})});var ne=he((Bt,we)=>{"use strict";we.exports={}});async function et(i){let r=(await Promise.resolve().then(()=>q(ve(),1))).default;return new Promise((e,a)=>{let c=Math.ceil(i.size/2097152),d=0,g=new r.ArrayBuffer,f=new FileReader,m=()=>{let y=d*2097152,b=Math.min(y+2097152,i.size);f.readAsArrayBuffer(i.slice(y,b))};f.onload=y=>{let b=y.target?.result;if(!b){a(h.business("Failed to read file chunk"));return}g.append(b),d++,d<c?m():e({md5:g.end()})},f.onerror=()=>{a(h.business("Failed to calculate MD5: FileReader error"))},m()})}async function tt(i){let r=await Promise.resolve().then(()=>q(ne(),1));if(Buffer.isBuffer(i)){let a=r.createHash("md5");return a.update(i),{md5:a.digest("hex")}}let e=await Promise.resolve().then(()=>q(ne(),1));return new Promise((a,u)=>{let c=r.createHash("md5"),d=e.createReadStream(i);d.on("error",g=>u(h.business(`Failed to read file for MD5: ${g.message}`))),d.on("data",g=>c.update(g)),d.on("end",()=>a({md5:c.digest("hex")}))})}async function H(i){let r=k();if(r==="browser"){if(!(i instanceof Blob))throw h.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 h.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return tt(i)}throw h.business("Unknown or unsupported execution environment for MD5 calculation.")}var K=x(()=>{"use strict";z();w()});function Fe(i){return it.test(i)}var rt,it,Pe=x(()=>{"use strict";rt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],it=new RegExp(rt.join("|"))});function _e(i){if(!i||i.length===0)return[];if(i.find(e=>e&&L(e)))throw h.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(Fe(u))return!1;for(let d of a)if(d!==".well-known"&&(d.startsWith(".")||d.length>255))return!1;let c=a.slice(0,-1);for(let d of c)if(ot.some(g=>d.toLowerCase()===g.toLowerCase()))return!1;return!0})}var ot,re=x(()=>{"use strict";Pe();w();ot=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function j(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Oe=x(()=>{"use strict"});function $e(i,r={}){if(r.flatten===!1)return i.map(a=>({path:j(a),name:ie(a)}));let e=st(i);return i.map(a=>{let u=j(a);if(e){let c=e.endsWith("/")?e:`${e}/`;u.startsWith(c)&&(u=u.substring(c.length))}return u||(u=ie(a)),{path:u,name:ie(a)}})}function st(i){if(!i.length)return"";let e=i.map(c=>j(c)).map(c=>c.split("/")),a=[],u=Math.min(...e.map(c=>c.length));for(let c=0;c<u-1;c++){let d=e[0][c];if(e.every(g=>g[c]===d))a.push(d);else break}return a.join("/")}function ie(i){return i.split(/[/\\]/).pop()||i}var oe=x(()=>{"use strict";Oe()});function se(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 ae(i){if(ye(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 f={file:"(no files)",message:"At least one file must be provided"};return e.push(f),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let f of i)if(L(f.name))return e.push({file:f.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:i.map(m=>({...m,status:E.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(i.length>r.maxFilesCount){let f={file:`(${i.length} files)`,message:`File count (${i.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(f),{files:i.map(m=>({...m,status:E.VALIDATION_FAILED,statusMessage:f.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let f of i){let m=E.READY,y="Ready for upload",b=f.name?ae(f.name):{valid:!1,reason:"File name cannot be empty"};if(f.status===E.PROCESSING_ERROR)m=E.VALIDATION_FAILED,y=f.statusMessage||"File failed during processing",e.push({file:f.name,message:y});else if(f.size===0){m=E.EXCLUDED,y="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:f.name,message:y}),u.push({...f,status:m,statusMessage:y});continue}else f.size<0?(m=E.VALIDATION_FAILED,y="File size must be positive",e.push({file:f.name,message:y})):!f.name||f.name.trim().length===0?(m=E.VALIDATION_FAILED,y="File name cannot be empty",e.push({file:f.name||"(empty)",message:y})):f.name.includes("\0")?(m=E.VALIDATION_FAILED,y="File name contains invalid characters (null byte)",e.push({file:f.name,message:y})):b.valid?N(f.name)?(m=E.VALIDATION_FAILED,y=`File extension not allowed: "${f.name}"`,e.push({file:f.name,message:y})):f.size>r.maxFileSize?(m=E.VALIDATION_FAILED,y=`File size (${se(f.size)}) exceeds limit of ${se(r.maxFileSize)}`,e.push({file:f.name,message:y})):(c+=f.size,c>r.maxTotalSize&&(m=E.VALIDATION_FAILED,y=`Total size would exceed limit of ${se(r.maxTotalSize)}`,e.push({file:f.name,message:y}))):(m=E.VALIDATION_FAILED,y=b.reason||"Invalid file name",e.push({file:f.name,message:y}));u.push({...f,status:m,statusMessage:y})}e.length>0&&(u=u.map(f=>f.status===E.EXCLUDED?f:{...f,status:E.VALIDATION_FAILED,statusMessage:f.status===E.VALIDATION_FAILED?f.statusMessage:"Deployment failed due to validation errors in bundle"}));let d=e.length===0?u.filter(f=>f.status===E.READY):[],g=e.length===0;return{files:u,validFiles:d,errors:e,warnings:a,canDeploy:g}}function at(i){return i.filter(r=>r.status===E.READY)}function dn(i){return at(i).length>0}var le=x(()=>{"use strict";w()});function Ne(i,r){if(i.includes("\0")||i.includes("/../")||i.startsWith("../")||i.endsWith("/.."))throw h.business(`Security error: Unsafe file path "${i}" for file: ${r}`)}function Le(i,r){let e=ae(i);if(!e.valid)throw h.business(e.reason||"Invalid file name");if(N(i))throw h.business(`File extension not allowed: "${r}"`)}var pe=x(()=>{"use strict";w();le()});var Be={};qe(Be,{processFilesForBrowser:()=>Ue});async function Ue(i,r={}){if(k()!=="browser")throw h.business("processFilesForBrowser can only be called in a browser environment.");let e=i.map(m=>m.webkitRelativePath||m.name),a=new Set(_e(e)),u=[];for(let m=0;m<i.length;m++)a.has(e[m])&&u.push({file:i[m],rawPath:e[m]});if(u.length===0)return[];let c=$e(u.map(m=>m.rawPath),{flatten:r.pathDetect!==!1}),d=F(),g=[],f=0;for(let m=0;m<u.length;m++){let{file:y}=u[m],b=c[m].path;if(Ne(b,y.name),y.size===0)continue;if(Le(b,y.name),y.size>d.maxFileSize)throw h.business(`File ${y.name} is too large. Maximum allowed size is ${d.maxFileSize/(1024*1024)}MB.`);if(f+=y.size,f>d.maxTotalSize)throw h.business(`Total deploy size is too large. Maximum allowed is ${d.maxTotalSize/(1024*1024)}MB.`);let{md5:G}=await H(y);g.push({path:b,content:y,size:y.size,md5:G})}if(g.length>d.maxFilesCount)throw h.business(`Too many files to deploy. Maximum allowed is ${d.maxFilesCount} files.`);return g}var ue=x(()=>{"use strict";K();w();z();re();oe();pe();P()});w();var B=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 c of u)try{c(...e)}catch(d){a.delete(c),r!=="error"&&setTimeout(()=>{d instanceof Error?this.emit("error",d,String(r)):this.emit("error",new Error(String(d)),String(r))},0)}}transfer(r){this.handlers.forEach((e,a)=>{e.forEach(u=>{r.on(a,u)})})}clear(){this.handlers.clear()}};var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Qe=3e4,M=class extends B{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||U,this.getAuthHeadersCallback=e.getAuthHeaders,this.timeout=e.timeout??Qe,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||S.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,a,u){let c=this.mergeHeaders(a.headers),{signal:d,cleanup:g}=this.createTimeoutSignal(a.signal),f={...a,headers:c,credentials:c.Authorization?void 0:"include",signal:d};this.emit("request",e,f);try{let m=await fetch(e,f);return g(),m.ok||await this.handleResponseError(m,u),this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(m){g();let y=m instanceof Error?m:new Error(String(m));this.emit("error",y,e),this.handleFetchError(m,u)}}async request(e,a,u){let{data:c}=await this.executeRequest(e,a,u);return c}async requestWithStatus(e,a,u){return this.executeRequest(e,a,u)}mergeHeaders(e={}){return{...this.globalHeaders,...e,...this.getAuthHeadersCallback()}}createTimeoutSignal(e){let a=new AbortController,u=setTimeout(()=>a.abort(),this.timeout);if(e){let c=()=>a.abort();e.addEventListener("abort",c),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 g=await e.json();if(g&&typeof g=="object"){let f=g;typeof f.message=="string"&&(u.message=f.message),typeof f.error=="string"&&(u.error=f.error)}}else u={message:await e.text()}}catch{u={message:"Failed to parse error response"}}let c=u.message||u.error||`${a} failed`;throw e.status===401?h.authentication(c):h.api(c,e.status)}handleFetchError(e,a){throw X(e)?e:e instanceof Error&&e.name==="AbortError"?h.cancelled(`${a} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?h.network(`${a} failed: ${e.message}`,e):e instanceof Error?h.business(`${a} failed: ${e.message}`):h.business(`${a} failed: Unknown error`)}async deploy(e,a={}){if(!e.length)throw h.business("No files to deploy");for(let g of e)if(!g.md5)throw h.file(`MD5 checksum missing for file: ${g.path}`,g.path);let{body:u,headers:c}=await this.createDeployBody(e,a.labels,a.via),d={};return a.deployToken?d.Authorization=`Bearer ${a.deployToken}`:a.apiKey&&(d.Authorization=`Bearer ${a.apiKey}`),a.caller&&(d["X-Caller"]=a.caller),this.request(`${a.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:u,headers:{...c,...d},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){return this.request(`${this.apiUrl}${S.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}${S.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,u){let c={};a&&(c.deployment=a),u!==void 0&&(c.labels=u);let{data:d,status:g}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Set domain");return{...d,isCreate:g===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 u={};return e!==void 0&&(u.ttl=e),a!==void 0&&(u.labels=a),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"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 getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${S.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e){let a=e.find(g=>g.path==="index.html"||g.path==="/index.html");if(!a||a.size>100*1024)return!1;let u;if(typeof Buffer<"u"&&Buffer.isBuffer(a.content))u=a.content.toString("utf-8");else if(typeof Blob<"u"&&a.content instanceof Blob)u=await a.content.text();else if(typeof File<"u"&&a.content instanceof File)u=await a.content.text();else return!1;let c={files:e.map(g=>g.path),index:u};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"SPA check")).isSPA}};w();P();w();w();function Ae(i={},r={}){let e={apiUrl:i.apiUrl||r.apiUrl||U,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 De(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();K();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 H(e);return{path:Q,content:e,size:r.length,md5:a}}async function be(i,r,e){if(e.spaDetect===!1||i.some(a=>a.path===Q))return i;try{if(await r.checkSPA(i)){let u=await nt();return[...i,u]}}catch{}return i}function xe(i){let{getApi:r,ensureInit:e,processInput:a,clientDefaults:u,hasAuth:c}=i;return{upload:async(d,g={})=>{await e();let f=u?De(g,u):g;if(c&&!c()&&!f.deployToken&&!f.apiKey)throw h.authentication("Authentication credentials are required for deployment. Please call setDeployToken() or setApiKey() first, or pass credentials in the deployment options.");if(!a)throw h.config("processInput function is not provided.");let m=r(),y=await a(d,f);return y=await be(y,m,f),m.deploy(y,f)},list:async()=>(await e(),r().listDeployments()),get:async d=>(await e(),r().getDeployment(d)),set:async(d,g)=>(await e(),r().updateDeploymentLabels(d,g.labels)),remove:async d=>{await e(),await r().removeDeployment(d)}}}function Re(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 Ce(i){let{getApi:r,ensureInit:e}=i;return{get:async()=>(await e(),r().getAccount())}}function Te(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 V=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 M({...r,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let a={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=xe({...a,processInput:(u,c)=>this.processInput(u,c),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=Re(a),this._account=Ce(a),this._tokens=Te(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=F(),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 h.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 h.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}};P();w();w();async function Ie(i,r,e){let a=new FormData,u=[];for(let c of i){if(!(c.content instanceof File||c.content instanceof Blob))throw h.file(`Unsupported file.content type for browser: ${c.path}`,c.path);if(!c.md5)throw h.file(`File missing md5 checksum: ${c.path}`,c.path);let d=new File([c.content],c.path,{type:"application/octet-stream"});a.append("files[]",d),u.push(c.md5)}return a.append("checksums",JSON.stringify(u)),r&&r.length>0&&a.append("labels",JSON.stringify(r)),e&&a.append("via",e),{body:a,headers:{}}}K();function nn(i,r,e,a=!0){let u=i===1?r:e;return a?`${i} ${u}`:u}re();oe();z();le();pe();w();P();ue();var ce=class extends V{constructor(r={}){super(r)}resolveInitialConfig(r){return Ae(r,{})}async loadFullConfig(){try{let r=await this.http.getConfig();ee(r)}catch(r){throw this.initPromise=null,r}}async processInput(r,e){if(!this.isFileArray(r))throw h.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw h.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(ue(),Be));return a(r,e)}isFileArray(r){return Array.isArray(r)&&r.every(e=>e instanceof File)}getDeployBodyCreator(){return Ie}},jn=ce;export{J as API_KEY_HEX_LENGTH,ft as API_KEY_HINT_LENGTH,T as API_KEY_PREFIX,de as API_KEY_TOTAL_LENGTH,ct as AccountPlan,M as ApiHttp,ht as AuthMethod,Je as BLOCKED_EXTENSIONS,U as DEFAULT_API,Q as DEPLOYMENT_CONFIG_FILENAME,W as DEPLOY_TOKEN_HEX_LENGTH,I as DEPLOY_TOKEN_PREFIX,me as DEPLOY_TOKEN_TOTAL_LENGTH,pt as DeploymentStatus,ut as DomainStatus,D as ErrorType,E as FILE_VALIDATION_STATUS,E as FileValidationStatus,ot as JUNK_DIRECTORIES,vt as LABEL_CONSTRAINTS,wt as LABEL_PATTERN,ce as Ship,h as ShipError,Xe as UNBUILT_PROJECT_MARKERS,We as UNSAFE_FILENAME_CHARS,Lt as __setTestEnvironment,dn as allValidFilesReady,H as calculateMD5,Ce as createAccountResource,xe as createDeploymentResource,Re as createDomainResource,Te as createTokenResource,jn as default,xt as deserializeLabels,Dt as extractSubdomain,_e as filterJunk,se as formatFileSize,St as generateDeploymentUrl,Et as generateDomainUrl,F as getCurrentConfig,k as getENV,at as getValidFiles,L as hasUnbuiltMarker,ye as hasUnsafeChars,N as isBlockedExtension,At as isCustomDomain,gt as isDeployment,ge as isPlatformDomain,X as isShipError,De as mergeDeployOptions,$e as optimizeDeployPaths,nn as pluralize,Ue as processFilesForBrowser,Ae as resolveConfig,bt as serializeLabels,ee as setPlatformConfig,dt as validateApiKey,yt as validateApiUrl,Le as validateDeployFile,Ne as validateDeployPath,mt as validateDeployToken,ae as validateFileName,hn as validateFiles};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|