@squoosh-kit/core 0.0.44 → 0.1.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.
@@ -1,3 +0,0 @@
1
- import{a as P}from"./chunk-h7zpk6jq.js";import{d as v}from"./chunk-p24n653d.js";function O(f){if(typeof f!=="object"||f===null)throw TypeError("options must be an object");let b=f;if(b.width!==void 0){if(typeof b.width!=="number"||!Number.isInteger(b.width)||b.width<=0)throw RangeError(`options.width must be a positive integer, got ${b.width}`)}if(b.height!==void 0){if(typeof b.height!=="number"||!Number.isInteger(b.height)||b.height<=0)throw RangeError(`options.height must be a positive integer, got ${b.height}`)}if(b.method!==void 0){let $=["triangular","catrom","mitchell","lanczos3"];if(!$.includes(b.method))throw TypeError(`options.method must be one of: ${$.join(", ")}, got ${b.method}`)}if(b.premultiply!==void 0&&typeof b.premultiply!=="boolean")throw TypeError(`options.premultiply must be boolean, got ${typeof b.premultiply}`);if(b.linearRGB!==void 0&&typeof b.linearRGB!=="boolean")throw TypeError(`options.linearRGB must be boolean, got ${typeof b.linearRGB}`)}var B,J=null;function E(){if(J===null||J.buffer!==B.memory.buffer)J=new Uint8Array(B.memory.buffer);return J}var T=0;function I(f,b){let $=b(f.length*1);return E().set(f,$/1),T=f.length,$}var K=null;function S(){if(K===null||K.buffer!==B.memory.buffer)K=new Int32Array(B.memory.buffer);return K}var N=null;function H(){if(N===null||N.buffer!==B.memory.buffer)N=new Uint8ClampedArray(B.memory.buffer);return N}function C(f,b){return H().subarray(f/1,f/1+b)}function V(f,b,$,G,j,k,R,X){try{let Y=B.__wbindgen_add_to_stack_pointer(-16);var F=I(f,B.__wbindgen_malloc),w=T;B.resize(Y,F,w,b,$,G,j,k,R,X);var x=S()[Y/4+0],L=S()[Y/4+1],A=C(x,L).slice();return B.__wbindgen_free(x,L*1),A}finally{B.__wbindgen_add_to_stack_pointer(16)}}async function U(f,b){if(typeof Response==="function"&&f instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(f,b)}catch(G){if(f.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",G);else throw G}let $=await f.arrayBuffer();return await WebAssembly.instantiate($,b)}else{let $=await WebAssembly.instantiate(f,b);if($ instanceof WebAssembly.Instance)return{instance:$,module:f};else return $}}async function q(f){if(typeof f>"u")f=new URL("squoosh_resize_bg.wasm",import.meta.url);let b={};if(typeof f==="string"||typeof Request==="function"&&f instanceof Request||typeof URL==="function"&&f instanceof URL)f=fetch(f);let{instance:$,module:G}=await U(await f,b);return B=$.exports,q.__wbindgen_wasm_module=G,B}var Z=q;var Q=null,D=null;async function h(){if(Q)return;if(D)return D;return D=(async()=>{try{let f=null,b=[new URL("./wasm/squoosh_resize_bg.wasm",import.meta.url).href,new URL("../wasm/squoosh_resize_bg.wasm",import.meta.url).href],$=null;for(let G of b)try{f=await P(G);break}catch(j){$=j instanceof Error?j:Error(String(j))}if(!f)throw $||Error("Could not load WASM binary from any path");try{await Z(f)}catch(G){if(G instanceof Error&&(G.message.includes("SharedArrayBuffer")||G.message.includes("first argument must be"))){if(typeof SharedArrayBuffer>"u")globalThis.SharedArrayBuffer=ArrayBuffer;try{await Z(f)}catch(j){throw Error(`WASM module initialization failed even with polyfill: ${j instanceof Error?j.message:String(j)}`)}}else throw G}Q=V}catch(f){throw D=null,Error(`Failed to initialize resize WASM module: ${f instanceof Error?f.message:String(f)}`)}})(),D}async function z(f,b){if(v(f),O(b),await h(),!Q)throw Error("Resize module not initialized");let{data:$,width:G,height:j}=f,k=b.width??G,R=b.height??j;if(b.width&&!b.height)R=Math.max(1,Math.round(j*b.width/G));else if(b.height&&!b.width)k=Math.max(1,Math.round(G*b.height/j));if(k<1||R<1)throw RangeError(`Output dimensions must be at least 1x1, got ${k}x${R}`);let X=$ instanceof Uint8ClampedArray?new Uint8Array($.buffer,$.byteOffset,$.length):new Uint8Array($.buffer,$.byteOffset,$.length);return{data:Q(X,G,j,k,R,M(b),b.premultiply??!0,b.linearRGB??!0),width:k,height:R}}async function _(f,b,$){if($?.aborted)throw new DOMException("Aborted","AbortError");return z(f,b)}function M(f){return{triangular:0,catrom:1,mitchell:2,lanczos3:3}[f?.method??"lanczos3"]??3}if(typeof self<"u")self.onmessage=async(f)=>{let b=f.data;if(b?.type==="worker:ping"){self.postMessage({type:"worker:ready"});return}let{id:$,type:G,payload:j}=b,k={id:$,ok:!1};try{if(G!=="resize:run")throw Error(`Unknown message type: ${G}`);let R=await z(j.image,j.options);k.ok=!0,k.data=R,self.postMessage(k)}catch(R){k.error=R instanceof Error?R.message:String(R),self.postMessage(k)}};export{_ as resizeClient};
2
-
3
- //# debugId=F5BB79C15A6B9F8464756E2164756E21
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{a as P}from"./chunk-14jg2dxs.js";import{d as v}from"./chunk-02ytt443.js";function O(f){if(typeof f!=="object"||f===null)throw TypeError("options must be an object");let b=f;if(b.width!==void 0){if(typeof b.width!=="number"||!Number.isInteger(b.width)||b.width<=0)throw RangeError(`options.width must be a positive integer, got ${b.width}`)}if(b.height!==void 0){if(typeof b.height!=="number"||!Number.isInteger(b.height)||b.height<=0)throw RangeError(`options.height must be a positive integer, got ${b.height}`)}if(b.method!==void 0){let $=["triangular","catrom","mitchell","lanczos3"];if(!$.includes(b.method))throw TypeError(`options.method must be one of: ${$.join(", ")}, got ${b.method}`)}if(b.premultiply!==void 0&&typeof b.premultiply!=="boolean")throw TypeError(`options.premultiply must be boolean, got ${typeof b.premultiply}`);if(b.linearRGB!==void 0&&typeof b.linearRGB!=="boolean")throw TypeError(`options.linearRGB must be boolean, got ${typeof b.linearRGB}`)}var B,J=null;function E(){if(J===null||J.buffer!==B.memory.buffer)J=new Uint8Array(B.memory.buffer);return J}var T=0;function I(f,b){let $=b(f.length*1);return E().set(f,$/1),T=f.length,$}var K=null;function S(){if(K===null||K.buffer!==B.memory.buffer)K=new Int32Array(B.memory.buffer);return K}var N=null;function H(){if(N===null||N.buffer!==B.memory.buffer)N=new Uint8ClampedArray(B.memory.buffer);return N}function C(f,b){return H().subarray(f/1,f/1+b)}function V(f,b,$,G,j,k,R,X){try{let Y=B.__wbindgen_add_to_stack_pointer(-16);var F=I(f,B.__wbindgen_malloc),w=T;B.resize(Y,F,w,b,$,G,j,k,R,X);var x=S()[Y/4+0],L=S()[Y/4+1],A=C(x,L).slice();return B.__wbindgen_free(x,L*1),A}finally{B.__wbindgen_add_to_stack_pointer(16)}}async function U(f,b){if(typeof Response==="function"&&f instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(f,b)}catch(G){if(f.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",G);else throw G}let $=await f.arrayBuffer();return await WebAssembly.instantiate($,b)}else{let $=await WebAssembly.instantiate(f,b);if($ instanceof WebAssembly.Instance)return{instance:$,module:f};else return $}}async function q(f){if(typeof f>"u")f=new URL("squoosh_resize_bg.wasm",import.meta.url);let b={};if(typeof f==="string"||typeof Request==="function"&&f instanceof Request||typeof URL==="function"&&f instanceof URL)f=fetch(f);let{instance:$,module:G}=await U(await f,b);return B=$.exports,q.__wbindgen_wasm_module=G,B}var Z=q;var Q=null,D=null;async function h(){if(Q)return;if(D)return D;return D=(async()=>{try{let f=null,b=[new URL("./wasm/squoosh_resize_bg.wasm",import.meta.url).href,new URL("../wasm/squoosh_resize_bg.wasm",import.meta.url).href],$=null;for(let G of b)try{f=await P(G);break}catch(j){$=j instanceof Error?j:Error(String(j))}if(!f)throw $||Error("Could not load WASM binary from any path");try{await Z(f)}catch(G){if(G instanceof Error&&(G.message.includes("SharedArrayBuffer")||G.message.includes("first argument must be"))){if(typeof SharedArrayBuffer>"u")globalThis.SharedArrayBuffer=ArrayBuffer;try{await Z(f)}catch(j){throw Error(`WASM module initialization failed even with polyfill: ${j instanceof Error?j.message:String(j)}`)}}else throw G}Q=V}catch(f){throw D=null,Error(`Failed to initialize resize WASM module: ${f instanceof Error?f.message:String(f)}`)}})(),D}async function z(f,b){if(v(f),O(b),await h(),!Q)throw Error("Resize module not initialized");let{data:$,width:G,height:j}=f,k=b.width??G,R=b.height??j;if(b.width&&!b.height)R=Math.max(1,Math.round(j*b.width/G));else if(b.height&&!b.width)k=Math.max(1,Math.round(G*b.height/j));if(k<1||R<1)throw RangeError(`Output dimensions must be at least 1x1, got ${k}x${R}`);let X=$ instanceof Uint8ClampedArray?new Uint8Array($.buffer,$.byteOffset,$.length):new Uint8Array($.buffer,$.byteOffset,$.length);return{data:Q(X,G,j,k,R,M(b),b.premultiply??!0,b.linearRGB??!0),width:k,height:R}}async function _(f,b,$){if($?.aborted)throw new DOMException("Aborted","AbortError");return z(f,b)}function M(f){return{triangular:0,catrom:1,mitchell:2,lanczos3:3}[f?.method??"lanczos3"]??3}if(typeof self<"u")self.onmessage=async(f)=>{let b=f.data;if(b?.type==="worker:ping"){self.postMessage({type:"worker:ready"});return}let{id:$,type:G,payload:j}=b,k={id:$,ok:!1};try{if(G!=="resize:run")throw Error(`Unknown message type: ${G}`);let R=await z(j.image,j.options);k.ok=!0,k.data=R,self.postMessage(k)}catch(R){k.error=R instanceof Error?R.message:String(R),self.postMessage(k)}};export{_ as resizeClient};
3
-
4
- //# debugId=F6E03855A58B1DD164756E2164756E21