@opensea/seadn
Advanced tools
Comparing version 2.3.2 to 2.3.3
@@ -1,2 +0,2 @@ | ||
"use strict";var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var r in n)f(e,r,{get:n[r],enumerable:!0})},g=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of R(n))!U.call(e,t)&&t!==r&&f(e,t,{get:()=>n[t],enumerable:!(i=h(n,t))||i.enumerable});return e};var w=e=>g(f({},"__esModule",{value:!0}),e);var y={};L(y,{optimize:()=>m,originalURL:()=>x});module.exports=w(y);var u=[80,250,500,750,1e3,2e3,4e3];function M(e,n){let r=u.find(t=>t>=e),i=u.find(t=>t>=n);if(i===r){let t=u.indexOf(i);i=u[t+1]}return i||u[u.length-1]}function s(e,n){if(n===void 0||n<=1)return e;let r=Number(e)*n;return M(Number(e),r)}function m(e,{width:n,height:r,format:i,quality:t,fit:c,frameTime:d,boost:b}){try{typeof e=="string"&&(e=new URL(e))}catch(v){return e.toString()}if(!(e instanceof URL))return e;let p=F(e);if(!N(e)&&!p)return e.toString();let o=new URLSearchParams;if(d!==void 0)p&&o.set("frame-time",String(d));else if(l(e))return e.toString();if(r!==void 0&&o.set("h",String(s(r,b))),n!==void 0&&o.set("w",String(s(n,b))),i!==void 0&&o.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");o.set("q",String(t))}return c!==void 0&&o.set("fit",c),e.search=o.toString(),e.toString()}function l(e){let n=a(e);return n==="mp4"||n==="mov"}function F(e){return l(e)||a(e)==="gif"}function N(e){if(!S(e))return!1;switch(a(e)){case"png":case"jpeg":case"webp":case"avif":case"ico":case"gif":case void 0:return!0;default:return!1}}function a(e){let n=e.pathname.split(".");if(!(n.length<=1))return n[n.length-1]}function S(e){return e.hostname.endsWith("seadn.io")}function x(e){try{typeof e=="string"&&(e=new URL(e))}catch(n){return e.toString()}return S(e)&&(e.hostname=e.hostname.replace("i2c","raw2").replace("i2","raw2")),e.toString()}0&&(module.exports={optimize,originalURL}); | ||
"use strict";var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var r in n)s(e,r,{get:n[r],enumerable:!0})},g=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of R(n))!U.call(e,t)&&t!==r&&s(e,t,{get:()=>n[t],enumerable:!(i=h(n,t))||i.enumerable});return e};var w=e=>g(s({},"__esModule",{value:!0}),e);var y={};L(y,{optimize:()=>m,originalURL:()=>x});module.exports=w(y);var u=[80,250,500,750,1e3,2e3,4e3];function M(e,n){let r=u.find(t=>t>=e),i=u.find(t=>t>=n);if(i===r){let t=u.indexOf(i);i=u[t+1]}return i||u[u.length-1]}function f(e,n){if(n===void 0||n<=1)return e;let r=Number(e)*n;return M(Number(e),r)}function m(e,{width:n,height:r,format:i,quality:t,fit:c,frameTime:d,boost:b}){try{typeof e=="string"&&(e=new URL(e))}catch(v){return e.toString()}if(!(e instanceof URL))return e;let p=F(e);if(!N(e)&&!p)return e.toString();let o=new URLSearchParams;if(d!==void 0)p&&o.set("frame-time",String(d));else if(l(e))return e.toString();if(r!==void 0&&o.set("h",String(f(r,b))),n!==void 0&&o.set("w",String(f(n,b))),i!==void 0&&o.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");o.set("q",String(t))}return c!==void 0&&o.set("fit",c),e.search=o.toString(),e.toString()}function l(e){let n=a(e);return n==="mp4"||n==="mov"}function F(e){return l(e)||a(e)==="gif"}function N(e){if(!S(e))return!1;switch(a(e)){case"jpg":case"png":case"jpeg":case"webp":case"avif":case"ico":case"gif":case void 0:return!0;default:return!1}}function a(e){let n=e.pathname.split(".");if(!(n.length<=1))return n[n.length-1]}function S(e){return e.hostname.endsWith("seadn.io")}function x(e){try{typeof e=="string"&&(e=new URL(e))}catch(n){return e.toString()}return S(e)&&(e.hostname=e.hostname.replace("i2c","raw2").replace("i2","raw2")),e.toString()}0&&(module.exports={optimize,originalURL}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@opensea/seadn", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"description": "Javascript SDK to work with SeaDN", | ||
@@ -15,2 +15,8 @@ "license": "MIT", | ||
], | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.16.4", | ||
"tsup": "8.3.5", | ||
"typescript": "5.6.3", | ||
"vitest": "1.5.0" | ||
}, | ||
"scripts": { | ||
@@ -21,9 +27,3 @@ "build": "tsup", | ||
"typecheck": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.16.4", | ||
"tsup": "8.3.0", | ||
"typescript": "5.6.3", | ||
"vitest": "1.5.0" | ||
} | ||
} | ||
} |
@@ -136,2 +136,7 @@ import { test, expect } from "vitest"; | ||
], | ||
[ | ||
"https://i.seadn.io/s/raw/files/d89900cc5ecd6cabd26f835a32860f62.jpg", | ||
{ width: 100 } satisfies MediaParams, | ||
"https://i.seadn.io/s/raw/files/d89900cc5ecd6cabd26f835a32860f62.jpg?w=100", | ||
], | ||
])("optimize(%o, %o) -> %o", (url, resizeParams, expected) => { | ||
@@ -148,2 +153,8 @@ expect(optimize(url as string, resizeParams)).toEqual(expected); | ||
], | ||
[ | ||
new URL( | ||
"https://i.seadn.io/s/raw/files/d89900cc5ecd6cabd26f835a32860f62.jpg", | ||
), | ||
true, | ||
], | ||
])("isSeadnURL(%s) -> %o", (url, expected) => { | ||
@@ -150,0 +161,0 @@ expect(isSeadnURL(url)).toEqual(expected); |
@@ -85,2 +85,3 @@ import { boostSize } from "./boost"; | ||
switch (extension) { | ||
case "jpg": | ||
case "png": | ||
@@ -87,0 +88,0 @@ case "jpeg": |
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
27819
334