@squoosh-kit/webp 0.0.26 → 0.0.27

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.
Files changed (54) hide show
  1. package/dist/bridge.browser.mjs +3 -3
  2. package/dist/bridge.browser.mjs.map +4 -4
  3. package/dist/bridge.bun.js +3 -3
  4. package/dist/bridge.bun.js.map +4 -4
  5. package/dist/bridge.d.ts +1 -1
  6. package/dist/bridge.d.ts.map +1 -1
  7. package/dist/bridge.node.cjs +2 -2
  8. package/dist/bridge.node.cjs.map +4 -4
  9. package/dist/bridge.node.mjs +3 -3
  10. package/dist/bridge.node.mjs.map +4 -4
  11. package/dist/chunk-5vdxd0v3.js +4 -0
  12. package/dist/chunk-5vdxd0v3.js.map +10 -0
  13. package/dist/chunk-gw29pvyv.js +3 -0
  14. package/dist/chunk-gw29pvyv.js.map +10 -0
  15. package/dist/chunk-q0apy7nk.js +5 -0
  16. package/dist/chunk-q0apy7nk.js.map +10 -0
  17. package/dist/chunk-szbj3b6y.js +4 -0
  18. package/dist/chunk-szbj3b6y.js.map +10 -0
  19. package/dist/index.browser.mjs +2 -2
  20. package/dist/index.browser.mjs.map +3 -3
  21. package/dist/index.bun.js +2 -2
  22. package/dist/index.bun.js.map +3 -3
  23. package/dist/index.d.ts +30 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.node.cjs +2 -2
  26. package/dist/index.node.cjs.map +3 -3
  27. package/dist/index.node.mjs +2 -2
  28. package/dist/index.node.mjs.map +3 -3
  29. package/dist/validators.browser.mjs +4 -0
  30. package/dist/validators.browser.mjs.map +10 -0
  31. package/dist/validators.bun.js +5 -0
  32. package/dist/validators.bun.js.map +10 -0
  33. package/dist/validators.d.ts +2 -0
  34. package/dist/validators.d.ts.map +1 -0
  35. package/dist/validators.node.cjs +3 -0
  36. package/dist/validators.node.cjs.map +10 -0
  37. package/dist/validators.node.mjs +4 -0
  38. package/dist/validators.node.mjs.map +10 -0
  39. package/dist/webp.worker.browser.mjs +10 -10
  40. package/dist/webp.worker.browser.mjs.map +5 -5
  41. package/dist/webp.worker.bun.js +10 -10
  42. package/dist/webp.worker.bun.js.map +5 -5
  43. package/dist/webp.worker.d.ts.map +1 -1
  44. package/dist/webp.worker.node.cjs +10 -10
  45. package/dist/webp.worker.node.cjs.map +5 -5
  46. package/dist/webp.worker.node.mjs +10 -10
  47. package/dist/webp.worker.node.mjs.map +5 -5
  48. package/package.json +2 -2
  49. package/dist/chunk-2t18cpk4.js +0 -3
  50. package/dist/chunk-2t18cpk4.js.map +0 -10
  51. package/dist/chunk-eqkkc09z.js +0 -4
  52. package/dist/chunk-eqkkc09z.js.map +0 -10
  53. package/dist/chunk-m5rj68ef.js +0 -5
  54. package/dist/chunk-m5rj68ef.js.map +0 -10
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["node:url"],
4
+ "sourcesContent": [
5
+ "var{URL,URLSearchParams}=globalThis;function util_isString(arg){return typeof arg===\"string\"}function util_isObject(arg){return typeof arg===\"object\"&&arg!==null}function util_isNull(arg){return arg===null}function util_isNullOrUndefined(arg){return arg==null}function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\\/\\/?(?!\\/)[^\\?\\s]*)(\\?[^\\s]*)?$/,delims=[\"<\",\">\",'\"',\"`\",\" \",\"\\r\",`\n`,\"\\t\"],unwise=[\"{\",\"}\",\"|\",\"\\\\\",\"^\",\"`\"].concat(delims),autoEscape=[\"'\"].concat(unwise),nonHostChars=[\"%\",\"/\",\"?\",\";\",\"#\"].concat(autoEscape),hostEndingChars=[\"/\",\"?\",\"#\"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,\"javascript:\":!0},hostlessProtocol={javascript:!0,\"javascript:\":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,\"http:\":!0,\"https:\":!0,\"ftp:\":!0,\"gopher:\":!0,\"file:\":!0},querystring={parse(str){var decode=decodeURIComponent;return(str+\"\").replace(/\\+/g,\" \").split(\"&\").filter(Boolean).reduce(function(obj,item,index){var ref=item.split(\"=\"),key=decode(ref[0]||\"\"),val=decode(ref[1]||\"\"),prev=obj[key];return obj[key]=prev===void 0?val:[].concat(prev,val),obj},{})},stringify(obj){var encode=encodeURIComponent;return Object.keys(obj||{}).reduce(function(arr,key){return[].concat(obj[key]).forEach(function(v){arr.push(encode(key)+\"=\"+encode(v))}),arr},[]).join(\"&\").replace(/\\s/g,\"+\")}};function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util_isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util_isString(url))throw new TypeError(\"Parameter 'url' must be a string, not \"+typeof url);var queryIndex=url.indexOf(\"?\"),splitter=queryIndex!==-1&&queryIndex<url.indexOf(\"#\")?\"?\":\"#\",uSplit=url.split(splitter),slashRegex=/\\\\/g;uSplit[0]=uSplit[0].replace(slashRegex,\"/\"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&url.split(\"#\").length===1){var simplePath=simplePathPattern.exec(rest);if(simplePath){if(this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2])if(this.search=simplePath[2],parseQueryString)this.query=querystring.parse(this.search.substr(1));else this.query=this.search.substr(1);else if(parseQueryString)this.search=\"\",this.query={};return this}}var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\\/\\/[^@\\/]+@[^@\\/]+/)){var slashes=rest.substr(0,2)===\"//\";if(slashes&&!(proto&&hostlessProtocol[proto]))rest=rest.substr(2),this.slashes=!0}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}var auth,atSign;if(hostEnd===-1)atSign=rest.lastIndexOf(\"@\");else atSign=rest.lastIndexOf(\"@\",hostEnd);if(atSign!==-1)auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth);hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}if(hostEnd===-1)hostEnd=rest.length;this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||\"\";var ipv6Hostname=this.hostname[0]===\"[\"&&this.hostname[this.hostname.length-1]===\"]\";if(!ipv6Hostname){var hostparts=this.hostname.split(/\\./);for(var i=0,l=hostparts.length;i<l;i++){var part=hostparts[i];if(!part)continue;if(!part.match(hostnamePartPattern)){var newpart=\"\";for(var j=0,k=part.length;j<k;j++)if(part.charCodeAt(j)>127)newpart+=\"x\";else newpart+=part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);if(bit)validParts.push(bit[1]),notHost.unshift(bit[2]);if(notHost.length)rest=\"/\"+notHost.join(\".\")+rest;this.hostname=validParts.join(\".\");break}}}}if(this.hostname.length>hostnameMaxLen)this.hostname=\"\";else this.hostname=this.hostname.toLowerCase();if(!ipv6Hostname)this.hostname=new URL(`https://${this.hostname}`).hostname;var p=this.port?\":\"+this.port:\"\",h=this.hostname||\"\";if(this.host=h+p,this.href+=this.host,ipv6Hostname){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),rest[0]!==\"/\")rest=\"/\"+rest}}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length;i<l;i++){var ae=autoEscape[i];if(rest.indexOf(ae)===-1)continue;var esc=encodeURIComponent(ae);if(esc===ae)esc=escape(ae);rest=rest.split(ae).join(esc)}var hash=rest.indexOf(\"#\");if(hash!==-1)this.hash=rest.substr(hash),rest=rest.slice(0,hash);var qm=rest.indexOf(\"?\");if(qm!==-1){if(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString)this.query=querystring.parse(this.query);rest=rest.slice(0,qm)}else if(parseQueryString)this.search=\"\",this.query={};if(rest)this.pathname=rest;if(slashedProtocol[lowerProto]&&this.hostname&&!this.pathname)this.pathname=\"/\";if(this.pathname||this.search){var p=this.pathname||\"\",s=this.search||\"\";this.path=p+s}return this.href=this.format(),this};function urlFormat(obj){if(util_isString(obj))obj=urlParse(obj);if(!(obj instanceof Url))return Url.prototype.format.call(obj);return obj.format()}Url.prototype.format=function(){var auth=this.auth||\"\";if(auth)auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,\":\"),auth+=\"@\";var protocol=this.protocol||\"\",pathname=this.pathname||\"\",hash=this.hash||\"\",host=!1,query=\"\";if(this.host)host=auth+this.host;else if(this.hostname){if(host=auth+(this.hostname.indexOf(\":\")===-1?this.hostname:\"[\"+this.hostname+\"]\"),this.port)host+=\":\"+this.port}if(this.query&&util_isObject(this.query)&&Object.keys(this.query).length)query=querystring.stringify(this.query);var search=this.search||query&&\"?\"+query||\"\";if(protocol&&protocol.substr(-1)!==\":\")protocol+=\":\";if(this.slashes||(!protocol||slashedProtocol[protocol])&&host!==!1){if(host=\"//\"+(host||\"\"),pathname&&pathname.charAt(0)!==\"/\")pathname=\"/\"+pathname}else if(!host)host=\"\";if(hash&&hash.charAt(0)!==\"#\")hash=\"#\"+hash;if(search&&search.charAt(0)!==\"?\")search=\"?\"+search;return pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace(\"#\",\"%23\"),protocol+host+pathname+search+hash};function urlResolve(source,relative){return urlParse(source,!1,!0).resolve(relative)}Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()};function urlResolveObject(source,relative){if(!source)return relative;return urlParse(source,!1,!0).resolveObject(relative)}Url.prototype.resolveObject=function(relative){if(util_isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}var result=new Url,tkeys=Object.keys(this);for(var tk=0;tk<tkeys.length;tk++){var tkey=tkeys[tk];result[tkey]=this[tkey]}if(result.hash=relative.hash,relative.href===\"\")return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){var rkeys=Object.keys(relative);for(var rk=0;rk<rkeys.length;rk++){var rkey=rkeys[rk];if(rkey!==\"protocol\")result[rkey]=relative[rkey]}if(slashedProtocol[result.protocol]&&result.hostname&&!result.pathname)result.path=result.pathname=\"/\";return result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){var keys=Object.keys(relative);for(var v=0;v<keys.length;v++){var k=keys[v];result[k]=relative[k]}return result.href=result.format(),result}if(result.protocol=relative.protocol,!relative.host&&!hostlessProtocol[relative.protocol]){var relPath=(relative.pathname||\"\").split(\"/\");while(relPath.length&&!(relative.host=relPath.shift()));if(!relative.host)relative.host=\"\";if(!relative.hostname)relative.hostname=\"\";if(relPath[0]!==\"\")relPath.unshift(\"\");if(relPath.length<2)relPath.unshift(\"\");result.pathname=relPath.join(\"/\")}else result.pathname=relative.pathname;if(result.search=relative.search,result.query=relative.query,result.host=relative.host||\"\",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||\"\",s=result.search||\"\";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&result.pathname.charAt(0)===\"/\",isRelAbs=relative.host||relative.pathname&&relative.pathname.charAt(0)===\"/\",mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split(\"/\")||[],relPath=relative.pathname&&relative.pathname.split(\"/\")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic){if(result.hostname=\"\",result.port=null,result.host)if(srcPath[0]===\"\")srcPath[0]=result.host;else srcPath.unshift(result.host);if(result.host=\"\",relative.protocol){if(relative.hostname=null,relative.port=null,relative.host)if(relPath[0]===\"\")relPath[0]=relative.host;else relPath.unshift(relative.host);relative.host=null}mustEndAbs=mustEndAbs&&(relPath[0]===\"\"||srcPath[0]===\"\")}if(isRelAbs)result.host=relative.host||relative.host===\"\"?relative.host:result.host,result.hostname=relative.hostname||relative.hostname===\"\"?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length){if(!srcPath)srcPath=[];srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query}else if(!util_isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=result.host&&result.host.indexOf(\"@\")>0?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift()}if(result.search=relative.search,result.query=relative.query,!util_isNull(result.pathname)||!util_isNull(result.search))result.path=(result.pathname?result.pathname:\"\")+(result.search?result.search:\"\");return result.href=result.format(),result}if(!srcPath.length){if(result.pathname=null,result.search)result.path=\"/\"+result.search;else result.path=null;return result.href=result.format(),result}var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&(last===\".\"||last===\"..\")||last===\"\",up=0;for(var i=srcPath.length;i>=0;i--)if(last=srcPath[i],last===\".\")srcPath.splice(i,1);else if(last===\"..\")srcPath.splice(i,1),up++;else if(up)srcPath.splice(i,1),up--;if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift(\"..\");if(mustEndAbs&&srcPath[0]!==\"\"&&(!srcPath[0]||srcPath[0].charAt(0)!==\"/\"))srcPath.unshift(\"\");if(hasTrailingSlash&&srcPath.join(\"/\").substr(-1)!==\"/\")srcPath.push(\"\");var isAbsolute=srcPath[0]===\"\"||srcPath[0]&&srcPath[0].charAt(0)===\"/\";if(psychotic){result.hostname=result.host=isAbsolute?\"\":srcPath.length?srcPath.shift():\"\";var authInHost=result.host&&result.host.indexOf(\"@\")>0?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift()}if(mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute)srcPath.unshift(\"\");if(!srcPath.length)result.pathname=null,result.path=null;else result.pathname=srcPath.join(\"/\");if(!util_isNull(result.pathname)||!util_isNull(result.search))result.path=(result.pathname?result.pathname:\"\")+(result.search?result.search:\"\");return result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result};Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);if(port){if(port=port[0],port!==\":\")this.port=port.substr(1);host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};var url_default={parse:urlParse,resolve:urlResolve,resolveObject:urlResolveObject,format:urlFormat,Url,URL,URLSearchParams};export{urlResolveObject as resolveObject,urlResolve as resolve,urlParse as parse,urlFormat as format,url_default as default,Url,URLSearchParams,URL};"
6
+ ],
7
+ "mappings": "4BAAA,IAAI,MAAI,mBAAiB,WAAW,SAAS,CAAa,CAAC,EAAI,CAAC,OAAO,OAAO,IAAM,SAAS,SAAS,CAAa,CAAC,EAAI,CAAC,OAAO,OAAO,IAAM,UAAU,IAAM,KAAK,SAAS,CAAW,CAAC,EAAI,CAAC,OAAO,IAAM,KAAK,SAAS,CAAsB,CAAC,EAAI,CAAC,OAAO,GAAK,KAAK,SAAS,CAAG,EAAE,CAAC,KAAK,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,KAAK,KAAK,OAAO,K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I,EAAE,GAAG,EAAK,CAAC,GAAG,EAAK,EAAK,GAAG,IAAO,IAAI,KAAK,KAAK,EAAK,OAAO,CAAC,EAAE,EAAK,EAAK,OAAO,EAAE,EAAK,OAAO,EAAK,MAAM,EAAE,GAAG,EAAK,KAAK,SAAS,GAAM,IAAI,GAAY,CAAC,MAAM,EAAS,QAAQ,GAAW,cAAc,GAAiB,OAAO,GAAU,MAAI,MAAI,iBAAe",
8
+ "debugId": "A51CEBA1D864A1DF64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,3 @@
1
+ function H(F){if(!F||typeof F!=="object")throw TypeError("image must be an object");let D=F;if(!("data"in D))throw TypeError("image.data is required");let{data:E}=D;if(!(E instanceof Uint8Array||E 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:l,height:q}=D;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)throw RangeError(`image.width must be a positive integer, got ${l}`);if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw RangeError(`image.height must be a positive integer, got ${q}`);let G=l*q*4;if(E.length<G)throw RangeError(`image.data too small: ${E.length} bytes, expected at least ${G} bytes for ${l}x${q} RGBA image`)}
2
+
3
+ //# debugId=09889CC44937212964756E2164756E21
@@ -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"
6
+ ],
7
+ "mappings": "AAqBO,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",
8
+ "debugId": "09889CC44937212964756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ function H(F){if(!F||typeof F!=="object")throw TypeError("image must be an object");let D=F;if(!("data"in D))throw TypeError("image.data is required");let{data:E}=D;if(!(E instanceof Uint8Array||E 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:l,height:q}=D;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)throw RangeError(`image.width must be a positive integer, got ${l}`);if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw RangeError(`image.height must be a positive integer, got ${q}`);let G=l*q*4;if(E.length<G)throw RangeError(`image.data too small: ${E.length} bytes, expected at least ${G} bytes for ${l}x${q} RGBA image`)}
3
+ export{H as b};
4
+
5
+ //# debugId=7AE3A24486B7640E64756E2164756E21
@@ -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"
6
+ ],
7
+ "mappings": ";AAqBO,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",
8
+ "debugId": "7AE3A24486B7640E64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ function H(F){if(!F||typeof F!=="object")throw TypeError("image must be an object");let D=F;if(!("data"in D))throw TypeError("image.data is required");let{data:E}=D;if(!(E instanceof Uint8Array||E 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:l,height:q}=D;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)throw RangeError(`image.width must be a positive integer, got ${l}`);if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw RangeError(`image.height must be a positive integer, got ${q}`);let G=l*q*4;if(E.length<G)throw RangeError(`image.data too small: ${E.length} bytes, expected at least ${G} bytes for ${l}x${q} RGBA image`)}
2
+ export{H as b};
3
+
4
+ //# debugId=BE7FDBD72E428B8E64756E2164756E21
@@ -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"
6
+ ],
7
+ "mappings": "AAqBO,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",
8
+ "debugId": "BE7FDBD72E428B8E64756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,3 +1,3 @@
1
- import{a as E}from"./bridge.browser.mjs";import"./chunk-eqkkc09z.js";import"./chunk-bhj61bkd.js";var z=null;async function I(q,j,y){if(!z)z=E("worker");return z.encode(q,j,y)}function J(q="worker"){let j=E(q);return Object.assign((y,F,G)=>{return j.encode(y,F,G)},{terminate:async()=>{await j.terminate()}})}export{I as encode,J as createWebpEncoder};
1
+ import{a as J}from"./bridge.browser.mjs";import"./chunk-szbj3b6y.js";import"./chunk-bhj61bkd.js";var G=null,K;function Y(z){K=z,G=null}async function Z(z,H,F){if(!G)G=J("worker",K);return G.encode(z,H,F)}function _(z="worker",H){let F=J(z,H);return Object.assign((M,N,Q)=>{return F.encode(M,N,Q)},{terminate:async()=>{await F.terminate()}})}export{Z as encode,_ as createWebpEncoder,Y as configureWebpWorker};
2
2
 
