@squoosh-kit/core 0.0.1 → 0.0.3
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 +49 -12
- package/dist/features/resize/resize.worker.js +2 -2
- package/dist/features/resize/resize.worker.js.map +3 -3
- package/dist/features/resize/types.d.ts +19 -2
- package/dist/features/webp/types.d.ts +17 -2
- package/dist/features/webp/webp.worker.js +2 -2
- package/dist/features/webp/webp.worker.js.map +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/%40squoosh-kit%2Fcore)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**The complete Squoosh Kit experience in a single package**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`@squoosh-kit/core` brings together all the image processing power of Squoosh Kit in one convenient package. Perfect for when you want everything at your fingertips without worrying about which specific package to install.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- [`@squoosh-kit/resize`](https://www.npmjs.com/package/@squoosh-kit/resize) - High-quality image resizing.
|
|
9
|
+
This meta-package re-exports all functionality from the individual Squoosh Kit packages, so you get WebP encoding, high-quality resizing, and all the underlying runtime utilities in one place.
|
|
11
10
|
|
|
12
11
|
## Installation
|
|
13
12
|
|
|
@@ -19,20 +18,58 @@ npm install @squoosh-kit/core
|
|
|
19
18
|
|
|
20
19
|
## Quick Start
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
Everything you need, right at your fingertips:
|
|
23
22
|
|
|
24
23
|
```typescript
|
|
25
|
-
import {
|
|
24
|
+
import { encode, resize, createWebpEncoder, createResizer } from '@squoosh-kit/core';
|
|
26
25
|
|
|
27
|
-
//
|
|
28
|
-
const webpData = await
|
|
26
|
+
// Quick one-off operations
|
|
27
|
+
const webpData = await encode(
|
|
28
|
+
new AbortController().signal,
|
|
29
|
+
imageData,
|
|
30
|
+
{ quality: 85 }
|
|
31
|
+
);
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
const resizedImage = await resize(
|
|
34
|
+
new AbortController().signal,
|
|
35
|
+
imageData,
|
|
36
|
+
{ width: 800, height: 600 }
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Or create reusable processors for batch operations
|
|
40
|
+
const encoder = createWebpEncoder('worker');
|
|
41
|
+
const resizer = createResizer('worker');
|
|
32
42
|
```
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
## What's Included
|
|
45
|
+
|
|
46
|
+
This package bundles together:
|
|
47
|
+
|
|
48
|
+
- **WebP Encoding** - Convert images to the modern WebP format with fine-tuned quality control
|
|
49
|
+
- **Image Resizing** - High-quality Lanczos3 resizing for crisp, clear results
|
|
50
|
+
- **Worker Management** - Automatic Web Worker integration to keep your app responsive
|
|
51
|
+
- **TypeScript Support** - Full type definitions for a great development experience
|
|
52
|
+
|
|
53
|
+
## When to Use Core vs Individual Packages
|
|
54
|
+
|
|
55
|
+
**Use `@squoosh-kit/core` when:**
|
|
56
|
+
- You're just getting started and want everything available
|
|
57
|
+
- Your project needs both WebP encoding and resizing
|
|
58
|
+
- You prefer a single dependency for simplicity
|
|
59
|
+
- You're building a prototype or proof of concept
|
|
60
|
+
|
|
61
|
+
**Consider individual packages when:**
|
|
62
|
+
- You only need one specific feature (like just WebP encoding)
|
|
63
|
+
- Bundle size is critical and you want to minimize dependencies
|
|
64
|
+
- You need fine-grained control over versions
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
All functions follow the same patterns as the individual packages. For detailed documentation, see:
|
|
69
|
+
|
|
70
|
+
- [WebP Encoding API](./webp) - Advanced encoding options and examples
|
|
71
|
+
- [Resize API](./resize) - Resizing algorithms and configuration details
|
|
35
72
|
|
|
36
73
|
## License
|
|
37
74
|
|
|
38
|
-
MIT
|
|
75
|
+
MIT - part of the Squoosh Kit family
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var K=null;async function O(){if(K)return;let
|
|
2
|
+
var K=null;async function O(){if(K)return;let F="./wasm/resize",j=await import.meta.resolve(`${F}/squoosh_resize.js`),x=await import(j);await x.default(fetch(new URL(`${F}/squoosh_resize_bg.wasm`,j))),K=x.resize}async function L(F,j){if(await O(),!K)throw Error("Resize module not initialized");let{data:x,width:G,height:B}=F,E=j.width??G,J=j.height??B;if(j.width&&!j.height)J=Math.round(B*j.width/G);else if(j.height&&!j.width)E=Math.round(G*j.height/B);if(E<=0||J<=0)throw Error("Invalid output dimensions");let N=x instanceof Uint8ClampedArray?new Uint8Array(x):x;return{data:K(N,G,B,E,J,Q(),j.premultiply?1:0,j.linearRGB?1:0),width:E,height:J}}async function T(F,j,x){if(F.aborted)throw new DOMException("Aborted","AbortError");return L(j,x)}function Q(){return 3}if(typeof self<"u")self.onmessage=async(F)=>{let{id:j,type:x,payload:G}=F.data,B={id:j,ok:!1};try{if(x!=="resize:run")throw Error(`Unknown message type: ${x}`);let E=await L(G.image,G.options);B.ok=!0,B.data=E;let J=E.data.buffer;if(J)self.postMessage(B,[J]);else self.postMessage(B)}catch(E){B.error=E instanceof Error?E.message:String(E),self.postMessage(B)}};export{T as resizeClient};
|
|
3
3
|
export{T as a};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=2E07CB4CD56250F364756E2164756E21
|
|
6
6
|
//# sourceMappingURL=resize.worker.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/resize.worker.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Resize processor - single-source worker/client implementation\n */\n\nimport {\n hasImageData,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { ResizeOptions } from './types.ts';\n\n// Define the type locally to avoid module resolution issues with the linter\ntype SquooshWasmResize = (\n data: Uint8Array,\n input_width: number,\n input_height: number,\n output_width: number,\n output_height: number,\n typ_idx: number,\n premultiply: number,\n color_space_conversion: number,\n) => Uint8Array;\n\nlet wasmResize: SquooshWasmResize | null = null;\n\nasync function init(): Promise<void> {\n if (wasmResize) {\n return;\n }\n\n const
|
|
5
|
+
"/**\n * Resize processor - single-source worker/client implementation\n */\n\nimport {\n hasImageData,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { ResizeOptions } from './types.ts';\n\n// Define the type locally to avoid module resolution issues with the linter\ntype SquooshWasmResize = (\n data: Uint8Array,\n input_width: number,\n input_height: number,\n output_width: number,\n output_height: number,\n typ_idx: number,\n premultiply: number,\n color_space_conversion: number,\n) => Uint8Array;\n\nlet wasmResize: SquooshWasmResize | null = null;\n\nasync function init(): Promise<void> {\n if (wasmResize) {\n return;\n }\n\n const wasmDirectory = './wasm/resize';\n const modulePath = await import.meta.resolve(\n `${wasmDirectory}/squoosh_resize.js`,\n );\n const module = await import(modulePath);\n\n // Squoosh's WASM modules expect to be initialized with promises\n await module.default(\n fetch(new URL(`${wasmDirectory}/squoosh_resize_bg.wasm`, modulePath)),\n );\n wasmResize = module.resize;\n}\n\nasync function _resizeCore(\n image: ImageInput,\n options: ResizeOptions,\n): Promise<ImageInput> {\n await init();\n if (!wasmResize) {\n throw new Error('Resize module not initialized');\n }\n\n const { data, width: inputWidth, height: inputHeight } = image;\n\n let outputWidth = options.width ?? inputWidth;\n let outputHeight = options.height ?? inputHeight;\n\n if (options.width && !options.height) {\n outputHeight = Math.round((inputHeight * options.width) / inputWidth);\n } else if (options.height && !options.width) {\n outputWidth = Math.round((inputWidth * options.height) / inputHeight);\n }\n\n if (outputWidth <= 0 || outputHeight <= 0) {\n throw new Error('Invalid output dimensions');\n }\n\n const dataArray =\n data instanceof Uint8ClampedArray ? new Uint8Array(data) : data;\n\n const result = wasmResize(\n dataArray,\n inputWidth,\n inputHeight,\n outputWidth,\n outputHeight,\n getResizeMethod(),\n options.premultiply ? 1 : 0,\n options.linearRGB ? 1 : 0,\n );\n\n return {\n data: result,\n width: outputWidth,\n height: outputHeight,\n };\n}\n\nexport async function resizeClient(\n signal: AbortSignal,\n image: ImageInput,\n options: ResizeOptions,\n): Promise<ImageInput> {\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n return _resizeCore(image, options);\n}\n\n/**\n * Map ResizeOptions to the typ_idx parameter for the resize function\n * 0: Triangular, 1: Catrom, 2: Mitchell, 3: Lanczos3\n */\nfunction getResizeMethod(): number {\n // Default to Lanczos3 (highest quality)\n return 3;\n}\n\n/**\n * Worker message handler\n */\nif (typeof self !== 'undefined') {\n self.onmessage = async (\n event: MessageEvent<\n WorkerRequest<{ image: ImageInput; options: ResizeOptions }>\n >,\n ) => {\n const { id, type, payload } = event.data;\n\n const response: WorkerResponse<ImageInput> = { id, ok: false };\n\n try {\n if (type !== 'resize:run') {\n throw new Error(`Unknown message type: ${type}`);\n }\n\n const resultImage = await _resizeCore(payload.image, payload.options);\n\n response.ok = true;\n response.data = resultImage;\n\n const transferable = resultImage.data.buffer;\n if (transferable) {\n self.postMessage(response, [transferable as ArrayBuffer]);\n } else {\n self.postMessage(response);\n }\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAwBA,IAAI,EAAuC,KAE3C,eAAe,CAAI,EAAkB,CACnC,GAAI,EACF,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAwBA,IAAI,EAAuC,KAE3C,eAAe,CAAI,EAAkB,CACnC,GAAI,EACF,OAGF,IAAM,EAAgB,gBAChB,EAAa,MAAM,YAAY,QACnC,GAAG,qBACL,EACM,EAAS,MAAa,UAG5B,MAAM,EAAO,QACX,MAAM,IAAI,IAAI,GAAG,2BAAwC,CAAU,CAAC,CACtE,EACA,EAAa,EAAO,OAGtB,eAAe,CAAW,CACxB,EACA,EACqB,C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,EACtE,KAAK,YAAY,CAAQ",
|
|
8
|
+
"debugId": "2E07CB4CD56250F364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for the Resize package
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Options for resizing an image.
|
|
6
|
+
*/
|
|
7
|
+
export type ResizeOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* The target width of the resized image.
|
|
10
|
+
*/
|
|
5
11
|
width?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The target height of the resized image.
|
|
14
|
+
*/
|
|
6
15
|
height?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Premultiply the alpha channel.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
7
20
|
premultiply?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Use a linear RGB color space for resizing.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
8
25
|
linearRGB?: boolean;
|
|
9
|
-
}
|
|
26
|
+
};
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for the WebP package
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Options for WebP encoding.
|
|
6
|
+
*/
|
|
7
|
+
export type WebpOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Quality, 0-100.
|
|
10
|
+
* @default 82
|
|
11
|
+
*/
|
|
5
12
|
quality?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Use lossless compression.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
6
17
|
lossless?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Use near-lossless compression.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
7
22
|
nearLossless?: boolean;
|
|
8
|
-
}
|
|
23
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var N=null;async function U(){if(N)return N;try{if(typeof self>"u")global.self=global;if(typeof self<"u"&&!self.location)self.location={href:import.meta.url};let
|
|
2
|
+
var N=null;async function U(){if(N)return N;try{if(typeof self>"u")global.self=global;if(typeof self<"u"&&!self.location)self.location={href:import.meta.url};let j="./wasm/webp",x=await import(new URL(`${j}/webp_enc.js`,import.meta.url).href),G=new URL(`${j}/`,import.meta.url).href,I=await x.default({locateFile:(H)=>{if(H.endsWith(".wasm"))return new URL(H,G).href;return H}});return N=I,I}catch(j){throw Error(`Failed to load WebP module: ${j instanceof Error?j.message:String(j)}`)}}function V(j){let z=Math.max(0,Math.min(100,j?.quality??82)),x=j?.lossless??!1,G=j?.nearLossless??!1;return{quality:z,target_size:0,target_PSNR:0,method:4,sns_strength:50,filter_strength:60,filter_sharpness:0,filter_type:1,partitions:0,segments:4,pass:1,show_compressed:0,preprocessing:0,autofilter:0,partition_limit:0,alpha_compression:1,alpha_filtering:1,alpha_quality:100,lossless:x?1:0,exact:0,image_hint:0,emulate_jpeg_size:0,thread_level:0,low_memory:0,near_lossless:G?z:100,use_delta_palette:0,use_sharp_yuv:0}}async function X(j,z,x){if(j.aborted)throw new DOMException("Aborted","AbortError");let{width:G,height:I,data:H}=z;if(!(H instanceof Uint8Array)&&!(H instanceof Uint8ClampedArray))throw Error("Image data must be Uint8Array or Uint8ClampedArray");let J=await U();if(j.aborted)throw new DOMException("Aborted","AbortError");let K=V(x),R=H instanceof Uint8ClampedArray?new Uint8Array(H):H,S=new Uint8Array(R),Q=J.encode(S,G,I,K);if(j.aborted)throw new DOMException("Aborted","AbortError");if(!Q)throw Error("WebP encoding failed");return Q}if(typeof self<"u")self.onmessage=async(j)=>{let z=j.data,x={id:z.id,ok:!1};try{if(z.type==="webp:encode"){let{image:G,options:I}=z.payload,H=new AbortController,J=await X(H.signal,G,I);x.ok=!0,x.data=J;let K=x.data.buffer;self.postMessage(x,[K])}else x.error=`Unknown message type: ${z.type}`,self.postMessage(x)}catch(G){x.error=G instanceof Error?G.message:String(G),self.postMessage(x)}};export{X as webpEncodeClient};
|
|
3
3
|
export{X as a};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=66000A60E94E382464756E2164756E21
|
|
6
6
|
//# sourceMappingURL=webp.worker.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/webp.worker.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * WebP encoder - single-source worker/client implementation\n */\n\nimport {\n isWorker,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { WebpOptions } from './types.js';\n\n// Types from webp_enc.d.ts\ninterface EncodeOptions {\n quality: number;\n target_size: number;\n target_PSNR: number;\n method: number;\n sns_strength: number;\n filter_strength: number;\n filter_sharpness: number;\n filter_type: number;\n partitions: number;\n segments: number;\n pass: number;\n show_compressed: number;\n preprocessing: number;\n autofilter: number;\n partition_limit: number;\n alpha_compression: number;\n alpha_filtering: number;\n alpha_quality: number;\n lossless: number;\n exact: number;\n image_hint: number;\n emulate_jpeg_size: number;\n thread_level: number;\n low_memory: number;\n near_lossless: number;\n use_delta_palette: number;\n use_sharp_yuv: number;\n}\n\ninterface WebPModule {\n encode(\n data: BufferSource,\n width: number,\n height: number,\n options: EncodeOptions\n ): Uint8Array | null;\n}\n\nlet cachedModule: WebPModule | null = null;\n\nasync function loadWebPModule(): Promise<WebPModule> {\n if (cachedModule) {\n return cachedModule;\n }\n\n try {\n // Environment polyfills for Emscripten-generated code\n // The WebP encoder WASM module expects browser-like globals (self, location)\n // These polyfills ensure compatibility when running in Bun/Node.js environments\n if (typeof self === 'undefined') {\n // Polyfill 'self' global for Emscripten compatibility\n (global as { self?: typeof globalThis }).self = global;\n }\n if (typeof self !== 'undefined' && !self.location) {\n // Polyfill 'location' object for Emscripten module initialization\n (self as { location?: { href: string } }).location = {\n href: import.meta.url,\n };\n }\n\n //
|
|
5
|
+
"/**\n * WebP encoder - single-source worker/client implementation\n */\n\nimport {\n isWorker,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { WebpOptions } from './types.js';\n\n// Types from webp_enc.d.ts\ninterface EncodeOptions {\n quality: number;\n target_size: number;\n target_PSNR: number;\n method: number;\n sns_strength: number;\n filter_strength: number;\n filter_sharpness: number;\n filter_type: number;\n partitions: number;\n segments: number;\n pass: number;\n show_compressed: number;\n preprocessing: number;\n autofilter: number;\n partition_limit: number;\n alpha_compression: number;\n alpha_filtering: number;\n alpha_quality: number;\n lossless: number;\n exact: number;\n image_hint: number;\n emulate_jpeg_size: number;\n thread_level: number;\n low_memory: number;\n near_lossless: number;\n use_delta_palette: number;\n use_sharp_yuv: number;\n}\n\ninterface WebPModule {\n encode(\n data: BufferSource,\n width: number,\n height: number,\n options: EncodeOptions\n ): Uint8Array | null;\n}\n\nlet cachedModule: WebPModule | null = null;\n\nasync function loadWebPModule(): Promise<WebPModule> {\n if (cachedModule) {\n return cachedModule;\n }\n\n try {\n // Environment polyfills for Emscripten-generated code\n // The WebP encoder WASM module expects browser-like globals (self, location)\n // These polyfills ensure compatibility when running in Bun/Node.js environments\n if (typeof self === 'undefined') {\n // Polyfill 'self' global for Emscripten compatibility\n (global as { self?: typeof globalThis }).self = global;\n }\n if (typeof self !== 'undefined' && !self.location) {\n // Polyfill 'location' object for Emscripten module initialization\n (self as { location?: { href: string } }).location = {\n href: import.meta.url,\n };\n }\n\n // The WASM assets are expected to be in a directory relative to the worker script.\n const wasmDirectory = './wasm/webp';\n\n // Dynamically import the WebP encoder module\n const modulePath = new URL(`${wasmDirectory}/webp_enc.js`, import.meta.url)\n .href;\n const moduleFactory = await import(modulePath);\n\n // Initialize the WebP module with locateFile to properly resolve the WASM\n const wasmPath = new URL(`${wasmDirectory}/`, import.meta.url).href;\n const module = await moduleFactory.default({\n locateFile: (path: string) => {\n // Return the full URL to the WASM file\n if (path.endsWith('.wasm')) {\n return new URL(path, wasmPath).href;\n }\n return path;\n },\n });\n\n cachedModule = module;\n return module;\n } catch (error) {\n throw new Error(\n `Failed to load WebP module: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\n/**\n * Convert our simplified options to full EncodeOptions\n */\nfunction createEncodeOptions(options?: WebpOptions): EncodeOptions {\n const quality = Math.max(0, Math.min(100, options?.quality ?? 82));\n const lossless = options?.lossless ?? false;\n const nearLossless = options?.nearLossless ?? false;\n\n // Default encode options from Squoosh\n return {\n quality,\n target_size: 0,\n target_PSNR: 0,\n method: 4,\n sns_strength: 50,\n filter_strength: 60,\n filter_sharpness: 0,\n filter_type: 1,\n partitions: 0,\n segments: 4,\n pass: 1,\n show_compressed: 0,\n preprocessing: 0,\n autofilter: 0,\n partition_limit: 0,\n alpha_compression: 1,\n alpha_filtering: 1,\n alpha_quality: 100,\n lossless: lossless ? 1 : 0,\n exact: 0,\n image_hint: 0,\n emulate_jpeg_size: 0,\n thread_level: 0,\n low_memory: 0,\n near_lossless: nearLossless ? quality : 100,\n use_delta_palette: 0,\n use_sharp_yuv: 0,\n };\n}\n\n/**\n * Client-mode WebP encoder (exported for direct use)\n */\nexport async function webpEncodeClient(\n signal: AbortSignal,\n image: ImageInput,\n options?: WebpOptions\n): Promise<Uint8Array> {\n // Check abort before starting\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n // Normalize image input\n const width = image.width;\n const height = image.height;\n const data = image.data;\n\n if (!(data instanceof Uint8Array) && !(data instanceof Uint8ClampedArray)) {\n throw new Error('Image data must be Uint8Array or Uint8ClampedArray');\n }\n\n const module = await loadWebPModule();\n\n // Check abort after async operation\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n const encodeOptions = createEncodeOptions(options);\n\n // Call the encode function\n // Convert Uint8ClampedArray to Uint8Array if needed for BufferSource compatibility\n const dataArray =\n data instanceof Uint8ClampedArray ? new Uint8Array(data) : data;\n // Create a new Uint8Array with a proper ArrayBuffer to satisfy BufferSource\n const buffer = new Uint8Array(dataArray);\n const result = module.encode(buffer, width, height, encodeOptions);\n\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n if (!result) {\n throw new Error('WebP encoding failed');\n }\n\n return result;\n}\n\n/**\n * Worker message handler\n * Register the handler regardless of environment (for both worker context and tests)\n */\nif (typeof self !== 'undefined') {\n self.onmessage = async (event: MessageEvent) => {\n const request = event.data as WorkerRequest<{\n image: ImageInput;\n options?: WebpOptions;\n }>;\n\n const response: WorkerResponse<Uint8Array> = {\n id: request.id,\n ok: false,\n };\n\n try {\n if (request.type === 'webp:encode') {\n const { image, options } = request.payload;\n\n // Create an AbortController for this request\n const controller = new AbortController();\n\n const result = await webpEncodeClient(\n controller.signal,\n image,\n options\n );\n\n response.ok = true;\n response.data = result;\n\n // Transfer the result buffer back directly from the response data\n const resultBuffer: ArrayBuffer = response.data.buffer as ArrayBuffer;\n self.postMessage(response, [resultBuffer]);\n } else {\n response.error = `Unknown message type: ${request.type}`;\n self.postMessage(response);\n }\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAoDA,IAAI,EAAkC,KAEtC,eAAe,CAAc,EAAwB,CACnD,GAAI,EACF,OAAO,EAGT,GAAI,CAIF,GAAI,OAAO,KAAS,IAEjB,OAAwC,KAAO,OAElD,GAAI,OAAO,KAAS,KAAe,CAAC,KAAK,SAEtC,KAAyC,SAAW,CACnD,KAAM,YAAY,GACpB,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAoDA,IAAI,EAAkC,KAEtC,eAAe,CAAc,EAAwB,CACnD,GAAI,EACF,OAAO,EAGT,GAAI,CAIF,GAAI,OAAO,KAAS,IAEjB,OAAwC,KAAO,OAElD,GAAI,OAAO,KAAS,KAAe,CAAC,KAAK,SAEtC,KAAyC,SAAW,CACnD,KAAM,YAAY,GACpB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W,YAAY,EAGhD,IAAM,EAAgB,EAAoB,CAAO,EAI3C,EACJ,aAAgB,kBAAoB,IAAI,WAAW,CAAI,EAAI,EAEvD,EAAS,IAAI,WAAW,CAAS,EACjC,EAAS,EAAO,OAAO,EAAQ,EAAO,EAAQ,CAAa,EAEjE,GAAI,EAAO,QACT,MAAM,IAAI,aAAa,UAAW,YAAY,EAGhD,GAAI,CAAC,EACH,MAAU,MAAM,sBAAsB,EAGxC,OAAO,EAOT,GAAI,OAAO,KAAS,IAClB,KAAK,UAAY,MAAO,IAAwB,CAC9C,IAAM,EAAU,EAAM,KAKhB,EAAuC,CAC3C,GAAI,EAAQ,GACZ,GAAI,EACN,EAEA,GAAI,CACF,GAAI,EAAQ,OAAS,cAAe,CAClC,IAAQ,QAAO,WAAY,EAAQ,QAG7B,EAAa,IAAI,gBAEjB,EAAS,MAAM,EACnB,EAAW,OACX,EACA,CACF,EAEA,EAAS,GAAK,GACd,EAAS,KAAO,EAGhB,IAAM,EAA4B,EAAS,KAAK,OAChD,KAAK,YAAY,EAAU,CAAC,CAAY,CAAC,EAEzC,OAAS,MAAQ,yBAAyB,EAAQ,OAClD,KAAK,YAAY,CAAQ,EAE3B,MAAO,EAAO,CACd,EAAS,MAAQ,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,EACtE,KAAK,YAAY,CAAQ",
|
|
8
|
+
"debugId": "66000A60E94E382464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var F=0;async function b(W,
|
|
2
|
+
var F=0;async function b(I,W,k,z,P){return new Promise((B,A)=>{let O=++F;if(z?.aborted){A(new DOMException("Aborted","AbortError"));return}let R=(G)=>{let U=G.data;if(U.id!==O)return;if(console.log("\uD83D\uDD27 Worker call: Response received",U),c(),U.ok&&U.data!==void 0)console.log("\uD83D\uDD27 Worker call: Response data",U.data),B(U.data);else console.log("\uD83D\uDD27 Worker call: Response error",U.error),A(Error(U.error||"Unknown worker error"))},S=(G)=>{c(),A(Error(`Worker error: ${G.message}`))},f=()=>{c(),A(new DOMException("Aborted","AbortError"))},c=()=>{I.removeEventListener("message",R),I.removeEventListener("error",S),z?.removeEventListener("abort",f)};I.addEventListener("message",R),I.addEventListener("error",S),z?.addEventListener("abort",f);let V={type:W,id:O,payload:k};if(P&&P.length>0)I.postMessage(V,P);else I.postMessage(V)})}var J=null;async function L(){if(J)return J;try{if(typeof self>"u")global.self=global;if(typeof self<"u"&&!self.location)self.location={href:import.meta.url};let I="./wasm/webp",k=await import(new URL(`${I}/webp_enc.js`,import.meta.url).href),z=new URL(`${I}/`,import.meta.url).href,P=await k.default({locateFile:(B)=>{if(B.endsWith(".wasm"))return new URL(B,z).href;return B}});return J=P,P}catch(I){throw Error(`Failed to load WebP module: ${I instanceof Error?I.message:String(I)}`)}}function _(I){let W=Math.max(0,Math.min(100,I?.quality??82)),k=I?.lossless??!1,z=I?.nearLossless??!1;return{quality:W,target_size:0,target_PSNR:0,method:4,sns_strength:50,filter_strength:60,filter_sharpness:0,filter_type:1,partitions:0,segments:4,pass:1,show_compressed:0,preprocessing:0,autofilter:0,partition_limit:0,alpha_compression:1,alpha_filtering:1,alpha_quality:100,lossless:k?1:0,exact:0,image_hint:0,emulate_jpeg_size:0,thread_level:0,low_memory:0,near_lossless:z?W:100,use_delta_palette:0,use_sharp_yuv:0}}async function w(I,W,k){if(I.aborted)throw new DOMException("Aborted","AbortError");let{width:z,height:P,data:B}=W;if(!(B instanceof Uint8Array)&&!(B instanceof Uint8ClampedArray))throw Error("Image data must be Uint8Array or Uint8ClampedArray");let A=await L();if(I.aborted)throw new DOMException("Aborted","AbortError");let O=_(k),R=B instanceof Uint8ClampedArray?new Uint8Array(B):B,S=new Uint8Array(R),f=A.encode(S,z,P,O);if(I.aborted)throw new DOMException("Aborted","AbortError");if(!f)throw Error("WebP encoding failed");return f}if(typeof self<"u")self.onmessage=async(I)=>{let W=I.data,k={id:W.id,ok:!1};try{if(W.type==="webp:encode"){let{image:z,options:P}=W.payload,B=new AbortController,A=await w(B.signal,z,P);k.ok=!0,k.data=A;let O=k.data.buffer;self.postMessage(k,[O])}else k.error=`Unknown message type: ${W.type}`,self.postMessage(k)}catch(z){k.error=z instanceof Error?z.message:String(z),self.postMessage(k)}};class X{async encode(I,W,k){return w(I,W,k)}}class Y{worker=null;async getWorker(){if(!this.worker){let I=await import.meta.resolve("@squoosh-kit/webp/webp.worker.js");this.worker=new Worker(I,{type:"module"})}return this.worker}async encode(I,W,k){let z=await this.getWorker(),P=W.data.buffer;return b(z,"webp:encode",{image:W,options:k},I,[P])}}function K(I){return I==="client"?new X:new Y}async function j(I,W,k){return K("worker").encode(I,W,k)}function q(I="worker"){let W=K(I);return W.encode.bind(W)}var x=null;async function v(){if(x)return;let I="./wasm/resize",W=await import.meta.resolve(`${I}/squoosh_resize.js`),k=await import(W);await k.default(fetch(new URL(`${I}/squoosh_resize_bg.wasm`,W))),x=k.resize}async function Z(I,W){if(await v(),!x)throw Error("Resize module not initialized");let{data:k,width:z,height:P}=I,B=W.width??z,A=W.height??P;if(W.width&&!W.height)A=Math.round(P*W.width/z);else if(W.height&&!W.width)B=Math.round(z*W.height/P);if(B<=0||A<=0)throw Error("Invalid output dimensions");let O=k instanceof Uint8ClampedArray?new Uint8Array(k):k;return{data:x(O,z,P,B,A,C(),W.premultiply?1:0,W.linearRGB?1:0),width:B,height:A}}async function N(I,W,k){if(I.aborted)throw new DOMException("Aborted","AbortError");return Z(W,k)}function C(){return 3}if(typeof self<"u")self.onmessage=async(I)=>{let{id:W,type:k,payload:z}=I.data,P={id:W,ok:!1};try{if(k!=="resize:run")throw Error(`Unknown message type: ${k}`);let B=await Z(z.image,z.options);P.ok=!0,P.data=B;let A=B.data.buffer;if(A)self.postMessage(P,[A]);else self.postMessage(P)}catch(B){P.error=B instanceof Error?B.message:String(B),self.postMessage(P)}};class ${async resize(I,W,k){return N(I,W,k)}}class m{worker=null;async getWorker(){if(!this.worker){let I=await import.meta.resolve("@squoosh-kit/resize/resize.worker.js");this.worker=new Worker(I,{type:"module"})}return this.worker}async resize(I,W,k){let z=await this.getWorker();console.log("worker",z);let P=W.data.buffer;console.log("buffer",P);try{let B=await b(z,"resize:run",{image:W,options:k},I,[P]);return console.log("result",B),B}catch(B){throw console.error("error",B),B}}}function Q(I){return I==="client"?new $:new m}async function p(I,W,k){return Q("worker").resize(I,W,k)}function d(I="worker"){let W=Q(I);return W.resize.bind(W)}export{w as webpEncodeClient,N as resizeClient,p as resize,j as encode,q as createWebpEncoder,d as createResizer};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=A25FC2E4D0B3C47A64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"sources": ["../../runtime/src/worker-call.ts", "../../webp/src/webp.worker.ts", "../../webp/src/bridge.ts", "../../webp/src/index.ts", "../../resize/src/resize.worker.ts", "../../resize/src/bridge.ts", "../../resize/src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Generic worker communication helper with support for transferables and AbortSignal\n */\n\nexport interface WorkerRequest<T = unknown> {\n type: string;\n id: number;\n payload: T;\n}\n\nexport interface WorkerResponse<T = unknown> {\n id: number;\n ok: boolean;\n data?: T;\n error?: string;\n}\n\nlet requestId = 0;\n\n/**\n * Call a worker with a typed request and wait for response\n *\n * @param worker - The worker instance to call\n * @param type - The message type\n * @param payload - The payload to send\n * @param signal - Optional AbortSignal to cancel the operation\n * @param transfer - Optional list of Transferable objects to transfer\n * @returns Promise that resolves with the worker's response data\n */\nexport async function callWorker<TPayload, TResponse>(\n worker: Worker,\n type: string,\n payload: TPayload,\n signal?: AbortSignal,\n transfer?: Transferable[]\n): Promise<TResponse> {\n return new Promise<TResponse>((resolve, reject) => {\n const id = ++requestId;\n\n // Check if already aborted\n if (signal?.aborted) {\n reject(new DOMException('Aborted', 'AbortError'));\n return;\n }\n\n const handleMessage = (event: MessageEvent) => {\n const response = event.data as WorkerResponse<TResponse>;\n if (response.id !== id) return;\n\n console.log('🔧 Worker call: Response received', response);\n cleanup();\n\n if (response.ok && response.data !== undefined) {\n console.log('🔧 Worker call: Response data', response.data);\n resolve(response.data);\n } else {\n console.log('🔧 Worker call: Response error', response.error);\n reject(new Error(response.error || 'Unknown worker error'));\n }\n };\n\n const handleError = (error: ErrorEvent) => {\n cleanup();\n reject(new Error(`Worker error: ${error.message}`));\n };\n\n const handleAbort = () => {\n cleanup();\n reject(new DOMException('Aborted', 'AbortError'));\n };\n\n const cleanup = () => {\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n signal?.removeEventListener('abort', handleAbort);\n };\n\n // Set up listeners\n worker.addEventListener('message', handleMessage);\n worker.addEventListener('error', handleError);\n signal?.addEventListener('abort', handleAbort);\n\n // Send the request\n const request: WorkerRequest<TPayload> = { type, id, payload };\n\n if (transfer && transfer.length > 0) {\n worker.postMessage(request, transfer);\n } else {\n worker.postMessage(request);\n }\n });\n}\n",
|
|
6
|
-
"/**\n * WebP encoder - single-source worker/client implementation\n */\n\nimport {\n isWorker,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { WebpOptions } from './types.js';\n\n// Types from webp_enc.d.ts\ninterface EncodeOptions {\n quality: number;\n target_size: number;\n target_PSNR: number;\n method: number;\n sns_strength: number;\n filter_strength: number;\n filter_sharpness: number;\n filter_type: number;\n partitions: number;\n segments: number;\n pass: number;\n show_compressed: number;\n preprocessing: number;\n autofilter: number;\n partition_limit: number;\n alpha_compression: number;\n alpha_filtering: number;\n alpha_quality: number;\n lossless: number;\n exact: number;\n image_hint: number;\n emulate_jpeg_size: number;\n thread_level: number;\n low_memory: number;\n near_lossless: number;\n use_delta_palette: number;\n use_sharp_yuv: number;\n}\n\ninterface WebPModule {\n encode(\n data: BufferSource,\n width: number,\n height: number,\n options: EncodeOptions\n ): Uint8Array | null;\n}\n\nlet cachedModule: WebPModule | null = null;\n\nasync function loadWebPModule(): Promise<WebPModule> {\n if (cachedModule) {\n return cachedModule;\n }\n\n try {\n // Environment polyfills for Emscripten-generated code\n // The WebP encoder WASM module expects browser-like globals (self, location)\n // These polyfills ensure compatibility when running in Bun/Node.js environments\n if (typeof self === 'undefined') {\n // Polyfill 'self' global for Emscripten compatibility\n (global as { self?: typeof globalThis }).self = global;\n }\n if (typeof self !== 'undefined' && !self.location) {\n // Polyfill 'location' object for Emscripten module initialization\n (self as { location?: { href: string } }).location = {\n href: import.meta.url,\n };\n }\n\n //
|
|
6
|
+
"/**\n * WebP encoder - single-source worker/client implementation\n */\n\nimport {\n isWorker,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { WebpOptions } from './types.js';\n\n// Types from webp_enc.d.ts\ninterface EncodeOptions {\n quality: number;\n target_size: number;\n target_PSNR: number;\n method: number;\n sns_strength: number;\n filter_strength: number;\n filter_sharpness: number;\n filter_type: number;\n partitions: number;\n segments: number;\n pass: number;\n show_compressed: number;\n preprocessing: number;\n autofilter: number;\n partition_limit: number;\n alpha_compression: number;\n alpha_filtering: number;\n alpha_quality: number;\n lossless: number;\n exact: number;\n image_hint: number;\n emulate_jpeg_size: number;\n thread_level: number;\n low_memory: number;\n near_lossless: number;\n use_delta_palette: number;\n use_sharp_yuv: number;\n}\n\ninterface WebPModule {\n encode(\n data: BufferSource,\n width: number,\n height: number,\n options: EncodeOptions\n ): Uint8Array | null;\n}\n\nlet cachedModule: WebPModule | null = null;\n\nasync function loadWebPModule(): Promise<WebPModule> {\n if (cachedModule) {\n return cachedModule;\n }\n\n try {\n // Environment polyfills for Emscripten-generated code\n // The WebP encoder WASM module expects browser-like globals (self, location)\n // These polyfills ensure compatibility when running in Bun/Node.js environments\n if (typeof self === 'undefined') {\n // Polyfill 'self' global for Emscripten compatibility\n (global as { self?: typeof globalThis }).self = global;\n }\n if (typeof self !== 'undefined' && !self.location) {\n // Polyfill 'location' object for Emscripten module initialization\n (self as { location?: { href: string } }).location = {\n href: import.meta.url,\n };\n }\n\n // The WASM assets are expected to be in a directory relative to the worker script.\n const wasmDirectory = './wasm/webp';\n\n // Dynamically import the WebP encoder module\n const modulePath = new URL(`${wasmDirectory}/webp_enc.js`, import.meta.url)\n .href;\n const moduleFactory = await import(modulePath);\n\n // Initialize the WebP module with locateFile to properly resolve the WASM\n const wasmPath = new URL(`${wasmDirectory}/`, import.meta.url).href;\n const module = await moduleFactory.default({\n locateFile: (path: string) => {\n // Return the full URL to the WASM file\n if (path.endsWith('.wasm')) {\n return new URL(path, wasmPath).href;\n }\n return path;\n },\n });\n\n cachedModule = module;\n return module;\n } catch (error) {\n throw new Error(\n `Failed to load WebP module: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\n/**\n * Convert our simplified options to full EncodeOptions\n */\nfunction createEncodeOptions(options?: WebpOptions): EncodeOptions {\n const quality = Math.max(0, Math.min(100, options?.quality ?? 82));\n const lossless = options?.lossless ?? false;\n const nearLossless = options?.nearLossless ?? false;\n\n // Default encode options from Squoosh\n return {\n quality,\n target_size: 0,\n target_PSNR: 0,\n method: 4,\n sns_strength: 50,\n filter_strength: 60,\n filter_sharpness: 0,\n filter_type: 1,\n partitions: 0,\n segments: 4,\n pass: 1,\n show_compressed: 0,\n preprocessing: 0,\n autofilter: 0,\n partition_limit: 0,\n alpha_compression: 1,\n alpha_filtering: 1,\n alpha_quality: 100,\n lossless: lossless ? 1 : 0,\n exact: 0,\n image_hint: 0,\n emulate_jpeg_size: 0,\n thread_level: 0,\n low_memory: 0,\n near_lossless: nearLossless ? quality : 100,\n use_delta_palette: 0,\n use_sharp_yuv: 0,\n };\n}\n\n/**\n * Client-mode WebP encoder (exported for direct use)\n */\nexport async function webpEncodeClient(\n signal: AbortSignal,\n image: ImageInput,\n options?: WebpOptions\n): Promise<Uint8Array> {\n // Check abort before starting\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n // Normalize image input\n const width = image.width;\n const height = image.height;\n const data = image.data;\n\n if (!(data instanceof Uint8Array) && !(data instanceof Uint8ClampedArray)) {\n throw new Error('Image data must be Uint8Array or Uint8ClampedArray');\n }\n\n const module = await loadWebPModule();\n\n // Check abort after async operation\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n const encodeOptions = createEncodeOptions(options);\n\n // Call the encode function\n // Convert Uint8ClampedArray to Uint8Array if needed for BufferSource compatibility\n const dataArray =\n data instanceof Uint8ClampedArray ? new Uint8Array(data) : data;\n // Create a new Uint8Array with a proper ArrayBuffer to satisfy BufferSource\n const buffer = new Uint8Array(dataArray);\n const result = module.encode(buffer, width, height, encodeOptions);\n\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n if (!result) {\n throw new Error('WebP encoding failed');\n }\n\n return result;\n}\n\n/**\n * Worker message handler\n * Register the handler regardless of environment (for both worker context and tests)\n */\nif (typeof self !== 'undefined') {\n self.onmessage = async (event: MessageEvent) => {\n const request = event.data as WorkerRequest<{\n image: ImageInput;\n options?: WebpOptions;\n }>;\n\n const response: WorkerResponse<Uint8Array> = {\n id: request.id,\n ok: false,\n };\n\n try {\n if (request.type === 'webp:encode') {\n const { image, options } = request.payload;\n\n // Create an AbortController for this request\n const controller = new AbortController();\n\n const result = await webpEncodeClient(\n controller.signal,\n image,\n options\n );\n\n response.ok = true;\n response.data = result;\n\n // Transfer the result buffer back directly from the response data\n const resultBuffer: ArrayBuffer = response.data.buffer as ArrayBuffer;\n self.postMessage(response, [resultBuffer]);\n } else {\n response.error = `Unknown message type: ${request.type}`;\n self.postMessage(response);\n }\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n",
|
|
7
7
|
"/**\n * Bridge implementation for the WebP package, handling worker and client modes.\n */\n\nimport { callWorker, type ImageInput } from '@squoosh-kit/runtime';\nimport { webpEncodeClient } from './webp.worker.js';\nimport type { WebpOptions } from './types.js';\n\ninterface WebPBridge {\n encode(\n signal: AbortSignal,\n image: ImageInput,\n options?: WebpOptions\n ): Promise<Uint8Array>;\n}\n\nclass WebpClientBridge implements WebPBridge {\n async encode(\n signal: AbortSignal,\n image: ImageInput,\n options?: WebpOptions\n ): Promise<Uint8Array> {\n return webpEncodeClient(signal, image, options);\n }\n}\n\nclass WebpWorkerBridge implements WebPBridge {\n private worker: Worker | null = null;\n private async getWorker(): Promise<Worker> {\n if (!this.worker) {\n const workerUrl = await import.meta.resolve(\n '@squoosh-kit/webp/webp.worker.js'\n );\n this.worker = new Worker(workerUrl, { type: 'module' });\n }\n return this.worker;\n }\n async encode(\n signal: AbortSignal,\n image: ImageInput,\n options?: WebpOptions\n ): Promise<Uint8Array> {\n const worker = await this.getWorker();\n const buffer = image.data.buffer;\n return callWorker(worker, 'webp:encode', { image, options }, signal, [\n buffer as ArrayBuffer,\n ]);\n }\n}\n\nexport function createBridge(mode: 'worker' | 'client'): WebPBridge {\n return mode === 'client' ? new WebpClientBridge() : new WebpWorkerBridge();\n}\n",
|
|
8
8
|
"/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge.js';\nimport type { WebpOptions } from './types.js';\n\nexport type { ImageInput, WebpOptions };\n\n/**\n * Encodes an image to WebP format. Defaults to 'worker' mode.\n *\n * @param signal - An AbortSignal to cancel the encoding operation.\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n */\nexport async function encode(\n signal: AbortSignal,\n imageData: ImageInput,\n options?: WebpOptions\n): Promise<Uint8Array> {\n // Always use a worker for a single, one-off call for best performance.\n const bridge = createBridge('worker');\n return bridge.encode(signal, imageData, options);\n}\n\n/**\n * Creates a reusable WebP encoder function for a specific execution mode.\n * This is useful for processing multiple images without the overhead of\n * creating a new worker or client instance each time.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @returns A function that encodes an image to WebP format.\n */\nexport function createWebpEncoder(mode: 'worker' | 'client' = 'worker') {\n const bridge = createBridge(mode);\n return bridge.encode.bind(bridge);\n}\n\n// Export the client-side implementation for direct use by the bridge.\n// This is not intended for public consumption.\nexport { webpEncodeClient } from './webp.worker.js';\n",
|
|
9
|
-
"/**\n * Resize processor - single-source worker/client implementation\n */\n\nimport {\n hasImageData,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { ResizeOptions } from './types.ts';\n\n// Define the type locally to avoid module resolution issues with the linter\ntype SquooshWasmResize = (\n data: Uint8Array,\n input_width: number,\n input_height: number,\n output_width: number,\n output_height: number,\n typ_idx: number,\n premultiply: number,\n color_space_conversion: number,\n) => Uint8Array;\n\nlet wasmResize: SquooshWasmResize | null = null;\n\nasync function init(): Promise<void> {\n if (wasmResize) {\n return;\n }\n\n const
|
|
9
|
+
"/**\n * Resize processor - single-source worker/client implementation\n */\n\nimport {\n hasImageData,\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { ResizeOptions } from './types.ts';\n\n// Define the type locally to avoid module resolution issues with the linter\ntype SquooshWasmResize = (\n data: Uint8Array,\n input_width: number,\n input_height: number,\n output_width: number,\n output_height: number,\n typ_idx: number,\n premultiply: number,\n color_space_conversion: number,\n) => Uint8Array;\n\nlet wasmResize: SquooshWasmResize | null = null;\n\nasync function init(): Promise<void> {\n if (wasmResize) {\n return;\n }\n\n const wasmDirectory = './wasm/resize';\n const modulePath = await import.meta.resolve(\n `${wasmDirectory}/squoosh_resize.js`,\n );\n const module = await import(modulePath);\n\n // Squoosh's WASM modules expect to be initialized with promises\n await module.default(\n fetch(new URL(`${wasmDirectory}/squoosh_resize_bg.wasm`, modulePath)),\n );\n wasmResize = module.resize;\n}\n\nasync function _resizeCore(\n image: ImageInput,\n options: ResizeOptions,\n): Promise<ImageInput> {\n await init();\n if (!wasmResize) {\n throw new Error('Resize module not initialized');\n }\n\n const { data, width: inputWidth, height: inputHeight } = image;\n\n let outputWidth = options.width ?? inputWidth;\n let outputHeight = options.height ?? inputHeight;\n\n if (options.width && !options.height) {\n outputHeight = Math.round((inputHeight * options.width) / inputWidth);\n } else if (options.height && !options.width) {\n outputWidth = Math.round((inputWidth * options.height) / inputHeight);\n }\n\n if (outputWidth <= 0 || outputHeight <= 0) {\n throw new Error('Invalid output dimensions');\n }\n\n const dataArray =\n data instanceof Uint8ClampedArray ? new Uint8Array(data) : data;\n\n const result = wasmResize(\n dataArray,\n inputWidth,\n inputHeight,\n outputWidth,\n outputHeight,\n getResizeMethod(),\n options.premultiply ? 1 : 0,\n options.linearRGB ? 1 : 0,\n );\n\n return {\n data: result,\n width: outputWidth,\n height: outputHeight,\n };\n}\n\nexport async function resizeClient(\n signal: AbortSignal,\n image: ImageInput,\n options: ResizeOptions,\n): Promise<ImageInput> {\n if (signal.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n return _resizeCore(image, options);\n}\n\n/**\n * Map ResizeOptions to the typ_idx parameter for the resize function\n * 0: Triangular, 1: Catrom, 2: Mitchell, 3: Lanczos3\n */\nfunction getResizeMethod(): number {\n // Default to Lanczos3 (highest quality)\n return 3;\n}\n\n/**\n * Worker message handler\n */\nif (typeof self !== 'undefined') {\n self.onmessage = async (\n event: MessageEvent<\n WorkerRequest<{ image: ImageInput; options: ResizeOptions }>\n >,\n ) => {\n const { id, type, payload } = event.data;\n\n const response: WorkerResponse<ImageInput> = { id, ok: false };\n\n try {\n if (type !== 'resize:run') {\n throw new Error(`Unknown message type: ${type}`);\n }\n\n const resultImage = await _resizeCore(payload.image, payload.options);\n\n response.ok = true;\n response.data = resultImage;\n\n const transferable = resultImage.data.buffer;\n if (transferable) {\n self.postMessage(response, [transferable as ArrayBuffer]);\n } else {\n self.postMessage(response);\n }\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n",
|
|
10
10
|
"/**\n * Bridge implementation for the Resize package, handling worker and client modes.\n */\n\nimport { callWorker, type ImageInput } from '@squoosh-kit/runtime';\nimport { resizeClient } from './resize.worker.ts';\nimport type { ResizeOptions } from './types.ts';\n\ninterface ResizeBridge {\n resize(\n signal: AbortSignal,\n image: ImageInput,\n options: ResizeOptions\n ): Promise<ImageInput>;\n}\n\nclass ResizeClientBridge implements ResizeBridge {\n async resize(\n signal: AbortSignal,\n image: ImageInput,\n options: ResizeOptions\n ): Promise<ImageInput> {\n return resizeClient(signal, image, options);\n }\n}\n\nclass ResizeWorkerBridge implements ResizeBridge {\n private worker: Worker | null = null;\n private async getWorker(): Promise<Worker> {\n if (!this.worker) {\n const workerUrl = await import.meta.resolve(\n '@squoosh-kit/resize/resize.worker.js'\n );\n this.worker = new Worker(workerUrl, { type: 'module' });\n }\n return this.worker;\n }\n async resize(\n signal: AbortSignal,\n image: ImageInput,\n options: ResizeOptions\n ): Promise<ImageInput> {\n const worker = await this.getWorker();\n console.log('worker', worker);\n const buffer = image.data.buffer;\n console.log('buffer', buffer);\n\n try {\n const result = await callWorker<{ image: ImageInput; options: ResizeOptions }, ImageInput>(worker, 'resize:run', { image, options }, signal, [\n buffer as ArrayBuffer,\n ]);\n \n console.log('result', result);\n\n return result;\n } catch (error) {\n console.error('error', error);\n throw error;\n }\n }\n}\n\nexport function createBridge(mode: 'worker' | 'client'): ResizeBridge {\n return mode === 'client'\n ? new ResizeClientBridge()\n : new ResizeWorkerBridge();\n}\n",
|
|
11
11
|
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge.ts';\nimport type { ResizeOptions } from './types.ts';\n\nexport type { ImageInput, ResizeOptions };\n\n/**\n * Resizes an image. Defaults to 'worker' mode.\n *\n * @param signal - An AbortSignal to cancel the resizing operation.\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @returns A Promise resolving to the resized image data.\n */\nexport async function resize(\n signal: AbortSignal,\n imageData: ImageInput,\n options: ResizeOptions\n): Promise<ImageInput> {\n // Always use a worker for a single, one-off call for best performance.\n const bridge = createBridge('worker');\n return bridge.resize(signal, imageData, options);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @returns A function that resizes an image.\n */\nexport function createResizer(mode: 'worker' | 'client' = 'worker') {\n const bridge = createBridge(mode);\n return bridge.resize.bind(bridge);\n}\n\n// Export the client-side implementation for direct use by the bridge.\n// This is not intended for public consumption.\nexport { resizeClient } from './resize.worker.js';\n"
|
|
12
12
|
],
|
|
13
|
-
"mappings": ";AAiBA,IAAI,EAAY,EAYhB,eAAsB,CAA+B,CACnD,EACA,EACA,EACA,EACA,EACoB,CACpB,OAAO,IAAI,QAAmB,CAAC,EAAS,IAAW,CACjD,IAAM,EAAK,EAAE,EAGb,GAAI,GAAQ,QAAS,CACnB,EAAO,IAAI,aAAa,UAAW,YAAY,CAAC,EAChD,OAGF,IAAM,EAAgB,CAAC,IAAwB,CAC7C,IAAM,EAAW,EAAM,KACvB,GAAI,EAAS,KAAO,EAAI,OAKxB,GAHA,QAAQ,IAAI,8CAAoC,CAAQ,EACxD,EAAQ,EAEJ,EAAS,IAAM,EAAS,OAAS,OACnC,QAAQ,IAAI,0CAAgC,EAAS,IAAI,EACzD,EAAQ,EAAS,IAAI,EAErB,aAAQ,IAAI,2CAAiC,EAAS,KAAK,EAC3D,EAAW,MAAM,EAAS,OAAS,sBAAsB,CAAC,GAIxD,EAAc,CAAC,IAAsB,CACzC,EAAQ,EACR,EAAW,MAAM,iBAAiB,EAAM,SAAS,CAAC,GAG9C,EAAc,IAAM,CACxB,EAAQ,EACR,EAAO,IAAI,aAAa,UAAW,YAAY,CAAC,GAG5C,EAAU,IAAM,CACpB,EAAO,oBAAoB,UAAW,CAAa,EACnD,EAAO,oBAAoB,QAAS,CAAW,EAC/C,GAAQ,oBAAoB,QAAS,CAAW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V,EACA,EACA,EACqB,CACrB,OAAO,EAAa,EAAQ,EAAO,CAAO,EAE9C,CAEA,MAAM,CAA2C,CACvC,OAAwB,UAClB,UAAS,EAAoB,CACzC,GAAI,CAAC,KAAK,OAAQ,CAChB,IAAM,EAAY,MAAM,YAAY,QAClC,sCACF,EACA,KAAK,OAAS,IAAI,OAAO,EAAW,CAAE,KAAM,QAAS,CAAC,EAExD,OAAO,KAAK,YAER,OAAM,CACV,EACA,EACA,EACqB,CACrB,IAAM,EAAS,MAAM,KAAK,UAAU,EACpC,QAAQ,IAAI,SAAU,CAAM,EAC5B,IAAM,EAAS,EAAM,KAAK,OAC1B,QAAQ,IAAI,SAAU,CAAM,EAE5B,GAAI,CACF,IAAM,EAAS,MAAM,EAAsE,EAAQ,aAAc,CAAE,QAAO,SAAQ,EAAG,EAAQ,CAC3I,CACF,CAAC,EAID,OAFA,QAAQ,IAAI,SAAU,CAAM,EAErB,EACP,MAAO,EAAO,CAEd,MADA,QAAQ,MAAM,QAAS,CAAK,EACtB,GAGZ,CAEO,SAAS,CAAY,CAAC,EAAyC,CACpE,OAAO,IAAS,SACZ,IAAI,EACJ,IAAI,EC/CV,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAGrB,OADe,EAAa,QAAQ,EACtB,OAAO,EAAQ,EAAW,CAAO,EAS1C,SAAS,CAAa,CAAC,EAA4B,SAAU,CAClE,IAAM,EAAS,EAAa,CAAI,EAChC,OAAO,EAAO,OAAO,KAAK,CAAM",
|
|
14
|
+
"debugId": "A25FC2E4D0B3C47A64756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squoosh-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"description": "Per-feature adapters around Squoosh codecs (Bun-first), worker/client runtimes.",
|
|
5
|
+
"description": "Per-feature adapters around Squoosh codecs, worker/client runtimes.",
|
|
7
6
|
"author": "Bartosz Nowak <bnowak008@gmail.com>",
|
|
8
7
|
"license": "MIT",
|
|
9
8
|
"repository": {
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
"prepack": "bun run build"
|
|
71
70
|
},
|
|
72
71
|
"dependencies": {
|
|
73
|
-
"@squoosh-kit/webp": "0.
|
|
74
|
-
"@squoosh-kit/resize": "0.
|
|
72
|
+
"@squoosh-kit/webp": "0.0.3",
|
|
73
|
+
"@squoosh-kit/resize": "0.0.3"
|
|
75
74
|
}
|
|
76
75
|
}
|