@opensea/seadn
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -9,4 +9,3 @@ type MediaFormat = "webp" | "avif" | "jpeg" | "png"; | ||
declare function optimize(image: string | URL, { width, height, format, quality }: MediaParams): string; | ||
declare function canBeOptimized(url: URL): boolean; | ||
export { type MediaFormat, type MediaParams, canBeOptimized, optimize }; | ||
export { type MediaFormat, type MediaParams, optimize }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},m=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!c.call(e,n)&&n!==r&&a(e,n,{get:()=>t[n],enumerable:!(i=u(t,n))||i.enumerable});return e};var b=e=>m(a({},"__esModule",{value:!0}),e);var w={};d(w,{canBeOptimized:()=>s,optimize:()=>f});module.exports=b(w);function f(e,{width:t,height:r,format:i,quality:n}){try{typeof e=="string"&&(e=new URL(e))}catch(S){return e.toString()}if(!(e instanceof URL))return e;if(!s(e))return e.toString();let o=new URLSearchParams;if(r!==void 0&&o.set("h",String(r)),t!==void 0&&o.set("w",String(t)),i!==void 0&&o.set("format",i),n){if(Number(n)<=0||Number(n)>100)throw new Error("Quality has to be a positive number between 1 and 100");o.set("q",String(n))}return e.search=o.toString(),e.toString()}function s(e){if(!h(e))return!1;let t=e.pathname.split(".");if(t.length<=1)return!0;switch(t[t.length-1]){case"png":case"jpeg":case"webp":case"avif":case"ico":case void 0:return!0;default:return!1}}function h(e){return e.hostname.endsWith("seadn.io")}0&&(module.exports={canBeOptimized,optimize}); | ||
"use strict";var a=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(e,n)=>{for(var r in n)a(e,r,{get:n[r],enumerable:!0})},d=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of u(n))!c.call(e,t)&&t!==r&&a(e,t,{get:()=>n[t],enumerable:!(i=f(n,t))||i.enumerable});return e};var b=e=>d(a({},"__esModule",{value:!0}),e);var w={};p(w,{optimize:()=>o});module.exports=b(w);function o(e,{width:n,height:r,format:i,quality:t}){try{typeof e=="string"&&(e=new URL(e))}catch(S){return e.toString()}if(!(e instanceof URL))return e;if(!m(e))return e.toString();let s=new URLSearchParams;if(r!==void 0&&s.set("h",String(r)),n!==void 0&&s.set("w",String(n)),i!==void 0&&s.set("format",i),t){if(Number(t)<=0||Number(t)>100)throw new Error("Quality has to be a positive number between 1 and 100");s.set("q",String(t))}return e.search=s.toString(),e.toString()}function m(e){if(!h(e))return!1;let n=e.pathname.split(".");if(n.length<=1)return!0;switch(n[n.length-1]){case"png":case"jpeg":case"webp":case"avif":case"ico":case"gif":case void 0:return!0;default:return!1}}function h(e){return e.hostname.endsWith("seadn.io")}0&&(module.exports={optimize}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@opensea/seadn", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Javascript SDK to work with SeaDN", | ||
@@ -22,7 +22,7 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.13.6", | ||
"tsup": "8.0.1", | ||
"typescript": "5.3.3", | ||
"vitest": "1.2.2" | ||
"@arethetypeswrong/cli": "0.15.3", | ||
"tsup": "8.0.2", | ||
"typescript": "5.4.5", | ||
"vitest": "1.5.0" | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
export { optimize, MediaParams, MediaFormat, canBeOptimized } from "./sdk"; | ||
export { optimize, MediaParams, MediaFormat } from "./sdk"; |
@@ -41,2 +41,7 @@ import { test, expect } from "vitest"; | ||
[ | ||
"https://i2.seadn.io/bored-ape.gif", | ||
{ height: 100, width: 100 } satisfies MediaParams, | ||
"https://i2.seadn.io/bored-ape.gif?h=100&w=100", | ||
], | ||
[ | ||
"https://i2.seadn.io/bored-ape.png.x", | ||
@@ -43,0 +48,0 @@ { height: 100, width: 100 } satisfies MediaParams, |
@@ -26,3 +26,3 @@ export type MediaFormat = "webp" | "avif" | "jpeg" | "png"; | ||
if (!canBeOptimized(image)) { | ||
if (!canBeResized(image)) { | ||
return image.toString(); | ||
@@ -52,3 +52,3 @@ } | ||
export function canBeOptimized(url: URL): boolean { | ||
function canBeResized(url: URL): boolean { | ||
if (!isSeadnURL(url)) { | ||
@@ -70,2 +70,3 @@ return false; | ||
case "ico": | ||
case "gif": | ||
case undefined: | ||
@@ -72,0 +73,0 @@ return true; |
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
177
14114