wasm-image-optimization 1.2.23 → 1.2.25

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,77 +1,47 @@
1
1
  # wasm-image-optimization
2
2
 
3
- ## Supported Environments
4
-
5
- - Cloudflare workers
6
- `import { optimizeImage } from 'wasm-image-optimization';`
7
- - Next.js (Webpack)
8
- `import { optimizeImage } from 'wasm-image-optimization/next';`
9
- - ESM (import base) & Deno Deploy
10
- `import { optimizeImage } from 'wasm-image-optimization';`
11
- - Node.js
12
- `import { optimizeImage } from 'wasm-image-optimization';`
13
- - Node.js(Multi thread)
14
- `import { optimizeImage } from 'wasm-image-optimization/node-worker';`
15
- - Vite (Browser)
16
- `import { optimizeImage } from 'wasm-image-optimization/vite';`
17
- - Web Worker (Browser) Multi process
18
- `import { optimizeImage } from 'wasm-image-optimization/web-worker';`
19
-
20
- ## Samples
21
-
22
- https://github.com/SoraKumo001/wasm-image-optimization-samples
23
-
24
- ### cloudflare-ogp
25
-
26
- Sample for generating OGP images on Cloudflare Workers.
27
-
28
- ### deno-ogp
29
-
30
- Sample for generating OGP images on Deno.
3
+ WebAssembly is used to provide image transformation functionality.
31
4
 
32
- ### cloudflare-image-optimization
5
+ - Frontend
33
6
 
34
- Sample for image optimization on Cloudflare Workers.
7
+ - Next.js (Multithreading support)
8
+ - React Router (Multithreading support)
35
9
 
36
- ### deno-image-optimization
10
+ - Backend
37
11
 
38
- Sample for image optimization on Deno.
12
+ - Cloudflare Workers
13
+ - Deno Deploy
14
+ - Node.js (Multithreading support)
39
15
 
40
- ### node-image-convert
16
+ - Convert
17
+ - source format
18
+ - svg
19
+ - jpeg (EXIF orientation is supported)
20
+ - png
21
+ - webp
22
+ - avif
23
+ - output format
24
+ - jpeg
25
+ - png
26
+ - webp
27
+ - avif (default)
41
28
 
42
- Sample for converting image formats on Node.js.
43
- Single-threaded and multi-threaded operation can be selected.
29
+ ## Example
44
30
 
