@ibanzajoe/uploader 0.3.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -21
- package/dist/{chunk-EM6NZZSU.js → chunk-6AJTZNOI.js} +152 -51
- package/dist/chunk-6AJTZNOI.js.map +1 -0
- package/dist/chunk-DJK2SQ5I.js +56 -0
- package/dist/chunk-DJK2SQ5I.js.map +1 -0
- package/dist/client-CUmYuQ7Z.d.cts +154 -0
- package/dist/client-CUmYuQ7Z.d.ts +154 -0
- package/dist/core.cjs +158 -3
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +8 -4
- package/dist/index.cjs +158 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +79 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +54 -0
- package/dist/server.d.ts +54 -0
- package/dist/server.js +26 -0
- package/dist/server.js.map +1 -0
- package/dist/styles.css +2 -2
- package/dist/transform-BTZ0kodO.d.cts +130 -0
- package/dist/transform-BTZ0kodO.d.ts +130 -0
- package/package.json +12 -2
- package/dist/chunk-EM6NZZSU.js.map +0 -1
- package/dist/transform-ybCOCWBG.d.cts +0 -225
- package/dist/transform-ybCOCWBG.d.ts +0 -225
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SDK-level option and result types for UploaderClient.
|
|
3
|
-
*
|
|
4
|
-
* The upload-contract types below are VENDORED from @uploader/shared so that
|
|
5
|
-
* @uploader/react is self-contained for consumers outside this monorepo — one
|
|
6
|
-
* install, no @uploader/* or zod transitive deps. They mirror the API contract
|
|
7
|
-
* exactly; `contract.conformance.ts` asserts at typecheck time that they stay
|
|
8
|
-
* structurally identical to the shared definitions, failing the build on drift.
|
|
9
|
-
*/
|
|
10
|
-
/** A stored file result returned by the upload API and SDK. Mirrors Filestack's FileResult. */
|
|
11
|
-
type FileResult = {
|
|
12
|
-
handle: string;
|
|
13
|
-
url: string;
|
|
14
|
-
filename: string;
|
|
15
|
-
mimetype: string;
|
|
16
|
-
size: number;
|
|
17
|
-
status: 'Stored';
|
|
18
|
-
uploadId?: string;
|
|
19
|
-
};
|
|
20
|
-
/** Response from the picker overlay / upload batch. */
|
|
21
|
-
type PickerResponse = {
|
|
22
|
-
filesUploaded: FileResult[];
|
|
23
|
-
filesFailed: FileResult[];
|
|
24
|
-
};
|
|
25
|
-
/** JSON payload that is base64-encoded and HMAC-signed as a security policy. */
|
|
26
|
-
type PolicySpec = {
|
|
27
|
-
/** Unix epoch seconds when the policy expires. */
|
|
28
|
-
expiry: number;
|
|
29
|
-
/** Allowed API calls, e.g. ["store", "read", "remove"]. */
|
|
30
|
-
call: string[];
|
|
31
|
-
/** Restrict to a specific file handle (read/remove). */
|
|
32
|
-
handle?: string;
|
|
33
|
-
/** Maximum file size in bytes (store). */
|
|
34
|
-
maxSize?: number;
|
|
35
|
-
/** Minimum file size in bytes (store). */
|
|
36
|
-
minSize?: number;
|
|
37
|
-
/** Restrict store destination path prefix. */
|
|
38
|
-
path?: string;
|
|
39
|
-
};
|
|
40
|
-
/** Options passed to UploaderClient constructor. */
|
|
41
|
-
type UploaderClientOptions = {
|
|
42
|
-
/** Public API key (pk_...). */
|
|
43
|
-
apikey: string;
|
|
44
|
-
/** Base URL of the upload API. Defaults to the hosted endpoint. */
|
|
45
|
-
apiUrl?: string;
|
|
46
|
-
/** Optional signed security policy. */
|
|
47
|
-
security?: {
|
|
48
|
-
policy: string;
|
|
49
|
-
signature: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/** Per-file upload options. */
|
|
53
|
-
type UploadOptions = {
|
|
54
|
-
/** Progress callback, value 0–100. */
|
|
55
|
-
onProgress?: (percent: number) => void;
|
|
56
|
-
/** Storage path prefix. */
|
|
57
|
-
path?: string;
|
|
58
|
-
/** Override the file's stored name. */
|
|
59
|
-
filename?: string;
|
|
60
|
-
/** AbortSignal to cancel the upload. */
|
|
61
|
-
signal?: AbortSignal;
|
|
62
|
-
/**
|
|
63
|
-
* Chunk size in bytes for multipart uploads.
|
|
64
|
-
* Defaults to ~5 MB; files larger than this threshold use multipart.
|
|
65
|
-
*/
|
|
66
|
-
chunkSize?: number;
|
|
67
|
-
};
|
|
68
|
-
/** Options for uploadAll — extends per-file options with concurrency control. */
|
|
69
|
-
type UploadAllOptions = UploadOptions & {
|
|
70
|
-
/** Maximum concurrent uploads. Defaults to 3. */
|
|
71
|
-
concurrency?: number;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* UploaderClient — headless upload client.
|
|
76
|
-
*
|
|
77
|
-
* Chooses single-shot (POST /api/store, multipart/form-data) vs multipart
|
|
78
|
-
* (start/part/complete) based on file size relative to MULTIPART_THRESHOLD
|
|
79
|
-
* (5 MB). Parts are retried individually with exponential backoff. Progress
|
|
80
|
-
* is emitted as a 0–100 integer. AbortSignal cancels in-flight work.
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
declare class UploaderClient {
|
|
84
|
-
#private;
|
|
85
|
-
readonly apikey: string;
|
|
86
|
-
readonly apiUrl: string;
|
|
87
|
-
readonly security: UploaderClientOptions['security'];
|
|
88
|
-
constructor(options: UploaderClientOptions);
|
|
89
|
-
/**
|
|
90
|
-
* Upload a single file.
|
|
91
|
-
*
|
|
92
|
-
* Automatically selects single-shot vs multipart upload based on file size.
|
|
93
|
-
* Emits progress via `opts.onProgress` (0–100). Respects `opts.signal` for
|
|
94
|
-
* cancellation. Retries network errors and 5xx responses up to 3 times with
|
|
95
|
-
* exponential backoff; 4xx errors are surfaced immediately.
|
|
96
|
-
*
|
|
97
|
-
* @throws {UploaderError} with code ABORTED | NETWORK_ERROR | SERVER_ERROR |
|
|
98
|
-
* CLIENT_ERROR | INVALID_RESPONSE
|
|
99
|
-
*/
|
|
100
|
-
upload(file: File | Blob, opts?: UploadOptions): Promise<FileResult>;
|
|
101
|
-
/**
|
|
102
|
-
* Upload multiple files with concurrency limiting.
|
|
103
|
-
*
|
|
104
|
-
* Resolves once all uploads settle (fulfilled or rejected). The returned
|
|
105
|
-
* array preserves input order. `opts.concurrency` caps simultaneous
|
|
106
|
-
* in-flight uploads (default 3). Each file shares the same opts
|
|
107
|
-
* (including onProgress — the callback fires per-file, not aggregate).
|
|
108
|
-
*
|
|
109
|
-
* @returns Array of PromiseSettledResult in input order.
|
|
110
|
-
*/
|
|
111
|
-
uploadAll(files: Array<File | Blob>, opts?: UploadAllOptions): Promise<PromiseSettledResult<FileResult>[]>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Delivery / transform URL builder.
|
|
116
|
-
*
|
|
117
|
-
* The API serves transformed derivatives at `GET /<chain>/<handle>`, where
|
|
118
|
-
* <chain> is a slash-joined list of ops (e.g. `resize=w:200,h:200,fit:crop`).
|
|
119
|
-
* These op builders + `transformUrl()` construct that URL from an uploaded file
|
|
120
|
-
* handle, so consumers render an image at any size/format/quality without
|
|
121
|
-
* hand-assembling URL strings.
|
|
122
|
-
*
|
|
123
|
-
* The op/param types and serialization mirror @uploader/shared EXACTLY — the
|
|
124
|
-
* API's `parseTransformChain` is the other half of this contract, and
|
|
125
|
-
* `contract.conformance.ts` asserts at typecheck time that they stay in sync.
|
|
126
|
-
*/
|
|
127
|
-
type TransformOpName = 'resize' | 'crop' | 'rotate' | 'flip' | 'flop' | 'quality' | 'output';
|
|
128
|
-
/** Parameters for the resize operation. */
|
|
129
|
-
type ResizeParams = {
|
|
130
|
-
w?: number;
|
|
131
|
-
h?: number;
|
|
132
|
-
fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside' | 'crop';
|
|
133
|
-
};
|
|
134
|
-
/** Parameters for the crop operation. */
|
|
135
|
-
type CropParams = {
|
|
136
|
-
/** "x,y,w,h" notation. */
|
|
137
|
-
dim: string;
|
|
138
|
-
x?: number;
|
|
139
|
-
y?: number;
|
|
140
|
-
w?: number;
|
|
141
|
-
h?: number;
|
|
142
|
-
};
|
|
143
|
-
/** Parameters for the rotate operation. */
|
|
144
|
-
type RotateParams = {
|
|
145
|
-
deg: number;
|
|
146
|
-
};
|
|
147
|
-
/** Parameters for the quality operation. */
|
|
148
|
-
type QualityParams = {
|
|
149
|
-
n: number;
|
|
150
|
-
};
|
|
151
|
-
/** Parameters for the output operation. */
|
|
152
|
-
type OutputParams = {
|
|
153
|
-
format: string;
|
|
154
|
-
};
|
|
155
|
-
/** A single transform operation with its typed params. */
|
|
156
|
-
type TransformOp = {
|
|
157
|
-
name: 'resize';
|
|
158
|
-
params: ResizeParams;
|
|
159
|
-
} | {
|
|
160
|
-
name: 'crop';
|
|
161
|
-
params: CropParams;
|
|
162
|
-
} | {
|
|
163
|
-
name: 'rotate';
|
|
164
|
-
params: RotateParams;
|
|
165
|
-
} | {
|
|
166
|
-
name: 'flip';
|
|
167
|
-
params: Record<string, never>;
|
|
168
|
-
} | {
|
|
169
|
-
name: 'flop';
|
|
170
|
-
params: Record<string, never>;
|
|
171
|
-
} | {
|
|
172
|
-
name: 'quality';
|
|
173
|
-
params: QualityParams;
|
|
174
|
-
} | {
|
|
175
|
-
name: 'output';
|
|
176
|
-
params: OutputParams;
|
|
177
|
-
};
|
|
178
|
-
/** An ordered list of transform operations. */
|
|
179
|
-
type TransformChain = {
|
|
180
|
-
ops: TransformOp[];
|
|
181
|
-
};
|
|
182
|
-
/** Resize to a width and/or height with an optional fit mode. */
|
|
183
|
-
declare const resize: (params: ResizeParams) => TransformOp;
|
|
184
|
-
/** Crop a rectangular region: origin (x, y) and size w×h, in source pixels. */
|
|
185
|
-
declare const crop: (rect: {
|
|
186
|
-
x: number;
|
|
187
|
-
y: number;
|
|
188
|
-
w: number;
|
|
189
|
-
h: number;
|
|
190
|
-
}) => TransformOp;
|
|
191
|
-
/** Rotate clockwise by `deg` degrees. */
|
|
192
|
-
declare const rotate: (params: RotateParams) => TransformOp;
|
|
193
|
-
/** Flip vertically (mirror top↔bottom). */
|
|
194
|
-
declare const flip: () => TransformOp;
|
|
195
|
-
/** Flop horizontally (mirror left↔right). */
|
|
196
|
-
declare const flop: () => TransformOp;
|
|
197
|
-
/** Set output quality 1–100 (ignored by lossless formats). */
|
|
198
|
-
declare const quality: (params: QualityParams) => TransformOp;
|
|
199
|
-
/** Convert the output format, e.g. `{ format: 'webp' }`. */
|
|
200
|
-
declare const output: (params: OutputParams) => TransformOp;
|
|
201
|
-
type TransformUrlOptions = {
|
|
202
|
-
/** File handle from an upload (`FileResult.handle`). */
|
|
203
|
-
handle: string;
|
|
204
|
-
/** Ordered transform ops to apply. Must contain at least one op. */
|
|
205
|
-
ops: TransformOp[];
|
|
206
|
-
/**
|
|
207
|
-
* Base API URL. Defaults to '' so the URL is relative — `/<chain>/<handle>` —
|
|
208
|
-
* and resolves same-origin (e.g. proxied to the API). Pass an absolute URL to
|
|
209
|
-
* point at a remote API directly.
|
|
210
|
-
*/
|
|
211
|
-
apiUrl?: string;
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Build a delivery URL that applies `ops` to the file identified by `handle`.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* transformUrl({
|
|
218
|
-
* handle: file.handle,
|
|
219
|
-
* ops: [resize({ w: 200, h: 200, fit: 'crop' }), output({ format: 'webp' })],
|
|
220
|
-
* })
|
|
221
|
-
* // => "/resize=w:200,h:200,fit:crop/output=format:webp/<handle>"
|
|
222
|
-
*/
|
|
223
|
-
declare function transformUrl({ handle, ops, apiUrl }: TransformUrlOptions): string;
|
|
224
|
-
|
|
225
|
-
export { type CropParams as C, type FileResult as F, type OutputParams as O, type PickerResponse as P, type QualityParams as Q, type ResizeParams as R, type TransformChain as T, type UploadAllOptions as U, type PolicySpec as a, type RotateParams as b, type TransformOp as c, type TransformOpName as d, type TransformUrlOptions as e, type UploadOptions as f, UploaderClient as g, type UploaderClientOptions as h, crop as i, flip as j, flop as k, rotate as l, output as o, quality as q, resize as r, transformUrl as t };
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SDK-level option and result types for UploaderClient.
|
|
3
|
-
*
|
|
4
|
-
* The upload-contract types below are VENDORED from @uploader/shared so that
|
|
5
|
-
* @uploader/react is self-contained for consumers outside this monorepo — one
|
|
6
|
-
* install, no @uploader/* or zod transitive deps. They mirror the API contract
|
|
7
|
-
* exactly; `contract.conformance.ts` asserts at typecheck time that they stay
|
|
8
|
-
* structurally identical to the shared definitions, failing the build on drift.
|
|
9
|
-
*/
|
|
10
|
-
/** A stored file result returned by the upload API and SDK. Mirrors Filestack's FileResult. */
|
|
11
|
-
type FileResult = {
|
|
12
|
-
handle: string;
|
|
13
|
-
url: string;
|
|
14
|
-
filename: string;
|
|
15
|
-
mimetype: string;
|
|
16
|
-
size: number;
|
|
17
|
-
status: 'Stored';
|
|
18
|
-
uploadId?: string;
|
|
19
|
-
};
|
|
20
|
-
/** Response from the picker overlay / upload batch. */
|
|
21
|
-
type PickerResponse = {
|
|
22
|
-
filesUploaded: FileResult[];
|
|
23
|
-
filesFailed: FileResult[];
|
|
24
|
-
};
|
|
25
|
-
/** JSON payload that is base64-encoded and HMAC-signed as a security policy. */
|
|
26
|
-
type PolicySpec = {
|
|
27
|
-
/** Unix epoch seconds when the policy expires. */
|
|
28
|
-
expiry: number;
|
|
29
|
-
/** Allowed API calls, e.g. ["store", "read", "remove"]. */
|
|
30
|
-
call: string[];
|
|
31
|
-
/** Restrict to a specific file handle (read/remove). */
|
|
32
|
-
handle?: string;
|
|
33
|
-
/** Maximum file size in bytes (store). */
|
|
34
|
-
maxSize?: number;
|
|
35
|
-
/** Minimum file size in bytes (store). */
|
|
36
|
-
minSize?: number;
|
|
37
|
-
/** Restrict store destination path prefix. */
|
|
38
|
-
path?: string;
|
|
39
|
-
};
|
|
40
|
-
/** Options passed to UploaderClient constructor. */
|
|
41
|
-
type UploaderClientOptions = {
|
|
42
|
-
/** Public API key (pk_...). */
|
|
43
|
-
apikey: string;
|
|
44
|
-
/** Base URL of the upload API. Defaults to the hosted endpoint. */
|
|
45
|
-
apiUrl?: string;
|
|
46
|
-
/** Optional signed security policy. */
|
|
47
|
-
security?: {
|
|
48
|
-
policy: string;
|
|
49
|
-
signature: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/** Per-file upload options. */
|
|
53
|
-
type UploadOptions = {
|
|
54
|
-
/** Progress callback, value 0–100. */
|
|
55
|
-
onProgress?: (percent: number) => void;
|
|
56
|
-
/** Storage path prefix. */
|
|
57
|
-
path?: string;
|
|
58
|
-
/** Override the file's stored name. */
|
|
59
|
-
filename?: string;
|
|
60
|
-
/** AbortSignal to cancel the upload. */
|
|
61
|
-
signal?: AbortSignal;
|
|
62
|
-
/**
|
|
63
|
-
* Chunk size in bytes for multipart uploads.
|
|
64
|
-
* Defaults to ~5 MB; files larger than this threshold use multipart.
|
|
65
|
-
*/
|
|
66
|
-
chunkSize?: number;
|
|
67
|
-
};
|
|
68
|
-
/** Options for uploadAll — extends per-file options with concurrency control. */
|
|
69
|
-
type UploadAllOptions = UploadOptions & {
|
|
70
|
-
/** Maximum concurrent uploads. Defaults to 3. */
|
|
71
|
-
concurrency?: number;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* UploaderClient — headless upload client.
|
|
76
|
-
*
|
|
77
|
-
* Chooses single-shot (POST /api/store, multipart/form-data) vs multipart
|
|
78
|
-
* (start/part/complete) based on file size relative to MULTIPART_THRESHOLD
|
|
79
|
-
* (5 MB). Parts are retried individually with exponential backoff. Progress
|
|
80
|
-
* is emitted as a 0–100 integer. AbortSignal cancels in-flight work.
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
declare class UploaderClient {
|
|
84
|
-
#private;
|
|
85
|
-
readonly apikey: string;
|
|
86
|
-
readonly apiUrl: string;
|
|
87
|
-
readonly security: UploaderClientOptions['security'];
|
|
88
|
-
constructor(options: UploaderClientOptions);
|
|
89
|
-
/**
|
|
90
|
-
* Upload a single file.
|
|
91
|
-
*
|
|
92
|
-
* Automatically selects single-shot vs multipart upload based on file size.
|
|
93
|
-
* Emits progress via `opts.onProgress` (0–100). Respects `opts.signal` for
|
|
94
|
-
* cancellation. Retries network errors and 5xx responses up to 3 times with
|
|
95
|
-
* exponential backoff; 4xx errors are surfaced immediately.
|
|
96
|
-
*
|
|
97
|
-
* @throws {UploaderError} with code ABORTED | NETWORK_ERROR | SERVER_ERROR |
|
|
98
|
-
* CLIENT_ERROR | INVALID_RESPONSE
|
|
99
|
-
*/
|
|
100
|
-
upload(file: File | Blob, opts?: UploadOptions): Promise<FileResult>;
|
|
101
|
-
/**
|
|
102
|
-
* Upload multiple files with concurrency limiting.
|
|
103
|
-
*
|
|
104
|
-
* Resolves once all uploads settle (fulfilled or rejected). The returned
|
|
105
|
-
* array preserves input order. `opts.concurrency` caps simultaneous
|
|
106
|
-
* in-flight uploads (default 3). Each file shares the same opts
|
|
107
|
-
* (including onProgress — the callback fires per-file, not aggregate).
|
|
108
|
-
*
|
|
109
|
-
* @returns Array of PromiseSettledResult in input order.
|
|
110
|
-
*/
|
|
111
|
-
uploadAll(files: Array<File | Blob>, opts?: UploadAllOptions): Promise<PromiseSettledResult<FileResult>[]>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Delivery / transform URL builder.
|
|
116
|
-
*
|
|
117
|
-
* The API serves transformed derivatives at `GET /<chain>/<handle>`, where
|
|
118
|
-
* <chain> is a slash-joined list of ops (e.g. `resize=w:200,h:200,fit:crop`).
|
|
119
|
-
* These op builders + `transformUrl()` construct that URL from an uploaded file
|
|
120
|
-
* handle, so consumers render an image at any size/format/quality without
|
|
121
|
-
* hand-assembling URL strings.
|
|
122
|
-
*
|
|
123
|
-
* The op/param types and serialization mirror @uploader/shared EXACTLY — the
|
|
124
|
-
* API's `parseTransformChain` is the other half of this contract, and
|
|
125
|
-
* `contract.conformance.ts` asserts at typecheck time that they stay in sync.
|
|
126
|
-
*/
|
|
127
|
-
type TransformOpName = 'resize' | 'crop' | 'rotate' | 'flip' | 'flop' | 'quality' | 'output';
|
|
128
|
-
/** Parameters for the resize operation. */
|
|
129
|
-
type ResizeParams = {
|
|
130
|
-
w?: number;
|
|
131
|
-
h?: number;
|
|
132
|
-
fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside' | 'crop';
|
|
133
|
-
};
|
|
134
|
-
/** Parameters for the crop operation. */
|
|
135
|
-
type CropParams = {
|
|
136
|
-
/** "x,y,w,h" notation. */
|
|
137
|
-
dim: string;
|
|
138
|
-
x?: number;
|
|
139
|
-
y?: number;
|
|
140
|
-
w?: number;
|
|
141
|
-
h?: number;
|
|
142
|
-
};
|
|
143
|
-
/** Parameters for the rotate operation. */
|
|
144
|
-
type RotateParams = {
|
|
145
|
-
deg: number;
|
|
146
|
-
};
|
|
147
|
-
/** Parameters for the quality operation. */
|
|
148
|
-
type QualityParams = {
|
|
149
|
-
n: number;
|
|
150
|
-
};
|
|
151
|
-
/** Parameters for the output operation. */
|
|
152
|
-
type OutputParams = {
|
|
153
|
-
format: string;
|
|
154
|
-
};
|
|
155
|
-
/** A single transform operation with its typed params. */
|
|
156
|
-
type TransformOp = {
|
|
157
|
-
name: 'resize';
|
|
158
|
-
params: ResizeParams;
|
|
159
|
-
} | {
|
|
160
|
-
name: 'crop';
|
|
161
|
-
params: CropParams;
|
|
162
|
-
} | {
|
|
163
|
-
name: 'rotate';
|
|
164
|
-
params: RotateParams;
|
|
165
|
-
} | {
|
|
166
|
-
name: 'flip';
|
|
167
|
-
params: Record<string, never>;
|
|
168
|
-
} | {
|
|
169
|
-
name: 'flop';
|
|
170
|
-
params: Record<string, never>;
|
|
171
|
-
} | {
|
|
172
|
-
name: 'quality';
|
|
173
|
-
params: QualityParams;
|
|
174
|
-
} | {
|
|
175
|
-
name: 'output';
|
|
176
|
-
params: OutputParams;
|
|
177
|
-
};
|
|
178
|
-
/** An ordered list of transform operations. */
|
|
179
|
-
type TransformChain = {
|
|
180
|
-
ops: TransformOp[];
|
|
181
|
-
};
|
|
182
|
-
/** Resize to a width and/or height with an optional fit mode. */
|
|
183
|
-
declare const resize: (params: ResizeParams) => TransformOp;
|
|
184
|
-
/** Crop a rectangular region: origin (x, y) and size w×h, in source pixels. */
|
|
185
|
-
declare const crop: (rect: {
|
|
186
|
-
x: number;
|
|
187
|
-
y: number;
|
|
188
|
-
w: number;
|
|
189
|
-
h: number;
|
|
190
|
-
}) => TransformOp;
|
|
191
|
-
/** Rotate clockwise by `deg` degrees. */
|
|
192
|
-
declare const rotate: (params: RotateParams) => TransformOp;
|
|
193
|
-
/** Flip vertically (mirror top↔bottom). */
|
|
194
|
-
declare const flip: () => TransformOp;
|
|
195
|
-
/** Flop horizontally (mirror left↔right). */
|
|
196
|
-
declare const flop: () => TransformOp;
|
|
197
|
-
/** Set output quality 1–100 (ignored by lossless formats). */
|
|
198
|
-
declare const quality: (params: QualityParams) => TransformOp;
|
|
199
|
-
/** Convert the output format, e.g. `{ format: 'webp' }`. */
|
|
200
|
-
declare const output: (params: OutputParams) => TransformOp;
|
|
201
|
-
type TransformUrlOptions = {
|
|
202
|
-
/** File handle from an upload (`FileResult.handle`). */
|
|
203
|
-
handle: string;
|
|
204
|
-
/** Ordered transform ops to apply. Must contain at least one op. */
|
|
205
|
-
ops: TransformOp[];
|
|
206
|
-
/**
|
|
207
|
-
* Base API URL. Defaults to '' so the URL is relative — `/<chain>/<handle>` —
|
|
208
|
-
* and resolves same-origin (e.g. proxied to the API). Pass an absolute URL to
|
|
209
|
-
* point at a remote API directly.
|
|
210
|
-
*/
|
|
211
|
-
apiUrl?: string;
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Build a delivery URL that applies `ops` to the file identified by `handle`.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* transformUrl({
|
|
218
|
-
* handle: file.handle,
|
|
219
|
-
* ops: [resize({ w: 200, h: 200, fit: 'crop' }), output({ format: 'webp' })],
|
|
220
|
-
* })
|
|
221
|
-
* // => "/resize=w:200,h:200,fit:crop/output=format:webp/<handle>"
|
|
222
|
-
*/
|
|
223
|
-
declare function transformUrl({ handle, ops, apiUrl }: TransformUrlOptions): string;
|
|
224
|
-
|
|
225
|
-
export { type CropParams as C, type FileResult as F, type OutputParams as O, type PickerResponse as P, type QualityParams as Q, type ResizeParams as R, type TransformChain as T, type UploadAllOptions as U, type PolicySpec as a, type RotateParams as b, type TransformOp as c, type TransformOpName as d, type TransformUrlOptions as e, type UploadOptions as f, UploaderClient as g, type UploaderClientOptions as h, crop as i, flip as j, flop as k, rotate as l, output as o, quality as q, resize as r, transformUrl as t };
|