@keeratita/heic-converter 0.6.1 → 0.6.2-prerelease.1

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.
@@ -0,0 +1 @@
1
+ "use strict";var r="undefined"!=typeof document?document.currentScript:null;module.exports=async function(t={}){var e=t,n=!!globalThis.window,a=!!globalThis.WorkerGlobalScope,i=globalThis.process?.versions?.node&&"renderer"!=globalThis.process?.type;if(i){const{createRequire:t}=await(import("module"));var o=t("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-DRALRKX4.js",document.baseURI).href)}var s,c,f="./this.program",u="undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-DRALRKX4.js",document.baseURI).href,h="";if(i){var l=o("node:fs");u.startsWith("file:")&&(h=o("node:path").dirname(o("node:url").fileURLToPath(u))+"/"),c=r=>(r=y(r)?new URL(r):r,l.readFileSync(r)),s=async(r,t=!0)=>(r=y(r)?new URL(r):r,l.readFileSync(r,t?void 0:"utf8")),process.argv.length>1&&(f=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else if(n||a){try{h=new URL(".",u).href}catch{}a&&(c=r=>{var t=new XMLHttpRequest;return t.open("GET",r,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),s=async r=>{var t=await fetch(r,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)}}var v,p,d=console.log.bind(console),w=console.error.bind(console),g=!1,y=r=>r.startsWith("file://");class m{}class _ extends m{constructor(r){super(),this.excPtr=r}}function b(){if(!p?.buffer?.resizable){var r=er.buffer;p=new Int8Array(r),e.HEAPU8=I=new Uint8Array(r),U=new Uint32Array(r)}}function R(r){throw e.onAbort?.(r),w(r=`Aborted(${r})`),g=!0,r+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(r)}var U,A=r=>{for(;r.length>0;)r.shift()(e)},T=[],C=[],L=r=>Q(r),P=()=>V(),S=[],x=0;class E{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){U[this.ptr+4>>2]=r}get_type(){return U[this.ptr+4>>2]}set_destructor(r){U[this.ptr+8>>2]=r}get_destructor(){return U[this.ptr+8>>2]}set_caught(r){r=r?1:0,p[this.ptr+12]=r}get_caught(){return 0!=p[this.ptr+12]}set_rethrown(r){r=r?1:0,p[this.ptr+13]=r}get_rethrown(){return 0!=p[this.ptr+13]}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){U[this.ptr+16>>2]=r}get_adjusted_ptr(){return U[this.ptr+16>>2]}}var I,F=null,k=r=>J(r),j=r=>{var t=F?.excPtr;if(!t)return k(0),0;var e=new E(t);e.set_adjusted_ptr(t);var n=e.get_type();if(!n)return k(0),t;for(var a of r){if(!a||a===n)break;var i=e.ptr+16;if(rr(a,n,i))return k(a),t}return k(n),t},M=r=>{throw r},W=(r,t)=>Math.ceil(r/t)*t,D=r=>{var t=(r-er.buffer.byteLength+65535)/65536|0;try{return er.grow(t),b(),1}catch(r){}},N={},q=()=>{if(!q.strings){var r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:f};for(var t in N)void 0===N[t]?delete r[t]:r[t]=N[t];var e=[];for(var t in r)e.push(`${t}=${r[t]}`);q.strings=e}return q.strings},G=(r,t,e)=>((r,t,e,n)=>{for(var a=e,i=e+n-1,o=0;o<r.length;++o){var s=r.codePointAt(o);if(s<=127){if(e>=i)break;t[e++]=s}else if(s<=2047){if(e+1>=i)break;t[e++]=192|s>>6,t[e++]=128|63&s}else if(s<=65535){if(e+2>=i)break;t[e++]=224|s>>12,t[e++]=128|s>>6&63,t[e++]=128|63&s}else{if(e+3>=i)break;t[e++]=240|s>>18,t[e++]=128|s>>12&63,t[e++]=128|s>>6&63,t[e++]=128|63&s,o++}}return t[e]=0,e-a})(r,I,t,e),H=r=>{for(var t=0,e=0;e<r.length;++e){var n=r.charCodeAt(e);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++e):t+=3}return t},$=[null,[],[]],B=globalThis.TextDecoder&&new TextDecoder,K=(r,t)=>{var e=$[r];t&&10!==t?e.push(t):((1===r?d:w)(((r,t=0)=>{var e=((r,t)=>{for(var e=t+void 0;r[t]&&!(t>=e);)++t;return t})(r,t);if(e-t>16&&r.buffer&&B)return B.decode(r.subarray(t,e));for(var n="";t<e;){var a=r[t++];if(128&a){var i=63&r[t++];if(192!=(224&a)){var o=63&r[t++];if((a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&r[t++])<65536)n+=String.fromCharCode(a);else{var s=a-65536;n+=String.fromCharCode(55296|s>>10,56320|1023&s)}}else n+=String.fromCharCode((31&a)<<6|i)}else n+=String.fromCharCode(a)}return n})(e)),e.length=0)},O=[],X=r=>{var t=O[r];return t||(O[r]=t=nr.get(r)),t};e.noExitRuntime&&e.noExitRuntime,e.print&&(d=e.print),e.printErr&&(w=e.printErr),e.arguments&&e.arguments,e.thisProgram&&(f=e.thisProgram);var z,J,Q,V,Y,Z,rr,tr,er,nr,ar=e.preInit;if(ar)for("function"==typeof ar&&(e.preInit=ar=[ar]);ar.length>0;)ar.shift()();var ir,or={j:r=>{var t=new E(r);return t.get_caught()||(t.set_caught(!0),x--),t.set_rethrown(!1),S.push(t),tr(r)},l:()=>{z(0,0);var r=S.pop();Y(r.excPtr),F=null},a:()=>j([]),b:r=>j([r]),u:()=>{S.length||R("no exception to throw");var r=S.at(-1),t=r.excPtr;r.set_rethrown(!0),r.set_caught(!1),x++,Z(t),t=F=new _(t),M(t)},h:(r,t,e)=>{new E(r).init(t,e),Z(r),r=F=new _(r),x++,M(r)},t:()=>x,e:r=>{(r=>{throw r})(r=F??=new _(r))},w:()=>{},y:()=>R(""),n:function(r){try{e.__progressCb&&e.__progressCb(r)}catch(r){}},v:r=>{var t=I.length,e=2147483648;if((r>>>=0)>e)return!1;for(var n=1;n<=4;n*=2){var a=t*(1+.2/n);a=Math.min(a,r+100663296);var i=Math.min(e,W(Math.max(r,a),65536));if(D(i))return!0}return!1},A:(r,t)=>{var e=0,n=0;for(var a of q()){var i=t+e;U[r+n>>2]=i,e+=G(a,i,1/0)+1,n+=4}return 0},B:(r,t)=>{var e=q();U[r>>2]=e.length;var n=0;for(var a of e)n+=H(a)+1;return U[t>>2]=n,0},x:()=>52,z:function(r,t){return 70},o:(r,t,e,n)=>{for(var a=0,i=0;i<e;i++){var o=U[t>>2],s=U[t+4>>2];t+=8;for(var c=0;c<s;c++)K(r,I[o+c]);a+=s}return U[n>>2]=a,0},d:function(r,t){var e=P();try{return X(r)(t)}catch(r){if(L(e),!(r instanceof m))throw r;z(1,0)}},c:function(r,t,e){var n=P();try{return X(r)(t,e)}catch(r){if(L(n),!(r instanceof m))throw r;z(1,0)}},i:function(r,t,e,n){var a=P();try{return X(r)(t,e,n)}catch(r){if(L(a),!(r instanceof m))throw r;z(1,0)}},q:function(r,t,e,n,a){var i=P();try{return X(r)(t,e,n,a)}catch(r){if(L(i),!(r instanceof m))throw r;z(1,0)}},m:function(r,t,e,n,a,i){var o=P();try{return X(r)(t,e,n,a,i)}catch(r){if(L(o),!(r instanceof m))throw r;z(1,0)}},s:function(r,t,e,n,a,i){var o=P();try{return X(r)(t,e,n,a,i)}catch(r){if(L(o),!(r instanceof m))throw r;z(1,0)}},k:function(r){var t=P();try{X(r)()}catch(r){if(L(t),!(r instanceof m))throw r;z(1,0)}},C:function(r,t){var e=P();try{X(r)(t)}catch(r){if(L(e),!(r instanceof m))throw r;z(1,0)}},g:function(r,t){var e=P();try{X(r)(t)}catch(r){if(L(e),!(r instanceof m))throw r;z(1,0)}},f:function(r,t,e){var n=P();try{X(r)(t,e)}catch(r){if(L(n),!(r instanceof m))throw r;z(1,0)}},r:function(r,t,e,n){var a=P();try{X(r)(t,e,n)}catch(r){if(L(a),!(r instanceof m))throw r;z(1,0)}},p:function(r,t,e,n,a){var i=P();try{X(r)(t,e,n,a)}catch(r){if(L(i),!(r instanceof m))throw r;z(1,0)}},D:function(r,t,e){var n=P();try{X(r)(t,e)}catch(r){if(L(n),!(r instanceof m))throw r;z(1,0)}}};return ir=await async function(){function t(r){var t;return t=ir=r.exports,e._heic_decode=t.G,e._heic_result_free=t.H,e._free=t.J,e._malloc=t.K,z=t.L,J=t.M,Q=t.N,V=t.O,Y=t.P,Z=t.Q,rr=t.R,tr=t.S,er=t.E,nr=t.I,b(),ir}var n,a={a:or},o=e.instantiateWasm;return o?new Promise(r=>{o(a,e=>r(t(e)))}):(v??=e.locateFile?(n="heic-decoder.wasm",e.locateFile?e.locateFile(n,h):h+n):new URL("heic-decoder.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("heic-decoder-DRALRKX4.js",document.baseURI).href).href,t((await async function(r,t,e){if(!i)try{var n=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,e)}catch(r){w(`wasm streaming compile failed: ${r}`),w("falling back to ArrayBuffer instantiation")}return async function(r,t){try{var e=await async function(r){try{var t=await s(r);return new Uint8Array(t)}catch{}return function(r){if(c)return c(r);throw"both async and sync fetching of the wasm failed"}(r)}(r);return await WebAssembly.instantiate(e,t)}catch(r){w(`failed to asynchronously prepare wasm: ${r}`),R(r)}}(t,e)}(0,v,a)).instance))}(),await async function(){var r;(r=e.preRun)&&("function"==typeof r&&(r=[r]),C.push(...r)),A(C);var t,n=e.setStatus;n&&(n("Running..."),await new Promise(r=>setTimeout(r,1)),setTimeout(n,1,"")),g||(ir.F(),e.onRuntimeInitialized?.(),(t=e.postRun)&&("function"==typeof t&&(t=[t]),T.push(...t)),A(T))}(),e};
@@ -0,0 +1 @@
1
+ var r=async function(r={}){var t=r,e=!!globalThis.window,n=!!globalThis.WorkerGlobalScope,a=globalThis.process?.versions?.node&&"renderer"!=globalThis.process?.type;if(a){const{createRequire:r}=await(import("module"));var i=r(import.meta.url)}var o,s,c="./this.program",f=import.meta.url,u="";if(a){var h=i("node:fs");f.startsWith("file:")&&(u=i("node:path").dirname(i("node:url").fileURLToPath(f))+"/"),s=r=>(r=d(r)?new URL(r):r,h.readFileSync(r)),o=async(r,t=!0)=>(r=d(r)?new URL(r):r,h.readFileSync(r,t?void 0:"utf8")),process.argv.length>1&&(c=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else if(e||n){try{u=new URL(".",f).href}catch{}n&&(s=r=>{var t=new XMLHttpRequest;return t.open("GET",r,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),o=async r=>{var t=await fetch(r,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)}}var l,v,p=console.log.bind(console),w=console.error.bind(console),g=!1,d=r=>r.startsWith("file://");class y{}class m extends y{constructor(r){super(),this.excPtr=r}}function _(){if(!v?.buffer?.resizable){var r=tr.buffer;v=new Int8Array(r),t.HEAPU8=L=new Uint8Array(r),A=new Uint32Array(r)}}function b(r){throw t.onAbort?.(r),w(r=`Aborted(${r})`),g=!0,r+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(r)}var A,R=r=>{for(;r.length>0;)r.shift()(t)},T=[],x=[],P=r=>Q(r),S=()=>X(),C=[],E=0;class U{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){A[this.ptr+4>>2]=r}get_type(){return A[this.ptr+4>>2]}set_destructor(r){A[this.ptr+8>>2]=r}get_destructor(){return A[this.ptr+8>>2]}set_caught(r){r=r?1:0,v[this.ptr+12]=r}get_caught(){return 0!=v[this.ptr+12]}set_rethrown(r){r=r?1:0,v[this.ptr+13]=r}get_rethrown(){return 0!=v[this.ptr+13]}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){A[this.ptr+16>>2]=r}get_adjusted_ptr(){return A[this.ptr+16>>2]}}var L,k=null,M=r=>K(r),W=r=>{var t=k?.excPtr;if(!t)return M(0),0;var e=new U(t);e.set_adjusted_ptr(t);var n=e.get_type();if(!n)return M(0),t;for(var a of r){if(!a||a===n)break;var i=e.ptr+16;if(Z(a,n,i))return M(a),t}return M(n),t},F=r=>{throw r},I=(r,t)=>Math.ceil(r/t)*t,j=r=>{var t=(r-tr.buffer.byteLength+65535)/65536|0;try{return tr.grow(t),_(),1}catch(r){}},G={},H=()=>{if(!H.strings){var r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:c};for(var t in G)void 0===G[t]?delete r[t]:r[t]=G[t];var e=[];for(var t in r)e.push(`${t}=${r[t]}`);H.strings=e}return H.strings},$=(r,t,e)=>((r,t,e,n)=>{for(var a=e,i=e+n-1,o=0;o<r.length;++o){var s=r.codePointAt(o);if(s<=127){if(e>=i)break;t[e++]=s}else if(s<=2047){if(e+1>=i)break;t[e++]=192|s>>6,t[e++]=128|63&s}else if(s<=65535){if(e+2>=i)break;t[e++]=224|s>>12,t[e++]=128|s>>6&63,t[e++]=128|63&s}else{if(e+3>=i)break;t[e++]=240|s>>18,t[e++]=128|s>>12&63,t[e++]=128|s>>6&63,t[e++]=128|63&s,o++}}return t[e]=0,e-a})(r,L,t,e),B=r=>{for(var t=0,e=0;e<r.length;++e){var n=r.charCodeAt(e);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++e):t+=3}return t},D=[null,[],[]],N=globalThis.TextDecoder&&new TextDecoder,O=(r,t)=>{var e=D[r];t&&10!==t?e.push(t):((1===r?p:w)(((r,t=0)=>{var e=((r,t)=>{for(var e=t+void 0;r[t]&&!(t>=e);)++t;return t})(r,t);if(e-t>16&&r.buffer&&N)return N.decode(r.subarray(t,e));for(var n="";t<e;){var a=r[t++];if(128&a){var i=63&r[t++];if(192!=(224&a)){var o=63&r[t++];if((a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&r[t++])<65536)n+=String.fromCharCode(a);else{var s=a-65536;n+=String.fromCharCode(55296|s>>10,56320|1023&s)}}else n+=String.fromCharCode((31&a)<<6|i)}else n+=String.fromCharCode(a)}return n})(e)),e.length=0)},q=[],z=r=>{var t=q[r];return t||(q[r]=t=er.get(r)),t};t.noExitRuntime&&t.noExitRuntime,t.print&&(p=t.print),t.printErr&&(w=t.printErr),t.arguments&&t.arguments,t.thisProgram&&(c=t.thisProgram);var J,K,Q,X,V,Y,Z,rr,tr,er,nr=t.preInit;if(nr)for("function"==typeof nr&&(t.preInit=nr=[nr]);nr.length>0;)nr.shift()();var ar,ir={j:r=>{var t=new U(r);return t.get_caught()||(t.set_caught(!0),E--),t.set_rethrown(!1),C.push(t),rr(r)},l:()=>{J(0,0);var r=C.pop();V(r.excPtr),k=null},a:()=>W([]),b:r=>W([r]),u:()=>{C.length||b("no exception to throw");var r=C.at(-1),t=r.excPtr;r.set_rethrown(!0),r.set_caught(!1),E++,Y(t),t=k=new m(t),F(t)},h:(r,t,e)=>{new U(r).init(t,e),Y(r),r=k=new m(r),E++,F(r)},t:()=>E,e:r=>{(r=>{throw r})(r=k??=new m(r))},w:()=>{},y:()=>b(""),n:function(r){try{t.__progressCb&&t.__progressCb(r)}catch(r){}},v:r=>{var t=L.length,e=2147483648;if((r>>>=0)>e)return!1;for(var n=1;n<=4;n*=2){var a=t*(1+.2/n);a=Math.min(a,r+100663296);var i=Math.min(e,I(Math.max(r,a),65536));if(j(i))return!0}return!1},A:(r,t)=>{var e=0,n=0;for(var a of H()){var i=t+e;A[r+n>>2]=i,e+=$(a,i,1/0)+1,n+=4}return 0},B:(r,t)=>{var e=H();A[r>>2]=e.length;var n=0;for(var a of e)n+=B(a)+1;return A[t>>2]=n,0},x:()=>52,z:function(r,t){return 70},o:(r,t,e,n)=>{for(var a=0,i=0;i<e;i++){var o=A[t>>2],s=A[t+4>>2];t+=8;for(var c=0;c<s;c++)O(r,L[o+c]);a+=s}return A[n>>2]=a,0},d:function(r,t){var e=S();try{return z(r)(t)}catch(r){if(P(e),!(r instanceof y))throw r;J(1,0)}},c:function(r,t,e){var n=S();try{return z(r)(t,e)}catch(r){if(P(n),!(r instanceof y))throw r;J(1,0)}},i:function(r,t,e,n){var a=S();try{return z(r)(t,e,n)}catch(r){if(P(a),!(r instanceof y))throw r;J(1,0)}},q:function(r,t,e,n,a){var i=S();try{return z(r)(t,e,n,a)}catch(r){if(P(i),!(r instanceof y))throw r;J(1,0)}},m:function(r,t,e,n,a,i){var o=S();try{return z(r)(t,e,n,a,i)}catch(r){if(P(o),!(r instanceof y))throw r;J(1,0)}},s:function(r,t,e,n,a,i){var o=S();try{return z(r)(t,e,n,a,i)}catch(r){if(P(o),!(r instanceof y))throw r;J(1,0)}},k:function(r){var t=S();try{z(r)()}catch(r){if(P(t),!(r instanceof y))throw r;J(1,0)}},C:function(r,t){var e=S();try{z(r)(t)}catch(r){if(P(e),!(r instanceof y))throw r;J(1,0)}},g:function(r,t){var e=S();try{z(r)(t)}catch(r){if(P(e),!(r instanceof y))throw r;J(1,0)}},f:function(r,t,e){var n=S();try{z(r)(t,e)}catch(r){if(P(n),!(r instanceof y))throw r;J(1,0)}},r:function(r,t,e,n){var a=S();try{z(r)(t,e,n)}catch(r){if(P(a),!(r instanceof y))throw r;J(1,0)}},p:function(r,t,e,n,a){var i=S();try{z(r)(t,e,n,a)}catch(r){if(P(i),!(r instanceof y))throw r;J(1,0)}},D:function(r,t,e){var n=S();try{z(r)(t,e)}catch(r){if(P(n),!(r instanceof y))throw r;J(1,0)}}};return ar=await async function(){function r(r){var e;return e=ar=r.exports,t._heic_decode=e.G,t._heic_result_free=e.H,t._free=e.J,t._malloc=e.K,J=e.L,K=e.M,Q=e.N,X=e.O,V=e.P,Y=e.Q,Z=e.R,rr=e.S,tr=e.E,er=e.I,_(),ar}var e,n={a:ir},i=t.instantiateWasm;return i?new Promise(t=>{i(n,e=>t(r(e)))}):(l??=t.locateFile?(e="heic-decoder.wasm",t.locateFile?t.locateFile(e,u):u+e):new URL("heic-decoder.wasm",import.meta.url).href,r((await async function(r,t,e){if(!a)try{var n=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,e)}catch(r){w(`wasm streaming compile failed: ${r}`),w("falling back to ArrayBuffer instantiation")}return async function(r,t){try{var e=await async function(r){try{var t=await o(r);return new Uint8Array(t)}catch{}return function(r){if(s)return s(r);throw"both async and sync fetching of the wasm failed"}(r)}(r);return await WebAssembly.instantiate(e,t)}catch(r){w(`failed to asynchronously prepare wasm: ${r}`),b(r)}}(t,e)}(0,l,n)).instance))}(),await async function(){var r;(r=t.preRun)&&("function"==typeof r&&(r=[r]),x.push(...r)),R(x);var e,n=t.setStatus;n&&(n("Running..."),await new Promise(r=>setTimeout(r,1)),setTimeout(n,1,"")),g||(ar.F(),t.onRuntimeInitialized?.(),(e=t.postRun)&&("function"==typeof e&&(e=[e]),T.push(...e)),R(T))}(),t};export{r as default};
Binary file
Binary file
Binary file
@@ -0,0 +1,566 @@
1
+ interface DecodedImage {
2
+ width: number;
3
+ height: number;
4
+ /**
5
+ * RGBA pixel data, interleaved, row-major, 4 bytes per pixel. Always a
6
+ * plain `ArrayBuffer` owned by the returned array — never a WASM-heap
7
+ * view — so it stays valid after `LibheifDecoder.free()` and passes
8
+ * directly to `new ImageData(...)` / `putImageData`, including the
9
+ * `ImageData` overload that requires `Uint8ClampedArray<ArrayBuffer>`
10
+ * under TS >= 5.7.
11
+ */
12
+ data: Uint8ClampedArray;
13
+ /**
14
+ * Raw EXIF block copied from the source file, normalized to the JPEG APP1
15
+ * payload form: `"Exif\0\0"` followed by the TIFF structure. Present
16
+ * whenever the file carries an Exif item — including files where libheif
17
+ * already applied `irot`/`imir` (reported independently of
18
+ * {@link DecodedImage.orientation}). `convertHeic` re-injects it into
19
+ * JPEG (APP1) and PNG (`eXIf`) output when `preserveExif: true`;
20
+ * raw-decode consumers can attach it to their own encoder output (e.g.
21
+ * `sharp`'s `.withMetadata({ exif })`). Owned by the returned object,
22
+ * never a WASM-heap view.
23
+ */
24
+ exif?: Uint8Array;
25
+ /**
26
+ * EXIF orientation of the **stored** pixels (1–8, EXIF tag 274 semantics;
27
+ * 1 = upright). Absent or 1 means no rotation is pending. libheif applies
28
+ * `irot`/`imir` container transforms at decode — for those files this is
29
+ * 1 and the pixels are upright. A value > 1 means the orientation comes
30
+ * only from the Exif item: `convertHeic` applies it automatically unless
31
+ * `applyOrientation: false`; raw `decode()` consumers get stored pixels
32
+ * and must apply it themselves. Decoders that do not report orientation
33
+ * may omit this field.
34
+ */
35
+ orientation?: number;
36
+ }
37
+ /**
38
+ * Decoder contract used by {@link ConvertOptions.decoder} /
39
+ * {@link ConvertManyOptions.decoder} and implemented by `LibheifDecoder`.
40
+ *
41
+ * Lifecycle rules followed by the library (implementations may rely on them):
42
+ * - `initialize()` is called before every `decode()`; repeated/concurrent
43
+ * calls must be cheap (e.g. memoize the load promise).
44
+ * - `decode()` is awaited before the library calls `free()`; the returned
45
+ * `DecodedImage` must therefore not reference decoder-owned memory that
46
+ * `free()` releases (copy pixels out, as `LibheifDecoder` does).
47
+ * - `free()` is called at most once per conversion. Decoders **injected**
48
+ * via options are never freed by the library — the caller owns their
49
+ * lifetime.
50
+ *
51
+ * Concurrency: with `convertMany`, a single injected decoder is shared by
52
+ * all concurrent conversions, so `decode()` must be safe to call concurrently
53
+ * on one instance (no shared mutable state across in-flight decodes).
54
+ */
55
+ interface IHeicDecoder {
56
+ /** Initializes the decoder (e.g. loading the WebAssembly module). */
57
+ initialize(): Promise<void>;
58
+ /**
59
+ * Decodes HEIC binary data into raw RGBA pixel data; `onProgress`
60
+ * receives the progress percentage.
61
+ */
62
+ decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>;
63
+ /** Cleans up allocated resources. Idempotent: safe to call multiple times. */
64
+ free(): void;
65
+ }
66
+ type ImageFormat = 'jpeg' | 'jpg' | 'png' | 'svg' | 'webp' | 'avif';
67
+ /**
68
+ * Formats accepted by {@link ConvertOptions.to} (case-insensitive).
69
+ * `'jpg'` is an alias of `'jpeg'`. `'avif'` requires an environment whose
70
+ * canvas can encode AVIF (Chromium/Firefox today); elsewhere it rejects with
71
+ * `format_unsupported`.
72
+ */
73
+ declare const SUPPORTED_FORMATS: readonly ImageFormat[];
74
+ /** Default encoding quality used when `quality` is not provided. */
75
+ declare const DEFAULT_QUALITY = 0.92;
76
+ /**
77
+ * Accepted input for every convert entry point. `ArrayBufferView` is a
78
+ * declared (tested) surface: `DataView` and non-Uint8 typed arrays are read
79
+ * as raw bytes via byteOffset/byteLength, SharedArrayBuffer-backed views
80
+ * included. Cross-realm Blob-likes (anything exposing `arrayBuffer()`, e.g.
81
+ * a Blob from another frame) are accepted at runtime even though
82
+ * `instanceof Blob` cannot see them.
83
+ */
84
+ type HeicInput = Blob | ArrayBuffer | ArrayBufferView;
85
+ /**
86
+ * How {@link convertHeic} returns the converted image.
87
+ * - `'blob'` — a `Blob` (the default; browser-native, works everywhere)
88
+ * - `'dataUrl'` — a `data:image/...;base64,…` string (previews, `<img src>`)
89
+ * - `'arrayBuffer'` — raw bytes (uploads, WebCodecs, Node-friendly transfer)
90
+ */
91
+ type OutputShape = 'blob' | 'dataUrl' | 'arrayBuffer';
92
+ /** Resolved return type of `convertHeic`/`convertMany` for an output shape. */
93
+ type ConvertResult<S extends OutputShape> = S extends 'dataUrl' ? string : S extends 'arrayBuffer' ? ArrayBuffer : Blob;
94
+ /** Crop rectangle in **post-orientation display pixels** (top-left origin). */
95
+ interface CropOptions {
96
+ /** Left edge of the crop box. @default 0 */
97
+ x?: number;
98
+ /** Top edge of the crop box. @default 0 */
99
+ y?: number;
100
+ /** Crop width in pixels. Must be a positive integer and fit inside the image. */
101
+ width: number;
102
+ /** Crop height in pixels. Must be a positive integer and fit inside the image. */
103
+ height: number;
104
+ }
105
+ /** Per-item outcome when `continueOnError: true`. */
106
+ type ConvertItemResult<T = Blob> = {
107
+ index: number;
108
+ ok: true;
109
+ result: T;
110
+ } | {
111
+ index: number;
112
+ ok: false;
113
+ error: Error;
114
+ };
115
+ interface ResizeOptions {
116
+ /**
117
+ * Maximum width in pixels; downscaled to fit while preserving the aspect
118
+ * ratio. Images smaller than the bound are never upscaled.
119
+ */
120
+ maxWidth?: number;
121
+ /**
122
+ * Maximum height in pixels; downscaled to fit while preserving the aspect
123
+ * ratio. Images smaller than the bound are never upscaled.
124
+ */
125
+ maxHeight?: number;
126
+ /**
127
+ * Uniform scale factor for both dimensions (e.g. 0.5 halves the image).
128
+ * Takes precedence over `maxWidth`/`maxHeight` when set.
129
+ */
130
+ scale?: number;
131
+ }
132
+ interface ConvertOptions extends ResizeOptions {
133
+ /**
134
+ * Target format; must be one of {@link SUPPORTED_FORMATS}. An unknown
135
+ * value is rejected up front, before the input is decoded.
136
+ * @default 'jpeg'
137
+ */
138
+ to?: ImageFormat;
139
+ /**
140
+ * Quality between 0.0 and 1.0 (inclusive). Applies to `'jpeg'`, `'jpg'`,
141
+ * `'webp'` and `'avif'` but is validated for every format: an out-of-range
142
+ * value (e.g. `90` from a 0-100 scale) throws regardless of `to`.
143
+ * @default 0.92
144
+ */
145
+ quality?: number;
146
+ /**
147
+ * Custom decoder to inject; a default `LibheifDecoder` is used otherwise.
148
+ * The library never calls `free()` on an injected decoder.
149
+ */
150
+ decoder?: IHeicDecoder;
151
+ /**
152
+ * Progress callback receiving percentages normalized and clamped to
153
+ * 0–100; the final 100% is emitted only when the conversion succeeds. A
154
+ * callback that throws rejects the conversion with
155
+ * `progress_callback_failed`.
156
+ */
157
+ onProgress?: (percent: number) => void;
158
+ /**
159
+ * Rotate/flip the output to match the source's EXIF orientation, applied
160
+ * as a canvas transform during rendering; `irot`/`imir` container
161
+ * transforms are already applied by the decoder and never stacked on top.
162
+ * `false` keeps the exact stored-pixel geometry. A non-boolean value is
163
+ * rejected up front with `invalid_input`.
164
+ * @default true
165
+ */
166
+ applyOrientation?: boolean;
167
+ /**
168
+ * Representation of the converted image. See {@link OutputShape}.
169
+ * @default 'blob'
170
+ */
171
+ output?: OutputShape;
172
+ /**
173
+ * Cancels the conversion at stage boundaries (input read, decoder init,
174
+ * before/after decode, before encode). `convertHeicInWorker` aborts
175
+ * immediately by terminating the worker; the synchronous WASM decode
176
+ * itself cannot be preempted mid-call. An aborted signal rejects with
177
+ * code `aborted`.
178
+ */
179
+ signal?: AbortSignal;
180
+ /**
181
+ * Crop rectangle in post-orientation display pixels (the geometry the
182
+ * image will be displayed in). Applied before resize: `scale`/`maxWidth`/
183
+ * `maxHeight` then downscale the cropped region. Out-of-bounds crops
184
+ * reject with `invalid_crop`.
185
+ */
186
+ crop?: CropOptions;
187
+ /**
188
+ * Copy the source HEIC's EXIF block into JPEG (APP1) and PNG (`eXIf`
189
+ * chunk) output so converted files keep camera metadata (orientation, GPS,
190
+ * timestamps). This **preserves private data** like GPS — set
191
+ * deliberately. Ignored for `webp`/`svg` output.
192
+ * @default false
193
+ */
194
+ preserveExif?: boolean;
195
+ /**
196
+ * Decode with the platform's native HEIC stack (`createImageBitmap` on
197
+ * Safari/iOS, Edge, Windows) instead of the bundled libheif WASM decoder,
198
+ * skipping its ~300 KB payload. Hosts without native HEIC support fall
199
+ * back to libheif on the same conversion; the refusal is cached per realm.
200
+ * Ignored (libheif used) with an injected `decoder`, `preserveExif: true`
201
+ * or `applyOrientation: false`. Native output is upright and progress
202
+ * fires only at completion (tile progress is a libheif feature).
203
+ * @default false
204
+ */
205
+ nativeDecode?: boolean;
206
+ }
207
+ interface ConvertManyOptions extends Omit<ConvertOptions, 'onProgress'> {
208
+ /**
209
+ * Maximum number of conversions running concurrently.
210
+ * @default 4
211
+ */
212
+ concurrency?: number;
213
+ /**
214
+ * Progress callback receiving the 0-based item index and its percentage
215
+ * (normalized to 0–100) during decoding.
216
+ */
217
+ onProgress?: (index: number, percent: number) => void;
218
+ /**
219
+ * Custom decoder to inject; the same instance is shared by all concurrent
220
+ * conversions, so it must be safe for concurrent `decode()` calls (see
221
+ * {@link IHeicDecoder}). A fresh default `LibheifDecoder` is created per
222
+ * item otherwise.
223
+ */
224
+ decoder?: IHeicDecoder;
225
+ /**
226
+ * Resolve with `ConvertItemResult[]` in input order instead of rejecting
227
+ * the whole batch on the first failure; all items run to completion.
228
+ * Up-front option validation failures still reject normally (a typo is a
229
+ * caller bug, not an item failure).
230
+ * @default false
231
+ */
232
+ continueOnError?: boolean;
233
+ /**
234
+ * Reuse one library-owned `LibheifDecoder` per concurrent runner across
235
+ * items instead of creating (and WASM-initializing) a fresh instance per
236
+ * item — amortizes the module load in large batches while preserving the
237
+ * exclusive-use invariant (an instance is only ever held by one runner,
238
+ * never decodes concurrently). Ignored when `decoder` is injected.
239
+ * @default false
240
+ */
241
+ reuseDecoders?: boolean;
242
+ }
243
+
244
+ interface LibheifDecoderOptions {
245
+ /**
246
+ * Custom WASM file locator, for serving the binary from a custom route or CDN.
247
+ */
248
+ locateFile?: (path: string, prefix: string) => string;
249
+ /**
250
+ * Raw WASM binary, used instead of fetching the file. Accepts an
251
+ * `ArrayBuffer` or any `ArrayBufferView` (e.g. a Node.js `Buffer` from
252
+ * `fs.readFileSync`).
253
+ */
254
+ wasmBinary?: ArrayBuffer | ArrayBufferView;
255
+ /**
256
+ * Advanced: extra properties merged into the Emscripten module argument
257
+ * object (e.g. `instantiateWasm` for streaming compilation). Prefer
258
+ * `locateFile`/`wasmBinary` for the common cases; keys must not collide
259
+ * with them.
260
+ */
261
+ moduleOverrides?: Record<string, unknown>;
262
+ }
263
+ declare class LibheifDecoder implements IHeicDecoder {
264
+ private options?;
265
+ private module;
266
+ private initPromise;
267
+ private initGeneration;
268
+ constructor(options?: LibheifDecoderOptions);
269
+ /**
270
+ * Initializes the WebAssembly module (the raw C-ABI decoder surface).
271
+ * Safe to call concurrently: the module is loaded at most once per instance.
272
+ */
273
+ initialize(): Promise<void>;
274
+ /**
275
+ * Decodes HEIC binary data into raw RGBA pixel data.
276
+ * @param onProgress Optional progress callback; receives percentages
277
+ * normalized and clamped to 0-100.
278
+ */
279
+ decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>;
280
+ /**
281
+ * Cleans up the WebAssembly decoder resources. Idempotent. After `free()`,
282
+ * the next `initialize()` — or `decode()` directly, which re-initializes
283
+ * transparently — loads a fresh module. Safe during an in-flight
284
+ * `initialize()`: a load completing after `free()` discards itself instead
285
+ * of resurrecting state.
286
+ */
287
+ free(): void;
288
+ }
289
+
290
+ interface WorkerConvertOptions extends Omit<ConvertOptions, 'decoder'> {
291
+ /**
292
+ * URL of the worker script. Should be a compile-time constant (e.g.
293
+ * `new URL('./worker.js', import.meta.url)` under a bundler); the script
294
+ * runs with the page's privileges.
295
+ */
296
+ workerUrl: string | URL;
297
+ /**
298
+ * Milliseconds to wait for the worker result before rejecting with a
299
+ * timeout. Queueing for a free worker slot counts toward this. Defaults to
300
+ * 60000; 0 disables the timeout.
301
+ */
302
+ timeoutMs?: number;
303
+ /**
304
+ * Worker script type. Use `'module'` when the script uses ES module
305
+ * imports (e.g. `import { convertHeic } from ...`); `'classic'`
306
+ * scripts must be pre-bundled.
307
+ * @default 'classic'
308
+ */
309
+ workerType?: 'classic' | 'module';
310
+ /**
311
+ * Upper bound on simultaneously live workers for this worker script; calls
312
+ * beyond the bound queue until a slot frees, keeping bulk conversions from
313
+ * exhausting memory or the browser's worker limit. Must be an integer from
314
+ * 1 to 64 — each worker is a full WASM boot with its own heap, so an
315
+ * unbounded value is a page-taking-down footgun, not capacity. Defaults to
316
+ * `navigator.hardwareConcurrency` clamped to 1–8.
317
+ */
318
+ maxConcurrentWorkers?: number;
319
+ }
320
+ interface CorrelatedMessage {
321
+ id: number;
322
+ }
323
+ /** Progress message a worker script posts to report decode progress. */
324
+ interface WorkerProgressMessage extends CorrelatedMessage {
325
+ type: 'progress';
326
+ percent: number;
327
+ }
328
+ /** Result message a worker script posts to settle a conversion. */
329
+ interface WorkerResultMessage extends CorrelatedMessage {
330
+ type: 'result';
331
+ ok: boolean;
332
+ /**
333
+ * The converted image as `convertHeic` returned it inside the worker:
334
+ * `Blob`, data-URL string, or `ArrayBuffer`. The field name `blob` is kept
335
+ * for protocol compatibility.
336
+ */
337
+ blob?: Blob | string | ArrayBuffer;
338
+ error?: string;
339
+ }
340
+ /**
341
+ * Options for {@link convertManyInWorker}: the {@link convertHeicInWorker}
342
+ * worker options plus the batch semantics of `convertMany`.
343
+ */
344
+ interface WorkerBatchOptions extends Omit<WorkerConvertOptions, 'onProgress'> {
345
+ /**
346
+ * Per-item progress callback: receives the 0-based item index and its
347
+ * progress percentage (normalized 0–100). Values below 100 may also be
348
+ * reported for items that ultimately fail; the 100% event fires only for
349
+ * items that succeed.
350
+ */
351
+ onProgress?: (index: number, percent: number) => void;
352
+ /**
353
+ * Resolve with per-item results instead of rejecting the batch on the
354
+ * first failure; all items run to completion (see
355
+ * `ConvertManyOptions.continueOnError`).
356
+ * @default false
357
+ */
358
+ continueOnError?: boolean;
359
+ }
360
+
361
+ /**
362
+ * Stable, machine-readable error codes attached to every error the library
363
+ * throws (as `HeicConverterError.code`). Codes are part of the public API:
364
+ * they are additive-only and never repurposed, so callers can branch on
365
+ * `error.code` instead of matching on message strings.
366
+ */
367
+ type HeicConverterErrorCode = 'invalid_input' | 'invalid_quality' | 'invalid_resize' | 'invalid_format' | 'invalid_crop' | 'invalid_concurrency' | 'decoder_init_failed' | 'decode_failed' | 'progress_callback_failed' | 'render_encode_failed' | 'unsupported_environment' | 'format_unsupported' | 'aborted' | 'worker_unsupported' | 'worker_load_failed' | 'worker_create_failed' | 'worker_post_failed' | 'worker_failed' | 'worker_timeout' | 'batch_item_failed';
368
+ /**
369
+ * Error thrown by all first-party code paths. Extends `Error` so existing
370
+ * `instanceof Error` / message-based handling keeps working; the `code`
371
+ * (and, for batch failures, `itemIndex`/`itemTotal`/`failedCount`) fields
372
+ * add a structured discriminator without changing message text.
373
+ */
374
+ declare class HeicConverterError extends Error {
375
+ readonly code: HeicConverterErrorCode;
376
+ /** 0-based index of the failing input. Only set on `batch_item_failed` errors. */
377
+ readonly itemIndex?: number;
378
+ /** Total number of inputs in the batch. Only set on `batch_item_failed` errors. */
379
+ readonly itemTotal?: number;
380
+ /** How many items failed overall. Only set on `batch_item_failed` errors. */
381
+ readonly failedCount?: number;
382
+ constructor(code: HeicConverterErrorCode, message: string, options?: {
383
+ cause?: unknown;
384
+ itemIndex?: number;
385
+ itemTotal?: number;
386
+ failedCount?: number;
387
+ });
388
+ }
389
+
390
+ /**
391
+ * Converts a HEIC image inside a Web Worker so the main thread stays responsive
392
+ * during the (potentially slow) WASM decode. The implementation lives in
393
+ * `src/worker.ts`, fetched as a lazy chunk on the first call — a deployment
394
+ * missing that chunk rejects with `worker_load_failed` (original failure on
395
+ * `cause`) rather than a raw module-load error.
396
+ *
397
+ * The worker script is user-provided and must handle the following message
398
+ * protocol (types are exported as {@link WorkerProgressMessage} and
399
+ * {@link WorkerResultMessage}); the canonical reference implementation is
400
+ * `docs/worker.js`, and this example is kept byte-equal to it (modulo the
401
+ * import specifier) by `test/unit/docs-sync.test.ts`:
402
+ *
403
+ * ```js
404
+ * // converter.worker.js
405
+ * import { convertHeic } from '@keeratita/heic-converter';
406
+ *
407
+ * self.onmessage = async (event) => {
408
+ * const { id, input, options } = event.data;
409
+ * try {
410
+ * const blob = await convertHeic(input, {
411
+ * ...options,
412
+ * onProgress: (percent) => self.postMessage({ id, type: 'progress', percent }),
413
+ * });
414
+ * // With output: 'arrayBuffer' the payload is zero-copy via a transfer list.
415
+ * self.postMessage(
416
+ * { id, type: 'result', ok: true, blob },
417
+ * blob instanceof ArrayBuffer ? [blob] : []
418
+ * );
419
+ * } catch (error) {
420
+ * self.postMessage({ id, type: 'result', ok: false, error: error?.stack ?? error?.message ?? String(error) });
421
+ * }
422
+ * };
423
+ * ```
424
+ *
425
+ * ```ts
426
+ * const jpegBlob = await convertHeicInWorker(heicBlob, {
427
+ * workerUrl: new URL('./converter.worker.js', import.meta.url),
428
+ * workerType: 'module',
429
+ * to: 'jpeg',
430
+ * });
431
+ * ```
432
+ *
433
+ * Only `progress` and `result` messages are understood; any other message type
434
+ * is ignored (the first unknown type is reported in the timeout diagnostic).
435
+ * Use `workerType: 'module'` when the script uses ES module imports (as above);
436
+ * `'classic'` scripts must be pre-bundled, since static ES imports are not
437
+ * supported there.
438
+ *
439
+ * Notes that are easy to trip over:
440
+ * - `decoder` is rejected — class instances cannot cross the worker boundary,
441
+ * so the worker creates its own.
442
+ * - `timeoutMs` is a per-call deadline that **includes queueing** for a free
443
+ * worker slot, not just the conversion itself.
444
+ * - An error raised *inside* the worker comes back stringified under
445
+ * `worker_failed`: the numeric `code` does not survive the boundary, so match
446
+ * on the message. Option validation happens here instead, so an invalid
447
+ * option keeps its own code.
448
+ * - Workers are pooled per `workerUrl`, so concurrent callers to the same URL
449
+ * share one bounded set rather than spawning unbounded workers.
450
+ *
451
+ * @param input HEIC image as a Blob (incl. File), ArrayBuffer, or ArrayBufferView
452
+ * (typed array or DataView).
453
+ * @param options Conversion options plus the worker script URL.
454
+ * @returns The converted image as a Blob, data URL string, or ArrayBuffer
455
+ * depending on `options.output` (default Blob).
456
+ */
457
+ declare function convertHeicInWorker<S extends OutputShape = 'blob'>(input: HeicInput, options: WorkerConvertOptions & {
458
+ output?: S;
459
+ }): Promise<ConvertResult<S>>;
460
+ /**
461
+ * Converts multiple HEIC images inside Web Workers, mirroring {@link convertMany}
462
+ * semantics (input order, bounded concurrency, `batch_item_failed` aggregation
463
+ * or `continueOnError` per-item results). Concurrency is bounded by
464
+ * `maxConcurrentWorkers` (default `navigator.hardwareConcurrency` clamped to
465
+ * 1–8), so a large batch never exhausts memory or the browser's worker limit;
466
+ * workers are pooled per `workerUrl`, so items reuse live instances instead
467
+ * of paying boot per item (the script must stay alive across requests — see
468
+ * the protocol above). Runs via {@link convertHeicInWorker}: `decoder` cannot
469
+ * be injected and `workerUrl` is required — see it for the protocol and the
470
+ * `timeoutMs`, worker-boundary, and `worker_load_failed` caveats.
471
+ *
472
+ * ```ts
473
+ * const blobs = await convertManyInWorker(heicFiles, {
474
+ * workerUrl: new URL('./converter.worker.js', import.meta.url),
475
+ * workerType: 'module',
476
+ * to: 'webp',
477
+ * continueOnError: true, // get per-item results instead of batch rejection
478
+ * });
479
+ * ```
480
+ *
481
+ * Overloads must mirror `convertManyInWorker` in `src/worker.ts`: the deferred
482
+ * call below erases the union, so drift here is a public typing bug that `tsc`,
483
+ * the unit tests and the bundle guard all fail to catch.
484
+ *
485
+ * @param inputs HEIC images as Blobs (incl. Files), ArrayBuffers, or ArrayBufferViews.
486
+ * @param options Batch + worker conversion options (see {@link WorkerBatchOptions}).
487
+ * @returns The converted images in input order, or per-item result entries
488
+ * when `continueOnError: true`.
489
+ */
490
+ declare function convertManyInWorker<S extends OutputShape = 'blob'>(inputs: HeicInput[], options: WorkerBatchOptions & {
491
+ output?: S;
492
+ continueOnError: true;
493
+ }): Promise<ConvertItemResult<ConvertResult<S>>[]>;
494
+ declare function convertManyInWorker<S extends OutputShape = 'blob'>(inputs: HeicInput[], options: WorkerBatchOptions & {
495
+ output?: S;
496
+ continueOnError?: false;
497
+ }): Promise<ConvertResult<S>[]>;
498
+ declare function convertManyInWorker<S extends OutputShape = 'blob'>(inputs: HeicInput[], options: WorkerBatchOptions & {
499
+ output?: S;
500
+ continueOnError: boolean;
501
+ }): Promise<Array<ConvertResult<S> | ConvertItemResult<ConvertResult<S>>>>;
502
+
503
+ /**
504
+ * Releases any cached decoder resources.
505
+ *
506
+ * Decoders are now created and released per conversion, so there is no shared
507
+ * instance to free. This function is kept for API compatibility.
508
+ */
509
+ declare function freeSharedDecoder(): void;
510
+ /**
511
+ * Converts HEIC image data to a standard web format (JPEG, PNG, WebP, AVIF,
512
+ * or SVG).
513
+ *
514
+ * @param input HEIC image as a Blob (incl. File), ArrayBuffer, or ArrayBufferView
515
+ * (typed array or DataView).
516
+ * @param options Conversion configuration options (see {@link ConvertOptions}).
517
+ * @returns The converted image as a Blob, data URL string, or ArrayBuffer
518
+ * depending on `options.output` (default Blob).
519
+ * @throws HeicConverterError with a machine-readable `code`:
520
+ * `invalid_input` (unsupported input type or option value),
521
+ * `invalid_quality`, `invalid_resize`, `invalid_crop`,
522
+ * `invalid_format` (unknown `to` value), `decoder_init_failed` (WASM
523
+ * module could not load), `decode_failed` (invalid/corrupt HEIC),
524
+ * `unsupported_environment` (no canvas APIs — e.g. Node.js, where raw RGBA
525
+ * decoding via `LibheifDecoder` is the supported path),
526
+ * `format_unsupported` (environment cannot encode the format, e.g. AVIF
527
+ * in Safari), `aborted` (`options.signal` aborted), or
528
+ * `render_encode_failed`.
529
+ */
530
+ declare function convertHeic<S extends OutputShape = 'blob'>(input: HeicInput, options?: ConvertOptions & {
531
+ output?: S;
532
+ }): Promise<ConvertResult<S>>;
533
+ /**
534
+ * Converts multiple HEIC images to a standard web format.
535
+ *
536
+ * Conversions run with a bounded concurrency (default 4) and results are
537
+ * returned in the same order as the inputs. By default, if any conversion
538
+ * fails, the returned promise rejects as soon as the failure is known
539
+ * (in-flight conversions are allowed to finish in the background) with a
540
+ * `batch_item_failed` HeicConverterError carrying `itemIndex`, `itemTotal`,
541
+ * and `failedCount` — a batch is all-or-nothing. With
542
+ * `options.continueOnError: true` the promise instead fulfills with
543
+ * per-item `ConvertItemResult` entries and all items run to completion
544
+ * (a mid-batch abort completes not-yet-started items with `aborted`
545
+ * entries instead of launching them).
546
+ *
547
+ * @param inputs HEIC images as Blobs (incl. Files), ArrayBuffers, or ArrayBufferViews.
548
+ * @param options Batch conversion options (see {@link ConvertManyOptions}).
549
+ * @returns The converted images in input order: results array by default,
550
+ * or per-item result entries when `continueOnError: true`.
551
+ */
552
+ declare function convertMany<S extends OutputShape = 'blob'>(inputs: HeicInput[], options: ConvertManyOptions & {
553
+ output?: S;
554
+ continueOnError: true;
555
+ }): Promise<ConvertItemResult<ConvertResult<S>>[]>;
556
+ declare function convertMany<S extends OutputShape = 'blob'>(inputs: HeicInput[], options?: ConvertManyOptions & {
557
+ output?: S;
558
+ continueOnError?: false;
559
+ }): Promise<ConvertResult<S>[]>;
560
+ declare function convertMany<S extends OutputShape = 'blob'>(inputs: HeicInput[], options: ConvertManyOptions & {
561
+ output?: S;
562
+ continueOnError: boolean;
563
+ }): Promise<Array<ConvertResult<S> | ConvertItemResult<ConvertResult<S>>>>;
564
+
565
+ export { DEFAULT_QUALITY, HeicConverterError, LibheifDecoder, SUPPORTED_FORMATS, convertHeic, convertHeicInWorker, convertMany, convertManyInWorker, freeSharedDecoder };
566
+ export type { ConvertItemResult, ConvertManyOptions, ConvertOptions, ConvertResult, CropOptions, DecodedImage, HeicConverterErrorCode, HeicInput, IHeicDecoder, ImageFormat, LibheifDecoderOptions, OutputShape, ResizeOptions, WorkerBatchOptions, WorkerConvertOptions, WorkerProgressMessage, WorkerResultMessage };