45
- ## WebWorker on Vite
46
-
47
- - vite.config.ts
31
+ https://next-image-convert.vercel.app/
32
+ ![](https://raw.githubusercontent.com/node-libraries/wasm-image-optimization/refs/heads/master/doc/image.avif)
48
33
 
49
- ```ts
50
- import wasmImageOptimizationPlugin from "wasm-image-optimization/vite-plugin";
51
-
52
- export default defineConfig(() => ({
53
- plugins: [wasmImageOptimizationPlugin()],
54
- }));
55
- ```
56
-
57
- ## Next.js on Backend API
58
-
59
- ```ts
60
- import { optimizeImage } from "wasm-image-optimization";
61
-
62
- export const runtime = "edge";
63
- ```
34
+ ## Functions
64
35
 
65
- ## function
36
+ - Convert image
66
37
 
67
38
  ```ts
68
-
69
39
  optimizeImage({
70
40
  image: ArrayBuffer,
71
41
  width?: number,
72
42
  height?:number,
73
43
  quality?: number, // quality: 1-100
74
- format?: "png" | "jpeg" | "avif" | "webp"}
44
+ format?: "png" | "jpeg" | "avif" | "webp" | "none"}
75
45
  speed?: number // avif-speed: 0-10 (Slow-Fast, default: 6)
76
46
  ):
77
47
  Promise<
@@ -82,26 +52,57 @@ optimizeImageExt({
82
52
  width?: number,
83
53
  height?:number,
84
54
  quality?: number,
85
- format?: "png" | "jpeg" | "avif" | "webp"}
55
+ format?: "png" | "jpeg" | "avif" | "webp" | "none"}
86
56
  speed?: number // avif-speed: 0-10 (Slow-Fast, default: 6)
87
57
  ):
88
58
  Promise<{
89
- data: Uint8Array;
90
- originalWidth: number;
91
- originalHeight: number;
92
- width: number;
93
- height: number;}>
59
+ data: Uint8Array,
60
+ originalWidth: number,
61
+ originalHeight: number,
62
+ width: number,
63
+ height: number}>
64
+
65
+ ```
94
66
 
67
+ - Multi Threading
68
+
69
+ ```ts
70
+ waitAll(): Promise<void>
71
+ waitReady(retryTime?: number) :Promise<void>
72
+ close():void;
95
73
  ```
96
74
 
97
- - source format
98
- - svg
99
- - jpeg(EXIF orientation is supported)
100
- - png
101
- - webp
102
- - avif
103
- - output format
104
- - jpeg
105
- - png
106
- - webp
107
- - avif(default)
75
+ ## WebWorker on Vite
76
+
77
+ To use Vite, the following settings are required
78
+
79
+ - vite.config.ts
80
+
81
+ ```ts
82
+ import wasmImageOptimizationPlugin from "wasm-image-optimization/vite-plugin";
83
+
84
+ export default defineConfig(() => ({
85
+ plugins: [wasmImageOptimizationPlugin()],
86
+ }));
87
+ ```
88
+
89
+ ## Supported Environments
90
+
91
+ - Cloudflare workers
92
+ `import { optimizeImage } from 'wasm-image-optimization';`
93
+ - Next.js (Webpack)
94
+ `import { optimizeImage } from 'wasm-image-optimization/next';`
95
+ - ESM (import base) & Deno Deploy
96
+ `import { optimizeImage } from 'wasm-image-optimization';`
97
+ - Node.js
98
+ `import { optimizeImage } from 'wasm-image-optimization';`
99
+ - Node.js(Multi thread)
100
+ `import { optimizeImage } from 'wasm-image-optimization/node-worker';`
101
+ - Vite (Browser)
102
+ `import { optimizeImage } from 'wasm-image-optimization/vite';`
103
+ - Web Worker (Browser) Multi process
104
+ `import { optimizeImage } from 'wasm-image-optimization/web-worker';`
105
+
106
+ ## Samples
107
+
108
+ https://github.com/SoraKumo001/wasm-image-optimization-samples
@@ -4,3 +4,5 @@ export declare const optimizeImage: (_params: OptimizeParams) => OptimizeResult;
4
4
  export declare const optimizeImageExt: (_params: OptimizeParams) => OptimizeResult;
5
5
  export declare const setLimit: (_limit: number) => void;
6
6
  export declare const close: () => void;
7
+ export declare const waitAll: () => Promise<void>;
8
+ export declare const waitReady: (_retryTime?: number) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.close = exports.setLimit = exports.optimizeImageExt = exports.optimizeImage = void 0;
3
+ exports.waitReady = exports.waitAll = exports.close = exports.setLimit = exports.optimizeImageExt = exports.optimizeImage = void 0;
4
4
  const optimizeImage = (_params) => {
5
5
  return undefined;
6
6
  };
@@ -13,4 +13,8 @@ const setLimit = (_limit) => { };
13
13
  exports.setLimit = setLimit;
14
14
  const close = () => { };
15
15
  exports.close = close;
16
+ const waitAll = () => Promise.resolve();
17
+ exports.waitAll = waitAll;
18
+ const waitReady = (_retryTime) => Promise.resolve();
19
+ exports.waitReady = waitReady;
16
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dummy/index.ts"],"names":[],"mappings":";;;AAIO,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAkB,EAAE;IACvE,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AACK,MAAM,gBAAgB,GAAG,CAAC,OAAuB,EAAkB,EAAE;IAC1E,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AACK,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAQ,EAAE,GAAE,CAAC,CAAC;AAAxC,QAAA,QAAQ,YAAgC;AAC9C,MAAM,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAAjB,QAAA,KAAK,SAAY","sourcesContent":["import { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nexport const optimizeImage = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const optimizeImageExt = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const setLimit = (_limit: number): void => {};\nexport const close = () => {};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dummy/index.ts"],"names":[],"mappings":";;;AAIO,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAkB,EAAE;IACvE,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AACK,MAAM,gBAAgB,GAAG,CAAC,OAAuB,EAAkB,EAAE;IAC1E,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AACK,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAQ,EAAE,GAAE,CAAC,CAAC;AAAxC,QAAA,QAAQ,YAAgC;AAC9C,MAAM,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAAjB,QAAA,KAAK,SAAY;AACvB,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAAlC,QAAA,OAAO,WAA2B;AACxC,MAAM,SAAS,GAAG,CAAC,UAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAAvD,QAAA,SAAS,aAA8C","sourcesContent":["import { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nexport const optimizeImage = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const optimizeImageExt = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const setLimit = (_limit: number): void => {};\nexport const close = () => {};\nexport const waitAll = () => Promise.resolve();\nexport const waitReady = (_retryTime?: number) => Promise.resolve();\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { OptimizeParams } from "./index.js";
2
- declare const waitAll: () => Promise<void>, close: () => void, setLimit: (limit: number) => void;
2
+ declare const waitAll: () => Promise<void>, waitReady: (retryTime?: number) => Promise<void>, close: () => void, setLimit: (limit: number) => void;
3
3
  export declare const optimizeImage: (params: OptimizeParams) => Promise<any>;
4
4
  export declare const optimizeImageExt: (params: OptimizeParams) => Promise<any>;
5
- export { waitAll, close, setLimit };
5
+ export { waitAll, waitReady, close, setLimit };
@@ -3,15 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setLimit = exports.close = exports.waitAll = exports.optimizeImageExt = exports.optimizeImage = void 0;
6
+ exports.setLimit = exports.close = exports.waitReady = exports.waitAll = exports.optimizeImageExt = exports.optimizeImage = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const node_worker_threads_1 = require("node:worker_threads");
9
9
  const node_1 = require("worker-lib/node");
10
- const { execute, waitAll, close, setLimit } = (0, node_1.createWorker)(() => {
10
+ const { execute, waitAll, waitReady, close, setLimit } = (0, node_1.createWorker)(() => {
11
11
  const url = node_path_1.default.resolve(__dirname, "./node-worker.js");
12
12
  return new node_worker_threads_1.Worker(url);
13
13
  });
14
14
  exports.waitAll = waitAll;
15
+ exports.waitReady = waitReady;
15
16
  exports.close = close;
16
17
  exports.setLimit = setLimit;
17
18
  const optimizeImage = async (params) => execute("optimizeImage", params);
@@ -1 +1 @@
1
- {"version":3,"file":"cjs-worker.js","sourceRoot":"","sources":["../../../src/node/cjs-worker.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,6DAA6C;AAC7C,0CAA+C;AAK/C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAA,mBAAY,EAAa,GAAG,EAAE;IAC1E,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACxD,OAAO,IAAI,4BAAM,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAQM,0BAAO;AAAE,sBAAK;AAAE,4BAAQ;AAN1B,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AADtB,QAAA,aAAa,iBACS;AAE5B,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AADzB,QAAA,gBAAgB,oBACS","sourcesContent":["import path from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\nimport { createWorker } from \"worker-lib/node\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { WorkerType } from \"./_node-worker.js\";\nimport type { OptimizeParams } from \"./index.js\";\n\nconst { execute, waitAll, close, setLimit } = createWorker<WorkerType>(() => {\n const url = path.resolve(__dirname, \"./node-worker.js\");\n return new Worker(url);\n});\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n execute(\"optimizeImage\", params);\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n execute(\"optimizeImageExt\", params);\n\nexport { waitAll, close, setLimit };\n"]}
1
+ {"version":3,"file":"cjs-worker.js","sourceRoot":"","sources":["../../../src/node/cjs-worker.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,6DAA6C;AAC7C,0CAA+C;AAK/C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GACpD,IAAA,mBAAY,EAAa,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACxD,OAAO,IAAI,4BAAM,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAQI,0BAAO;AAAE,8BAAS;AAAE,sBAAK;AAAE,4BAAQ;AANrC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AADtB,QAAA,aAAa,iBACS;AAE5B,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AADzB,QAAA,gBAAgB,oBACS","sourcesContent":["import path from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\nimport { createWorker } from \"worker-lib/node\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { WorkerType } from \"./_node-worker.js\";\nimport type { OptimizeParams } from \"./index.js\";\n\nconst { execute, waitAll, waitReady, close, setLimit } =\n createWorker<WorkerType>(() => {\n const url = path.resolve(__dirname, \"./node-worker.js\");\n return new Worker(url);\n });\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n execute(\"optimizeImage\", params);\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n execute(\"optimizeImageExt\", params);\n\nexport { waitAll, waitReady, close, setLimit };\n"]}
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod) => function __require() {
4
4
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
5
  };
6
6
 
7
- // node_modules/.pnpm/worker-lib@2.0.3/node_modules/worker-lib/dist/cjs/node.js
7
+ // node_modules/.pnpm/worker-lib@2.0.6/node_modules/worker-lib/dist/cjs/node.js
8
8
  var require_node = __commonJS({
9
- "node_modules/.pnpm/worker-lib@2.0.3/node_modules/worker-lib/dist/cjs/node.js"(exports2) {
9
+ "node_modules/.pnpm/worker-lib@2.0.6/node_modules/worker-lib/dist/cjs/node.js"(exports2) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports2, "__esModule", { value: true });
12
12
  exports2.initWorker = exports2.createWorker = void 0;
@@ -52,6 +52,8 @@ var require_node = __commonJS({
52
52
  };
53
53
  var createWorker = (builder, limit = 4) => {
54
54
  let workers = Array(limit).fill(void 0).map(() => ({}));
55
+ const emptyWaits = [];
56
+ let isEmptyWait = false;
55
57
  const getResolver = async () => {
56
58
  while (true) {
57
59
  const target = workers.find(({ resultResolver }) => !resultResolver);
@@ -79,6 +81,27 @@ var require_node = __commonJS({
79
81
  await Promise.all(workers.flatMap(({ resultResolver }) => resultResolver ? [resultResolver.promise] : []));
80
82
  }
81
83
  };
84
+ const waitReady = async (retryTime = 1) => {
85
+ const p = Promise.withResolvers();
86
+ emptyWaits.push(p);
87
+ (async () => {
88
+ if (!isEmptyWait) {
89
+ isEmptyWait = true;
90
+ do {
91
+ const actives = workers.flatMap(({ resultResolver }) => resultResolver ? [resultResolver.promise] : []);
92
+ if (workers.length === actives.length)
93
+ await Promise.race(actives);
94
+ emptyWaits.shift()?.resolve();
95
+ if (retryTime)
96
+ await new Promise((r) => setTimeout(r, retryTime));
97
+ else
98
+ await Promise.resolve();
99
+ } while (emptyWaits.length);
100
+ isEmptyWait = false;
101
+ }
102
+ })();
103
+ return p.promise;
104
+ };
82
105
  const close = () => {
83
106
  for (const { worker } of workers) {
84
107
  worker?.terminate();
@@ -88,7 +111,7 @@ var require_node = __commonJS({
88
111
  workers.forEach((w) => w.worker?.terminate());
89
112
  workers = Array(limit2).fill(void 0).map(() => ({}));
90
113
  };
91
- return { execute, waitAll, close, setLimit };
114
+ return { execute, waitAll, waitReady, close, setLimit };
92
115
  };
93
116
  exports2.createWorker = createWorker;
94
117
  var initWorker = (WorkerProc) => {
@@ -4,3 +4,5 @@ export declare const optimizeImage: (_params: OptimizeParams) => OptimizeResult;
4
4
  export declare const optimizeImageExt: (_params: OptimizeParams) => OptimizeResult;
5
5
  export declare const setLimit: (_limit: number) => void;
6
6
  export declare const close: () => void;
7
+ export declare const waitAll: () => Promise<void>;
8
+ export declare const waitReady: (_retryTime?: number) => Promise<void>;
@@ -6,4 +6,6 @@ export const optimizeImageExt = (_params) => {
6
6
  };
7
7
  export const setLimit = (_limit) => { };
8
8
  export const close = () => { };
9
+ export const waitAll = () => Promise.resolve();
10
+ export const waitReady = (_retryTime) => Promise.resolve();
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dummy/index.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAkB,EAAE;IACvE,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAuB,EAAkB,EAAE;IAC1E,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAQ,EAAE,GAAE,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC","sourcesContent":["import { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nexport const optimizeImage = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const optimizeImageExt = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const setLimit = (_limit: number): void => {};\nexport const close = () => {};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dummy/index.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAkB,EAAE;IACvE,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAuB,EAAkB,EAAE;IAC1E,OAAO,SAAkB,CAAC;AAC5B,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAQ,EAAE,GAAE,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC","sourcesContent":["import { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nexport const optimizeImage = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const optimizeImageExt = (_params: OptimizeParams): OptimizeResult => {\n return undefined as never;\n};\nexport const setLimit = (_limit: number): void => {};\nexport const close = () => {};\nexport const waitAll = () => Promise.resolve();\nexport const waitReady = (_retryTime?: number) => Promise.resolve();\n"]}
@@ -3926,7 +3926,7 @@ var init_libImage = __esm({
3926
3926
  }
3927
3927
  });
3928
3928
 
3929
- // node_modules/.pnpm/worker-lib@2.0.3/node_modules/worker-lib/dist/esm/index.js
3929
+ // node_modules/.pnpm/worker-lib@2.0.6/node_modules/worker-lib/dist/esm/index.js
3930
3930
  var initWorker = (WorkerProc) => {
3931
3931
  const worker = self;
3932
3932
  worker.addEventListener("message", async (e) => {
@@ -3940,7 +3940,7 @@
3940
3940
  }
3941
3941
  });
3942
3942
 
3943
- // node_modules/.pnpm/worker-lib@2.0.3/node_modules/worker-lib/dist/esm/index.js
3943
+ // node_modules/.pnpm/worker-lib@2.0.6/node_modules/worker-lib/dist/esm/index.js
3944
3944
  var initWorker = (WorkerProc) => {
3945
3945
  const worker = self;
3946
3946
  worker.addEventListener("message", async (e) => {
@@ -3,3 +3,5 @@ export declare const optimizeImage: (params: OptimizeParams) => Promise<any>;
3
3
  export declare const optimizeImageExt: (params: OptimizeParams) => Promise<any>;
4
4
  export declare const setLimit: (_limit: number) => void;
5
5
  export declare const close: () => void;
6
+ export declare const waitAll: () => Promise<void>;
7
+ export declare const waitReady: (_retryTime?: number) => Promise<void>;
@@ -7,4 +7,6 @@ export const optimizeImage = async (params) => _optimizeImage({ ...params, libIm
7
7
  export const optimizeImageExt = async (params) => _optimizeImageExt({ ...params, libImage: getLibImage() });
8
8
  export const setLimit = (_limit) => { };
9
9
  export const close = () => { };
10
+ export const waitAll = () => Promise.resolve();
11
+ export const waitReady = (_retryTime) => Promise.resolve();
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5E,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE,CAC7B,QAAQ,CAAC;IACP,UAAU,EAAE,MAAM,KAAK,CACrB,oFAAoF,CACrF,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;CAC/B,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,cAAc,CAAC,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,iBAAiB,CAAC,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAQ,EAAE,GAAE,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC","sourcesContent":["import LibImage from \"../cjs/libImage.js\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { OptimizeParams } from \"../types/index.js\";\n\nconst getLibImage = async () =>\n LibImage({\n wasmBinary: await fetch(\n \"https://cdn.jsdelivr.net/npm/wasm-image-optimization@1.2.18/dist/esm/libImage.wasm\"\n ).then((v) => v.arrayBuffer()),\n });\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n _optimizeImage({ ...params, libImage: getLibImage() });\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n _optimizeImageExt({ ...params, libImage: getLibImage() });\n\nexport const setLimit = (_limit: number): void => {};\nexport const close = () => {};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5E,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE,CAC7B,QAAQ,CAAC;IACP,UAAU,EAAE,MAAM,KAAK,CACrB,oFAAoF,CACrF,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;CAC/B,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,cAAc,CAAC,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,iBAAiB,CAAC,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAQ,EAAE,GAAE,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC","sourcesContent":["import LibImage from \"../cjs/libImage.js\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { OptimizeParams } from \"../types/index.js\";\n\nconst getLibImage = async () =>\n LibImage({\n wasmBinary: await fetch(\n \"https://cdn.jsdelivr.net/npm/wasm-image-optimization@1.2.18/dist/esm/libImage.wasm\"\n ).then((v) => v.arrayBuffer()),\n });\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n _optimizeImage({ ...params, libImage: getLibImage() });\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n _optimizeImageExt({ ...params, libImage: getLibImage() });\n\nexport const setLimit = (_limit: number): void => {};\nexport const close = () => {};\nexport const waitAll = () => Promise.resolve();\nexport const waitReady = (_retryTime?: number) => Promise.resolve();\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { OptimizeParams, OptimizeResult } from "../types/index.js";
2
2
  export type { OptimizeParams, OptimizeResult };
3
- declare const setLimit: (limit: number) => void, close: () => void;
3
+ declare const setLimit: (limit: number) => void, close: () => void, waitAll: () => Promise<void>, waitReady: (retryTime?: number) => Promise<void>;
4
4
  export declare const optimizeImage: (params: OptimizeParams) => Promise<any>;
5
5
  export declare const optimizeImageExt: (params: OptimizeParams) => Promise<any>;
6
- export { setLimit, close };
6
+ export { setLimit, close, waitAll, waitReady };
@@ -1,6 +1,6 @@
1
1
  import { createWorker } from "worker-lib";
2
- const { execute, setLimit, close } = createWorker(() => new Worker(new URL("../esm/next-web-worker.js", import.meta.url)), 5);
2
+ const { execute, setLimit, close, waitAll, waitReady } = createWorker(() => new Worker(new URL("../esm/next-web-worker.js", import.meta.url)), 5);
3
3
  export const optimizeImage = async (params) => execute("optimizeImage", params);
4
4
  export const optimizeImageExt = async (params) => execute("optimizeImageExt", params);
5
- export { setLimit, close };
5
+ export { setLimit, close, waitAll, waitReady };
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next-web-worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,YAAY,CAC/C,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { createWorker } from \"worker-lib\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { WorkerType } from \"./_web-worker.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nconst { execute, setLimit, close } = createWorker<WorkerType>(\n () => new Worker(new URL(\"../esm/next-web-worker.js\", import.meta.url)),\n 5,\n);\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n execute(\"optimizeImage\", params);\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n execute(\"optimizeImageExt\", params);\n\nexport { setLimit, close };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next-web-worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GACpD,YAAY,CACV,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEJ,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { createWorker } from \"worker-lib\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { WorkerType } from \"./_web-worker.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nconst { execute, setLimit, close, waitAll, waitReady } =\n createWorker<WorkerType>(\n () => new Worker(new URL(\"../esm/next-web-worker.js\", import.meta.url)),\n 5\n );\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n execute(\"optimizeImage\", params);\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n execute(\"optimizeImageExt\", params);\n\nexport { setLimit, close, waitAll, waitReady };\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { OptimizeParams, OptimizeResult } from "../types/index.js";
2
2
  export type { OptimizeParams, OptimizeResult };
3
- declare const setLimit: (limit: number) => void, close: () => void;
3
+ declare const setLimit: (limit: number) => void, close: () => void, waitAll: () => Promise<void>, waitReady: (retryTime?: number) => Promise<void>;
4
4
  export declare const optimizeImage: (params: OptimizeParams) => Promise<any>;
5
5
  export declare const optimizeImageExt: (params: OptimizeParams) => Promise<any>;
6
- export { setLimit, close };
6
+ export { setLimit, close, waitAll, waitReady };
@@ -1,6 +1,6 @@
1
1
  import { createWorker } from "worker-lib";
2
- const { execute, setLimit, close } = createWorker(() => new Worker(new URL("../esm/vite-web-worker.js", import.meta.url)), 5);
2
+ const { execute, setLimit, close, waitAll, waitReady } = createWorker(() => new Worker(new URL("../esm/vite-web-worker.js", import.meta.url)), 5);
3
3
  export const optimizeImage = async (params) => execute("optimizeImage", params);
4
4
  export const optimizeImageExt = async (params) => execute("optimizeImageExt", params);
5
- export { setLimit, close };
5
+ export { setLimit, close, waitAll, waitReady };
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite-web-worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,YAAY,CAC/C,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { createWorker } from \"worker-lib\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { WorkerType } from \"./_web-worker.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nconst { execute, setLimit, close } = createWorker<WorkerType>(\n () => new Worker(new URL(\"../esm/vite-web-worker.js\", import.meta.url)),\n 5,\n);\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n execute(\"optimizeImage\", params);\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n execute(\"optimizeImageExt\", params);\n\nexport { setLimit, close };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite-web-worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GACpD,YAAY,CACV,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEJ,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC5D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAsB,EAAE,EAAE,CAC/D,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { createWorker } from \"worker-lib\";\nimport { _optimizeImage, _optimizeImageExt } from \"../lib/optimizeImage.js\";\nimport type { WorkerType } from \"./_web-worker.js\";\nimport type { OptimizeParams, OptimizeResult } from \"../types/index.js\";\nexport type { OptimizeParams, OptimizeResult };\n\nconst { execute, setLimit, close, waitAll, waitReady } =\n createWorker<WorkerType>(\n () => new Worker(new URL(\"../esm/vite-web-worker.js\", import.meta.url)),\n 5\n );\n\nexport const optimizeImage = async (params: OptimizeParams) =>\n execute(\"optimizeImage\", params);\n\nexport const optimizeImageExt = async (params: OptimizeParams) =>\n execute(\"optimizeImageExt\", params);\n\nexport { setLimit, close, waitAll, waitReady };\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wasm-image-optimization",
3
3
  "description": "Optimize images with wasm on edge runtime",
4
- "version": "1.2.23",
4
+ "version": "1.2.25",
5
5
  "scripts": {
6
6
  "test": "yarn ts-node test",
7
7
  "lint:fix": "eslint --fix src/ && prettier -w src",
@@ -100,11 +100,11 @@
100
100
  },
101
101
  "license": "MIT",
102
102
  "dependencies": {
103
- "worker-lib": "2.0.3"
103
+ "worker-lib": "2.0.6"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@eslint/js": "9.21.0",
107
- "@types/node": "22.13.5",
107
+ "@types/node": "22.13.8",
108
108
  "@typescript-eslint/eslint-plugin": "^8.25.0",
109
109
  "@typescript-eslint/parser": "^8.25.0",
110
110
  "cpy-cli": "^5.0.0",
@@ -116,7 +116,7 @@
116
116
  "prettier": "^3.5.2",
117
117
  "ts-node": "^10.9.2",
118
118
  "tsx": "4.19.3",
119
- "typescript": "^5.7.3",
119
+ "typescript": "^5.8.2",
120
120
  "typescript-eslint": "^8.25.0",
121
121
  "vite": "6.2.0"
122
122
  },