3
- //# debugId=90E601329CA59A6864756E2164756E21
3
+ //# debugId=D9A58DF1C7A64D4964756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 with optional AbortSignal.\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker'\n): WebpEncoderFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
5
+ "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global WebP worker URL. Call this before using the encode function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the WebP worker file.\n * In Vite apps, use: new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureWebpWorker, encode } from '@squoosh-kit/webp';\n *\n * // In your Vite app initialization:\n * configureWebpWorker(\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use encode normally:\n * const result = await encode(imageData, { quality: 85 });\n */\nexport function configureWebpWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that encodes an image to WebP format with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const encoder = createWebpEncoder(\n * 'worker',\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await encoder(imageData, { quality: 85 });\n * await encoder.terminate();\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): WebpEncoderFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
6
6
  ],
7
- "mappings": "6GAWA,FAAI,JAA6D,KA+CjE,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,QAAQ,EAG5C,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAWtD,SAAS,CAAiB,CAC/B,EAA4B,SACR,CACpB,IAAM,EAAS,EAAa,CAAI,EAEhC,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
- "debugId": "90E601329CA59A6864756E2164756E21",
7
+ "mappings": "6GAWA,FAAI,JAA6D,KAC7D,EA4CG,SAAS,CAAmB,CAAC,EAAyB,CAC3D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAqBtD,SAAS,CAAiB,CAC/B,EAA4B,SAC5B,EACoB,CACpB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
+ "debugId": "D9A58DF1C7A64D4964756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/index.bun.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{a as E}from"./bridge.bun.js";import"./chunk-m5rj68ef.js";import"./chunk-8y42hv65.js";var z=null;async function I(q,j,y){if(!z)z=E("worker");return z.encode(q,j,y)}function J(q="worker"){let j=E(q);return Object.assign((y,F,G)=>{return j.encode(y,F,G)},{terminate:async()=>{await j.terminate()}})}export{I as encode,J as createWebpEncoder};
2
+ import{a as J}from"./bridge.bun.js";import"./chunk-q0apy7nk.js";import"./chunk-8y42hv65.js";var G=null,K;function Y(z){K=z,G=null}async function Z(z,H,F){if(!G)G=J("worker",K);return G.encode(z,H,F)}function _(z="worker",H){let F=J(z,H);return Object.assign((M,N,Q)=>{return F.encode(M,N,Q)},{terminate:async()=>{await F.terminate()}})}export{Z as encode,_ as createWebpEncoder,Y as configureWebpWorker};
3
3
 
