@opensea/seadn 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,4 +9,4 @@ type MediaParams = {
|
|
|
9
9
|
};
|
|
10
10
|
declare function optimize(image: string | URL, { width, height, format, quality, fit }: MediaParams): string;
|
|
11
11
|
|
|
12
|
-
export { type MediaFormat, type MediaParams, optimize };
|
|
12
|
+
export { type MediaFit, type MediaFormat, type MediaParams, optimize };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ type MediaParams = {
|
|
|
9
9
|
};
|
|
10
10
|
declare function optimize(image: string | URL, { width, height, format, quality, fit }: MediaParams): string;
|
|
11
11
|
|
|
12
|
-
export { type MediaFormat, type MediaParams, optimize };
|
|
12
|
+
export { type MediaFit, type MediaFormat, type MediaParams, optimize };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},b=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!c.call(e,n)&&n!==r&&o(e,n,{get:()=>t[n],enumerable:!(a=u(t,n))||a.enumerable});return e};var m=e=>b(o({},"__esModule",{value:!0}),e);var w={};p(w,{optimize:()=>f});module.exports=m(w);function f(e,{width:t,height:r,format:a,quality:n,fit:s}){try{typeof e=="string"&&(e=new URL(e))}catch(M){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)),a!==void 0&&i.set("format",a),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 s!==void 0&&i.set("fit",s),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});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/sdk.ts"],"sourcesContent":["export { optimize, MediaParams, MediaFormat } from \"./sdk\";\n","export type MediaFormat = \"webp\" | \"avif\" | \"jpeg\" | \"png\";\nexport type MediaFit = \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n\nexport type MediaParams = {\n width?: number | `${number}`;\n height?: number | `${number}`;\n format?: MediaFormat;\n quality?: number | `${number}`;\n fit?: MediaFit;\n};\n\nexport function optimize(\n image: string | URL,\n { width, height, format, quality, fit }: MediaParams,\n): string {\n try {\n if (typeof image === \"string\") {\n image = new URL(image);\n }\n } catch {\n return image.toString();\n }\n\n if (!(image instanceof URL)) {\n return image;\n }\n\n if (!canBeResized(image)) {\n return image.toString();\n }\n\n const params = new URLSearchParams();\n if (height !== undefined) {\n params.set(\"h\", String(height));\n }\n if (width !== undefined) {\n params.set(\"w\", String(width));\n }\n if (format !== undefined) {\n params.set(\"format\", format);\n }\n if (quality) {\n if (Number(quality) <= 0 || Number(quality) > 100) {\n throw new Error(\"Quality has to be a positive number between 1 and 100\");\n }\n params.set(\"q\", String(quality));\n }\n if (fit !== undefined) {\n params.set(\"fit\", fit);\n }\n\n image.search = params.toString();\n return image.toString();\n}\n\nfunction canBeResized(url: URL): boolean {\n if (!isSeadnURL(url)) {\n return false;\n }\n\n const split = url.pathname.split(\".\");\n if (split.length <= 1) {\n return true;\n }\n\n const extension = split[split.length - 1];\n switch (extension) {\n case \"png\":\n case \"jpeg\":\n case \"webp\":\n case \"avif\":\n case \"ico\":\n case \"gif\":\n case undefined:\n return true;\n default:\n return false;\n }\n}\n\nexport function isSeadnURL(url: URL): boolean {\n return url.hostname.endsWith(\"seadn.io\");\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GCWO,SAASI,EACdC,EACA,CAAE,MAAAC,EAAO,OAAAC,EAAQ,OAAAC,EAAQ,QAAAC,EAAS,IAAAC,CAAI,EAC9B,CACR,GAAI,CACE,OAAOL,GAAU,WACnBA,EAAQ,IAAI,IAAIA,CAAK,EAEzB,OAAQM,EAAA,CACN,OAAON,EAAM,SAAS,CACxB,CAEA,GAAI,EAAEA,aAAiB,KACrB,OAAOA,EAGT,GAAI,CAACO,EAAaP,CAAK,EACrB,OAAOA,EAAM,SAAS,EAGxB,IAAMQ,EAAS,IAAI,gBAUnB,GATIN,IAAW,QACbM,EAAO,IAAI,IAAK,OAAON,CAAM,CAAC,EAE5BD,IAAU,QACZO,EAAO,IAAI,IAAK,OAAOP,CAAK,CAAC,EAE3BE,IAAW,QACbK,EAAO,IAAI,SAAUL,CAAM,EAEzBC,EAAS,CACX,GAAI,OAAOA,CAAO,GAAK,GAAK,OAAOA,CAAO,EAAI,IAC5C,MAAM,IAAI,MAAM,uDAAuD,EAEzEI,EAAO,IAAI,IAAK,OAAOJ,CAAO,CAAC,CACjC,CACA,OAAIC,IAAQ,QACVG,EAAO,IAAI,MAAOH,CAAG,EAGvBL,EAAM,OAASQ,EAAO,SAAS,EACxBR,EAAM,SAAS,CACxB,CAEA,SAASO,EAAaE,EAAmB,CACvC,GAAI,CAACC,EAAWD,CAAG,EACjB,MAAO,GAGT,IAAME,EAAQF,EAAI,SAAS,MAAM,GAAG,EACpC,GAAIE,EAAM,QAAU,EAClB,MAAO,GAIT,OADkBA,EAAMA,EAAM,OAAS,CAAC,EACrB,CACjB,IAAK,MACL,IAAK,OACL,IAAK,OACL,IAAK,OACL,IAAK,MACL,IAAK,MACL,KAAK,OACH,MAAO,GACT,QACE,MAAO,EACX,CACF,CAEO,SAASD,EAAWD,EAAmB,CAC5C,OAAOA,EAAI,SAAS,SAAS,UAAU,CACzC","names":["src_exports","__export","optimize","__toCommonJS","optimize","image","width","height","format","quality","fit","e","canBeResized","params","url","isSeadnURL","split"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sdk.ts"],"sourcesContent":["export { optimize, MediaParams, MediaFormat, MediaFit } from \"./sdk\";\n","export type MediaFormat = \"webp\" | \"avif\" | \"jpeg\" | \"png\";\nexport type MediaFit = \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n\nexport type MediaParams = {\n width?: number | `${number}`;\n height?: number | `${number}`;\n format?: MediaFormat;\n quality?: number | `${number}`;\n fit?: MediaFit;\n};\n\nexport function optimize(\n image: string | URL,\n { width, height, format, quality, fit }: MediaParams,\n): string {\n try {\n if (typeof image === \"string\") {\n image = new URL(image);\n }\n } catch {\n return image.toString();\n }\n\n if (!(image instanceof URL)) {\n return image;\n }\n\n if (!canBeResized(image)) {\n return image.toString();\n }\n\n const params = new URLSearchParams();\n if (height !== undefined) {\n params.set(\"h\", String(height));\n }\n if (width !== undefined) {\n params.set(\"w\", String(width));\n }\n if (format !== undefined) {\n params.set(\"format\", format);\n }\n if (quality) {\n if (Number(quality) <= 0 || Number(quality) > 100) {\n throw new Error(\"Quality has to be a positive number between 1 and 100\");\n }\n params.set(\"q\", String(quality));\n }\n if (fit !== undefined) {\n params.set(\"fit\", fit);\n }\n\n image.search = params.toString();\n return image.toString();\n}\n\nfunction canBeResized(url: URL): boolean {\n if (!isSeadnURL(url)) {\n return false;\n }\n\n const split = url.pathname.split(\".\");\n if (split.length <= 1) {\n return true;\n }\n\n const extension = split[split.length - 1];\n switch (extension) {\n case \"png\":\n case \"jpeg\":\n case \"webp\":\n case \"avif\":\n case \"ico\":\n case \"gif\":\n case undefined:\n return true;\n default:\n return false;\n }\n}\n\nexport function isSeadnURL(url: URL): boolean {\n return url.hostname.endsWith(\"seadn.io\");\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GCWO,SAASI,EACdC,EACA,CAAE,MAAAC,EAAO,OAAAC,EAAQ,OAAAC,EAAQ,QAAAC,EAAS,IAAAC,CAAI,EAC9B,CACR,GAAI,CACE,OAAOL,GAAU,WACnBA,EAAQ,IAAI,IAAIA,CAAK,EAEzB,OAAQM,EAAA,CACN,OAAON,EAAM,SAAS,CACxB,CAEA,GAAI,EAAEA,aAAiB,KACrB,OAAOA,EAGT,GAAI,CAACO,EAAaP,CAAK,EACrB,OAAOA,EAAM,SAAS,EAGxB,IAAMQ,EAAS,IAAI,gBAUnB,GATIN,IAAW,QACbM,EAAO,IAAI,IAAK,OAAON,CAAM,CAAC,EAE5BD,IAAU,QACZO,EAAO,IAAI,IAAK,OAAOP,CAAK,CAAC,EAE3BE,IAAW,QACbK,EAAO,IAAI,SAAUL,CAAM,EAEzBC,EAAS,CACX,GAAI,OAAOA,CAAO,GAAK,GAAK,OAAOA,CAAO,EAAI,IAC5C,MAAM,IAAI,MAAM,uDAAuD,EAEzEI,EAAO,IAAI,IAAK,OAAOJ,CAAO,CAAC,CACjC,CACA,OAAIC,IAAQ,QACVG,EAAO,IAAI,MAAOH,CAAG,EAGvBL,EAAM,OAASQ,EAAO,SAAS,EACxBR,EAAM,SAAS,CACxB,CAEA,SAASO,EAAaE,EAAmB,CACvC,GAAI,CAACC,EAAWD,CAAG,EACjB,MAAO,GAGT,IAAME,EAAQF,EAAI,SAAS,MAAM,GAAG,EACpC,GAAIE,EAAM,QAAU,EAClB,MAAO,GAIT,OADkBA,EAAMA,EAAM,OAAS,CAAC,EACrB,CACjB,IAAK,MACL,IAAK,OACL,IAAK,OACL,IAAK,OACL,IAAK,MACL,IAAK,MACL,KAAK,OACH,MAAO,GACT,QACE,MAAO,EACX,CACF,CAEO,SAASD,EAAWD,EAAmB,CAC5C,OAAOA,EAAI,SAAS,SAAS,UAAU,CACzC","names":["src_exports","__export","optimize","__toCommonJS","optimize","image","width","height","format","quality","fit","e","canBeResized","params","url","isSeadnURL","split"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(e,{width:t,height:i,format:a,quality:r,fit:o}){try{typeof e=="string"&&(e=new URL(e))}catch(d){return e.toString()}if(!(e instanceof URL))return e;if(!f(e))return e.toString();let n=new URLSearchParams;if(i!==void 0&&n.set("h",String(i)),t!==void 0&&n.set("w",String(t)),a!==void 0&&n.set("format",a),r){if(Number(r)<=0||Number(r)>100)throw new Error("Quality has to be a positive number between 1 and 100");n.set("q",String(r))}return o!==void 0&&n.set("fit",o),e.search=n.toString(),e.toString()}function f(e){if(!u(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 u(e){return e.hostname.endsWith("seadn.io")}export{s as optimize};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { optimize, MediaParams, MediaFormat } from "./sdk";
|
|
1
|
+
export { optimize, MediaParams, MediaFormat, MediaFit } from "./sdk";
|