@imagekit/javascript 5.0.0-beta.6 → 5.0.0
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 +0 -2
- package/dist/imagekit.cjs.js +11 -12
- package/dist/imagekit.esm.js +11 -12
- package/dist/imagekit.min.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/interfaces/UploadOptions.d.ts +4 -0
- package/dist/upload.d.ts +1 -1
- package/dist/url.d.ts +2 -2
- package/package.json +2 -3
- package/src/constants/errorMessages.ts +0 -14
- package/src/constants/supportedTransforms.ts +0 -80
- package/src/index.ts +0 -13
- package/src/interfaces/SrcOptions.ts +0 -35
- package/src/interfaces/Transformation.ts +0 -723
- package/src/interfaces/UploadOptions.ts +0 -192
- package/src/interfaces/UploadResponse.ts +0 -182
- package/src/interfaces/index.ts +0 -7
- package/src/upload.ts +0 -274
- package/src/url.ts +0 -301
- package/src/utils/transformation.ts +0 -40
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
# ImageKit.io JavaScript SDK
|
|
4
4
|
|
|
5
|
-

|
|
6
|
-

|
|
7
5
|

|
|
8
6
|
[](https://www.npmjs.com/package/@imagekit/javascript)
|
|
9
7
|
[](https://codecov.io/gh/imagekit-developer/imagekit-javascript)
|
package/dist/imagekit.cjs.js
CHANGED
|
@@ -119,32 +119,31 @@ const upload = uploadOptions => {
|
|
|
119
119
|
for (key in uploadOptions) {
|
|
120
120
|
if (key) {
|
|
121
121
|
if (key === "file" && typeof uploadOptions.file != "string") {
|
|
122
|
-
formData.
|
|
122
|
+
formData.set('file', uploadOptions.file, String(uploadOptions.fileName));
|
|
123
123
|
} else if (key === "tags" && Array.isArray(uploadOptions.tags)) {
|
|
124
|
-
formData.
|
|
124
|
+
formData.set('tags', uploadOptions.tags.join(","));
|
|
125
125
|
} else if (key === 'signature') {
|
|
126
|
-
formData.
|
|
126
|
+
formData.set("signature", uploadOptions.signature);
|
|
127
127
|
} else if (key === 'expire') {
|
|
128
|
-
formData.
|
|
128
|
+
formData.set("expire", String(uploadOptions.expire));
|
|
129
129
|
} else if (key === 'token') {
|
|
130
|
-
formData.
|
|
130
|
+
formData.set("token", uploadOptions.token);
|
|
131
131
|
} else if (key === "responseFields" && Array.isArray(uploadOptions.responseFields)) {
|
|
132
|
-
formData.
|
|
132
|
+
formData.set('responseFields', uploadOptions.responseFields.join(","));
|
|
133
133
|
} else if (key === "extensions" && Array.isArray(uploadOptions.extensions)) {
|
|
134
|
-
formData.
|
|
134
|
+
formData.set('extensions', JSON.stringify(uploadOptions.extensions));
|
|
135
135
|
} else if (key === "customMetadata" && typeof uploadOptions.customMetadata === "object" && !Array.isArray(uploadOptions.customMetadata) && uploadOptions.customMetadata !== null) {
|
|
136
|
-
formData.
|
|
136
|
+
formData.set('customMetadata', JSON.stringify(uploadOptions.customMetadata));
|
|
137
137
|
} else if (key === "transformation" && typeof uploadOptions.transformation === "object" && uploadOptions.transformation !== null) {
|
|
138
|
-
formData.
|
|
138
|
+
formData.set(key, JSON.stringify(uploadOptions.transformation));
|
|
139
139
|
} else if (key === 'checks' && uploadOptions.checks) {
|
|
140
|
-
formData.
|
|
140
|
+
formData.set("checks", uploadOptions.checks);
|
|
141
141
|
} else if (uploadOptions[key] !== undefined) {
|
|
142
142
|
if (["onProgress", "abortSignal"].includes(key)) continue;
|
|
143
|
-
formData.
|
|
143
|
+
formData.set(key, String(uploadOptions[key]));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
formData.append("publicKey", uploadOptions.publicKey);
|
|
148
147
|
if (uploadOptions.onProgress) {
|
|
149
148
|
xhr.upload.onprogress = function (event) {
|
|
150
149
|
if (uploadOptions.onProgress) uploadOptions.onProgress(event);
|
package/dist/imagekit.esm.js
CHANGED
|
@@ -115,32 +115,31 @@ const upload = uploadOptions => {
|
|
|
115
115
|
for (key in uploadOptions) {
|
|
116
116
|
if (key) {
|
|
117
117
|
if (key === "file" && typeof uploadOptions.file != "string") {
|
|
118
|
-
formData.
|
|
118
|
+
formData.set('file', uploadOptions.file, String(uploadOptions.fileName));
|
|
119
119
|
} else if (key === "tags" && Array.isArray(uploadOptions.tags)) {
|
|
120
|
-
formData.
|
|
120
|
+
formData.set('tags', uploadOptions.tags.join(","));
|
|
121
121
|
} else if (key === 'signature') {
|
|
122
|
-
formData.
|
|
122
|
+
formData.set("signature", uploadOptions.signature);
|
|
123
123
|
} else if (key === 'expire') {
|
|
124
|
-
formData.
|
|
124
|
+
formData.set("expire", String(uploadOptions.expire));
|
|
125
125
|
} else if (key === 'token') {
|
|
126
|
-
formData.
|
|
126
|
+
formData.set("token", uploadOptions.token);
|
|
127
127
|
} else if (key === "responseFields" && Array.isArray(uploadOptions.responseFields)) {
|
|
128
|
-
formData.
|
|
128
|
+
formData.set('responseFields', uploadOptions.responseFields.join(","));
|
|
129
129
|
} else if (key === "extensions" && Array.isArray(uploadOptions.extensions)) {
|
|
130
|
-
formData.
|
|
130
|
+
formData.set('extensions', JSON.stringify(uploadOptions.extensions));
|
|
131
131
|
} else if (key === "customMetadata" && typeof uploadOptions.customMetadata === "object" && !Array.isArray(uploadOptions.customMetadata) && uploadOptions.customMetadata !== null) {
|
|
132
|
-
formData.
|
|
132
|
+
formData.set('customMetadata', JSON.stringify(uploadOptions.customMetadata));
|
|
133
133
|
} else if (key === "transformation" && typeof uploadOptions.transformation === "object" && uploadOptions.transformation !== null) {
|
|
134
|
-
formData.
|
|
134
|
+
formData.set(key, JSON.stringify(uploadOptions.transformation));
|
|
135
135
|
} else if (key === 'checks' && uploadOptions.checks) {
|
|
136
|
-
formData.
|
|
136
|
+
formData.set("checks", uploadOptions.checks);
|
|
137
137
|
} else if (uploadOptions[key] !== undefined) {
|
|
138
138
|
if (["onProgress", "abortSignal"].includes(key)) continue;
|
|
139
|
-
formData.
|
|
139
|
+
formData.set(key, String(uploadOptions[key]));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
formData.append("publicKey", uploadOptions.publicKey);
|
|
144
143
|
if (uploadOptions.onProgress) {
|
|
145
144
|
xhr.upload.onprogress = function (event) {
|
|
146
145
|
if (uploadOptions.onProgress) uploadOptions.onProgress(event);
|
package/dist/imagekit.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ImageKit={})}(this,(function(e){"use strict";var r={message:"Missing file parameter for upload"},t={message:"Missing fileName parameter for upload"},n={message:"Missing public key for upload"},
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ImageKit={})}(this,(function(e){"use strict";var r={message:"Missing file parameter for upload"},t={message:"Missing fileName parameter for upload"},n={message:"Missing public key for upload"},s={message:"Request to ImageKit upload endpoint failed due to network error"},a={message:"Missing signature for upload. The SDK expects token, signature and expire for authentication."},o={message:"Missing token for upload. The SDK expects token, signature and expire for authentication."},i={message:"Missing expire for upload. The SDK expects token, signature and expire for authentication."},u={message:"Invalid transformation parameter. Please include at least pre, post, or both."},l={message:"Invalid pre transformation parameter."},p={message:"Invalid post transformation parameter."};class c extends Error{constructor(e,r){super(e),this.$ResponseMetadata=void 0,this.name="ImageKitInvalidRequestError",this.$ResponseMetadata=r}}class f extends Error{constructor(e,r){super(e),this.reason=void 0,this.name="ImageKitAbortError",this.reason=r}}class d extends Error{constructor(e){super(e),this.name="ImageKitUploadNetworkError"}}class g extends Error{constructor(e,r){super(e),this.$ResponseMetadata=void 0,this.name="ImageKitServerError",this.$ResponseMetadata=r}}const m=(e,r)=>{let t={...e};const n=h(r);return Object.defineProperty(t,"$ResponseMetadata",{value:n,enumerable:!1,writable:!1}),t},h=e=>{const r=function(e){const r={},t=e.getAllResponseHeaders();Object.keys(t).length&&t.trim().split(/[\r\n]+/).map(e=>e.split(/: /)).forEach(e=>{r[e[0].trim().toLowerCase()]=e[1].trim()});return r}(e);return{statusCode:e.status,headers:r,requestId:r["x-request-id"]}};const y={width:"w",height:"h",aspectRatio:"ar",background:"bg",border:"b",crop:"c",cropMode:"cm",dpr:"dpr",focus:"fo",quality:"q",x:"x",xCenter:"xc",y:"y",yCenter:"yc",format:"f",videoCodec:"vc",audioCodec:"ac",radius:"r",rotation:"rt",blur:"bl",named:"n",defaultImage:"di",flip:"fl",original:"orig",startOffset:"so",endOffset:"eo",duration:"du",streamingResolutions:"sr",grayscale:"e-grayscale",aiUpscale:"e-upscale",aiRetouch:"e-retouch",aiVariation:"e-genvar",aiDropShadow:"e-dropshadow",aiChangeBackground:"e-changebg",aiRemoveBackground:"e-bgremove",aiRemoveBackgroundExternal:"e-removedotbg",contrastStretch:"e-contrast",shadow:"e-shadow",sharpen:"e-sharpen",unsharpMask:"e-usm",gradient:"e-gradient",progressive:"pr",lossless:"lo",colorProfile:"cp",metadata:"md",opacity:"o",trim:"t",zoom:"z",page:"pg",fontSize:"fs",fontFamily:"ff",fontColor:"co",innerAlignment:"ia",padding:"pa",alpha:"al",typography:"tg",lineHeight:"lh",fontOutline:"fol",fontShadow:"fsh",raw:"raw"};var b=e=>"query"===e.transformationPosition,v=function(e){return e&&(y[e]||y[e.toLowerCase()])||""},w=function(){return":"},x=function(){return","},S=function(){return"-"};const k=function(e){return"undefined"!=typeof window?btoa(e):Buffer.from(e,"utf8").toString("base64")},R=new RegExp("^[a-zA-Z0-9-._/ ]*$"),I=new RegExp("^[a-zA-Z0-9-._ ]*$");function E(e){return"string"==typeof e&&"/"==e[e.length-1]&&(e=e.substring(0,e.length-1)),e}function M(e){return"string"==typeof e&&"/"==e[0]&&(e=e.slice(1)),e}function j(e,r){var t=r||"/",n=new RegExp(t+"{1,}","g");return e.join(t).replace(n,t)}function A(e,r){return e=E(M(e)),"plain"===r?"i-"+e.replace(/\//g,"@@"):"base64"===r?"ie-"+encodeURIComponent(k(e)):R.test(e)?"i-"+e.replace(/\//g,"@@"):"ie-"+encodeURIComponent(k(e))}function P(e){const r=[],{type:t,position:n={},timing:s={},transformation:a=[]}=e||{};if(!t)return;switch(t){case"text":{const t=e;if(!t.text)return;const n=t.encoding||"auto";r.push("l-text"),r.push(function(e,r){return"plain"===r?"i-"+encodeURIComponent(e):"base64"===r?"ie-"+encodeURIComponent(k(e)):I.test(e)?"i-"+encodeURIComponent(e):"ie-"+encodeURIComponent(k(e))}(t.text,n))}break;case"image":r.push("l-image");{const t=e,n=t.encoding||"auto";if(!t.input)return;r.push(A(t.input,n))}break;case"video":r.push("l-video");{const t=e,n=t.encoding||"auto";if(!t.input)return;r.push(A(t.input,n))}break;case"subtitle":r.push("l-subtitle");{const t=e,n=t.encoding||"auto";if(!t.input)return;r.push(A(t.input,n))}break;case"solidColor":r.push("l-image"),r.push("i-ik_canvas");{const t=e;if(!t.color)return;r.push("bg-"+t.color)}}const{x:o,y:i,focus:u}=n;o&&r.push("lx-"+o),i&&r.push("ly-"+i),u&&r.push("lfo-"+u);const{start:l,end:p,duration:c}=s;l&&r.push("lso-"+l),p&&r.push("leo-"+p),c&&r.push("ldu-"+c);const f=O(a);return f&&""!==f.trim()&&r.push(f),r.push("l-end"),r.join(x())}const O=function(e){if(!Array.isArray(e))return"";for(var r=[],t=0,n=e.length;t<n;t++){var s=[];for(var a in e[t]){let r=e[t][a];if(null!=r)if("overlay"!==a||"object"!=typeof r){var o=v(a);if(o||(o=a),""!==o)if(["e-grayscale","e-contrast","e-removedotbg","e-bgremove","e-upscale","e-retouch","e-genvar"].includes(o)){if(!0!==r&&"-"!==r&&"true"!==r)continue;s.push(o)}else!["e-sharpen","e-shadow","e-gradient","e-usm","e-dropshadow"].includes(o)||""!==r.toString().trim()&&!0!==r&&"true"!==r?"raw"===a?s.push(e[t][a]):("di"===o&&(r=E(M(r||"")),r=r.replace(/\//g,"@@")),"sr"===o&&Array.isArray(r)&&(r=r.join("_")),"t"===o&&""===r.toString().trim()&&(r="true"),s.push([o,r].join(S()))):s.push(o)}else{var i=P(r);i&&""!==i.trim()&&s.push(i)}}s.length&&r.push(s.join(x()))}return r.join(w())};e.ImageKitAbortError=f,e.ImageKitInvalidRequestError=c,e.ImageKitServerError=g,e.ImageKitUploadNetworkError=d,e.buildSrc=e=>{if(e.urlEndpoint=e.urlEndpoint||"",e.src=e.src||"",e.transformationPosition=e.transformationPosition||"query",!e.src)return"";const r=e.src.startsWith("http://")||e.src.startsWith("https://");var t,n,s;try{r?(t=new URL(e.src),n=!0):(s=new URL(e.urlEndpoint).pathname,t=new URL(j([e.urlEndpoint.replace(s,""),e.src])))}catch(e){return console.error(e),""}for(var a in e.queryParameters)t.searchParams.append(a,String(e.queryParameters[a]));var o=O(e.transformation);return o&&o.length&&(b(e)||n||(t.pathname=j(["tr"+w()+o,t.pathname]))),t.pathname=j(s?[s,t.pathname]:[t.pathname]),o&&o.length&&(b(e)||n)?""!==t.searchParams.toString()?`${t.href}&tr=${o}`:`${t.href}?tr=${o}`:t.href},e.buildTransformationString=O,e.upload=e=>e?new Promise((y,b)=>{const{xhr:v}=e||{};delete e.xhr;const w=v||new XMLHttpRequest;if(!e.file)return b(new c(r.message));if(!e.fileName)return b(new c(t.message));if(!e.publicKey||0===e.publicKey.length)return b(new c(n.message));if(!e.token)return b(new c(o.message));if(!e.signature)return b(new c(a.message));if(!e.expire)return b(new c(i.message));if(e.transformation){if(!Object.keys(e.transformation).includes("pre")&&!Object.keys(e.transformation).includes("post"))return b(new c(u.message));if(Object.keys(e.transformation).includes("pre")&&!e.transformation.pre)return b(new c(l.message));if(Object.keys(e.transformation).includes("post")){if(!Array.isArray(e.transformation.post))return b(new c(p.message));for(let r of e.transformation.post){if("abs"===r.type&&!r.protocol&&!r.value)return b(new c(p.message));if("transformation"===r.type&&!r.value)return b(new c(p.message))}}}var x=new FormData;let S;for(S in e)if(S)if("file"===S&&"string"!=typeof e.file)x.set("file",e.file,String(e.fileName));else if("tags"===S&&Array.isArray(e.tags))x.set("tags",e.tags.join(","));else if("signature"===S)x.set("signature",e.signature);else if("expire"===S)x.set("expire",String(e.expire));else if("token"===S)x.set("token",e.token);else if("responseFields"===S&&Array.isArray(e.responseFields))x.set("responseFields",e.responseFields.join(","));else if("extensions"===S&&Array.isArray(e.extensions))x.set("extensions",JSON.stringify(e.extensions));else if("customMetadata"!==S||"object"!=typeof e.customMetadata||Array.isArray(e.customMetadata)||null===e.customMetadata){if("transformation"===S&&"object"==typeof e.transformation&&null!==e.transformation)x.set(S,JSON.stringify(e.transformation));else if("checks"===S&&e.checks)x.set("checks",e.checks);else if(void 0!==e[S]){if(["onProgress","abortSignal"].includes(S))continue;x.set(S,String(e[S]))}}else x.set("customMetadata",JSON.stringify(e.customMetadata));function k(){var r;return w.abort(),b(new f("Upload aborted",null===(r=e.abortSignal)||void 0===r?void 0:r.reason))}if(e.onProgress&&(w.upload.onprogress=function(r){e.onProgress&&e.onProgress(r)}),e.abortSignal){var R;if(e.abortSignal.aborted)return b(new f("Upload aborted",null===(R=e.abortSignal)||void 0===R?void 0:R.reason));e.abortSignal.addEventListener("abort",k),w.addEventListener("loadend",()=>{e.abortSignal&&e.abortSignal.removeEventListener("abort",k)})}w.open("POST","https://upload.imagekit.io/api/v1/files/upload"),w.onerror=function(e){return b(new d(s.message))},w.onload=function(){if(w.status>=200&&w.status<300)try{var e=JSON.parse(w.responseText),r=m(e,w);return y(r)}catch(e){return b(e)}else if(w.status>=400&&w.status<500)try{e=JSON.parse(w.responseText);return b(new c(e.message??"Invalid request. Please check the parameters.",h(w)))}catch(e){return b(e)}else try{e=JSON.parse(w.responseText);return b(new g(e.message??"Server error occurred while uploading the file. This is rare and usually temporary.",h(w)))}catch(e){return b(new g("Server error occurred while uploading the file. This is rare and usually temporary.",h(w)))}},w.send(x)}):Promise.reject(new c("Invalid options provided for upload")),Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SrcOptions, Transformation, UploadOptions, UploadResponse } from "./interfaces";
|
|
1
|
+
import type { SrcOptions, Transformation, UploadOptions, UploadResponse } from "./interfaces";
|
|
2
2
|
import { ImageKitAbortError, ImageKitInvalidRequestError, ImageKitServerError, ImageKitUploadNetworkError, upload } from "./upload";
|
|
3
3
|
import { buildSrc, buildTransformationString } from "./url";
|
|
4
4
|
export { buildSrc, buildTransformationString, upload, ImageKitInvalidRequestError, ImageKitAbortError, ImageKitServerError, ImageKitUploadNetworkError };
|
|
@@ -16,6 +16,8 @@ interface Transformation {
|
|
|
16
16
|
/**
|
|
17
17
|
* Specifies pre-transformations to be applied. Must be a valid string of transformations like "w-300,h-300".
|
|
18
18
|
* Refer to the docs for more details on transformations.
|
|
19
|
+
*
|
|
20
|
+
* {@link https://imagekit.io/docs/dam/pre-and-post-transformation-on-upload#pre-transformation}
|
|
19
21
|
*/
|
|
20
22
|
pre?: string;
|
|
21
23
|
/**
|
|
@@ -25,6 +27,8 @@ interface Transformation {
|
|
|
25
27
|
* - protocol: Used only when type is "abs". Can be "hls" or "dash".
|
|
26
28
|
*
|
|
27
29
|
* Refer to the docs for more details on transformations and usage in post.
|
|
30
|
+
*
|
|
31
|
+
* {@link https://imagekit.io/docs/dam/pre-and-post-transformation-on-upload#post-transformation}
|
|
28
32
|
*/
|
|
29
33
|
post?: PostTransformation[];
|
|
30
34
|
}
|
package/dist/upload.d.ts
CHANGED
package/dist/url.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SrcOptions } from "./interfaces";
|
|
2
|
-
import { Transformation } from "./interfaces/Transformation";
|
|
1
|
+
import type { SrcOptions } from "./interfaces";
|
|
2
|
+
import type { Transformation } from "./interfaces/Transformation";
|
|
3
3
|
/**
|
|
4
4
|
* Builds a source URL with the given options.
|
|
5
5
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imagekit/javascript",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "ImageKit Javascript SDK",
|
|
5
5
|
"main": "dist/imagekit.cjs.js",
|
|
6
6
|
"module": "dist/imagekit.esm.js",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"unpkg": "dist/imagekit.min.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
"src"
|
|
11
|
+
"dist"
|
|
13
12
|
],
|
|
14
13
|
"devDependencies": {
|
|
15
14
|
"@babel/cli": "^7.10.5",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
MISSING_UPLOAD_FILE_PARAMETER: { message: "Missing file parameter for upload" },
|
|
3
|
-
MISSING_UPLOAD_FILENAME_PARAMETER: { message: "Missing fileName parameter for upload" },
|
|
4
|
-
MISSING_PUBLIC_KEY: { message: "Missing public key for upload" },
|
|
5
|
-
UPLOAD_ENDPOINT_NETWORK_ERROR: {
|
|
6
|
-
message: "Request to ImageKit upload endpoint failed due to network error"
|
|
7
|
-
},
|
|
8
|
-
MISSING_SIGNATURE: { message: "Missing signature for upload. The SDK expects token, signature and expire for authentication." },
|
|
9
|
-
MISSING_TOKEN: { message: "Missing token for upload. The SDK expects token, signature and expire for authentication." },
|
|
10
|
-
MISSING_EXPIRE: { message: "Missing expire for upload. The SDK expects token, signature and expire for authentication." },
|
|
11
|
-
INVALID_TRANSFORMATION: { message: "Invalid transformation parameter. Please include at least pre, post, or both." },
|
|
12
|
-
INVALID_PRE_TRANSFORMATION: { message: "Invalid pre transformation parameter." },
|
|
13
|
-
INVALID_POST_TRANSFORMATION: { message: "Invalid post transformation parameter." }
|
|
14
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* {@link https://imagekit.io/docs/transformations}
|
|
3
|
-
*/
|
|
4
|
-
export const supportedTransforms: { [key: string]: string } = {
|
|
5
|
-
// Basic sizing & layout
|
|
6
|
-
width: "w",
|
|
7
|
-
height: "h",
|
|
8
|
-
aspectRatio: "ar",
|
|
9
|
-
background: "bg",
|
|
10
|
-
border: "b",
|
|
11
|
-
crop: "c",
|
|
12
|
-
cropMode: "cm",
|
|
13
|
-
dpr: "dpr",
|
|
14
|
-
focus: "fo",
|
|
15
|
-
quality: "q",
|
|
16
|
-
x: "x",
|
|
17
|
-
xCenter: "xc",
|
|
18
|
-
y: "y",
|
|
19
|
-
yCenter: "yc",
|
|
20
|
-
format: "f",
|
|
21
|
-
videoCodec: "vc",
|
|
22
|
-
audioCodec: "ac",
|
|
23
|
-
radius: "r",
|
|
24
|
-
rotation: "rt",
|
|
25
|
-
blur: "bl",
|
|
26
|
-
named: "n",
|
|
27
|
-
defaultImage: "di",
|
|
28
|
-
flip: "fl",
|
|
29
|
-
original: "orig",
|
|
30
|
-
startOffset: "so",
|
|
31
|
-
endOffset: "eo",
|
|
32
|
-
duration: "du",
|
|
33
|
-
streamingResolutions: "sr",
|
|
34
|
-
|
|
35
|
-
// AI & advanced effects
|
|
36
|
-
grayscale: "e-grayscale",
|
|
37
|
-
aiUpscale: "e-upscale",
|
|
38
|
-
aiRetouch: "e-retouch",
|
|
39
|
-
aiVariation: "e-genvar",
|
|
40
|
-
aiDropShadow: "e-dropshadow",
|
|
41
|
-
aiChangeBackground: "e-changebg",
|
|
42
|
-
aiRemoveBackground: "e-bgremove",
|
|
43
|
-
aiRemoveBackgroundExternal: "e-removedotbg",
|
|
44
|
-
contrastStretch: "e-contrast",
|
|
45
|
-
shadow: "e-shadow",
|
|
46
|
-
sharpen: "e-sharpen",
|
|
47
|
-
unsharpMask: "e-usm",
|
|
48
|
-
gradient: "e-gradient",
|
|
49
|
-
|
|
50
|
-
// Other flags & finishing
|
|
51
|
-
progressive: "pr",
|
|
52
|
-
lossless: "lo",
|
|
53
|
-
colorProfile: "cp",
|
|
54
|
-
metadata: "md",
|
|
55
|
-
opacity: "o",
|
|
56
|
-
trim: "t",
|
|
57
|
-
zoom: "z",
|
|
58
|
-
page: "pg",
|
|
59
|
-
|
|
60
|
-
// Text overlay transformations which are not defined yet
|
|
61
|
-
fontSize: "fs",
|
|
62
|
-
fontFamily: "ff",
|
|
63
|
-
fontColor: "co",
|
|
64
|
-
innerAlignment: "ia",
|
|
65
|
-
padding: "pa",
|
|
66
|
-
alpha: "al",
|
|
67
|
-
typography: "tg",
|
|
68
|
-
lineHeight: "lh",
|
|
69
|
-
|
|
70
|
-
// Subtitles transformations which are not defined
|
|
71
|
-
fontOutline: "fol",
|
|
72
|
-
fontShadow: "fsh",
|
|
73
|
-
|
|
74
|
-
// Raw pass-through
|
|
75
|
-
raw: "raw",
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
export default supportedTransforms
|
package/src/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SrcOptions, Transformation, UploadOptions, UploadResponse } from "./interfaces";
|
|
2
|
-
import { ImageKitAbortError, ImageKitInvalidRequestError, ImageKitServerError, ImageKitUploadNetworkError, upload } from "./upload";
|
|
3
|
-
import { buildSrc, buildTransformationString } from "./url";
|
|
4
|
-
|
|
5
|
-
export { buildSrc, buildTransformationString, upload, ImageKitInvalidRequestError, ImageKitAbortError, ImageKitServerError, ImageKitUploadNetworkError };
|
|
6
|
-
export type {
|
|
7
|
-
Transformation,
|
|
8
|
-
SrcOptions,
|
|
9
|
-
UploadOptions,
|
|
10
|
-
UploadResponse
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Transformation } from "./Transformation";
|
|
2
|
-
import { TransformationPosition } from ".";
|
|
3
|
-
|
|
4
|
-
export interface SrcOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Accepts a relative or absolute path of the resource. If a relative path is provided, it is appended to the `urlEndpoint`.
|
|
7
|
-
* If an absolute path is provided, `urlEndpoint` is ignored.
|
|
8
|
-
*/
|
|
9
|
-
src: string;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints).
|
|
13
|
-
*/
|
|
14
|
-
urlEndpoint: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* An array of objects specifying the transformations to be applied in the URL. If more than one transformation is specified, they are applied in the order they are specified as chained transformations.
|
|
18
|
-
*
|
|
19
|
-
* {@link https://imagekit.io/docs/transformations#chained-transformations}
|
|
20
|
-
*/
|
|
21
|
-
transformation?: Array<Transformation>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* These are additional query parameters that you want to add to the final URL.
|
|
25
|
-
* They can be any query parameters and not necessarily related to ImageKit.
|
|
26
|
-
* This is especially useful if you want to add a versioning parameter to your URLs.
|
|
27
|
-
*/
|
|
28
|
-
queryParameters?: { [key: string]: string | number };
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* By default, the transformation string is added as a query parameter in the URL, e.g., `?tr=w-100,h-100`.
|
|
32
|
-
* If you want to add the transformation string in the path of the URL, set this to `path`.
|
|
33
|
-
*/
|
|
34
|
-
transformationPosition?: TransformationPosition;
|
|
35
|
-
}
|