@opensea/seadn 1.0.7 → 2.0.0

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/README.md CHANGED
@@ -1,57 +1,31 @@
1
1
  # SeaDN Javascript SDK
2
2
 
3
- ## Installation
3
+ ## Getting Started
4
+
5
+ ### Installation
6
+
7
+ **npm**
4
8
 
5
9
  ```sh
6
- npm i @opensea/seadn
10
+ npm install @opensea/seadn
7
11
  ```
8
12
 
9
- ## Usage
13
+ **yarn**
10
14
 
11
- **Resizing**
15
+ ```sh
16
+ yarn install @opensea/seadn
17
+ ```
12
18
 
13
- ```js
14
- import { resizeImage } from '@opensea/seadn';
19
+ **pnpm**
15
20
 
16
- const resized = resizeImage(image, { height: 100, width: 100 });
21
+ ```sh
22
+ pnpm add @opensea/seadn
17
23
  ```
18
24
 
19
- **Usage with next/image**
20
-
21
- ```jsx
22
- import { isSupportedURL, resizeImage } from '@opensea/seadn';
23
- import type { ImageLoader, ImageProps } from 'next/image';
24
-
25
- // custom loader
26
- export const seadnLoader: ImageLoader = ({ src, width }) => {
27
- if (!isSupportedURL(src)) {
28
- return src;
29
- }
30
- return resizeImage(src, { width });
31
- };
32
-
33
- // prop overrides
34
- export const nextImageProps = <T extends ImageProps>({
35
- src,
36
- ...rest
37
- }: T): ImageProps => {
38
- if (isSupportedURL(src)) {
39
- return {
40
- ...rest,
41
- src: resizeImage(src as string, {
42
- width: rest.width,
43
- height: rest.height
44
- }),
45
- unoptimized: true
46
- };
47
- }
48
- return { src, ...rest };
49
- };
50
-
51
- // MyComponent.tsx
52
- return (
53
- <>
54
- <Image {...nextImageProps({ alt: 'House', height: 200, src: imageUrl, width: 200 })} />
55
- </>
56
- )
25
+ ### Usage
26
+
27
+ ```js
28
+ import { resizeImage } from "@opensea/seadn";
29
+
30
+ const resized = resizeImage(image, { height: 100, width: 100 });
57
31
  ```
