@opensea/seadn
Advanced tools
Comparing version 1.0.4 to 1.0.6
/// <reference types="node" /> | ||
export type ResizeParams = { | ||
freezeAnimation?: boolean; | ||
dpr?: number; | ||
@@ -7,4 +8,4 @@ width?: number; | ||
}; | ||
export declare const resizeImage: (image: string | URL, { width, height, dpr }: ResizeParams) => string; | ||
export declare const resizeImage: (image: string | URL, { width, height, dpr, freezeAnimation }: ResizeParams) => string; | ||
export declare const isSupportedFormat: (image: string | URL) => boolean; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
const t=(t,{width:e,height:n,dpr:r=1})=>{"string"==typeof t&&(t=new URL(t));const i=new URLSearchParams({auto:"format",dpr:String(r)});return void 0!==e&&i.set("w",String(e)),void 0!==n&&i.set("h",String(n)),t.search=i.toString(),t.toString()},e=t=>{"string"==typeof t&&(t=new URL(t));const{pathname:e}=t;return e.endsWith(".jpg")||e.endsWith(".jpeg")||e.endsWith(".png")||e.endsWith(".webp")||e.endsWith(".gif")||e.startsWith("/gae/")};export{e as isSupportedFormat,t as resizeImage}; | ||
const t=(t,{width:e,height:n,dpr:r=1,freezeAnimation:i=!1})=>{"string"==typeof t&&(t=new URL(t));const s=new URLSearchParams({auto:"format",dpr:String(r)});return void 0!==e&&s.set("w",String(e)),void 0!==n&&s.set("h",String(n)),i&&s.set("fr","1"),t.search=s.toString(),t.toString()},e=t=>{"string"==typeof t&&(t=new URL(t));const{pathname:e}=t;return e.endsWith(".jpg")||e.endsWith(".jpeg")||e.endsWith(".png")||e.endsWith(".webp")||e.endsWith(".gif")||e.startsWith("/gae/")};export{e as isSupportedFormat,t as resizeImage}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
var t=function(t,n){var r=n.width,e=n.height,i=n.dpr,a=void 0===i?1:i;"string"==typeof t&&(t=new URL(t));var g=new URLSearchParams({auto:"format",dpr:String(a)});return void 0!==r&&g.set("w",String(r)),void 0!==e&&g.set("h",String(e)),t.search=g.toString(),t.toString()},n=function(t){"string"==typeof t&&(t=new URL(t));var n=t.pathname;return n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".png")||n.endsWith(".webp")||n.endsWith(".gif")||n.startsWith("/gae/")};export{n as isSupportedFormat,t as resizeImage}; | ||
var t=function(t,e){var n=e.width,r=e.height,i=e.dpr,a=void 0===i?1:i,o=e.freezeAnimation,s=void 0!==o&&o;"string"==typeof t&&(t=new URL(t));var g=new URLSearchParams({auto:"format",dpr:String(a)});return void 0!==n&&g.set("w",String(n)),void 0!==r&&g.set("h",String(r)),s&&g.set("fr","1"),t.search=g.toString(),t.toString()},e=function(t){"string"==typeof t&&(t=new URL(t));var e=t.pathname;return e.endsWith(".jpg")||e.endsWith(".jpeg")||e.endsWith(".png")||e.endsWith(".webp")||e.endsWith(".gif")||e.startsWith("/gae/")};export{e as isSupportedFormat,t as resizeImage}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).seadn={})}(this,function(e){e.isSupportedFormat=function(e){"string"==typeof e&&(e=new URL(e));var t=e.pathname;return t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".png")||t.endsWith(".webp")||t.endsWith(".gif")||t.startsWith("/gae/")},e.resizeImage=function(e,t){var n=t.width,i=t.height,o=t.dpr,r=void 0===o?1:o;"string"==typeof e&&(e=new URL(e));var s=new URLSearchParams({auto:"format",dpr:String(r)});return void 0!==n&&s.set("w",String(n)),void 0!==i&&s.set("h",String(i)),e.search=s.toString(),e.toString()}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).seadn={})}(this,function(e){e.isSupportedFormat=function(e){"string"==typeof e&&(e=new URL(e));var t=e.pathname;return t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".png")||t.endsWith(".webp")||t.endsWith(".gif")||t.startsWith("/gae/")},e.resizeImage=function(e,t){var n=t.width,i=t.height,o=t.dpr,r=void 0===o?1:o,s=t.freezeAnimation,d=void 0!==s&&s;"string"==typeof e&&(e=new URL(e));var f=new URLSearchParams({auto:"format",dpr:String(r)});return void 0!==n&&f.set("w",String(n)),void 0!==i&&f.set("h",String(i)),d&&f.set("fr","1"),e.search=f.toString(),e.toString()}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@opensea/seadn", | ||
"version": "1.0.4", | ||
"version": "1.0.6", | ||
"description": "Javascript SDK to work with SeaDN", | ||
@@ -31,11 +31,11 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@vitest/coverage-c8": "^0.29.1", | ||
"concurrently": "^7.6.0", | ||
"esbuild": "^0.17.10", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^13.1.2", | ||
"microbundle": "^0.15.1", | ||
"prettier": "^2.8.4", | ||
"prettier-package-json": "^2.8.0", | ||
"vitest": "^0.29.1" | ||
"@vitest/coverage-c8": "0.29.1", | ||
"concurrently": "7.6.0", | ||
"esbuild": "0.17.10", | ||
"husky": "8.0.3", | ||
"lint-staged": "13.1.2", | ||
"microbundle": "0.15.1", | ||
"prettier": "2.8.4", | ||
"prettier-package-json": "2.8.0", | ||
"vitest": "0.29.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "lint-staged": { |
@@ -24,2 +24,7 @@ import { expect, test } from 'vitest'; | ||
'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=1&w=200&h=200' | ||
], | ||
[ | ||
'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png', | ||
{ dpr: 5, freezeAnimation: true }, | ||
'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=5&fr=1' | ||
] | ||
@@ -26,0 +31,0 @@ ])('resizeSeadnImage(%i, %i) -> %i', (url, resizeParams, expected) => { |
export type ResizeParams = { | ||
freezeAnimation?: boolean; | ||
dpr?: number; | ||
@@ -9,3 +10,3 @@ width?: number; | ||
image: string | URL, | ||
{ width, height, dpr = 1 }: ResizeParams | ||
{ width, height, dpr = 1, freezeAnimation = false }: ResizeParams | ||
): string => { | ||
@@ -28,2 +29,6 @@ if (typeof image === 'string') { | ||
if (freezeAnimation) { | ||
params.set('fr', '1'); | ||
} | ||
image.search = params.toString(); | ||
@@ -30,0 +35,0 @@ return image.toString(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16315
110