@opensea/seadn
Advanced tools
Comparing version 2.0.6 to 2.0.7
type MediaFormat = "webp" | "avif" | "jpeg" | "png"; | ||
type MediaFit = "cover" | "contain" | "fill" | "inside" | "outside"; | ||
type MediaParams = { | ||
@@ -7,5 +8,6 @@ width?: number | `${number}`; | ||
quality?: number | `${number}`; | ||
fit?: MediaFit; | ||
}; | ||
declare function optimize(image: string | URL, { width, height, format, quality }: MediaParams): string; | ||
declare function optimize(image: string | URL, { width, height, format, quality, fit }: MediaParams): string; | ||
export { type MediaFormat, type MediaParams, optimize }; |
@@ -1,2 +0,2 @@ | ||
"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}); | ||
"use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var r in t)s(e,r,{get:t[r],enumerable:!0})},b=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!c.call(e,n)&&n!==r&&s(e,n,{get:()=>t[n],enumerable:!(o=u(t,n))||o.enumerable});return e};var m=e=>b(s({},"__esModule",{value:!0}),e);var w={};p(w,{optimize:()=>f});module.exports=m(w);function f(e,{width:t,height:r,format:o,quality:n,fit:a}){try{typeof e=="string"&&(e=new URL(e))}catch(S){return e.toString()}if(!(e instanceof URL))return e;if(!h(e))return e.toString();let i=new URLSearchParams;if(r!==void 0&&i.set("h",String(r)),t!==void 0&&i.set("w",String(t)),o!==void 0&&i.set("format",o),n){if(Number(n)<=0||Number(n)>100)throw new Error("Quality has to be a positive number between 1 and 100");i.set("q",String(n))}return a!==void 0&&i.set("fit",a),e.search=i.toString(),e.toString()}function h(e){if(!l(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"gif":case void 0:return!0;default:return!1}}function l(e){return e.hostname.endsWith("seadn.io")}0&&(module.exports={optimize}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@opensea/seadn", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "Javascript SDK to work with SeaDN", | ||
@@ -23,6 +23,6 @@ "license": "MIT", | ||
"@arethetypeswrong/cli": "0.15.3", | ||
"tsup": "8.0.2", | ||
"typescript": "5.4.5", | ||
"vitest": "1.5.0" | ||
"tsup": "8.1.0", | ||
"typescript": "5.5.3", | ||
"vitest": "1.6.0" | ||
} | ||
} |
@@ -32,1 +32,8 @@ # SeaDN Javascript SDK | ||
``` | ||
## Publishing | ||
```sh | ||
pnpm build | ||
npm publish --access public | ||
``` |
@@ -76,2 +76,13 @@ import { test, expect } from "vitest"; | ||
[ | ||
"https://i2.seadn.io/bored-ape", | ||
{ | ||
height: 100, | ||
width: 100, | ||
format: "avif", | ||
quality: 50, | ||
fit: "contain", | ||
} satisfies MediaParams, | ||
"https://i2.seadn.io/bored-ape?h=100&w=100&format=avif&q=50&fit=contain", | ||
], | ||
[ | ||
"https://xyz.com/bored-ape.png", | ||
@@ -78,0 +89,0 @@ { height: 100, width: 100, format: "avif" } satisfies MediaParams, |
export type MediaFormat = "webp" | "avif" | "jpeg" | "png"; | ||
export type MediaFit = "cover" | "contain" | "fill" | "inside" | "outside"; | ||
@@ -8,2 +9,3 @@ export type MediaParams = { | ||
quality?: number | `${number}`; | ||
fit?: MediaFit; | ||
}; | ||
@@ -13,3 +15,3 @@ | ||
image: string | URL, | ||
{ width, height, format, quality }: MediaParams, | ||
{ width, height, format, quality, fit }: MediaParams, | ||
): string { | ||
@@ -48,2 +50,5 @@ try { | ||
} | ||
if (fit !== undefined) { | ||
params.set("fit", fit); | ||
} | ||
@@ -50,0 +55,0 @@ image.search = params.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15312
195
39