@squoosh-kit/core 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2b0h6tnh.js +3 -0
- package/dist/chunk-2b0h6tnh.js.map +11 -0
- package/dist/chunk-924xe5vk.js +27 -0
- package/dist/chunk-924xe5vk.js.map +13 -0
- package/dist/chunk-9k2hvarz.js +27 -0
- package/dist/chunk-9k2hvarz.js.map +13 -0
- package/dist/chunk-bw4t01ac.js +27 -0
- package/dist/chunk-bw4t01ac.js.map +13 -0
- package/dist/chunk-byezjkj8.js +28 -0
- package/dist/chunk-byezjkj8.js.map +13 -0
- package/dist/chunk-n7m1gvbc.js +3 -0
- package/dist/chunk-n7m1gvbc.js.map +11 -0
- package/dist/chunk-rtj1fq2t.js +4 -0
- package/dist/chunk-rtj1fq2t.js.map +11 -0
- package/dist/chunk-wffz81h7.js +3 -0
- package/dist/chunk-wffz81h7.js.map +11 -0
- package/dist/index.browser.mjs +1 -1
- package/dist/index.bun.js +1 -1
- package/dist/index.node.cjs +1 -1
- package/dist/index.node.mjs +1 -1
- package/package.json +1 -1
package/dist/index.node.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as S,c as x}from"./chunk-07731nqj.js";import{f as N,g as M}from"./chunk-524wcxgb.js";function q(){return typeof Bun<"u"}var z=0;async function I(G,H,K,L,J){return new Promise((Q,X)=>{let V=++z;if(L?.aborted){X(new DOMException("Aborted","AbortError"));return}let Z=(R)=>{let O=R.data;if(O.id!==V)return;if($(),O.ok&&O.data!==void 0)Q(O.data);else X(Error(O.error||"Unknown worker error"))},U=(R)=>{$(),X(Error(`Worker error: ${R.message}`))},_=()=>{$(),X(new DOMException("Aborted","AbortError"))},$=()=>{G.removeEventListener("message",Z),G.removeEventListener("error",U),L?.removeEventListener("abort",_)};G.addEventListener("message",Z),G.addEventListener("error",U),L?.addEventListener("abort",_);let Y={type:H,id:V,payload:K};if(J&&J.length>0)G.postMessage(Y,J);else G.postMessage(Y)})}function v(G){let H=G.endsWith(".js")?G:`${G}.js`,K={"resize.worker.js":{package:"@squoosh-kit/resize",specifier:"resize.worker.js"},"webp.worker.js":{package:"@squoosh-kit/webp",specifier:"webp.worker.js"}},L=K[H];if(!L)throw Error(`Unknown worker: ${H}. Supported workers: ${Object.keys(K).join(", ")}`);try{if(typeof window<"u"){let V=L.package.split("/")[1],Z=H.replace(".js",".browser.mjs"),U=[`../../${V}/dist/${Z}`,`../../../node_modules/@squoosh-kit/${V}/dist/${Z}`,`../../../${V}/dist/${Z}`],_=null;for(let $ of U)try{let Y=new URL($,import.meta.url);return new Worker(Y,{type:"module"})}catch(Y){_=Y instanceof Error?Y:Error(String(Y))}if(_)throw _;throw Error(`Could not resolve worker ${H} using any available path strategy`)}if(typeof import.meta.resolve==="function")try{let V=import.meta.resolve(`${L.package}/${L.specifier}`);return new Worker(V,{type:"module"})}catch{}let J=q()?".bun.js":".node.mjs",Q=H.replace(".js",""),X=L.package.includes("resize")?`../../resize/dist/${Q}.${J.slice(1)}`:`../../webp/dist/${Q}.${J.slice(1)}`;return new Worker(new URL(X,import.meta.url),{type:"module"})}catch(J){let Q=J instanceof Error?J.message:String(J);throw Error(`Failed to create worker from ${H}: ${Q}. Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed. If you're using Vite, ensure the worker files are not being optimized as dependencies.`)}}function P(G,H=1e4){return new Promise((K,L)=>{let J=setTimeout(()=>{L(Error(`Worker initialization timeout after ${H}ms. Worker file: ${G}`))},H),Q;try{Q=v(G)}catch(V){clearTimeout(J),L(V);return}let X=(V)=>{if(V.data?.type==="worker:ready")clearTimeout(J),Q.removeEventListener("message",X),K(Q)};Q.addEventListener("message",X),Q.postMessage({type:"worker:ping"})})}class j{async encode(G,H,K){let J=(await import("./chunk-
|
|
1
|
+
import{b as S,c as x}from"./chunk-07731nqj.js";import{f as N,g as M}from"./chunk-524wcxgb.js";function q(){return typeof Bun<"u"}var z=0;async function I(G,H,K,L,J){return new Promise((Q,X)=>{let V=++z;if(L?.aborted){X(new DOMException("Aborted","AbortError"));return}let Z=(R)=>{let O=R.data;if(O.id!==V)return;if($(),O.ok&&O.data!==void 0)Q(O.data);else X(Error(O.error||"Unknown worker error"))},U=(R)=>{$(),X(Error(`Worker error: ${R.message}`))},_=()=>{$(),X(new DOMException("Aborted","AbortError"))},$=()=>{G.removeEventListener("message",Z),G.removeEventListener("error",U),L?.removeEventListener("abort",_)};G.addEventListener("message",Z),G.addEventListener("error",U),L?.addEventListener("abort",_);let Y={type:H,id:V,payload:K};if(J&&J.length>0)G.postMessage(Y,J);else G.postMessage(Y)})}function v(G){let H=G.endsWith(".js")?G:`${G}.js`,K={"resize.worker.js":{package:"@squoosh-kit/resize",specifier:"resize.worker.js"},"webp.worker.js":{package:"@squoosh-kit/webp",specifier:"webp.worker.js"}},L=K[H];if(!L)throw Error(`Unknown worker: ${H}. Supported workers: ${Object.keys(K).join(", ")}`);try{if(typeof window<"u"){let V=L.package.split("/")[1],Z=H.replace(".js",".browser.mjs"),U=[`../../${V}/dist/${Z}`,`../../../node_modules/@squoosh-kit/${V}/dist/${Z}`,`../../../${V}/dist/${Z}`],_=null;for(let $ of U)try{let Y=new URL($,import.meta.url);return new Worker(Y,{type:"module"})}catch(Y){_=Y instanceof Error?Y:Error(String(Y))}if(_)throw _;throw Error(`Could not resolve worker ${H} using any available path strategy`)}if(typeof import.meta.resolve==="function")try{let V=import.meta.resolve(`${L.package}/${L.specifier}`);return new Worker(V,{type:"module"})}catch{}let J=q()?".bun.js":".node.mjs",Q=H.replace(".js",""),X=L.package.includes("resize")?`../../resize/dist/${Q}.${J.slice(1)}`:`../../webp/dist/${Q}.${J.slice(1)}`;return new Worker(new URL(X,import.meta.url),{type:"module"})}catch(J){let Q=J instanceof Error?J.message:String(J);throw Error(`Failed to create worker from ${H}: ${Q}. Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed. If you're using Vite, ensure the worker files are not being optimized as dependencies.`)}}function P(G,H=1e4){return new Promise((K,L)=>{let J=setTimeout(()=>{L(Error(`Worker initialization timeout after ${H}ms. Worker file: ${G}`))},H),Q;try{Q=v(G)}catch(V){clearTimeout(J),L(V);return}let X=(V)=>{if(V.data?.type==="worker:ready")clearTimeout(J),Q.removeEventListener("message",X),K(Q)};Q.addEventListener("message",X),Q.postMessage({type:"worker:ping"})})}class j{async encode(G,H,K){let J=(await import("./chunk-924xe5vk.js")).webpEncodeClient;return J(G,H,K)}async terminate(){}}class F{worker=null;workerReady=null;async getWorker(){if(!this.worker){if(!this.workerReady)this.workerReady=this.createWorker();this.worker=await this.workerReady}return this.worker}async createWorker(){return P("webp.worker")}async encode(G,H,K){let L=await this.getWorker();x(G);let J=G.data.buffer;return S(J),I(L,"webp:encode",{image:G,options:H},K,[J])}async terminate(){if(this.worker)this.worker.terminate(),this.worker=null,this.workerReady=null}}function A(G){return G==="client"?new j:new F}var D=null;async function k(G,H,K){if(!D)D=A("worker");return D.encode(G,H,K)}function p(G="worker"){let H=A(G),K=(L,J,Q)=>{return H.encode(L,J,Q)};return K.terminate=async()=>{await H.terminate()},K}class W{async resize(G,H,K){let J=(await import("./chunk-n7m1gvbc.js")).resizeClient;return J(G,H,K)}async terminate(){}}class y{worker=null;workerReady=null;async getWorker(){if(!this.worker){if(!this.workerReady)this.workerReady=this.createWorker();this.worker=await this.workerReady}return this.worker}async createWorker(){return P("resize.worker")}async resize(G,H,K){let L=await this.getWorker();x(G);let J=G.data.buffer;S(J);try{return await I(L,"resize:run",{image:G,options:H},K,[J])}catch(Q){throw console.error("Resize error:",Q),Q}}async terminate(){if(this.worker)this.worker.terminate(),this.worker=null,this.workerReady=null}}function E(G){return G==="client"?new W:new y}var T=null;async function n(G,H,K){if(!T)T=E("worker");return T.resize(G,H,K)}function t(G="worker"){let H=E(G),K=(L,J,Q)=>{return H.resize(L,J,Q)};return K.terminate=async()=>{await H.terminate()},K}export{n as resize,k as encode,p as createWebpEncoder,t as createResizer};
|
|
2
2
|
|
|
3
3
|
//# debugId=0BF64D29A518C51864756E2164756E21
|