@squoosh-kit/resize 0.0.12 → 0.0.13
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/bridge.browser.mjs +1 -1
- package/dist/bridge.bun.js +1 -1
- package/dist/bridge.node.mjs +1 -1
- package/dist/chunk-atxx2y4c.js +4 -0
- package/dist/chunk-atxx2y4c.js.map +10 -0
- package/dist/chunk-fyfa8ceq.js +3 -0
- package/dist/chunk-fyfa8ceq.js.map +10 -0
- package/dist/chunk-pn10n1jn.js +5 -0
- package/dist/chunk-pn10n1jn.js.map +10 -0
- package/dist/chunk-x4xgrxwp.js +4 -0
- package/dist/chunk-x4xgrxwp.js.map +10 -0
- package/dist/index.browser.mjs +1 -1
- package/dist/index.bun.js +1 -1
- package/dist/index.node.mjs +1 -1
- package/dist/resize.worker.browser.mjs +1 -1
- package/dist/resize.worker.bun.js +1 -1
- package/dist/resize.worker.node.mjs +1 -1
- package/package.json +1 -1
package/dist/bridge.browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as T,c as E,d as P,e as S}from"./chunk-
|
|
1
|
+
import{b as T,c as E,d as P,e as S}from"./chunk-x4xgrxwp.js";function U(){return typeof Bun<"u"}var W=0;async function A(G,K,V,L,H){return new Promise((J,X)=>{let Q=++W;if(L?.aborted){X(new DOMException("Aborted","AbortError"));return}let Z=(O)=>{let D=O.data;if(D.id!==Q)return;if($(),D.ok&&D.data!==void 0)J(D.data);else X(Error(D.error||"Unknown worker error"))},x=(O)=>{$(),X(Error(`Worker error: ${O.message}`))},_=()=>{$(),X(new DOMException("Aborted","AbortError"))},$=()=>{G.removeEventListener("message",Z),G.removeEventListener("error",x),L?.removeEventListener("abort",_)};G.addEventListener("message",Z),G.addEventListener("error",x),L?.addEventListener("abort",_);let Y={type:K,id:Q,payload:V};if(H&&H.length>0)G.postMessage(Y,H);else G.postMessage(Y)})}function q(G){let K=G.endsWith(".js")?G:`${G}.js`,V={"resize.worker.js":{package:"@squoosh-kit/resize",specifier:"resize.worker.js"},"webp.worker.js":{package:"@squoosh-kit/webp",specifier:"webp.worker.js"}},L=V[K];if(!L)throw Error(`Unknown worker: ${K}. Supported workers: ${Object.keys(V).join(", ")}`);try{if(typeof window<"u"){let Q=L.package.split("/")[1],Z=K.replace(".js",".browser.mjs"),x=[`../../${Q}/dist/${Z}`,`../../../node_modules/@squoosh-kit/${Q}/dist/${Z}`,`../../../${Q}/dist/${Z}`],_=null;for(let $ of x)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 ${K} using any available path strategy`)}if(typeof import.meta.resolve==="function")try{let Q=import.meta.resolve(`${L.package}/${L.specifier}`);return new Worker(Q,{type:"module"})}catch{}let H=U()?".bun.js":".node.mjs",J=K.replace(".js",""),X=L.package.includes("resize")?`../../resize/dist/${J}.${H.slice(1)}`:`../../webp/dist/${J}.${H.slice(1)}`;return new Worker(new URL(X,import.meta.url),{type:"module"})}catch(H){let J=H instanceof Error?H.message:String(H);throw Error(`Failed to create worker from ${K}: ${J}. 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 I(G,K=1e4){return new Promise((V,L)=>{let H=setTimeout(()=>{L(Error(`Worker initialization timeout after ${K}ms. Worker file: ${G}`))},K),J;try{J=q(G)}catch(Q){clearTimeout(H),L(Q);return}let X=(Q)=>{if(Q.data?.type==="worker:ready")clearTimeout(H),J.removeEventListener("message",X),V(J)};J.addEventListener("message",X),J.postMessage({type:"worker:ping"})})}class R{async resize(G,K,V){let H=(await import("./resize.worker.browser.mjs")).resizeClient;return H(G,K,V)}async terminate(){}}class B{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 I("resize.worker")}async resize(G,K,V){let L=await this.getWorker();S(G);let H=G.data.buffer;P(H);try{return await A(L,"resize:run",{image:G,options:K},V,[H])}catch(J){throw console.error("Resize error:",J),J}}async terminate(){if(this.worker)this.worker.terminate(),this.worker=null,this.workerReady=null}}function F(G){return G==="client"?new R:new B}export{F as createBridge};
|
|
2
2
|
export{F as a};
|
|
3
3
|
|
|
4
4
|
//# debugId=CE025EE64E35F5AA64756E2164756E21
|
package/dist/bridge.bun.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{b as T,c as E,d as P,e as S}from"./chunk-
|
|
2
|
+
import{b as T,c as E,d as P,e as S}from"./chunk-pn10n1jn.js";function U(){return typeof Bun<"u"}var W=0;async function A(G,K,V,L,H){return new Promise((J,X)=>{let Q=++W;if(L?.aborted){X(new DOMException("Aborted","AbortError"));return}let Z=(O)=>{let D=O.data;if(D.id!==Q)return;if($(),D.ok&&D.data!==void 0)J(D.data);else X(Error(D.error||"Unknown worker error"))},x=(O)=>{$(),X(Error(`Worker error: ${O.message}`))},_=()=>{$(),X(new DOMException("Aborted","AbortError"))},$=()=>{G.removeEventListener("message",Z),G.removeEventListener("error",x),L?.removeEventListener("abort",_)};G.addEventListener("message",Z),G.addEventListener("error",x),L?.addEventListener("abort",_);let Y={type:K,id:Q,payload:V};if(H&&H.length>0)G.postMessage(Y,H);else G.postMessage(Y)})}function q(G){let K=G.endsWith(".js")?G:`${G}.js`,V={"resize.worker.js":{package:"@squoosh-kit/resize",specifier:"resize.worker.js"},"webp.worker.js":{package:"@squoosh-kit/webp",specifier:"webp.worker.js"}},L=V[K];if(!L)throw Error(`Unknown worker: ${K}. Supported workers: ${Object.keys(V).join(", ")}`);try{if(typeof window<"u"){let Q=L.package.split("/")[1],Z=K.replace(".js",".browser.mjs"),x=[`../../${Q}/dist/${Z}`,`../../../node_modules/@squoosh-kit/${Q}/dist/${Z}`,`../../../${Q}/dist/${Z}`],_=null;for(let $ of x)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 ${K} using any available path strategy`)}if(typeof import.meta.resolve==="function")try{let Q=import.meta.resolve(`${L.package}/${L.specifier}`);return new Worker(Q,{type:"module"})}catch{}let H=U()?".bun.js":".node.mjs",J=K.replace(".js",""),X=L.package.includes("resize")?`../../resize/dist/${J}.${H.slice(1)}`:`../../webp/dist/${J}.${H.slice(1)}`;return new Worker(new URL(X,import.meta.url),{type:"module"})}catch(H){let J=H instanceof Error?H.message:String(H);throw Error(`Failed to create worker from ${K}: ${J}. 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 I(G,K=1e4){return new Promise((V,L)=>{let H=setTimeout(()=>{L(Error(`Worker initialization timeout after ${K}ms. Worker file: ${G}`))},K),J;try{J=q(G)}catch(Q){clearTimeout(H),L(Q);return}let X=(Q)=>{if(Q.data?.type==="worker:ready")clearTimeout(H),J.removeEventListener("message",X),V(J)};J.addEventListener("message",X),J.postMessage({type:"worker:ping"})})}class R{async resize(G,K,V){let H=(await import("./resize.worker.bun.js")).resizeClient;return H(G,K,V)}async terminate(){}}class B{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 I("resize.worker")}async resize(G,K,V){let L=await this.getWorker();S(G);let H=G.data.buffer;P(H);try{return await A(L,"resize:run",{image:G,options:K},V,[H])}catch(J){throw console.error("Resize error:",J),J}}async terminate(){if(this.worker)this.worker.terminate(),this.worker=null,this.workerReady=null}}function F(G){return G==="client"?new R:new B}export{F as createBridge};
|
|
3
3
|
export{F as a};
|
|
4
4
|
|
|
5
5
|
//# debugId=9BB212ED42B2974464756E2164756E21
|
package/dist/bridge.node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as T,c as E,d as P,e as S}from"./chunk-
|
|
1
|
+
import{b as T,c as E,d as P,e as S}from"./chunk-atxx2y4c.js";function U(){return typeof Bun<"u"}var W=0;async function A(G,K,V,L,H){return new Promise((J,X)=>{let Q=++W;if(L?.aborted){X(new DOMException("Aborted","AbortError"));return}let Z=(O)=>{let D=O.data;if(D.id!==Q)return;if($(),D.ok&&D.data!==void 0)J(D.data);else X(Error(D.error||"Unknown worker error"))},x=(O)=>{$(),X(Error(`Worker error: ${O.message}`))},_=()=>{$(),X(new DOMException("Aborted","AbortError"))},$=()=>{G.removeEventListener("message",Z),G.removeEventListener("error",x),L?.removeEventListener("abort",_)};G.addEventListener("message",Z),G.addEventListener("error",x),L?.addEventListener("abort",_);let Y={type:K,id:Q,payload:V};if(H&&H.length>0)G.postMessage(Y,H);else G.postMessage(Y)})}function q(G){let K=G.endsWith(".js")?G:`${G}.js`,V={"resize.worker.js":{package:"@squoosh-kit/resize",specifier:"resize.worker.js"},"webp.worker.js":{package:"@squoosh-kit/webp",specifier:"webp.worker.js"}},L=V[K];if(!L)throw Error(`Unknown worker: ${K}. Supported workers: ${Object.keys(V).join(", ")}`);try{if(typeof window<"u"){let Q=L.package.split("/")[1],Z=K.replace(".js",".browser.mjs"),x=[`../../${Q}/dist/${Z}`,`../../../node_modules/@squoosh-kit/${Q}/dist/${Z}`,`../../../${Q}/dist/${Z}`],_=null;for(let $ of x)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 ${K} using any available path strategy`)}if(typeof import.meta.resolve==="function")try{let Q=import.meta.resolve(`${L.package}/${L.specifier}`);return new Worker(Q,{type:"module"})}catch{}let H=U()?".bun.js":".node.mjs",J=K.replace(".js",""),X=L.package.includes("resize")?`../../resize/dist/${J}.${H.slice(1)}`:`../../webp/dist/${J}.${H.slice(1)}`;return new Worker(new URL(X,import.meta.url),{type:"module"})}catch(H){let J=H instanceof Error?H.message:String(H);throw Error(`Failed to create worker from ${K}: ${J}. 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 I(G,K=1e4){return new Promise((V,L)=>{let H=setTimeout(()=>{L(Error(`Worker initialization timeout after ${K}ms. Worker file: ${G}`))},K),J;try{J=q(G)}catch(Q){clearTimeout(H),L(Q);return}let X=(Q)=>{if(Q.data?.type==="worker:ready")clearTimeout(H),J.removeEventListener("message",X),V(J)};J.addEventListener("message",X),J.postMessage({type:"worker:ping"})})}class R{async resize(G,K,V){let H=(await import("./resize.worker.node.mjs")).resizeClient;return H(G,K,V)}async terminate(){}}class B{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 I("resize.worker")}async resize(G,K,V){let L=await this.getWorker();S(G);let H=G.data.buffer;P(H);try{return await A(L,"resize:run",{image:G,options:K},V,[H])}catch(J){throw console.error("Resize error:",J),J}}async terminate(){if(this.worker)this.worker.terminate(),this.worker=null,this.workerReady=null}}function F(G){return G==="client"?new R:new B}export{F as createBridge};
|
|
2
2
|
export{F as a};
|
|
3
3
|
|
|
4
4
|
//# debugId=CE680EE057944D6464756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{createRequire as Q}from"node:module";var K=Object.create;var{getPrototypeOf:L,defineProperty:J,getOwnPropertyNames:N}=Object;var P=Object.prototype.hasOwnProperty;var R=(E,D,F)=>{F=E!=null?K(L(E)):{};let G=D||!E||!E.__esModule?J(F,"default",{value:E,enumerable:!0}):F;for(let H of N(E))if(!P.call(G,H))J(G,H,{get:()=>E[H],enumerable:!0});return G};var U=Q(import.meta.url);function W(E){if(typeof SharedArrayBuffer<"u"&&E instanceof SharedArrayBuffer)throw Error("SharedArrayBuffer is not supported. Use regular ArrayBuffer or Uint8Array instead.");if(!(E instanceof ArrayBuffer))throw TypeError("image.data.buffer must be an ArrayBuffer")}function X(E){if(!E||typeof E!=="object")throw TypeError("image must be an object");let D=E;if(!("data"in D))throw TypeError("image.data is required");let{data:F}=D;if(!(F instanceof Uint8Array||F instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:G,height:H}=D;if(typeof G!=="number"||!Number.isInteger(G)||G<=0)throw RangeError(`image.width must be a positive integer, got ${G}`);if(typeof H!=="number"||!Number.isInteger(H)||H<=0)throw RangeError(`image.height must be a positive integer, got ${H}`);let I=G*H*4;if(F.length<I)throw RangeError(`image.data too small: ${F.length} bytes, expected at least ${I} bytes for ${G}x${H} RGBA image`)}function Y(E){if(typeof E!=="object"||E===null)throw TypeError("options must be an object");let D=E;if(D.width!==void 0){if(typeof D.width!=="number"||!Number.isInteger(D.width)||D.width<=0)throw RangeError(`options.width must be a positive integer, got ${D.width}`)}if(D.height!==void 0){if(typeof D.height!=="number"||!Number.isInteger(D.height)||D.height<=0)throw RangeError(`options.height must be a positive integer, got ${D.height}`)}if(D.method!==void 0){let F=["triangular","catrom","mitchell","lanczos3"];if(!F.includes(D.method))throw TypeError(`options.method must be one of: ${F.join(", ")}, got ${D.method}`)}if(D.premultiply!==void 0&&typeof D.premultiply!=="boolean")throw TypeError(`options.premultiply must be boolean, got ${typeof D.premultiply}`);if(D.linearRGB!==void 0&&typeof D.linearRGB!=="boolean")throw TypeError(`options.linearRGB must be boolean, got ${typeof D.linearRGB}`)}
|
|
2
|
+
export{R as b,U as c,W as d,X as e,Y as f};
|
|
3
|
+
|
|
4
|
+
//# debugId=79A4E722518A72CB64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ImageInput } from './types.js';\n\nexport function validateArrayBuffer(\n buffer: unknown\n): asserts buffer is ArrayBuffer {\n // Check if SharedArrayBuffer is defined in the current environment before using it\n if (\n typeof SharedArrayBuffer !== 'undefined' &&\n buffer instanceof SharedArrayBuffer\n ) {\n throw new Error(\n 'SharedArrayBuffer is not supported. ' +\n 'Use regular ArrayBuffer or Uint8Array instead.'\n );\n }\n\n if (!(buffer instanceof ArrayBuffer)) {\n throw new TypeError('image.data.buffer must be an ArrayBuffer');\n }\n}\n\nexport function validateImageInput(\n image: unknown\n): asserts image is ImageInput {\n if (!image || typeof image !== 'object') {\n throw new TypeError('image must be an object');\n }\n\n const imageObj = image as Record<string, unknown>;\n\n if (!('data' in imageObj)) {\n throw new TypeError('image.data is required');\n }\n\n const { data } = imageObj;\n if (!(data instanceof Uint8Array || data instanceof Uint8ClampedArray)) {\n throw new TypeError('image.data must be Uint8Array or Uint8ClampedArray');\n }\n\n if (!('width' in imageObj) || !('height' in imageObj)) {\n throw new TypeError('image.width and image.height are required');\n }\n\n const { width, height } = imageObj;\n\n if (typeof width !== 'number' || !Number.isInteger(width) || width <= 0) {\n throw new RangeError(\n `image.width must be a positive integer, got ${width}`\n );\n }\n\n if (typeof height !== 'number' || !Number.isInteger(height) || height <= 0) {\n throw new RangeError(\n `image.height must be a positive integer, got ${height}`\n );\n }\n\n const expectedSize = width * height * 4;\n if (data.length < expectedSize) {\n throw new RangeError(\n `image.data too small: ${data.length} bytes, expected at least ${expectedSize} bytes for ${width}x${height} RGBA image`\n );\n }\n}\n\nexport function validateResizeOptions(options: unknown): asserts options is {\n width?: number;\n height?: number;\n method?: 'triangular' | 'catrom' | 'mitchell' | 'lanczos3';\n premultiply?: boolean;\n linearRGB?: boolean;\n} {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object');\n }\n\n const opts = options as Record<string, unknown>;\n\n if (opts.width !== undefined) {\n if (\n typeof opts.width !== 'number' ||\n !Number.isInteger(opts.width) ||\n opts.width <= 0\n ) {\n throw new RangeError(\n `options.width must be a positive integer, got ${opts.width}`\n );\n }\n }\n\n if (opts.height !== undefined) {\n if (\n typeof opts.height !== 'number' ||\n !Number.isInteger(opts.height) ||\n opts.height <= 0\n ) {\n throw new RangeError(\n `options.height must be a positive integer, got ${opts.height}`\n );\n }\n }\n\n if (opts.method !== undefined) {\n const validMethods = ['triangular', 'catrom', 'mitchell', 'lanczos3'];\n if (!validMethods.includes(opts.method as string)) {\n throw new TypeError(\n `options.method must be one of: ${validMethods.join(', ')}, got ${opts.method}`\n );\n }\n }\n\n if (opts.premultiply !== undefined && typeof opts.premultiply !== 'boolean') {\n throw new TypeError(\n `options.premultiply must be boolean, got ${typeof opts.premultiply}`\n );\n }\n\n if (opts.linearRGB !== undefined && typeof opts.linearRGB !== 'boolean') {\n throw new TypeError(\n `options.linearRGB must be boolean, got ${typeof opts.linearRGB}`\n );\n }\n}\n\nexport function validateWebpOptions(\n options: unknown\n): asserts options is Record<string, unknown> | undefined {\n if (options === undefined) {\n return;\n }\n\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object or undefined');\n }\n\n const opts = options as Record<string, unknown>;\n\n if ('quality' in opts && opts.quality !== undefined) {\n const quality = opts.quality;\n\n if (Number.isNaN(quality)) {\n throw new RangeError(\n 'quality must be a valid number in the range 0-100, got NaN'\n );\n }\n\n if (typeof quality !== 'number') {\n throw new TypeError('quality must be a number');\n }\n\n if (!Number.isInteger(quality)) {\n throw new RangeError(\n 'quality must be an integer in the range 0-100, got floating point'\n );\n }\n\n if (quality < 0 || quality > 100) {\n throw new RangeError(\n `quality must be in the range 0-100, got ${quality}`\n );\n }\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "4XAEO,SAAS,CAAmB,CACjC,EAC+B,CAE/B,GACE,OAAO,kBAAsB,KAC7B,aAAkB,kBAElB,MAAU,MACR,oFAEF,EAGF,GAAI,EAAE,aAAkB,aACtB,MAAU,UAAU,0CAA0C,EAI3D,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG,EAIG,SAAS,CAAqB,CAAC,EAMpC,CACA,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,2BAA2B,EAGjD,IAAM,EAAO,EAEb,GAAI,EAAK,QAAU,QACjB,GACE,OAAO,EAAK,QAAU,UACtB,CAAC,OAAO,UAAU,EAAK,KAAK,GAC5B,EAAK,OAAS,EAEd,MAAU,WACR,iDAAiD,EAAK,OACxD,EAIJ,GAAI,EAAK,SAAW,QAClB,GACE,OAAO,EAAK,SAAW,UACvB,CAAC,OAAO,UAAU,EAAK,MAAM,GAC7B,EAAK,QAAU,EAEf,MAAU,WACR,kDAAkD,EAAK,QACzD,EAIJ,GAAI,EAAK,SAAW,OAAW,CAC7B,IAAM,EAAe,CAAC,aAAc,SAAU,WAAY,UAAU,EACpE,GAAI,CAAC,EAAa,SAAS,EAAK,MAAgB,EAC9C,MAAU,UACR,kCAAkC,EAAa,KAAK,IAAI,UAAU,EAAK,QACzE,EAIJ,GAAI,EAAK,cAAgB,QAAa,OAAO,EAAK,cAAgB,UAChE,MAAU,UACR,4CAA4C,OAAO,EAAK,aAC1D,EAGF,GAAI,EAAK,YAAc,QAAa,OAAO,EAAK,YAAc,UAC5D,MAAU,UACR,0CAA0C,OAAO,EAAK,WACxD",
|
|
8
|
+
"debugId": "79A4E722518A72CB64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function J(E){if(typeof SharedArrayBuffer<"u"&&E instanceof SharedArrayBuffer)throw Error("SharedArrayBuffer is not supported. Use regular ArrayBuffer or Uint8Array instead.");if(!(E instanceof ArrayBuffer))throw TypeError("image.data.buffer must be an ArrayBuffer")}function K(E){if(!E||typeof E!=="object")throw TypeError("image must be an object");let D=E;if(!("data"in D))throw TypeError("image.data is required");let{data:F}=D;if(!(F instanceof Uint8Array||F instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:G,height:H}=D;if(typeof G!=="number"||!Number.isInteger(G)||G<=0)throw RangeError(`image.width must be a positive integer, got ${G}`);if(typeof H!=="number"||!Number.isInteger(H)||H<=0)throw RangeError(`image.height must be a positive integer, got ${H}`);let I=G*H*4;if(F.length<I)throw RangeError(`image.data too small: ${F.length} bytes, expected at least ${I} bytes for ${G}x${H} RGBA image`)}function L(E){if(typeof E!=="object"||E===null)throw TypeError("options must be an object");let D=E;if(D.width!==void 0){if(typeof D.width!=="number"||!Number.isInteger(D.width)||D.width<=0)throw RangeError(`options.width must be a positive integer, got ${D.width}`)}if(D.height!==void 0){if(typeof D.height!=="number"||!Number.isInteger(D.height)||D.height<=0)throw RangeError(`options.height must be a positive integer, got ${D.height}`)}if(D.method!==void 0){let F=["triangular","catrom","mitchell","lanczos3"];if(!F.includes(D.method))throw TypeError(`options.method must be one of: ${F.join(", ")}, got ${D.method}`)}if(D.premultiply!==void 0&&typeof D.premultiply!=="boolean")throw TypeError(`options.premultiply must be boolean, got ${typeof D.premultiply}`);if(D.linearRGB!==void 0&&typeof D.linearRGB!=="boolean")throw TypeError(`options.linearRGB must be boolean, got ${typeof D.linearRGB}`)}
|
|
2
|
+
|
|
3
|
+
//# debugId=6329D3052D6C5BE664756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ImageInput } from './types.js';\n\nexport function validateArrayBuffer(\n buffer: unknown\n): asserts buffer is ArrayBuffer {\n // Check if SharedArrayBuffer is defined in the current environment before using it\n if (\n typeof SharedArrayBuffer !== 'undefined' &&\n buffer instanceof SharedArrayBuffer\n ) {\n throw new Error(\n 'SharedArrayBuffer is not supported. ' +\n 'Use regular ArrayBuffer or Uint8Array instead.'\n );\n }\n\n if (!(buffer instanceof ArrayBuffer)) {\n throw new TypeError('image.data.buffer must be an ArrayBuffer');\n }\n}\n\nexport function validateImageInput(\n image: unknown\n): asserts image is ImageInput {\n if (!image || typeof image !== 'object') {\n throw new TypeError('image must be an object');\n }\n\n const imageObj = image as Record<string, unknown>;\n\n if (!('data' in imageObj)) {\n throw new TypeError('image.data is required');\n }\n\n const { data } = imageObj;\n if (!(data instanceof Uint8Array || data instanceof Uint8ClampedArray)) {\n throw new TypeError('image.data must be Uint8Array or Uint8ClampedArray');\n }\n\n if (!('width' in imageObj) || !('height' in imageObj)) {\n throw new TypeError('image.width and image.height are required');\n }\n\n const { width, height } = imageObj;\n\n if (typeof width !== 'number' || !Number.isInteger(width) || width <= 0) {\n throw new RangeError(\n `image.width must be a positive integer, got ${width}`\n );\n }\n\n if (typeof height !== 'number' || !Number.isInteger(height) || height <= 0) {\n throw new RangeError(\n `image.height must be a positive integer, got ${height}`\n );\n }\n\n const expectedSize = width * height * 4;\n if (data.length < expectedSize) {\n throw new RangeError(\n `image.data too small: ${data.length} bytes, expected at least ${expectedSize} bytes for ${width}x${height} RGBA image`\n );\n }\n}\n\nexport function validateResizeOptions(options: unknown): asserts options is {\n width?: number;\n height?: number;\n method?: 'triangular' | 'catrom' | 'mitchell' | 'lanczos3';\n premultiply?: boolean;\n linearRGB?: boolean;\n} {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object');\n }\n\n const opts = options as Record<string, unknown>;\n\n if (opts.width !== undefined) {\n if (\n typeof opts.width !== 'number' ||\n !Number.isInteger(opts.width) ||\n opts.width <= 0\n ) {\n throw new RangeError(\n `options.width must be a positive integer, got ${opts.width}`\n );\n }\n }\n\n if (opts.height !== undefined) {\n if (\n typeof opts.height !== 'number' ||\n !Number.isInteger(opts.height) ||\n opts.height <= 0\n ) {\n throw new RangeError(\n `options.height must be a positive integer, got ${opts.height}`\n );\n }\n }\n\n if (opts.method !== undefined) {\n const validMethods = ['triangular', 'catrom', 'mitchell', 'lanczos3'];\n if (!validMethods.includes(opts.method as string)) {\n throw new TypeError(\n `options.method must be one of: ${validMethods.join(', ')}, got ${opts.method}`\n );\n }\n }\n\n if (opts.premultiply !== undefined && typeof opts.premultiply !== 'boolean') {\n throw new TypeError(\n `options.premultiply must be boolean, got ${typeof opts.premultiply}`\n );\n }\n\n if (opts.linearRGB !== undefined && typeof opts.linearRGB !== 'boolean') {\n throw new TypeError(\n `options.linearRGB must be boolean, got ${typeof opts.linearRGB}`\n );\n }\n}\n\nexport function validateWebpOptions(\n options: unknown\n): asserts options is Record<string, unknown> | undefined {\n if (options === undefined) {\n return;\n }\n\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object or undefined');\n }\n\n const opts = options as Record<string, unknown>;\n\n if ('quality' in opts && opts.quality !== undefined) {\n const quality = opts.quality;\n\n if (Number.isNaN(quality)) {\n throw new RangeError(\n 'quality must be a valid number in the range 0-100, got NaN'\n );\n }\n\n if (typeof quality !== 'number') {\n throw new TypeError('quality must be a number');\n }\n\n if (!Number.isInteger(quality)) {\n throw new RangeError(\n 'quality must be an integer in the range 0-100, got floating point'\n );\n }\n\n if (quality < 0 || quality > 100) {\n throw new RangeError(\n `quality must be in the range 0-100, got ${quality}`\n );\n }\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "AAEO,SAAS,CAAmB,CACjC,EAC+B,CAE/B,GACE,OAAO,kBAAsB,KAC7B,aAAkB,kBAElB,MAAU,MACR,oFAEF,EAGF,GAAI,EAAE,aAAkB,aACtB,MAAU,UAAU,0CAA0C,EAI3D,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG,EAIG,SAAS,CAAqB,CAAC,EAMpC,CACA,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,2BAA2B,EAGjD,IAAM,EAAO,EAEb,GAAI,EAAK,QAAU,QACjB,GACE,OAAO,EAAK,QAAU,UACtB,CAAC,OAAO,UAAU,EAAK,KAAK,GAC5B,EAAK,OAAS,EAEd,MAAU,WACR,iDAAiD,EAAK,OACxD,EAIJ,GAAI,EAAK,SAAW,QAClB,GACE,OAAO,EAAK,SAAW,UACvB,CAAC,OAAO,UAAU,EAAK,MAAM,GAC7B,EAAK,QAAU,EAEf,MAAU,WACR,kDAAkD,EAAK,QACzD,EAIJ,GAAI,EAAK,SAAW,OAAW,CAC7B,IAAM,EAAe,CAAC,aAAc,SAAU,WAAY,UAAU,EACpE,GAAI,CAAC,EAAa,SAAS,EAAK,MAAgB,EAC9C,MAAU,UACR,kCAAkC,EAAa,KAAK,IAAI,UAAU,EAAK,QACzE,EAIJ,GAAI,EAAK,cAAgB,QAAa,OAAO,EAAK,cAAgB,UAChE,MAAU,UACR,4CAA4C,OAAO,EAAK,aAC1D,EAGF,GAAI,EAAK,YAAc,QAAa,OAAO,EAAK,YAAc,UAC5D,MAAU,UACR,0CAA0C,OAAO,EAAK,WACxD",
|
|
8
|
+
"debugId": "6329D3052D6C5BE664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var K=Object.create;var{getPrototypeOf:L,defineProperty:J,getOwnPropertyNames:N}=Object;var P=Object.prototype.hasOwnProperty;var Q=(E,D,F)=>{F=E!=null?K(L(E)):{};let G=D||!E||!E.__esModule?J(F,"default",{value:E,enumerable:!0}):F;for(let H of N(E))if(!P.call(G,H))J(G,H,{get:()=>E[H],enumerable:!0});return G};var R=import.meta.require;function U(E){if(typeof SharedArrayBuffer<"u"&&E instanceof SharedArrayBuffer)throw Error("SharedArrayBuffer is not supported. Use regular ArrayBuffer or Uint8Array instead.");if(!(E instanceof ArrayBuffer))throw TypeError("image.data.buffer must be an ArrayBuffer")}function V(E){if(!E||typeof E!=="object")throw TypeError("image must be an object");let D=E;if(!("data"in D))throw TypeError("image.data is required");let{data:F}=D;if(!(F instanceof Uint8Array||F instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:G,height:H}=D;if(typeof G!=="number"||!Number.isInteger(G)||G<=0)throw RangeError(`image.width must be a positive integer, got ${G}`);if(typeof H!=="number"||!Number.isInteger(H)||H<=0)throw RangeError(`image.height must be a positive integer, got ${H}`);let I=G*H*4;if(F.length<I)throw RangeError(`image.data too small: ${F.length} bytes, expected at least ${I} bytes for ${G}x${H} RGBA image`)}function W(E){if(typeof E!=="object"||E===null)throw TypeError("options must be an object");let D=E;if(D.width!==void 0){if(typeof D.width!=="number"||!Number.isInteger(D.width)||D.width<=0)throw RangeError(`options.width must be a positive integer, got ${D.width}`)}if(D.height!==void 0){if(typeof D.height!=="number"||!Number.isInteger(D.height)||D.height<=0)throw RangeError(`options.height must be a positive integer, got ${D.height}`)}if(D.method!==void 0){let F=["triangular","catrom","mitchell","lanczos3"];if(!F.includes(D.method))throw TypeError(`options.method must be one of: ${F.join(", ")}, got ${D.method}`)}if(D.premultiply!==void 0&&typeof D.premultiply!=="boolean")throw TypeError(`options.premultiply must be boolean, got ${typeof D.premultiply}`);if(D.linearRGB!==void 0&&typeof D.linearRGB!=="boolean")throw TypeError(`options.linearRGB must be boolean, got ${typeof D.linearRGB}`)}
|
|
3
|
+
export{Q as b,R as c,U as d,V as e,W as f};
|
|
4
|
+
|
|
5
|
+
//# debugId=3948CBA7CA5C27B064756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ImageInput } from './types.js';\n\nexport function validateArrayBuffer(\n buffer: unknown\n): asserts buffer is ArrayBuffer {\n // Check if SharedArrayBuffer is defined in the current environment before using it\n if (\n typeof SharedArrayBuffer !== 'undefined' &&\n buffer instanceof SharedArrayBuffer\n ) {\n throw new Error(\n 'SharedArrayBuffer is not supported. ' +\n 'Use regular ArrayBuffer or Uint8Array instead.'\n );\n }\n\n if (!(buffer instanceof ArrayBuffer)) {\n throw new TypeError('image.data.buffer must be an ArrayBuffer');\n }\n}\n\nexport function validateImageInput(\n image: unknown\n): asserts image is ImageInput {\n if (!image || typeof image !== 'object') {\n throw new TypeError('image must be an object');\n }\n\n const imageObj = image as Record<string, unknown>;\n\n if (!('data' in imageObj)) {\n throw new TypeError('image.data is required');\n }\n\n const { data } = imageObj;\n if (!(data instanceof Uint8Array || data instanceof Uint8ClampedArray)) {\n throw new TypeError('image.data must be Uint8Array or Uint8ClampedArray');\n }\n\n if (!('width' in imageObj) || !('height' in imageObj)) {\n throw new TypeError('image.width and image.height are required');\n }\n\n const { width, height } = imageObj;\n\n if (typeof width !== 'number' || !Number.isInteger(width) || width <= 0) {\n throw new RangeError(\n `image.width must be a positive integer, got ${width}`\n );\n }\n\n if (typeof height !== 'number' || !Number.isInteger(height) || height <= 0) {\n throw new RangeError(\n `image.height must be a positive integer, got ${height}`\n );\n }\n\n const expectedSize = width * height * 4;\n if (data.length < expectedSize) {\n throw new RangeError(\n `image.data too small: ${data.length} bytes, expected at least ${expectedSize} bytes for ${width}x${height} RGBA image`\n );\n }\n}\n\nexport function validateResizeOptions(options: unknown): asserts options is {\n width?: number;\n height?: number;\n method?: 'triangular' | 'catrom' | 'mitchell' | 'lanczos3';\n premultiply?: boolean;\n linearRGB?: boolean;\n} {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object');\n }\n\n const opts = options as Record<string, unknown>;\n\n if (opts.width !== undefined) {\n if (\n typeof opts.width !== 'number' ||\n !Number.isInteger(opts.width) ||\n opts.width <= 0\n ) {\n throw new RangeError(\n `options.width must be a positive integer, got ${opts.width}`\n );\n }\n }\n\n if (opts.height !== undefined) {\n if (\n typeof opts.height !== 'number' ||\n !Number.isInteger(opts.height) ||\n opts.height <= 0\n ) {\n throw new RangeError(\n `options.height must be a positive integer, got ${opts.height}`\n );\n }\n }\n\n if (opts.method !== undefined) {\n const validMethods = ['triangular', 'catrom', 'mitchell', 'lanczos3'];\n if (!validMethods.includes(opts.method as string)) {\n throw new TypeError(\n `options.method must be one of: ${validMethods.join(', ')}, got ${opts.method}`\n );\n }\n }\n\n if (opts.premultiply !== undefined && typeof opts.premultiply !== 'boolean') {\n throw new TypeError(\n `options.premultiply must be boolean, got ${typeof opts.premultiply}`\n );\n }\n\n if (opts.linearRGB !== undefined && typeof opts.linearRGB !== 'boolean') {\n throw new TypeError(\n `options.linearRGB must be boolean, got ${typeof opts.linearRGB}`\n );\n }\n}\n\nexport function validateWebpOptions(\n options: unknown\n): asserts options is Record<string, unknown> | undefined {\n if (options === undefined) {\n return;\n }\n\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object or undefined');\n }\n\n const opts = options as Record<string, unknown>;\n\n if ('quality' in opts && opts.quality !== undefined) {\n const quality = opts.quality;\n\n if (Number.isNaN(quality)) {\n throw new RangeError(\n 'quality must be a valid number in the range 0-100, got NaN'\n );\n }\n\n if (typeof quality !== 'number') {\n throw new TypeError('quality must be a number');\n }\n\n if (!Number.isInteger(quality)) {\n throw new RangeError(\n 'quality must be an integer in the range 0-100, got floating point'\n );\n }\n\n if (quality < 0 || quality > 100) {\n throw new RangeError(\n `quality must be in the range 0-100, got ${quality}`\n );\n }\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";iVAEO,SAAS,CAAmB,CACjC,EAC+B,CAE/B,GACE,OAAO,kBAAsB,KAC7B,aAAkB,kBAElB,MAAU,MACR,oFAEF,EAGF,GAAI,EAAE,aAAkB,aACtB,MAAU,UAAU,0CAA0C,EAI3D,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG,EAIG,SAAS,CAAqB,CAAC,EAMpC,CACA,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,2BAA2B,EAGjD,IAAM,EAAO,EAEb,GAAI,EAAK,QAAU,QACjB,GACE,OAAO,EAAK,QAAU,UACtB,CAAC,OAAO,UAAU,EAAK,KAAK,GAC5B,EAAK,OAAS,EAEd,MAAU,WACR,iDAAiD,EAAK,OACxD,EAIJ,GAAI,EAAK,SAAW,QAClB,GACE,OAAO,EAAK,SAAW,UACvB,CAAC,OAAO,UAAU,EAAK,MAAM,GAC7B,EAAK,QAAU,EAEf,MAAU,WACR,kDAAkD,EAAK,QACzD,EAIJ,GAAI,EAAK,SAAW,OAAW,CAC7B,IAAM,EAAe,CAAC,aAAc,SAAU,WAAY,UAAU,EACpE,GAAI,CAAC,EAAa,SAAS,EAAK,MAAgB,EAC9C,MAAU,UACR,kCAAkC,EAAa,KAAK,IAAI,UAAU,EAAK,QACzE,EAIJ,GAAI,EAAK,cAAgB,QAAa,OAAO,EAAK,cAAgB,UAChE,MAAU,UACR,4CAA4C,OAAO,EAAK,aAC1D,EAGF,GAAI,EAAK,YAAc,QAAa,OAAO,EAAK,YAAc,UAC5D,MAAU,UACR,0CAA0C,OAAO,EAAK,WACxD",
|
|
8
|
+
"debugId": "3948CBA7CA5C27B064756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var K=Object.create;var{getPrototypeOf:L,defineProperty:J,getOwnPropertyNames:N}=Object;var P=Object.prototype.hasOwnProperty;var Q=(E,D,F)=>{F=E!=null?K(L(E)):{};let G=D||!E||!E.__esModule?J(F,"default",{value:E,enumerable:!0}):F;for(let H of N(E))if(!P.call(G,H))J(G,H,{get:()=>E[H],enumerable:!0});return G};var R=((E)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(E,{get:(D,F)=>(typeof require<"u"?require:D)[F]}):E)(function(E){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+E+'" is not supported')});function U(E){if(typeof SharedArrayBuffer<"u"&&E instanceof SharedArrayBuffer)throw Error("SharedArrayBuffer is not supported. Use regular ArrayBuffer or Uint8Array instead.");if(!(E instanceof ArrayBuffer))throw TypeError("image.data.buffer must be an ArrayBuffer")}function V(E){if(!E||typeof E!=="object")throw TypeError("image must be an object");let D=E;if(!("data"in D))throw TypeError("image.data is required");let{data:F}=D;if(!(F instanceof Uint8Array||F instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:G,height:H}=D;if(typeof G!=="number"||!Number.isInteger(G)||G<=0)throw RangeError(`image.width must be a positive integer, got ${G}`);if(typeof H!=="number"||!Number.isInteger(H)||H<=0)throw RangeError(`image.height must be a positive integer, got ${H}`);let I=G*H*4;if(F.length<I)throw RangeError(`image.data too small: ${F.length} bytes, expected at least ${I} bytes for ${G}x${H} RGBA image`)}function W(E){if(typeof E!=="object"||E===null)throw TypeError("options must be an object");let D=E;if(D.width!==void 0){if(typeof D.width!=="number"||!Number.isInteger(D.width)||D.width<=0)throw RangeError(`options.width must be a positive integer, got ${D.width}`)}if(D.height!==void 0){if(typeof D.height!=="number"||!Number.isInteger(D.height)||D.height<=0)throw RangeError(`options.height must be a positive integer, got ${D.height}`)}if(D.method!==void 0){let F=["triangular","catrom","mitchell","lanczos3"];if(!F.includes(D.method))throw TypeError(`options.method must be one of: ${F.join(", ")}, got ${D.method}`)}if(D.premultiply!==void 0&&typeof D.premultiply!=="boolean")throw TypeError(`options.premultiply must be boolean, got ${typeof D.premultiply}`);if(D.linearRGB!==void 0&&typeof D.linearRGB!=="boolean")throw TypeError(`options.linearRGB must be boolean, got ${typeof D.linearRGB}`)}
|
|
2
|
+
export{Q as b,R as c,U as d,V as e,W as f};
|
|
3
|
+
|
|
4
|
+
//# debugId=C4416751B3C628B764756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ImageInput } from './types.js';\n\nexport function validateArrayBuffer(\n buffer: unknown\n): asserts buffer is ArrayBuffer {\n // Check if SharedArrayBuffer is defined in the current environment before using it\n if (\n typeof SharedArrayBuffer !== 'undefined' &&\n buffer instanceof SharedArrayBuffer\n ) {\n throw new Error(\n 'SharedArrayBuffer is not supported. ' +\n 'Use regular ArrayBuffer or Uint8Array instead.'\n );\n }\n\n if (!(buffer instanceof ArrayBuffer)) {\n throw new TypeError('image.data.buffer must be an ArrayBuffer');\n }\n}\n\nexport function validateImageInput(\n image: unknown\n): asserts image is ImageInput {\n if (!image || typeof image !== 'object') {\n throw new TypeError('image must be an object');\n }\n\n const imageObj = image as Record<string, unknown>;\n\n if (!('data' in imageObj)) {\n throw new TypeError('image.data is required');\n }\n\n const { data } = imageObj;\n if (!(data instanceof Uint8Array || data instanceof Uint8ClampedArray)) {\n throw new TypeError('image.data must be Uint8Array or Uint8ClampedArray');\n }\n\n if (!('width' in imageObj) || !('height' in imageObj)) {\n throw new TypeError('image.width and image.height are required');\n }\n\n const { width, height } = imageObj;\n\n if (typeof width !== 'number' || !Number.isInteger(width) || width <= 0) {\n throw new RangeError(\n `image.width must be a positive integer, got ${width}`\n );\n }\n\n if (typeof height !== 'number' || !Number.isInteger(height) || height <= 0) {\n throw new RangeError(\n `image.height must be a positive integer, got ${height}`\n );\n }\n\n const expectedSize = width * height * 4;\n if (data.length < expectedSize) {\n throw new RangeError(\n `image.data too small: ${data.length} bytes, expected at least ${expectedSize} bytes for ${width}x${height} RGBA image`\n );\n }\n}\n\nexport function validateResizeOptions(options: unknown): asserts options is {\n width?: number;\n height?: number;\n method?: 'triangular' | 'catrom' | 'mitchell' | 'lanczos3';\n premultiply?: boolean;\n linearRGB?: boolean;\n} {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object');\n }\n\n const opts = options as Record<string, unknown>;\n\n if (opts.width !== undefined) {\n if (\n typeof opts.width !== 'number' ||\n !Number.isInteger(opts.width) ||\n opts.width <= 0\n ) {\n throw new RangeError(\n `options.width must be a positive integer, got ${opts.width}`\n );\n }\n }\n\n if (opts.height !== undefined) {\n if (\n typeof opts.height !== 'number' ||\n !Number.isInteger(opts.height) ||\n opts.height <= 0\n ) {\n throw new RangeError(\n `options.height must be a positive integer, got ${opts.height}`\n );\n }\n }\n\n if (opts.method !== undefined) {\n const validMethods = ['triangular', 'catrom', 'mitchell', 'lanczos3'];\n if (!validMethods.includes(opts.method as string)) {\n throw new TypeError(\n `options.method must be one of: ${validMethods.join(', ')}, got ${opts.method}`\n );\n }\n }\n\n if (opts.premultiply !== undefined && typeof opts.premultiply !== 'boolean') {\n throw new TypeError(\n `options.premultiply must be boolean, got ${typeof opts.premultiply}`\n );\n }\n\n if (opts.linearRGB !== undefined && typeof opts.linearRGB !== 'boolean') {\n throw new TypeError(\n `options.linearRGB must be boolean, got ${typeof opts.linearRGB}`\n );\n }\n}\n\nexport function validateWebpOptions(\n options: unknown\n): asserts options is Record<string, unknown> | undefined {\n if (options === undefined) {\n return;\n }\n\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object or undefined');\n }\n\n const opts = options as Record<string, unknown>;\n\n if ('quality' in opts && opts.quality !== undefined) {\n const quality = opts.quality;\n\n if (Number.isNaN(quality)) {\n throw new RangeError(\n 'quality must be a valid number in the range 0-100, got NaN'\n );\n }\n\n if (typeof quality !== 'number') {\n throw new TypeError('quality must be a number');\n }\n\n if (!Number.isInteger(quality)) {\n throw new RangeError(\n 'quality must be an integer in the range 0-100, got floating point'\n );\n }\n\n if (quality < 0 || quality > 100) {\n throw new RangeError(\n `quality must be in the range 0-100, got ${quality}`\n );\n }\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "kjBAEO,SAAS,CAAmB,CACjC,EAC+B,CAE/B,GACE,OAAO,kBAAsB,KAC7B,aAAkB,kBAElB,MAAU,MACR,oFAEF,EAGF,GAAI,EAAE,aAAkB,aACtB,MAAU,UAAU,0CAA0C,EAI3D,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG,EAIG,SAAS,CAAqB,CAAC,EAMpC,CACA,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,2BAA2B,EAGjD,IAAM,EAAO,EAEb,GAAI,EAAK,QAAU,QACjB,GACE,OAAO,EAAK,QAAU,UACtB,CAAC,OAAO,UAAU,EAAK,KAAK,GAC5B,EAAK,OAAS,EAEd,MAAU,WACR,iDAAiD,EAAK,OACxD,EAIJ,GAAI,EAAK,SAAW,QAClB,GACE,OAAO,EAAK,SAAW,UACvB,CAAC,OAAO,UAAU,EAAK,MAAM,GAC7B,EAAK,QAAU,EAEf,MAAU,WACR,kDAAkD,EAAK,QACzD,EAIJ,GAAI,EAAK,SAAW,OAAW,CAC7B,IAAM,EAAe,CAAC,aAAc,SAAU,WAAY,UAAU,EACpE,GAAI,CAAC,EAAa,SAAS,EAAK,MAAgB,EAC9C,MAAU,UACR,kCAAkC,EAAa,KAAK,IAAI,UAAU,EAAK,QACzE,EAIJ,GAAI,EAAK,cAAgB,QAAa,OAAO,EAAK,cAAgB,UAChE,MAAU,UACR,4CAA4C,OAAO,EAAK,aAC1D,EAGF,GAAI,EAAK,YAAc,QAAa,OAAO,EAAK,YAAc,UAC5D,MAAU,UACR,0CAA0C,OAAO,EAAK,WACxD",
|
|
8
|
+
"debugId": "C4416751B3C628B764756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/index.browser.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as E}from"./bridge.browser.mjs";import"./chunk-
|
|
1
|
+
import{a as E}from"./bridge.browser.mjs";import"./chunk-x4xgrxwp.js";var y=null;async function J(v,j,q){if(!y)y=E("worker");return y.resize(v,j,q)}function K(v="worker"){let j=E(v),q=(F,G,H)=>{return j.resize(F,G,H)};return q.terminate=async()=>{await j.terminate()},q}export{J as resize,K as createResizer};
|
|
2
2
|
|
|
3
3
|
//# debugId=1FB4560D622A5BC164756E2164756E21
|
package/dist/index.bun.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as E}from"./bridge.bun.js";import"./chunk-
|
|
2
|
+
import{a as E}from"./bridge.bun.js";import"./chunk-pn10n1jn.js";var y=null;async function J(v,j,q){if(!y)y=E("worker");return y.resize(v,j,q)}function K(v="worker"){let j=E(v),q=(F,G,H)=>{return j.resize(F,G,H)};return q.terminate=async()=>{await j.terminate()},q}export{J as resize,K as createResizer};
|
|
3
3
|
|
|
4
4
|
//# debugId=19508812115D7B3764756E2164756E21
|
package/dist/index.node.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as E}from"./bridge.node.mjs";import"./chunk-
|
|
1
|
+
import{a as E}from"./bridge.node.mjs";import"./chunk-atxx2y4c.js";var y=null;async function J(v,j,q){if(!y)y=E("worker");return y.resize(v,j,q)}function K(v="worker"){let j=E(v),q=(F,G,H)=>{return j.resize(F,G,H)};return q.terminate=async()=>{await j.terminate()},q}export{J as resize,K as createResizer};
|
|
2
2
|
|
|
3
3
|
//# debugId=38F583F7E607D41664756E2164756E21
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as W,c as b,e as H,f as I}from"./chunk-
|
|
1
|
+
import{b as W,c as b,e as H,f as I}from"./chunk-x4xgrxwp.js";async function B(j){try{if(typeof process<"u"&&process.versions?.node){let D=await import("fs/promises"),J=new URL(j,import.meta.url).pathname,K=await D.readFile(J);return K.buffer.slice(K.byteOffset,K.byteOffset+K.byteLength)}}catch(D){}try{let D=new URL(j,import.meta.url),G=await fetch(D);if(!G.ok)throw Error(`Failed to fetch WASM binary: ${G.status} ${G.statusText}`);return await G.arrayBuffer()}catch(D){throw Error(`Failed to load WASM binary from "${j}": ${D instanceof Error?D.message:String(D)}`)}}var Y,F=null;function v(){if(F===null||F.buffer!==Y.memory.buffer)F=new Uint8Array(Y.memory.buffer);return F}var A=0;function M(j,D){let G=D(j.length*1);return v().set(j,G/1),A=j.length,G}var k=null;function T(){if(k===null||k.buffer!==Y.memory.buffer)k=new Int32Array(Y.memory.buffer);return k}var q=null;function P(){if(q===null||q.buffer!==Y.memory.buffer)q=new Uint8ClampedArray(Y.memory.buffer);return q}function f(j,D){return P().subarray(j/1,j/1+D)}function R(j,D,G,J,K,Q,X,Z){try{let V=Y.__wbindgen_add_to_stack_pointer(-16);var L=M(j,Y.__wbindgen_malloc),E=A;Y.resize(V,L,E,D,G,J,K,Q,X,Z);var O=T()[V/4+0],S=T()[V/4+1],U=f(O,S).slice();return Y.__wbindgen_free(O,S*1),U}finally{Y.__wbindgen_add_to_stack_pointer(16)}}async function w(j,D){if(typeof Response==="function"&&j instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(j,D)}catch(J){if(j.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",J);else throw J}let G=await j.arrayBuffer();return await WebAssembly.instantiate(G,D)}else{let G=await WebAssembly.instantiate(j,D);if(G instanceof WebAssembly.Instance)return{instance:G,module:j};else return G}}async function z(j){if(typeof j>"u")j=new URL("squoosh_resize_bg.wasm",import.meta.url);let D={};if(typeof j==="string"||typeof Request==="function"&&j instanceof Request||typeof URL==="function"&&j instanceof URL)j=fetch(j);let{instance:G,module:J}=await w(await j,D);return Y=G.exports,z.__wbindgen_wasm_module=J,Y}var x=z;var N=null,$=null;async function c(){if(N)return;if($)return $;return $=(async()=>{try{let j=null,D=[new URL("./wasm/squoosh_resize_bg.wasm",import.meta.url).href,new URL("../wasm/squoosh_resize_bg.wasm",import.meta.url).href],G=null;for(let J of D)try{j=await B(J);break}catch(K){G=K instanceof Error?K:Error(String(K))}if(!j)throw G||Error("Could not load WASM binary from any path");try{await x(j)}catch(J){if(J instanceof Error&&(J.message.includes("SharedArrayBuffer")||J.message.includes("first argument must be"))){if(typeof SharedArrayBuffer>"u")globalThis.SharedArrayBuffer=ArrayBuffer;try{await x(j)}catch(K){throw Error(`WASM module initialization failed even with polyfill: ${K instanceof Error?K.message:String(K)}`)}}else throw J}N=R}catch(j){throw $=null,Error(`Failed to initialize resize WASM module: ${j instanceof Error?j.message:String(j)}`)}})(),$}async function C(j,D){if(H(j),I(D),await c(),!N)throw Error("Resize module not initialized");let{data:G,width:J,height:K}=j,Q=D.width??J,X=D.height??K;if(D.width&&!D.height)X=Math.max(1,Math.round(K*D.width/J));else if(D.height&&!D.width)Q=Math.max(1,Math.round(J*D.height/K));if(Q<1||X<1)throw RangeError(`Output dimensions must be at least 1x1, got ${Q}x${X}`);let Z=G instanceof Uint8ClampedArray?new Uint8Array(G.buffer,G.byteOffset,G.length):new Uint8Array(G.buffer,G.byteOffset,G.length);return{data:N(Z,J,K,Q,X,y(D),D.premultiply??!0,D.linearRGB??!0),width:Q,height:X}}async function h(j,D,G){if(G?.aborted)throw new DOMException("Aborted","AbortError");return C(j,D)}function y(j){return{triangular:0,catrom:1,mitchell:2,lanczos3:3}[j?.method??"lanczos3"]??3}if(typeof self<"u")self.onmessage=async(j)=>{let D=j.data;if(D?.type==="worker:ping"){self.postMessage({type:"worker:ready"});return}let{id:G,type:J,payload:K}=D,Q={id:G,ok:!1};try{if(J!=="resize:run")throw Error(`Unknown message type: ${J}`);let X=await C(K.image,K.options);Q.ok=!0,Q.data=X;let Z=X.data.buffer;if(Z)self.postMessage(Q,[Z]);else self.postMessage(Q)}catch(X){Q.error=X instanceof Error?X.message:String(X),self.postMessage(Q)}};export{h as resizeClient};
|
|
2
2
|
|
|
3
3
|
//# debugId=ED2AE040BCCACDC464756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{b as W,c as b,e as H,f as I}from"./chunk-
|
|
2
|
+
import{b as W,c as b,e as H,f as I}from"./chunk-pn10n1jn.js";async function B(j){try{if(typeof process<"u"&&process.versions?.node){let D=await import("fs/promises"),J=new URL(j,import.meta.url).pathname,K=await D.readFile(J);return K.buffer.slice(K.byteOffset,K.byteOffset+K.byteLength)}}catch(D){}try{let D=new URL(j,import.meta.url),G=await fetch(D);if(!G.ok)throw Error(`Failed to fetch WASM binary: ${G.status} ${G.statusText}`);return await G.arrayBuffer()}catch(D){throw Error(`Failed to load WASM binary from "${j}": ${D instanceof Error?D.message:String(D)}`)}}var Y,F=null;function v(){if(F===null||F.buffer!==Y.memory.buffer)F=new Uint8Array(Y.memory.buffer);return F}var A=0;function M(j,D){let G=D(j.length*1);return v().set(j,G/1),A=j.length,G}var k=null;function T(){if(k===null||k.buffer!==Y.memory.buffer)k=new Int32Array(Y.memory.buffer);return k}var q=null;function P(){if(q===null||q.buffer!==Y.memory.buffer)q=new Uint8ClampedArray(Y.memory.buffer);return q}function f(j,D){return P().subarray(j/1,j/1+D)}function R(j,D,G,J,K,Q,X,Z){try{let V=Y.__wbindgen_add_to_stack_pointer(-16);var L=M(j,Y.__wbindgen_malloc),E=A;Y.resize(V,L,E,D,G,J,K,Q,X,Z);var O=T()[V/4+0],S=T()[V/4+1],U=f(O,S).slice();return Y.__wbindgen_free(O,S*1),U}finally{Y.__wbindgen_add_to_stack_pointer(16)}}async function w(j,D){if(typeof Response==="function"&&j instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(j,D)}catch(J){if(j.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",J);else throw J}let G=await j.arrayBuffer();return await WebAssembly.instantiate(G,D)}else{let G=await WebAssembly.instantiate(j,D);if(G instanceof WebAssembly.Instance)return{instance:G,module:j};else return G}}async function z(j){if(typeof j>"u")j=new URL("squoosh_resize_bg.wasm",import.meta.url);let D={};if(typeof j==="string"||typeof Request==="function"&&j instanceof Request||typeof URL==="function"&&j instanceof URL)j=fetch(j);let{instance:G,module:J}=await w(await j,D);return Y=G.exports,z.__wbindgen_wasm_module=J,Y}var x=z;var N=null,$=null;async function c(){if(N)return;if($)return $;return $=(async()=>{try{let j=null,D=[new URL("./wasm/squoosh_resize_bg.wasm",import.meta.url).href,new URL("../wasm/squoosh_resize_bg.wasm",import.meta.url).href],G=null;for(let J of D)try{j=await B(J);break}catch(K){G=K instanceof Error?K:Error(String(K))}if(!j)throw G||Error("Could not load WASM binary from any path");try{await x(j)}catch(J){if(J instanceof Error&&(J.message.includes("SharedArrayBuffer")||J.message.includes("first argument must be"))){if(typeof SharedArrayBuffer>"u")globalThis.SharedArrayBuffer=ArrayBuffer;try{await x(j)}catch(K){throw Error(`WASM module initialization failed even with polyfill: ${K instanceof Error?K.message:String(K)}`)}}else throw J}N=R}catch(j){throw $=null,Error(`Failed to initialize resize WASM module: ${j instanceof Error?j.message:String(j)}`)}})(),$}async function C(j,D){if(H(j),I(D),await c(),!N)throw Error("Resize module not initialized");let{data:G,width:J,height:K}=j,Q=D.width??J,X=D.height??K;if(D.width&&!D.height)X=Math.max(1,Math.round(K*D.width/J));else if(D.height&&!D.width)Q=Math.max(1,Math.round(J*D.height/K));if(Q<1||X<1)throw RangeError(`Output dimensions must be at least 1x1, got ${Q}x${X}`);let Z=G instanceof Uint8ClampedArray?new Uint8Array(G.buffer,G.byteOffset,G.length):new Uint8Array(G.buffer,G.byteOffset,G.length);return{data:N(Z,J,K,Q,X,y(D),D.premultiply??!0,D.linearRGB??!0),width:Q,height:X}}async function h(j,D,G){if(G?.aborted)throw new DOMException("Aborted","AbortError");return C(j,D)}function y(j){return{triangular:0,catrom:1,mitchell:2,lanczos3:3}[j?.method??"lanczos3"]??3}if(typeof self<"u")self.onmessage=async(j)=>{let D=j.data;if(D?.type==="worker:ping"){self.postMessage({type:"worker:ready"});return}let{id:G,type:J,payload:K}=D,Q={id:G,ok:!1};try{if(J!=="resize:run")throw Error(`Unknown message type: ${J}`);let X=await C(K.image,K.options);Q.ok=!0,Q.data=X;let Z=X.data.buffer;if(Z)self.postMessage(Q,[Z]);else self.postMessage(Q)}catch(X){Q.error=X instanceof Error?X.message:String(X),self.postMessage(Q)}};export{h as resizeClient};
|
|
3
3
|
|
|
4
4
|
//# debugId=0517B66F120856E264756E2164756E21
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as W,c as b,e as H,f as I}from"./chunk-
|
|
1
|
+
import{b as W,c as b,e as H,f as I}from"./chunk-atxx2y4c.js";async function B(j){try{if(typeof process<"u"&&process.versions?.node){let D=await import("fs/promises"),J=new URL(j,import.meta.url).pathname,K=await D.readFile(J);return K.buffer.slice(K.byteOffset,K.byteOffset+K.byteLength)}}catch(D){}try{let D=new URL(j,import.meta.url),G=await fetch(D);if(!G.ok)throw Error(`Failed to fetch WASM binary: ${G.status} ${G.statusText}`);return await G.arrayBuffer()}catch(D){throw Error(`Failed to load WASM binary from "${j}": ${D instanceof Error?D.message:String(D)}`)}}var Y,F=null;function v(){if(F===null||F.buffer!==Y.memory.buffer)F=new Uint8Array(Y.memory.buffer);return F}var A=0;function M(j,D){let G=D(j.length*1);return v().set(j,G/1),A=j.length,G}var k=null;function T(){if(k===null||k.buffer!==Y.memory.buffer)k=new Int32Array(Y.memory.buffer);return k}var q=null;function P(){if(q===null||q.buffer!==Y.memory.buffer)q=new Uint8ClampedArray(Y.memory.buffer);return q}function f(j,D){return P().subarray(j/1,j/1+D)}function R(j,D,G,J,K,Q,X,Z){try{let V=Y.__wbindgen_add_to_stack_pointer(-16);var L=M(j,Y.__wbindgen_malloc),E=A;Y.resize(V,L,E,D,G,J,K,Q,X,Z);var O=T()[V/4+0],S=T()[V/4+1],U=f(O,S).slice();return Y.__wbindgen_free(O,S*1),U}finally{Y.__wbindgen_add_to_stack_pointer(16)}}async function w(j,D){if(typeof Response==="function"&&j instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(j,D)}catch(J){if(j.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",J);else throw J}let G=await j.arrayBuffer();return await WebAssembly.instantiate(G,D)}else{let G=await WebAssembly.instantiate(j,D);if(G instanceof WebAssembly.Instance)return{instance:G,module:j};else return G}}async function z(j){if(typeof j>"u")j=new URL("squoosh_resize_bg.wasm",import.meta.url);let D={};if(typeof j==="string"||typeof Request==="function"&&j instanceof Request||typeof URL==="function"&&j instanceof URL)j=fetch(j);let{instance:G,module:J}=await w(await j,D);return Y=G.exports,z.__wbindgen_wasm_module=J,Y}var x=z;var N=null,$=null;async function c(){if(N)return;if($)return $;return $=(async()=>{try{let j=null,D=[new URL("./wasm/squoosh_resize_bg.wasm",import.meta.url).href,new URL("../wasm/squoosh_resize_bg.wasm",import.meta.url).href],G=null;for(let J of D)try{j=await B(J);break}catch(K){G=K instanceof Error?K:Error(String(K))}if(!j)throw G||Error("Could not load WASM binary from any path");try{await x(j)}catch(J){if(J instanceof Error&&(J.message.includes("SharedArrayBuffer")||J.message.includes("first argument must be"))){if(typeof SharedArrayBuffer>"u")globalThis.SharedArrayBuffer=ArrayBuffer;try{await x(j)}catch(K){throw Error(`WASM module initialization failed even with polyfill: ${K instanceof Error?K.message:String(K)}`)}}else throw J}N=R}catch(j){throw $=null,Error(`Failed to initialize resize WASM module: ${j instanceof Error?j.message:String(j)}`)}})(),$}async function C(j,D){if(H(j),I(D),await c(),!N)throw Error("Resize module not initialized");let{data:G,width:J,height:K}=j,Q=D.width??J,X=D.height??K;if(D.width&&!D.height)X=Math.max(1,Math.round(K*D.width/J));else if(D.height&&!D.width)Q=Math.max(1,Math.round(J*D.height/K));if(Q<1||X<1)throw RangeError(`Output dimensions must be at least 1x1, got ${Q}x${X}`);let Z=G instanceof Uint8ClampedArray?new Uint8Array(G.buffer,G.byteOffset,G.length):new Uint8Array(G.buffer,G.byteOffset,G.length);return{data:N(Z,J,K,Q,X,y(D),D.premultiply??!0,D.linearRGB??!0),width:Q,height:X}}async function h(j,D,G){if(G?.aborted)throw new DOMException("Aborted","AbortError");return C(j,D)}function y(j){return{triangular:0,catrom:1,mitchell:2,lanczos3:3}[j?.method??"lanczos3"]??3}if(typeof self<"u")self.onmessage=async(j)=>{let D=j.data;if(D?.type==="worker:ping"){self.postMessage({type:"worker:ready"});return}let{id:G,type:J,payload:K}=D,Q={id:G,ok:!1};try{if(J!=="resize:run")throw Error(`Unknown message type: ${J}`);let X=await C(K.image,K.options);Q.ok=!0,Q.data=X;let Z=X.data.buffer;if(Z)self.postMessage(Q,[Z]);else self.postMessage(Q)}catch(X){Q.error=X instanceof Error?X.message:String(X),self.postMessage(Q)}};export{h as resizeClient};
|
|
2
2
|
|
|
3
3
|
//# debugId=1EF3D28815B4A64864756E2164756E21
|