@@ -0,0 +1,10 @@
1
+ type MediaFormat = "webp" | "avif" | "jpeg" | "png";
2
+ type MediaParams = {
3
+ width?: number | `${number}`;
4
+ height?: number | `${number}`;
5
+ format?: MediaFormat;
6
+ };
7
+ declare function optimize(image: string | URL, { width, height, format }: MediaParams): string;
8
+ declare function canBeOptimized(url: URL): boolean;
9
+
10
+ export { type MediaFormat, type MediaParams, canBeOptimized, optimize };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
- export type ResizeParams = {
3
- freezeAnimation?: boolean;
4
- dpr?: number;
5
- width?: number | `${number}`;
6
- height?: number | `${number}`;
7
- };
8
- export declare const resizeImage: (image: string | URL, { width, height, dpr, freezeAnimation }: ResizeParams) => string;
9
- export declare const isSupportedFormat: (src: string | URL) => boolean;
10
- export declare const isSupportedURL: (src: string | URL) => boolean;
11
- //# sourceMappingURL=index.d.ts.map
1
+ type MediaFormat = "webp" | "avif" | "jpeg" | "png";
2
+ type MediaParams = {
3
+ width?: number | `${number}`;
4
+ height?: number | `${number}`;
5
+ format?: MediaFormat;
6
+ };
7
+ declare function optimize(image: string | URL, { width, height, format }: MediaParams): string;
8
+ declare function canBeOptimized(url: URL): boolean;
9
+
10
+ export { type MediaFormat, type MediaParams, canBeOptimized, optimize };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},p=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f(t))!d.call(e,n)&&n!==r&&a(e,n,{get:()=>t[n],enumerable:!(i=c(t,n))||i.enumerable});return e};var m=e=>p(a({},"__esModule",{value:!0}),e);var l={};u(l,{canBeOptimized:()=>s,optimize:()=>o});module.exports=m(l);function o(e,{width:t,height:r,format:i}){try{typeof e=="string"&&(e=new URL(e))}catch(b){return e.toString()}if(!(e instanceof URL))return e;if(!s(e))return e.toString();let n=new URLSearchParams;return r!==void 0&&n.set("h",String(r)),t!==void 0&&n.set("w",String(t)),i!==void 0&&n.set("format",i),e.search=n.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){switch(e.hostname){case"i2.dev.seadn.io":case"i2c.dev.seadn.io":case"i2.seadn.io":case"i2c.seadn.io":return!0;default:return!1}}0&&(module.exports={canBeOptimized,optimize});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/sdk.ts"],"sourcesContent":["export { optimize, MediaParams, MediaFormat, canBeOptimized } from \"./sdk\";\n","export type MediaFormat = \"webp\" | \"avif\" | \"jpeg\" | \"png\";\n\nexport type MediaParams = {\n width?: number | `${number}`;\n height?: number | `${number}`;\n format?: MediaFormat;\n};\n\nexport function optimize(\n image: string | URL,\n { width, height, format }: 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 (!canBeOptimized(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 image.search = params.toString();\n return image.toString();\n}\n\nexport function canBeOptimized(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 undefined:\n return true;\n default:\n return false;\n }\n}\n\nexport function isSeadnURL(url: URL): boolean {\n switch (url.hostname) {\n case \"i2.dev.seadn.io\":\n case \"i2c.dev.seadn.io\":\n case \"i2.seadn.io\":\n case \"i2c.seadn.io\":\n return true;\n default:\n return false;\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,aAAAC,IAAA,eAAAC,EAAAJ,GCQO,SAASK,EACdC,EACA,CAAE,MAAAC,EAAO,OAAAC,EAAQ,OAAAC,CAAO,EAChB,CACR,GAAI,CACE,OAAOH,GAAU,WACnBA,EAAQ,IAAI,IAAIA,CAAK,EAEzB,OAAQI,EAAA,CACN,OAAOJ,EAAM,SAAS,CACxB,CAEA,GAAI,EAAEA,aAAiB,KACrB,OAAOA,EAGT,GAAI,CAACK,EAAeL,CAAK,EACvB,OAAOA,EAAM,SAAS,EAGxB,IAAMM,EAAS,IAAI,gBACnB,OAAIJ,IAAW,QACbI,EAAO,IAAI,IAAK,OAAOJ,CAAM,CAAC,EAE5BD,IAAU,QACZK,EAAO,IAAI,IAAK,OAAOL,CAAK,CAAC,EAE3BE,IAAW,QACbG,EAAO,IAAI,SAAUH,CAAM,EAE7BH,EAAM,OAASM,EAAO,SAAS,EACxBN,EAAM,SAAS,CACxB,CAEO,SAASK,EAAeE,EAAmB,CAChD,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,KAAK,OACH,MAAO,GACT,QACE,MAAO,EACX,CACF,CAEO,SAASD,EAAWD,EAAmB,CAC5C,OAAQA,EAAI,SAAU,CACpB,IAAK,kBACL,IAAK,mBACL,IAAK,cACL,IAAK,eACH,MAAO,GACT,QACE,MAAO,EACX,CACF","names":["src_exports","__export","canBeOptimized","optimize","__toCommonJS","optimize","image","width","height","format","e","canBeOptimized","params","url","isSeadnURL","split"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ function s(e,{width:t,height:r,format:i}){try{typeof e=="string"&&(e=new URL(e))}catch(c){return e.toString()}if(!(e instanceof URL))return e;if(!a(e))return e.toString();let n=new URLSearchParams;return r!==void 0&&n.set("h",String(r)),t!==void 0&&n.set("w",String(t)),i!==void 0&&n.set("format",i),e.search=n.toString(),e.toString()}function a(e){if(!o(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 o(e){switch(e.hostname){case"i2.dev.seadn.io":case"i2c.dev.seadn.io":case"i2.seadn.io":case"i2c.seadn.io":return!0;default:return!1}}export{a as canBeOptimized,s as optimize};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["export type MediaFormat = \"webp\" | \"avif\" | \"jpeg\" | \"png\";\n\nexport type MediaParams = {\n width?: number | `${number}`;\n height?: number | `${number}`;\n format?: MediaFormat;\n};\n\nexport function optimize(\n image: string | URL,\n { width, height, format }: 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 (!canBeOptimized(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 image.search = params.toString();\n return image.toString();\n}\n\nexport function canBeOptimized(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 undefined:\n return true;\n default:\n return false;\n }\n}\n\nexport function isSeadnURL(url: URL): boolean {\n switch (url.hostname) {\n case \"i2.dev.seadn.io\":\n case \"i2c.dev.seadn.io\":\n case \"i2.seadn.io\":\n case \"i2c.seadn.io\":\n return true;\n default:\n return false;\n }\n}\n"],"mappings":"AAQO,SAASA,EACdC,EACA,CAAE,MAAAC,EAAO,OAAAC,EAAQ,OAAAC,CAAO,EAChB,CACR,GAAI,CACE,OAAOH,GAAU,WACnBA,EAAQ,IAAI,IAAIA,CAAK,EAEzB,OAAQI,EAAA,CACN,OAAOJ,EAAM,SAAS,CACxB,CAEA,GAAI,EAAEA,aAAiB,KACrB,OAAOA,EAGT,GAAI,CAACK,EAAeL,CAAK,EACvB,OAAOA,EAAM,SAAS,EAGxB,IAAMM,EAAS,IAAI,gBACnB,OAAIJ,IAAW,QACbI,EAAO,IAAI,IAAK,OAAOJ,CAAM,CAAC,EAE5BD,IAAU,QACZK,EAAO,IAAI,IAAK,OAAOL,CAAK,CAAC,EAE3BE,IAAW,QACbG,EAAO,IAAI,SAAUH,CAAM,EAE7BH,EAAM,OAASM,EAAO,SAAS,EACxBN,EAAM,SAAS,CACxB,CAEO,SAASK,EAAeE,EAAmB,CAChD,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,KAAK,OACH,MAAO,GACT,QACE,MAAO,EACX,CACF,CAEO,SAASD,EAAWD,EAAmB,CAC5C,OAAQA,EAAI,SAAU,CACpB,IAAK,kBACL,IAAK,mBACL,IAAK,cACL,IAAK,eACH,MAAO,GACT,QACE,MAAO,EACX,CACF","names":["optimize","image","width","height","format","e","canBeOptimized","params","url","isSeadnURL","split"]}
package/package.json CHANGED
@@ -1,51 +1,27 @@
1
1
  {
2
2
  "name": "@opensea/seadn",
3
- "version": "1.0.7",
3
+ "version": "2.0.0",
4
4
  "description": "Javascript SDK to work with SeaDN",
5
5
  "license": "MIT",
6
6
  "author": "OpenSea Developers",
7
- "type": "module",
8
- "exports": {
9
- "require": "./dist/index.cjs",
10
- "default": "./dist/index.modern.js"
11
- },
12
- "main": "./dist/index.cjs",
13
- "module": "./dist/index.module.js",
7
+ "sideEffects": false,
8
+ "main": "./src/index.ts",
9
+ "module": "./dist/index.mjs",
10
+ "types": "./dist/index.d.ts",
14
11
  "files": [
15
12
  "./dist",
16
13
  "./src"
17
14
  ],
18
15
  "scripts": {
19
- "build": "microbundle",
20
- "check-types": "tsc --noEmit",
21
- "lint": "concurrently \"npm run check-types\" \"npm run prettier:check\" \"npm run prettier:package.json:check\"",
22
- "prepare": "husky install",
23
- "prettier:check": "prettier --check .",
24
- "prettier:fix": "prettier --write .",
25
- "prettier:package.json:check": "prettier-package-json --list-different",
26
- "test": "vitest"
16
+ "build": "tsup",
17
+ "build:typecheck": "attw --pack",
18
+ "test": "vitest",
19
+ "typecheck": "tsc"
27
20
  },
28
- "sideEffects": false,
29
- "types": "./dist/index.d.ts",
30
21
  "devDependencies": {
31
- "@vitest/coverage-v8": "0.33.0",
32
- "concurrently": "8.2.0",
33
- "esbuild": "0.19.0",
34
- "husky": "8.0.3",
35
- "lint-staged": "13.2.3",
36
- "microbundle": "0.15.1",
37
- "prettier": "3.0.1",
38
- "prettier-package-json": "2.8.0",
39
- "vitest": "0.33.0"
40
- },
41
- "lint-staged": {
42
- "package.json": [
43
- "prettier-package-json --write"
44
- ],
45
- "**/*.{ts,tsx,js,jsx,html,md,mdx,yml,json}": [
46
- "prettier --write"
47
- ]
48
- },
49
- "source": "src/index.ts",
50
- "unpkg": "./dist/index.umd.js"
22
+ "@arethetypeswrong/cli": "0.13.4",
23
+ "tsup": "8.0.1",
24
+ "typescript": "5.3.3",
25
+ "vitest": "1.1.0"
26
+ }
51
27
  }
package/src/index.ts CHANGED
@@ -1,80 +1 @@
1
- export type ResizeParams = {
2
- freezeAnimation?: boolean;
3
- dpr?: number;
4
- width?: number | `${number}`;
5
- height?: number | `${number}`;
6
- };
7
-
8
- export const resizeImage = (
9
- image: string | URL,
10
- { width, height, dpr = 1, freezeAnimation = false }: ResizeParams
11
- ): string => {
12
- try {
13
- if (typeof image === 'string') {
14
- image = new URL(image);
15
- }
16
- } catch {
17
- return image.toString();
18
- }
19
-
20
- if (!(image instanceof URL)) {
21
- return image;
22
- }
23
-
24
- const params = new URLSearchParams({
25
- auto: 'format',
26
- dpr: String(dpr)
27
- });
28
-
29
- if (width !== undefined) {
30
- params.set('w', String(width));
31
- }
32
- if (height !== undefined) {
33
- params.set('h', String(height));
34
- }
35
-
36
- if (freezeAnimation) {
37
- params.set('fr', '1');
38
- }
39
-
40
- image.search = params.toString();
41
- return image.toString();
42
- };
43
-
44
- export const isSupportedFormat = (src: string | URL): boolean => {
45
- try {
46
- if (typeof src === 'string') {
47
- src = new URL(src);
48
- }
49
- } catch {
50
- return false;
51
- }
52
-
53
- if (!(src instanceof URL)) {
54
- return false;
55
- }
56
-
57
- const { pathname } = src;
58
- return (
59
- pathname.endsWith('.jpg') ||
60
- pathname.endsWith('.jpeg') ||
61
- pathname.endsWith('.png') ||
62
- pathname.endsWith('.webp') ||
63
- pathname.endsWith('.gif') ||
64
- pathname.startsWith('/gae/') // GoogleAppEngine URLs do not contain extensions
65
- );
66
- };
67
-
68
- export const isSupportedURL = (src: string | URL): boolean => {
69
- try {
70
- if (typeof src === 'string') {
71
- src = new URL(src);
72
- }
73
- } catch {
74
- return false;
75
- }
76
- if (!(src instanceof URL)) {
77
- return false;
78
- }
79
- return src.hostname === 'i.seadn.io' && isSupportedFormat(src);
80
- };
1
+ export { optimize, MediaParams, MediaFormat, canBeOptimized } from "./sdk";
@@ -0,0 +1,67 @@
1
+ import { test, expect } from "vitest";
2
+ import { MediaParams, optimize } from "./sdk";
3
+
4
+ test.each([
5
+ [undefined, {} satisfies MediaParams, undefined],
6
+ ["", {} satisfies MediaParams, ""],
7
+ ["random", {} satisfies MediaParams, "random"],
8
+ [[], {} satisfies MediaParams, []],
9
+ [{}, {} satisfies MediaParams, {}],
10
+ [
11
+ "https://i2.seadn.io/bored-ape.png",
12
+ {} satisfies MediaParams,
13
+ "https://i2.seadn.io/bored-ape.png",
14
+ ],
15
+ [
16
+ "https://i2.seadn.io/bored-ape.png",
17
+ { width: 100 } satisfies MediaParams,
18
+ "https://i2.seadn.io/bored-ape.png?w=100",
19
+ ],
20
+ [
21
+ "https://i2.seadn.io/bored-ape.png",
22
+ { height: 100 } satisfies MediaParams,
23
+ "https://i2.seadn.io/bored-ape.png?h=100",
24
+ ],
25
+ [
26
+ "https://i2.seadn.io/bored-ape.png",
27
+ { width: 100, height: 100 } satisfies MediaParams,
28
+ "https://i2.seadn.io/bored-ape.png?h=100&w=100",
29
+ ],
30
+ [
31
+ "https://i2.seadn.io/bored-ape.png",
32
+ { height: 100, width: 100 } satisfies MediaParams,
33
+ "https://i2.seadn.io/bored-ape.png?h=100&w=100",
34
+ ],
35
+ [
36
+ "https://i2.seadn.io/bored-ape.svg",
37
+ { height: 100, width: 100 } satisfies MediaParams,
38
+ "https://i2.seadn.io/bored-ape.svg",
39
+ ],
40
+ [
41
+ "https://i2.seadn.io/bored-ape.png.x",
42
+ { height: 100, width: 100 } satisfies MediaParams,
43
+ "https://i2.seadn.io/bored-ape.png.x",
44
+ ],
45
+ [
46
+ "https://i2.seadn.io/bored-ape.svg",
47
+ { height: 100, width: 100 } satisfies MediaParams,
48
+ "https://i2.seadn.io/bored-ape.svg",
49
+ ],
50
+ [
51
+ "https://i2.seadn.io/bored-ape",
52
+ { height: 100, width: 100 } satisfies MediaParams,
53
+ "https://i2.seadn.io/bored-ape?h=100&w=100",
54
+ ],
55
+ [
56
+ "https://i2.seadn.io/bored-ape",
57
+ { height: 100, width: 100, format: "avif" } satisfies MediaParams,
58
+ "https://i2.seadn.io/bored-ape?h=100&w=100&format=avif",
59
+ ],
60
+ [
61
+ "https://xyz.com/bored-ape.png",
62
+ { height: 100, width: 100, format: "avif" } satisfies MediaParams,
63
+ "https://xyz.com/bored-ape.png",
64
+ ],
65
+ ])("resizeImage(%o, %o) -> %o", (url, resizeParams, expected) => {
66
+ expect(optimize(url as string, resizeParams)).toEqual(expected);
67
+ });
package/src/sdk.ts ADDED
@@ -0,0 +1,77 @@
1
+ export type MediaFormat = "webp" | "avif" | "jpeg" | "png";
2
+
3
+ export type MediaParams = {
4
+ width?: number | `${number}`;
5
+ height?: number | `${number}`;
6
+ format?: MediaFormat;
7
+ };
8
+
9
+ export function optimize(
10
+ image: string | URL,
11
+ { width, height, format }: MediaParams,
12
+ ): string {
13
+ try {
14
+ if (typeof image === "string") {
15
+ image = new URL(image);
16
+ }
17
+ } catch {
18
+ return image.toString();
19
+ }
20
+
21
+ if (!(image instanceof URL)) {
22
+ return image;
23
+ }
24
+
25
+ if (!canBeOptimized(image)) {
26
+ return image.toString();
27
+ }
28
+
29
+ const params = new URLSearchParams();
30
+ if (height !== undefined) {
31
+ params.set("h", String(height));
32
+ }
33
+ if (width !== undefined) {
34
+ params.set("w", String(width));
35
+ }
36
+ if (format !== undefined) {
37
+ params.set("format", format);
38
+ }
39
+ image.search = params.toString();
40
+ return image.toString();
41
+ }
42
+
43
+ export function canBeOptimized(url: URL): boolean {
44
+ if (!isSeadnURL(url)) {
45
+ return false;
46
+ }
47
+
48
+ const split = url.pathname.split(".");
49
+ if (split.length <= 1) {
50
+ return true;
51
+ }
52
+
53
+ const extension = split[split.length - 1];
54
+ switch (extension) {
55
+ case "png":
56
+ case "jpeg":
57
+ case "webp":
58
+ case "avif":
59
+ case "ico":
60
+ case undefined:
61
+ return true;
62
+ default:
63
+ return false;
64
+ }
65
+ }
66
+
67
+ export function isSeadnURL(url: URL): boolean {
68
+ switch (url.hostname) {
69
+ case "i2.dev.seadn.io":
70
+ case "i2c.dev.seadn.io":
71
+ case "i2.seadn.io":
72
+ case "i2c.seadn.io":
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
package/dist/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- var t=function(t){try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}if(!(t instanceof URL))return!1;var r=t.pathname;return r.endsWith(".jpg")||r.endsWith(".jpeg")||r.endsWith(".png")||r.endsWith(".webp")||r.endsWith(".gif")||r.startsWith("/gae/")};exports.isSupportedFormat=t,exports.isSupportedURL=function(r){try{"string"==typeof r&&(r=new URL(r))}catch(t){return!1}return r instanceof URL&&"i.seadn.io"===r.hostname&&t(r)},exports.resizeImage=function(t,r){var e=r.width,n=r.height,i=r.dpr,o=void 0===i?1:i,s=r.freezeAnimation,a=void 0!==s&&s;try{"string"==typeof t&&(t=new URL(t))}catch(r){return t.toString()}if(!(t instanceof URL))return t;var h=new URLSearchParams({auto:"format",dpr:String(o)});return void 0!==e&&h.set("w",String(e)),void 0!==n&&h.set("h",String(n)),a&&h.set("fr","1"),t.search=h.toString(),t.toString()};
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export type ResizeParams = {\n freezeAnimation?: boolean;\n dpr?: number;\n width?: number | `${number}`;\n height?: number | `${number}`;\n};\n\nexport const resizeImage = (\n image: string | URL,\n { width, height, dpr = 1, freezeAnimation = false }: ResizeParams\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 const params = new URLSearchParams({\n auto: 'format',\n dpr: String(dpr)\n });\n\n if (width !== undefined) {\n params.set('w', String(width));\n }\n if (height !== undefined) {\n params.set('h', String(height));\n }\n\n if (freezeAnimation) {\n params.set('fr', '1');\n }\n\n image.search = params.toString();\n return image.toString();\n};\n\nexport const isSupportedFormat = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n\n if (!(src instanceof URL)) {\n return false;\n }\n\n const { pathname } = src;\n return (\n pathname.endsWith('.jpg') ||\n pathname.endsWith('.jpeg') ||\n pathname.endsWith('.png') ||\n pathname.endsWith('.webp') ||\n pathname.endsWith('.gif') ||\n pathname.startsWith('/gae/') // GoogleAppEngine URLs do not contain extensions\n );\n};\n\nexport const isSupportedURL = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n if (!(src instanceof URL)) {\n return false;\n }\n return src.hostname === 'i.seadn.io' && isSupportedFormat(src);\n};\n"],"names":["isSupportedFormat","src","URL","_unused2","pathname","endsWith","startsWith","_unused3","hostname","image","_ref","width","height","_ref$dpr","dpr","_ref$freezeAnimation","freezeAnimation","_unused","toString","params","URLSearchParams","auto","String","undefined","set","search"],"mappings":"AAOa,IAoCAA,EAAoB,SAACC,GAChC,IACqB,iBAARA,IACTA,EAAM,IAAIC,IAAID,GAEjB,CAAC,MAAAE,GACA,OACD,CAAA,CAED,KAAMF,aAAeC,KACnB,OAAO,EAGT,IAAQE,EAAaH,EAAbG,SACR,OACEA,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASE,WAAW,QAExB,qDAE8B,SAACL,GAC7B,IACqB,iBAARA,IACTA,EAAM,IAAIC,IAAID,GAEjB,CAAC,MAAAM,GACA,OACD,CAAA,CACD,OAAMN,aAAeC,KAGG,eAAjBD,EAAIO,UAA6BR,EAAkBC,EAC5D,sBAxE2B,SACzBQ,EAAmBC,GACjB,IAAAC,EAAKD,EAALC,MAAOC,EAAMF,EAANE,OAAMC,EAAAH,EAAEI,IAAAA,OAAM,IAAHD,EAAG,EAACA,EAAAE,EAAAL,EAAEM,gBAAAA,OAAkB,IAAHD,GAAQA,EAEjD,IACuB,iBAAVN,IACTA,EAAQ,IAAIP,IAAIO,GAEnB,CAAC,MAAAQ,GACA,OAAOR,EAAMS,UACd,CAED,KAAMT,aAAiBP,KACrB,OAAOO,EAGT,IAAMU,EAAS,IAAIC,gBAAgB,CACjCC,KAAM,SACNP,IAAKQ,OAAOR,KAed,YAZcS,IAAVZ,GACFQ,EAAOK,IAAI,IAAKF,OAAOX,SAEVY,IAAXX,GACFO,EAAOK,IAAI,IAAKF,OAAOV,IAGrBI,GACFG,EAAOK,IAAI,KAAM,KAGnBf,EAAMgB,OAASN,EAAOD,WACfT,EAAMS,UACf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,WAAW,UACf,MAAM,GAAG,GAAG,2CACkC,YAAY,KAChE,MA+BF,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAS,MAAM,GAAG,GAAG,KAAG,OAsBrD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,MAAM,GAAG,GAAG,KAAG,OAYlD,CAAC"}
@@ -1,2 +0,0 @@
1
- const t=(t,{width:n,height:e,dpr:r=1,freezeAnimation:i=!1})=>{try{"string"==typeof t&&(t=new URL(t))}catch(n){return t.toString()}if(!(t instanceof URL))return t;const s=new URLSearchParams({auto:"format",dpr:String(r)});return void 0!==n&&s.set("w",String(n)),void 0!==e&&s.set("h",String(e)),i&&s.set("fr","1"),t.search=s.toString(),t.toString()},n=t=>{try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}if(!(t instanceof URL))return!1;const{pathname:n}=t;return n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".png")||n.endsWith(".webp")||n.endsWith(".gif")||n.startsWith("/gae/")},e=t=>{try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}return t instanceof URL&&"i.seadn.io"===t.hostname&&n(t)};export{n as isSupportedFormat,e as isSupportedURL,t as resizeImage};
2
- //# sourceMappingURL=index.modern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["export type ResizeParams = {\n freezeAnimation?: boolean;\n dpr?: number;\n width?: number | `${number}`;\n height?: number | `${number}`;\n};\n\nexport const resizeImage = (\n image: string | URL,\n { width, height, dpr = 1, freezeAnimation = false }: ResizeParams\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 const params = new URLSearchParams({\n auto: 'format',\n dpr: String(dpr)\n });\n\n if (width !== undefined) {\n params.set('w', String(width));\n }\n if (height !== undefined) {\n params.set('h', String(height));\n }\n\n if (freezeAnimation) {\n params.set('fr', '1');\n }\n\n image.search = params.toString();\n return image.toString();\n};\n\nexport const isSupportedFormat = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n\n if (!(src instanceof URL)) {\n return false;\n }\n\n const { pathname } = src;\n return (\n pathname.endsWith('.jpg') ||\n pathname.endsWith('.jpeg') ||\n pathname.endsWith('.png') ||\n pathname.endsWith('.webp') ||\n pathname.endsWith('.gif') ||\n pathname.startsWith('/gae/') // GoogleAppEngine URLs do not contain extensions\n );\n};\n\nexport const isSupportedURL = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n if (!(src instanceof URL)) {\n return false;\n }\n return src.hostname === 'i.seadn.io' && isSupportedFormat(src);\n};\n"],"names":["resizeImage","image","width","height","dpr","freezeAnimation","URL","_unused","toString","params","URLSearchParams","auto","String","undefined","set","search","isSupportedFormat","src","_unused2","pathname","endsWith","startsWith","isSupportedURL","_unused3","hostname"],"mappings":"AAOa,MAAAA,EAAcA,CACzBC,GACEC,QAAOC,SAAQC,IAAAA,EAAM,EAAGC,gBAAAA,GAAkB,MAE5C,IACuB,iBAAVJ,IACTA,EAAQ,IAAIK,IAAIL,GAEnB,CAAC,MAAAM,GACA,OAAON,EAAMO,UACd,CAED,KAAMP,aAAiBK,KACrB,OAAOL,EAGT,MAAMQ,EAAS,IAAIC,gBAAgB,CACjCC,KAAM,SACNP,IAAKQ,OAAOR,KAed,YAZcS,IAAVX,GACFO,EAAOK,IAAI,IAAKF,OAAOV,SAEVW,IAAXV,GACFM,EAAOK,IAAI,IAAKF,OAAOT,IAGrBE,GACFI,EAAOK,IAAI,KAAM,KAGnBb,EAAMc,OAASN,EAAOD,WACfP,EAAMO,UACf,EAEaQ,EAAqBC,IAChC,IACqB,iBAARA,IACTA,EAAM,IAAIX,IAAIW,GAEjB,CAAC,MAAAC,GACA,OACD,CAAA,CAED,KAAMD,aAAeX,KACnB,OACD,EAED,MAAMa,SAAEA,GAAaF,EACrB,OACEE,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASE,WAAW,QAAO,EAIlBC,EAAkBL,IAC7B,IACqB,iBAARA,IACTA,EAAM,IAAIX,IAAIW,GAEjB,CAAC,MAAAM,GACA,QACD,CACD,OAAMN,aAAeX,KAGG,eAAjBW,EAAIO,UAA6BR,EAAkBC,EAAG"}
@@ -1,2 +0,0 @@
1
- var t=function(t,n){var r=n.width,e=n.height,i=n.dpr,a=void 0===i?1:i,o=n.freezeAnimation,s=void 0!==o&&o;try{"string"==typeof t&&(t=new URL(t))}catch(n){return t.toString()}if(!(t instanceof URL))return t;var h=new URLSearchParams({auto:"format",dpr:String(a)});return void 0!==r&&h.set("w",String(r)),void 0!==e&&h.set("h",String(e)),s&&h.set("fr","1"),t.search=h.toString(),t.toString()},n=function(t){try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}if(!(t instanceof URL))return!1;var n=t.pathname;return n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".png")||n.endsWith(".webp")||n.endsWith(".gif")||n.startsWith("/gae/")},r=function(t){try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}return t instanceof URL&&"i.seadn.io"===t.hostname&&n(t)};export{n as isSupportedFormat,r as isSupportedURL,t as resizeImage};
2
- //# sourceMappingURL=index.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.module.js","sources":["../src/index.ts"],"sourcesContent":["export type ResizeParams = {\n freezeAnimation?: boolean;\n dpr?: number;\n width?: number | `${number}`;\n height?: number | `${number}`;\n};\n\nexport const resizeImage = (\n image: string | URL,\n { width, height, dpr = 1, freezeAnimation = false }: ResizeParams\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 const params = new URLSearchParams({\n auto: 'format',\n dpr: String(dpr)\n });\n\n if (width !== undefined) {\n params.set('w', String(width));\n }\n if (height !== undefined) {\n params.set('h', String(height));\n }\n\n if (freezeAnimation) {\n params.set('fr', '1');\n }\n\n image.search = params.toString();\n return image.toString();\n};\n\nexport const isSupportedFormat = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n\n if (!(src instanceof URL)) {\n return false;\n }\n\n const { pathname } = src;\n return (\n pathname.endsWith('.jpg') ||\n pathname.endsWith('.jpeg') ||\n pathname.endsWith('.png') ||\n pathname.endsWith('.webp') ||\n pathname.endsWith('.gif') ||\n pathname.startsWith('/gae/') // GoogleAppEngine URLs do not contain extensions\n );\n};\n\nexport const isSupportedURL = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n if (!(src instanceof URL)) {\n return false;\n }\n return src.hostname === 'i.seadn.io' && isSupportedFormat(src);\n};\n"],"names":["resizeImage","image","_ref","width","height","_ref$dpr","dpr","_ref$freezeAnimation","freezeAnimation","URL","_unused","toString","params","URLSearchParams","auto","String","undefined","set","search","isSupportedFormat","src","_unused2","pathname","endsWith","startsWith","isSupportedURL","_unused3","hostname"],"mappings":"AAOa,IAAAA,EAAc,SACzBC,EAAmBC,GACjB,IAAAC,EAAKD,EAALC,MAAOC,EAAMF,EAANE,OAAMC,EAAAH,EAAEI,IAAAA,OAAM,IAAHD,EAAG,EAACA,EAAAE,EAAAL,EAAEM,gBAAAA,OAAkB,IAAHD,GAAQA,EAEjD,IACuB,iBAAVN,IACTA,EAAQ,IAAIQ,IAAIR,GAEnB,CAAC,MAAAS,GACA,OAAOT,EAAMU,UACd,CAED,KAAMV,aAAiBQ,KACrB,OAAOR,EAGT,IAAMW,EAAS,IAAIC,gBAAgB,CACjCC,KAAM,SACNR,IAAKS,OAAOT,KAed,YAZcU,IAAVb,GACFS,EAAOK,IAAI,IAAKF,OAAOZ,SAEVa,IAAXZ,GACFQ,EAAOK,IAAI,IAAKF,OAAOX,IAGrBI,GACFI,EAAOK,IAAI,KAAM,KAGnBhB,EAAMiB,OAASN,EAAOD,WACfV,EAAMU,UACf,EAEaQ,EAAoB,SAACC,GAChC,IACqB,iBAARA,IACTA,EAAM,IAAIX,IAAIW,GAEjB,CAAC,MAAAC,GACA,OACD,CAAA,CAED,KAAMD,aAAeX,KACnB,OAAO,EAGT,IAAQa,EAAaF,EAAbE,SACR,OACEA,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASE,WAAW,QAExB,EAEaC,EAAiB,SAACL,GAC7B,IACqB,iBAARA,IACTA,EAAM,IAAIX,IAAIW,GAEjB,CAAC,MAAAM,GACA,OACD,CAAA,CACD,OAAMN,aAAeX,KAGG,eAAjBW,EAAIO,UAA6BR,EAAkBC,EAC5D"}
package/dist/index.umd.js DELETED
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).seadn={})}(this,function(t){var e=function(t){try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}if(!(t instanceof URL))return!1;var e=t.pathname;return e.endsWith(".jpg")||e.endsWith(".jpeg")||e.endsWith(".png")||e.endsWith(".webp")||e.endsWith(".gif")||e.startsWith("/gae/")};t.isSupportedFormat=e,t.isSupportedURL=function(t){try{"string"==typeof t&&(t=new URL(t))}catch(t){return!1}return t instanceof URL&&"i.seadn.io"===t.hostname&&e(t)},t.resizeImage=function(t,e){var n=e.width,i=e.height,r=e.dpr,o=void 0===r?1:r,s=e.freezeAnimation,a=void 0!==s&&s;try{"string"==typeof t&&(t=new URL(t))}catch(e){return t.toString()}if(!(t instanceof URL))return t;var f=new URLSearchParams({auto:"format",dpr:String(o)});return void 0!==n&&f.set("w",String(n)),void 0!==i&&f.set("h",String(i)),a&&f.set("fr","1"),t.search=f.toString(),t.toString()}});
2
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["export type ResizeParams = {\n freezeAnimation?: boolean;\n dpr?: number;\n width?: number | `${number}`;\n height?: number | `${number}`;\n};\n\nexport const resizeImage = (\n image: string | URL,\n { width, height, dpr = 1, freezeAnimation = false }: ResizeParams\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 const params = new URLSearchParams({\n auto: 'format',\n dpr: String(dpr)\n });\n\n if (width !== undefined) {\n params.set('w', String(width));\n }\n if (height !== undefined) {\n params.set('h', String(height));\n }\n\n if (freezeAnimation) {\n params.set('fr', '1');\n }\n\n image.search = params.toString();\n return image.toString();\n};\n\nexport const isSupportedFormat = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n\n if (!(src instanceof URL)) {\n return false;\n }\n\n const { pathname } = src;\n return (\n pathname.endsWith('.jpg') ||\n pathname.endsWith('.jpeg') ||\n pathname.endsWith('.png') ||\n pathname.endsWith('.webp') ||\n pathname.endsWith('.gif') ||\n pathname.startsWith('/gae/') // GoogleAppEngine URLs do not contain extensions\n );\n};\n\nexport const isSupportedURL = (src: string | URL): boolean => {\n try {\n if (typeof src === 'string') {\n src = new URL(src);\n }\n } catch {\n return false;\n }\n if (!(src instanceof URL)) {\n return false;\n }\n return src.hostname === 'i.seadn.io' && isSupportedFormat(src);\n};\n"],"names":["isSupportedFormat","src","URL","_unused2","pathname","endsWith","startsWith","_unused3","hostname","image","_ref","width","height","_ref$dpr","dpr","_ref$freezeAnimation","freezeAnimation","_unused","toString","params","URLSearchParams","auto","String","undefined","set","search"],"mappings":"+NAOa,IAoCAA,EAAoB,SAACC,GAChC,IACqB,iBAARA,IACTA,EAAM,IAAIC,IAAID,GAEjB,CAAC,MAAAE,GACA,OACD,CAAA,CAED,KAAMF,aAAeC,KACnB,OAAO,EAGT,IAAQE,EAAaH,EAAbG,SACR,OACEA,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASC,SAAS,UAClBD,EAASC,SAAS,SAClBD,EAASE,WAAW,QAExB,yCAE8B,SAACL,GAC7B,IACqB,iBAARA,IACTA,EAAM,IAAIC,IAAID,GAEjB,CAAC,MAAAM,GACA,OACD,CAAA,CACD,OAAMN,aAAeC,KAGG,eAAjBD,EAAIO,UAA6BR,EAAkBC,EAC5D,gBAxE2B,SACzBQ,EAAmBC,GACjB,IAAAC,EAAKD,EAALC,MAAOC,EAAMF,EAANE,OAAMC,EAAAH,EAAEI,IAAAA,OAAM,IAAHD,EAAG,EAACA,EAAAE,EAAAL,EAAEM,gBAAAA,OAAkB,IAAHD,GAAQA,EAEjD,IACuB,iBAAVN,IACTA,EAAQ,IAAIP,IAAIO,GAEnB,CAAC,MAAAQ,GACA,OAAOR,EAAMS,UACd,CAED,KAAMT,aAAiBP,KACrB,OAAOO,EAGT,IAAMU,EAAS,IAAIC,gBAAgB,CACjCC,KAAM,SACNP,IAAKQ,OAAOR,KAed,YAZcS,IAAVZ,GACFQ,EAAOK,IAAI,IAAKF,OAAOX,SAEVY,IAAXX,GACFO,EAAOK,IAAI,IAAKF,OAAOV,IAGrBI,GACFG,EAAOK,IAAI,KAAM,KAGnBf,EAAMgB,OAASN,EAAOD,WACfT,EAAMS,UACf"}
package/src/index.test.ts DELETED
@@ -1,68 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { resizeImage, isSupportedFormat, isSupportedURL } from '.';
3
-
4
- test.each([
5
- [
6
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png',
7
- { height: 100 },
8
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=1&h=100'
9
- ],
10
- [
11
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png',
12
- { width: 100 },
13
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=1&w=100'
14
- ],
15
- [
16
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png',
17
- { height: 100, width: 100 },
18
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=1&w=100&h=100'
19
- ],
20
- [
21
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=1&w=100&h=100',
22
- { height: 200, width: 200 },
23
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=1&w=200&h=200'
24
- ],
25
- [
26
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png',
27
- { dpr: 5, freezeAnimation: true },
28
- 'https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png?auto=format&dpr=5&fr=1'
29
- ],
30
- ['unknown', { dpr: 5, freezeAnimation: true }, 'unknown'],
31
- [5, { dpr: 5, freezeAnimation: true }, 5]
32
- ])(
33
- 'resizeImage(%url, %resizeParams) -> %expected',
34
- (url, resizeParams, expected) => {
35
- expect(resizeImage(url as string, resizeParams)).toBe(expected);
36
- }
37
- );
38
-
39
- test.each([
40
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png', true],
41
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.jpg', true],
42
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.jpeg', true],
43
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.webp', true],
44
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.webp', true],
45
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.gif', true],
46
- ['https://i.seadn.io/gae/files/057bb30c6d80d54b78439927b2f07676', true],
47
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.mp3', false],
48
- ['unknown', false],
49
- [5, false]
50
- ])('isSupportedFormat(%url) -> %expected', (url, expected) => {
51
- expect(isSupportedFormat(url as string)).toBe(expected);
52
- });
53
-
54
- test.each([
55
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.png', true],
56
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.jpg', true],
57
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.jpeg', true],
58
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.webp', true],
59
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.webp', true],
60
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.gif', true],
61
- ['https://i.seadn.io/gae/files/057bb30c6d80d54b78439927b2f07676', true],
62
- ['https://i.seadn.io/gcs/files/057bb30c6d80d54b78439927b2f07676.mp3', false],
63
- ['https://i.seadn2.io/gcs/files/057bb30c6d80d54b78439927b2f07676.mp3', false],
64
- ['unknown', false],
65
- [5, false]
66
- ])('isSeadnUrl(%url) -> %expected', (url, expected) => {
67
- expect(isSupportedURL(url as string)).toBe(expected);
68
- });