@opensea/seadn
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -1,2 +0,2 @@ | ||
"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})},w=(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 g=e=>w(s({},"__esModule",{value:!0}),e);var y={};L(y,{optimize:()=>p,originalURL:()=>x});module.exports=g(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 p(e,{width:n,height:r,format:i,quality:t,fit:a,frameTime:c,boost:d}){try{typeof e=="string"&&(e=new URL(e))}catch(v){return e.toString()}if(!(e instanceof URL))return e;let b=F(e);if(!N(e)&&!b)return e.toString();let o=new URLSearchParams;if(r!==void 0&&o.set("h",String(f(r,d))),n!==void 0&&o.set("w",String(f(n,d))),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))}if(a!==void 0&&o.set("fit",a),c!==void 0)b&&o.set("frame-time",String(c));else if(m(e))return e.toString();return e.search=o.toString(),e.toString()}function m(e){let n=l(e);return n==="mp4"||n==="mov"}function F(e){return m(e)}function N(e){if(!S(e))return!1;switch(l(e)){case"png":case"jpeg":case"webp":case"avif":case"ico":case"gif":case void 0:return!0;default:return!1}}function l(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 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(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))}if(c!==void 0&&o.set("fit",c),d!==void 0)p&&o.set("frame-time",String(d));else if(l(e))return e.toString();return 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}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@opensea/seadn", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Javascript SDK to work with SeaDN", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -28,5 +28,5 @@ # SeaDN Javascript SDK | ||
```js | ||
import { resizeImage } from "@opensea/seadn"; | ||
import { optimize } from "@opensea/seadn"; | ||
const resized = resizeImage(image, { height: 100, width: 100 }); | ||
const resized = optimize(image, { height: 100, width: 100 }); | ||
``` | ||
@@ -33,0 +33,0 @@ |
@@ -104,3 +104,8 @@ import { test, expect } from "vitest"; | ||
{ frameTime: 0.1 } satisfies MediaParams, | ||
"https://i2.seadn.io/bored-ape.gif?frame-time=0.1", | ||
], | ||
[ | ||
"https://i2.seadn.io/bored-ape.gif", | ||
{ frameTime: 0.1, height: 50 } satisfies MediaParams, | ||
"https://i2.seadn.io/bored-ape.gif?h=50&frame-time=0.1", | ||
], | ||
@@ -132,3 +137,3 @@ [ | ||
], | ||
])("resizeImage(%o, %o) -> %o", (url, resizeParams, expected) => { | ||
])("optimize(%o, %o) -> %o", (url, resizeParams, expected) => { | ||
expect(optimize(url as string, resizeParams)).toEqual(expected); | ||
@@ -135,0 +140,0 @@ }); |
@@ -74,3 +74,3 @@ import { boostSize } from "./boost"; | ||
function canExtractFrame(url: URL): boolean { | ||
return isVideo(url); | ||
return isVideo(url) || getExtension(url) === "gif"; | ||
} | ||
@@ -77,0 +77,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27393
322
1