4
- //# debugId=CD24F8BD50B2DFDA64756E2164756E21
4
+ //# debugId=31F2087A3ED1328064756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 with optional AbortSignal.\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker'\n): WebpEncoderFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
5
+ "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global WebP worker URL. Call this before using the encode function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the WebP worker file.\n * In Vite apps, use: new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureWebpWorker, encode } from '@squoosh-kit/webp';\n *\n * // In your Vite app initialization:\n * configureWebpWorker(\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use encode normally:\n * const result = await encode(imageData, { quality: 85 });\n */\nexport function configureWebpWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that encodes an image to WebP format with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const encoder = createWebpEncoder(\n * 'worker',\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await encoder(imageData, { quality: 85 });\n * await encoder.terminate();\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): WebpEncoderFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
6
6
  ],
7
- "mappings": ";wGAWA,FAAI,JAA6D,KA+CjE,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,QAAQ,EAG5C,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAWtD,SAAS,CAAiB,CAC/B,EAA4B,SACR,CACpB,IAAM,EAAS,EAAa,CAAI,EAEhC,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
- "debugId": "CD24F8BD50B2DFDA64756E2164756E21",
7
+ "mappings": ";wGAWA,FAAI,JAA6D,KAC7D,EA4CG,SAAS,CAAmB,CAAC,EAAyB,CAC3D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAqBtD,SAAS,CAAiB,CAC/B,EAA4B,SAC5B,EACoB,CACpB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
+ "debugId": "31F2087A3ED1328064756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/index.d.ts CHANGED
@@ -23,6 +23,25 @@ export type WebpEncoderFactory = ((imageData: ImageInput, options?: EncodeInputO
23
23
  */
24
24
  terminate(): Promise<void>;
25
25
  };
26
+ /**
27
+ * Configure the global WebP worker URL. Call this before using the encode function
28
+ * in environments like Vite where the worker path needs to be explicitly resolved.
29
+ *
30
+ * @param workerUrl - The absolute URL to the WebP worker file.
31
+ * In Vite apps, use: new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href
32
+ *
33
+ * @example
34
+ * import { configureWebpWorker, encode } from '@squoosh-kit/webp';
35
+ *
36
+ * // In your Vite app initialization:
37
+ * configureWebpWorker(
38
+ * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href
39
+ * );
40
+ *
41
+ * // Then use encode normally:
42
+ * const result = await encode(imageData, { quality: 85 });
43
+ */
44
+ export declare function configureWebpWorker(workerUrl: string): void;
26
45
  /**
27
46
  * Encodes an image to WebP format. Uses worker mode for UI responsiveness.
28
47
  *
@@ -51,7 +70,17 @@ export declare function encode(imageData: ImageInput, options?: EncodeInputOptio
51
70
  * creating a new worker or client instance each time.
52
71
  *
53
72
  * @param mode - The execution mode, either 'worker' or 'client'.
73
+ * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.
54
74
  * @returns A function that encodes an image to WebP format with optional AbortSignal.
75
+ *
76
+ * @example
77
+ * // In a Vite app with custom worker URL:
78
+ * const encoder = createWebpEncoder(
79
+ * 'worker',
80
+ * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href
81
+ * );
82
+ * const result = await encoder(imageData, { quality: 85 });
83
+ * await encoder.terminate();
55
84
  */
56
- export declare function createWebpEncoder(mode?: 'worker' | 'client'): WebpEncoderFactory;
85
+ export declare function createWebpEncoder(mode?: 'worker' | 'client', customWorkerUrl?: string): WebpEncoderFactory;
57
86
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;AAK/C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAChC,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG;IAC1B;;;;;;;;;;;OAWG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,MAAM,CAC1B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAOrB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,GAAE,QAAQ,GAAG,QAAmB,GACnC,kBAAkB,CAiBpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;AAM/C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAChC,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG;IAC1B;;;;;;;;;;;OAWG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAI3D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,MAAM,CAC1B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAOrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,GAAE,QAAQ,GAAG,QAAmB,EACpC,eAAe,CAAC,EAAE,MAAM,GACvB,kBAAkB,CAiBpB"}
@@ -1,3 +1,3 @@
1
- var L={};I(L,{encode:()=>J,createWebpEncoder:()=>K});module.exports=H(L);var z=null;async function J(q,j,y){if(!z)z=E("worker");return z.encode(q,j,y)}function K(q="worker"){let j=E(q);return Object.assign((y,F,G)=>{return j.encode(y,F,G)},{terminate:async()=>{await j.terminate()}})}
1
+ var j={};Y(j,{encode:()=>_,createWebpEncoder:()=>$,configureWebpWorker:()=>Z});module.exports=X(j);var G=null,K;function Z(z){K=z,G=null}async function _(z,H,F){if(!G)G=J("worker",K);return G.encode(z,H,F)}function $(z="worker",H){let F=J(z,H);return Object.assign((M,N,Q)=>{return F.encode(M,N,Q)},{terminate:async()=>{await F.terminate()}})}
2
2
 
3
- //# debugId=AC064DDE983490B364756E2164756E21
3
+ //# debugId=0110644BF04FFA1E64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 with optional AbortSignal.\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker'\n): WebpEncoderFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
5
+ "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global WebP worker URL. Call this before using the encode function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the WebP worker file.\n * In Vite apps, use: new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureWebpWorker, encode } from '@squoosh-kit/webp';\n *\n * // In your Vite app initialization:\n * configureWebpWorker(\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use encode normally:\n * const result = await encode(imageData, { quality: 85 });\n */\nexport function configureWebpWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that encodes an image to WebP format with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const encoder = createWebpEncoder(\n * 'worker',\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await encoder(imageData, { quality: 85 });\n * await encoder.terminate();\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): WebpEncoderFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
6
6
  ],
7
- "mappings": "yEAWA,IAAI,EAA6D,KA+CjE,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,QAAQ,EAG5C,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAWtD,SAAS,CAAiB,CAC/B,EAA4B,SACR,CACpB,IAAM,EAAS,EAAa,CAAI,EAEhC,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
- "debugId": "AC064DDE983490B364756E2164756E21",
7
+ "mappings": "mGAWA,IAAI,EAA6D,KAC7D,EA4CG,SAAS,CAAmB,CAAC,EAAyB,CAC3D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAqBtD,SAAS,CAAiB,CAC/B,EAA4B,SAC5B,EACoB,CACpB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
+ "debugId": "0110644BF04FFA1E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,3 +1,3 @@
1
- import{a as E}from"./bridge.node.mjs";import"./chunk-eqkkc09z.js";import"./chunk-c6cx0d7q.js";var z=null;async function I(q,j,y){if(!z)z=E("worker");return z.encode(q,j,y)}function J(q="worker"){let j=E(q);return Object.assign((y,F,G)=>{return j.encode(y,F,G)},{terminate:async()=>{await j.terminate()}})}export{I as encode,J as createWebpEncoder};
1
+ import{a as J}from"./bridge.node.mjs";import"./chunk-szbj3b6y.js";import"./chunk-c6cx0d7q.js";var G=null,K;function Y(z){K=z,G=null}async function Z(z,H,F){if(!G)G=J("worker",K);return G.encode(z,H,F)}function _(z="worker",H){let F=J(z,H);return Object.assign((M,N,Q)=>{return F.encode(M,N,Q)},{terminate:async()=>{await F.terminate()}})}export{Z as encode,_ as createWebpEncoder,Y as configureWebpWorker};
2
2
 
3
- //# debugId=F3256E444F0CF21A64756E2164756E21
3
+ //# debugId=B8E9525FB3FFAABA64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 with optional AbortSignal.\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker'\n): WebpEncoderFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
5
+ "/**\n * @squoosh-kit/webp public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { EncodeInputOptions } from './types';\n\nexport type { ImageInput, EncodeInputOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A WebP image encoder that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type WebpEncoderFactory = ((\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n) => Promise<Uint8Array>) & {\n /**\n * Terminates the encoder and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const encoder = createWebpEncoder('worker');\n * try {\n * const result = await encoder(imageData, options);\n * } finally {\n * await encoder.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global WebP worker URL. Call this before using the encode function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the WebP worker file.\n * In Vite apps, use: new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureWebpWorker, encode } from '@squoosh-kit/webp';\n *\n * // In your Vite app initialization:\n * configureWebpWorker(\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use encode normally:\n * const result = await encode(imageData, { quality: 85 });\n */\nexport function configureWebpWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Encodes an image to WebP format. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to encode.\n * @param options - WebP encoding options.\n * @param signal - (Optional) AbortSignal to cancel the encoding operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the encoded WebP data as a Uint8Array.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await encode(imageData, { quality: 85 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await encode(imageData, { quality: 85 });\n */\nexport async function encode(\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.encode(imageData, options, signal);\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 * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that encodes an image to WebP format with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const encoder = createWebpEncoder(\n * 'worker',\n * new URL('@squoosh-kit/webp/dist/webp.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await encoder(imageData, { quality: 85 });\n * await encoder.terminate();\n */\nexport function createWebpEncoder(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): WebpEncoderFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (\n imageData: ImageInput,\n options?: EncodeInputOptions,\n signal?: AbortSignal\n ) => {\n return bridge.encode(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
6
6
  ],
7
- "mappings": "0GAWA,FAAI,JAA6D,KA+CjE,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,QAAQ,EAG5C,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAWtD,SAAS,CAAiB,CAC/B,EAA4B,SACR,CACpB,IAAM,EAAS,EAAa,CAAI,EAEhC,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
- "debugId": "F3256E444F0CF21A64756E2164756E21",
7
+ "mappings": "0GAWA,FAAI,JAA6D,KAC7D,EA4CG,SAAS,CAAmB,CAAC,EAAyB,CAC3D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAqBtD,SAAS,CAAiB,CAC/B,EAA4B,SAC5B,EACoB,CACpB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CACE,EACA,EACA,IACG,CACH,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
8
+ "debugId": "B8E9525FB3FFAABA64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,4 @@
1
+ import"./chunk-bhj61bkd.js";function r(n){if(n===void 0)return;if(typeof n!=="object"||n===null)throw TypeError("options must be an object or undefined");let t=n;if("quality"in t&&t.quality!==void 0){let e=t.quality;if(Number.isNaN(e))throw RangeError("quality must be a valid number in the range 0-100, got NaN");if(typeof e!=="number")throw TypeError("quality must be a number");if(!Number.isInteger(e))throw RangeError("quality must be an integer in the range 0-100, got floating point");if(e<0||e>100)throw RangeError(`quality must be in the range 0-100, got ${e}`)}}export{r as validateWebpOptions};
2
+ export{r as c};
3
+
4
+ //# debugId=EDB31E336FF05D5064756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/validators.ts"],
4
+ "sourcesContent": [
5
+ "export 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": "4BAAO,SAAS,CAAmB,CACjC,EACwD,CACxD,GAAI,IAAY,OACd,OAGF,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,wCAAwC,EAG9D,IAAM,EAAO,EAEb,GAAI,YAAa,GAAQ,EAAK,UAAY,OAAW,CACnD,IAAM,EAAU,EAAK,QAErB,GAAI,OAAO,MAAM,CAAO,EACtB,MAAU,WACR,4DACF,EAGF,GAAI,OAAO,IAAY,SACrB,MAAU,UAAU,0BAA0B,EAGhD,GAAI,CAAC,OAAO,UAAU,CAAO,EAC3B,MAAU,WACR,mEACF,EAGF,GAAI,EAAU,GAAK,EAAU,IAC3B,MAAU,WACR,2CAA2C,GAC7C",
8
+ "debugId": "EDB31E336FF05D5064756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import"./chunk-8y42hv65.js";function r(n){if(n===void 0)return;if(typeof n!=="object"||n===null)throw TypeError("options must be an object or undefined");let t=n;if("quality"in t&&t.quality!==void 0){let e=t.quality;if(Number.isNaN(e))throw RangeError("quality must be a valid number in the range 0-100, got NaN");if(typeof e!=="number")throw TypeError("quality must be a number");if(!Number.isInteger(e))throw RangeError("quality must be an integer in the range 0-100, got floating point");if(e<0||e>100)throw RangeError(`quality must be in the range 0-100, got ${e}`)}}export{r as validateWebpOptions};
3
+ export{r as c};
4
+
5
+ //# debugId=6C929DA4C7FA5D2564756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/validators.ts"],
4
+ "sourcesContent": [
5
+ "export 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": ";4BAAO,SAAS,CAAmB,CACjC,EACwD,CACxD,GAAI,IAAY,OACd,OAGF,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,wCAAwC,EAG9D,IAAM,EAAO,EAEb,GAAI,YAAa,GAAQ,EAAK,UAAY,OAAW,CACnD,IAAM,EAAU,EAAK,QAErB,GAAI,OAAO,MAAM,CAAO,EACtB,MAAU,WACR,4DACF,EAGF,GAAI,OAAO,IAAY,SACrB,MAAU,UAAU,0BAA0B,EAGhD,GAAI,CAAC,OAAO,UAAU,CAAO,EAC3B,MAAU,WACR,mEACF,EAGF,GAAI,EAAU,GAAK,EAAU,IAC3B,MAAU,WACR,2CAA2C,GAC7C",
8
+ "debugId": "6C929DA4C7FA5D2564756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,2 @@
1
+ export declare function validateWebpOptions(options: unknown): asserts options is Record<string, unknown> | undefined;
2
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAoCxD"}
@@ -0,0 +1,3 @@
1
+ var u={};i(u,{validateWebpOptions:()=>o});module.exports=r(u);function o(n){if(n===void 0)return;if(typeof n!=="object"||n===null)throw TypeError("options must be an object or undefined");let t=n;if("quality"in t&&t.quality!==void 0){let e=t.quality;if(Number.isNaN(e))throw RangeError("quality must be a valid number in the range 0-100, got NaN");if(typeof e!=="number")throw TypeError("quality must be a number");if(!Number.isInteger(e))throw RangeError("quality must be an integer in the range 0-100, got floating point");if(e<0||e>100)throw RangeError(`quality must be in the range 0-100, got ${e}`)}}
2
+
3
+ //# debugId=192485B1EBD2740364756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/validators.ts"],
4
+ "sourcesContent": [
5
+ "export 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": "8DAAO,SAAS,CAAmB,CACjC,EACwD,CACxD,GAAI,IAAY,OACd,OAGF,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,wCAAwC,EAG9D,IAAM,EAAO,EAEb,GAAI,YAAa,GAAQ,EAAK,UAAY,OAAW,CACnD,IAAM,EAAU,EAAK,QAErB,GAAI,OAAO,MAAM,CAAO,EACtB,MAAU,WACR,4DACF,EAGF,GAAI,OAAO,IAAY,SACrB,MAAU,UAAU,0BAA0B,EAGhD,GAAI,CAAC,OAAO,UAAU,CAAO,EAC3B,MAAU,WACR,mEACF,EAGF,GAAI,EAAU,GAAK,EAAU,IAC3B,MAAU,WACR,2CAA2C,GAC7C",
8
+ "debugId": "192485B1EBD2740364756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ import"./chunk-c6cx0d7q.js";function r(n){if(n===void 0)return;if(typeof n!=="object"||n===null)throw TypeError("options must be an object or undefined");let t=n;if("quality"in t&&t.quality!==void 0){let e=t.quality;if(Number.isNaN(e))throw RangeError("quality must be a valid number in the range 0-100, got NaN");if(typeof e!=="number")throw TypeError("quality must be a number");if(!Number.isInteger(e))throw RangeError("quality must be an integer in the range 0-100, got floating point");if(e<0||e>100)throw RangeError(`quality must be in the range 0-100, got ${e}`)}}export{r as validateWebpOptions};
2
+ export{r as c};
3
+
4
+ //# debugId=90FA6CE2E4DE0F5B64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/validators.ts"],
4
+ "sourcesContent": [
5
+ "export 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": "4BAAO,SAAS,CAAmB,CACjC,EACwD,CACxD,GAAI,IAAY,OACd,OAGF,GAAI,OAAO,IAAY,UAAY,IAAY,KAC7C,MAAU,UAAU,wCAAwC,EAG9D,IAAM,EAAO,EAEb,GAAI,YAAa,GAAQ,EAAK,UAAY,OAAW,CACnD,IAAM,EAAU,EAAK,QAErB,GAAI,OAAO,MAAM,CAAO,EACtB,MAAU,WACR,4DACF,EAGF,GAAI,OAAO,IAAY,SACrB,MAAU,UAAU,0BAA0B,EAGhD,GAAI,CAAC,OAAO,UAAU,CAAO,EAC3B,MAAU,WACR,mEACF,EAGF,GAAI,EAAU,GAAK,EAAU,IAC3B,MAAU,WACR,2CAA2C,GAC7C",
8
+ "debugId": "90FA6CE2E4DE0F5B64756E2164756E21",
9
+ "names": []
10
+ }