@keeratita/heic-converter 0.6.2-prerelease → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-6XIPSRPS.js +1 -0
- package/dist/chunk-N2LCVW2Q.js +1 -1
- package/dist/exif-H2Q7BO7Y.js +1 -1
- package/dist/heic-decoder-LWGIYGE3.js +1 -0
- package/dist/heic-decoder-ZFSRP4EX.mjs +1 -0
- package/dist/heic-decoder.wasm +0 -0
- package/dist/heic-decoder.wasm.br +0 -0
- package/dist/heic-decoder.wasm.gz +0 -0
- package/dist/index.d.mts +566 -0
- package/dist/index.d.ts +412 -30
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/native-JFFONPCS.js +1 -1
- package/dist/worker-4HVYKWRG.js +1 -0
- package/dist/{worker-VA6WQF25.mjs → worker-N6W3ASWN.mjs} +1 -1
- package/package.json +5 -5
- package/dist/batch.d.ts +0 -27
- package/dist/chunk-TND3VERK.js +0 -1
- package/dist/errors.d.ts +0 -28
- package/dist/heic-decoder-2EERQO7N.js +0 -1
- package/dist/heic-decoder-IZMSMJZ7.mjs +0 -1
- package/dist/messages/core.d.ts +0 -60
- package/dist/messages/worker.d.ts +0 -33
- package/dist/progress.d.ts +0 -39
- package/dist/render/canvas.d.ts +0 -71
- package/dist/render/exif.d.ts +0 -37
- package/dist/types.d.ts +0 -257
- package/dist/validate.d.ts +0 -59
- package/dist/wasm/fault.d.ts +0 -3
- package/dist/wasm/index.d.ts +0 -1
- package/dist/wasm/native.d.ts +0 -46
- package/dist/wasm/wrapper.d.ts +0 -61
- package/dist/worker-DISSAV3W.js +0 -1
- package/dist/worker.d.ts +0 -128
- /package/dist/{chunk-BTAX2PFV.mjs → chunk-GR5XSYDQ.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require("./chunk-6XIPSRPS.js"),r=require("./chunk-N2LCVW2Q.js"),t="Web Worker is not supported in the current environment",o="The decoder option is not supported by convertHeicInWorker: the worker creates its own decoder (functions and class instances cannot cross the worker boundary). Use convertHeic with an injected decoder instead.",s=e=>"Worker failed"+(void 0!==e?` (could not load worker script at ${String(e)}; check the path resolves and the script is served as JavaScript, e.g. Content-Type: text/javascript)`:"");function n(t){if(void 0!==t&&(!Number.isInteger(t)||t<1||t>e.MAX_BATCH_CONCURRENCY))throw new r.HeicConverterError("invalid_concurrency",(o=t,`maxConcurrentWorkers must be an integer between 1 and ${e.MAX_BATCH_CONCURRENCY}, got: ${o}`));var o}function i(e){if(void 0!==e&&("number"!=typeof e||!Number.isFinite(e)||e<0))throw new r.HeicConverterError("invalid_input",`timeoutMs must be a finite number >= 0 (0 disables the timeout), got: ${e}`)}function a(){const e="undefined"!=typeof navigator&&"number"==typeof navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;return Math.max(1,Math.min(e,8))}var d=new Map,c=1;function u(e,r,t){let o=d.get(e);o||(o={active:0,waiters:[],parked:[]},d.set(e,o));const s={granted:!1,released:!1},n=()=>{0===o.active&&0===o.waiters.length&&(0!==o.parked.length?o.idleTimer=setTimeout(()=>{o.idleTimer=void 0;for(const e of o.parked.splice(0))e.terminate();d.delete(e)},5e3):d.delete(e))},i=e=>{if(!s.released)if(s.released=!0,e&&(o.parked.length>=2&&o.parked.shift().terminate(),o.parked.push(e)),s.granted){s.granted=!1,o.active-=1;const e=o.waiters.shift();e?e():n()}else{const e=o.waiters.indexOf(a);-1!==e&&o.waiters.splice(e,1),n()}},a=()=>{s.released||(void 0!==o.idleTimer&&(clearTimeout(o.idleTimer),o.idleTimer=void 0),s.granted=!0,o.active+=1,t(i,o.parked.pop()))};return o.active<r?a():o.waiters.push(a),i}var l={reserveWorkerSlot:u,workerSlots:d,defaultMaxWorkers:a,WORKER_POOL_IDLE_MS:5e3,MAX_PARKED_WORKERS:2};function p(a,d){return new Promise((l,p)=>{if("undefined"==typeof Worker)return void p(new r.HeicConverterError("worker_unsupported",t));if(void 0!==d.decoder)return void p(new r.HeicConverterError("invalid_input",o));try{e.validateConvertOptions(d),n(d?.maxConcurrentWorkers),i(d?.timeoutMs)}catch(e){return void p(e)}if(d.signal?.aborted)return void p(new r.HeicConverterError("aborted",e.Messages.Aborted));const m={progressMessages:0},g=c++,f=e.progressGateFor(d.onProgress);let w,k,h,y=!1,C=!1;const E=(e=!1)=>{y||(y=!0,void 0!==k&&clearTimeout(k),d.signal?.removeEventListener("abort",b),w&&(w.removeEventListener("message",T),w.removeEventListener("messageerror",$),w.removeEventListener("error",P)),e&&w?h?.(w):(w?.terminate(),h?.()))},b=()=>{E(),p(new r.HeicConverterError("aborted",e.Messages.Aborted))};d.signal?.addEventListener("abort",b,{once:!0});const W=d.timeoutMs??6e4,M=Date.now();let _;W>0&&(k=setTimeout(()=>{E(),p(new r.HeicConverterError("worker_timeout",((e,r)=>{if(void 0===r.startedAt)return`Web Worker conversion timed out after ${e}ms before a worker slot was granted — the deadline was spent waiting behind other conversions (timeoutMs includes queue wait). Raise maxConcurrentWorkers or timeoutMs, or set timeoutMs to 0 to disable the timeout.`;const t=[`${r.progressMessages} progress message(s) received`];return void 0!==r.queueWaitMs&&r.queueWaitMs>0&&t.unshift(`started after ${r.queueWaitMs}ms queued`),void 0!==r.lastPercent&&t.push(`last percent ${r.lastPercent}`),void 0!==r.unknownType&&t.push(`last unknown message type '${r.unknownType}' (worker may not implement the progress/result protocol)`),void 0!==r.staleResults&&t.push(`${r.staleResults} result(s) ignored for not echoing the request id (duplicate or stale replies must not be posted)`),void 0!==r.staleProgress&&t.push(`${r.staleProgress} progress message(s) ignored for not echoing the request id`),r.adopted&&t.push("lease adopted from the pool — a script that calls self.close() after replying stalls adopted leases"),void 0!==r.workerUrl&&t.push(`worker ${String(r.workerUrl)}`),`Web Worker conversion timed out after ${e}ms (${t.join("; ")}). Increase timeoutMs for large images, set timeoutMs to 0 to disable the timeout, and verify the worker script implements the { id, type: "progress" | "result" } protocol.`})(W,{progressMessages:m.progressMessages,lastPercent:m.lastPercent,unknownType:m.unknownType,staleResults:m.staleResults,staleProgress:m.staleProgress,adopted:C,workerUrl:d.workerUrl,startedAt:_,queueWaitMs:void 0===_?void 0:_-M})))},W));const T=t=>{const o=t.data;if("progress"===o?.type){if(o.id!==g)return void(m.staleProgress=(m.staleProgress??0)+1);m.progressMessages+=1;const r=e.clampPercent(o.percent);if(m.lastPercent=r,r>=100)return;f?.report(r);const t=f?.pendingError();return void(t&&(E(),p(t)))}if("result"!==o?.type)return void("string"==typeof o?.type&&(m.unknownType=o.type));if(o.id!==g)return void(m.staleResults=(m.staleResults??0)+1);const s=!0===o.ok&&void 0!==o.blob;if(E(s),s){try{f?.complete()}catch(e){return void p(e)}l(o.blob)}else p(new r.HeicConverterError("worker_failed",o.error??"Worker conversion failed"))},P=e=>{E();const t=e.filename?` (${e.filename}:${e.lineno})`:"";p(new r.HeicConverterError("worker_failed",`${e.message||s(d.workerUrl)}${t}`))},$=e=>{E();const t=e.data;p(new r.HeicConverterError("worker_failed",t instanceof Error?t.message:void 0!==t?String(t):s(d.workerUrl),{cause:t}))},{workerUrl:H,onProgress:R,timeoutMs:x,workerType:A,maxConcurrentWorkers:O,signal:S,...L}=d,q=`${String(H)}|${d.workerType??"classic"}`,U=v(d.maxConcurrentWorkers);h=u(q,U,(e,t)=>{if(h=e,y)t?.terminate();else{_=Date.now(),C=void 0!==t;try{w=t??new Worker(H,"module"===d.workerType?{type:"module"}:void 0)}catch(e){return E(),void p(new r.HeicConverterError("worker_create_failed",(o=e instanceof Error?e.message:String(e),`Failed to create Web Worker: ${o}`),{cause:e}))}w.addEventListener("message",T),w.addEventListener("messageerror",$),w.addEventListener("error",P);try{w.postMessage({id:g,input:a,options:L})}catch(e){E(),p(new r.HeicConverterError("worker_post_failed",(e=>`Failed to post message to Web Worker: ${e}`)(e instanceof Error?e.message:String(e)),{cause:e}))}}var o})})}function v(e){return"number"==typeof e&&Number.isInteger(e)?Math.max(1,e):a()}exports.__resetWorkerPool=function(){for(const e of d.values()){void 0!==e.idleTimer&&(clearTimeout(e.idleTimer),e.idleTimer=void 0);for(const r of e.parked.splice(0))r.terminate()}d.clear()},exports.__semaphoreTestHooks=l,exports.convertHeicInWorker=p,exports.convertManyInWorker=async function(s,a){if(!Array.isArray(s))throw new r.HeicConverterError("invalid_input",e.Messages.InputsMustBeArray);if("undefined"==typeof Worker)throw new r.HeicConverterError("worker_unsupported",t);if(void 0!==a.decoder)throw new r.HeicConverterError("invalid_input",o);e.validateConvertOptions(a),e.validateBatchOptions(a),n(a.maxConcurrentWorkers),i(a.timeoutMs);const{onProgress:d,continueOnError:c,...u}=a,l=e.progressCallbackFor(d);return e.runBoundedBatch(s,v(a.maxConcurrentWorkers),(e,r)=>p(e,{...u,...l?{onProgress:e=>l(r,e)}:{}}),{continueOnError:!0===a.continueOnError,signal:a.signal})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{validateConvertOptions as e,Messages as r,progressGateFor as t,validateBatchOptions as o,progressCallbackFor as s,runBoundedBatch as n,MAX_BATCH_CONCURRENCY as i,clampPercent as a}from"./chunk-
|
|
1
|
+
import{validateConvertOptions as e,Messages as r,progressGateFor as t,validateBatchOptions as o,progressCallbackFor as s,runBoundedBatch as n,MAX_BATCH_CONCURRENCY as i,clampPercent as a}from"./chunk-GR5XSYDQ.mjs";import{HeicConverterError as d}from"./chunk-AROQBV5T.mjs";var u="Web Worker is not supported in the current environment",l="The decoder option is not supported by convertHeicInWorker: the worker creates its own decoder (functions and class instances cannot cross the worker boundary). Use convertHeic with an injected decoder instead.",c=e=>"Worker failed"+(void 0!==e?` (could not load worker script at ${String(e)}; check the path resolves and the script is served as JavaScript, e.g. Content-Type: text/javascript)`:"");function p(e){if(void 0!==e&&(!Number.isInteger(e)||e<1||e>i))throw new d("invalid_concurrency",`maxConcurrentWorkers must be an integer between 1 and ${i}, got: ${e}`)}function m(e){if(void 0!==e&&("number"!=typeof e||!Number.isFinite(e)||e<0))throw new d("invalid_input",`timeoutMs must be a finite number >= 0 (0 disables the timeout), got: ${e}`)}function g(){const e="undefined"!=typeof navigator&&"number"==typeof navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;return Math.max(1,Math.min(e,8))}var v=new Map,f=1;function w(e,r,t){let o=v.get(e);o||(o={active:0,waiters:[],parked:[]},v.set(e,o));const s={granted:!1,released:!1},n=()=>{0===o.active&&0===o.waiters.length&&(0!==o.parked.length?o.idleTimer=setTimeout(()=>{o.idleTimer=void 0;for(const e of o.parked.splice(0))e.terminate();v.delete(e)},5e3):v.delete(e))},i=e=>{if(!s.released)if(s.released=!0,e&&(o.parked.length>=2&&o.parked.shift().terminate(),o.parked.push(e)),s.granted){s.granted=!1,o.active-=1;const e=o.waiters.shift();e?e():n()}else{const e=o.waiters.indexOf(a);-1!==e&&o.waiters.splice(e,1),n()}},a=()=>{s.released||(void 0!==o.idleTimer&&(clearTimeout(o.idleTimer),o.idleTimer=void 0),s.granted=!0,o.active+=1,t(i,o.parked.pop()))};return o.active<r?a():o.waiters.push(a),i}var k={reserveWorkerSlot:w,workerSlots:v,defaultMaxWorkers:g,WORKER_POOL_IDLE_MS:5e3,MAX_PARKED_WORKERS:2};function h(){for(const e of v.values()){void 0!==e.idleTimer&&(clearTimeout(e.idleTimer),e.idleTimer=void 0);for(const r of e.parked.splice(0))r.terminate()}v.clear()}function y(o,s){return new Promise((n,i)=>{if("undefined"==typeof Worker)return void i(new d("worker_unsupported",u));if(void 0!==s.decoder)return void i(new d("invalid_input",l));try{e(s),p(s?.maxConcurrentWorkers),m(s?.timeoutMs)}catch(e){return void i(e)}if(s.signal?.aborted)return void i(new d("aborted",r.Aborted));const g={progressMessages:0},v=f++,k=t(s.onProgress);let h,y,W,M=!1,T=!1;const $=(e=!1)=>{M||(M=!0,void 0!==y&&clearTimeout(y),s.signal?.removeEventListener("abort",_),h&&(h.removeEventListener("message",x),h.removeEventListener("messageerror",A),h.removeEventListener("error",S)),e&&h?W?.(h):(h?.terminate(),W?.()))},_=()=>{$(),i(new d("aborted",r.Aborted))};s.signal?.addEventListener("abort",_,{once:!0});const E=s.timeoutMs??6e4,P=Date.now();let R;E>0&&(y=setTimeout(()=>{$(),i(new d("worker_timeout",((e,r)=>{if(void 0===r.startedAt)return`Web Worker conversion timed out after ${e}ms before a worker slot was granted — the deadline was spent waiting behind other conversions (timeoutMs includes queue wait). Raise maxConcurrentWorkers or timeoutMs, or set timeoutMs to 0 to disable the timeout.`;const t=[`${r.progressMessages} progress message(s) received`];return void 0!==r.queueWaitMs&&r.queueWaitMs>0&&t.unshift(`started after ${r.queueWaitMs}ms queued`),void 0!==r.lastPercent&&t.push(`last percent ${r.lastPercent}`),void 0!==r.unknownType&&t.push(`last unknown message type '${r.unknownType}' (worker may not implement the progress/result protocol)`),void 0!==r.staleResults&&t.push(`${r.staleResults} result(s) ignored for not echoing the request id (duplicate or stale replies must not be posted)`),void 0!==r.staleProgress&&t.push(`${r.staleProgress} progress message(s) ignored for not echoing the request id`),r.adopted&&t.push("lease adopted from the pool — a script that calls self.close() after replying stalls adopted leases"),void 0!==r.workerUrl&&t.push(`worker ${String(r.workerUrl)}`),`Web Worker conversion timed out after ${e}ms (${t.join("; ")}). Increase timeoutMs for large images, set timeoutMs to 0 to disable the timeout, and verify the worker script implements the { id, type: "progress" | "result" } protocol.`})(E,{progressMessages:g.progressMessages,lastPercent:g.lastPercent,unknownType:g.unknownType,staleResults:g.staleResults,staleProgress:g.staleProgress,adopted:T,workerUrl:s.workerUrl,startedAt:R,queueWaitMs:void 0===R?void 0:R-P})))},E));const x=e=>{const r=e.data;if("progress"===r?.type){if(r.id!==v)return void(g.staleProgress=(g.staleProgress??0)+1);g.progressMessages+=1;const e=a(r.percent);if(g.lastPercent=e,e>=100)return;k?.report(e);const t=k?.pendingError();return void(t&&($(),i(t)))}if("result"!==r?.type)return void("string"==typeof r?.type&&(g.unknownType=r.type));if(r.id!==v)return void(g.staleResults=(g.staleResults??0)+1);const t=!0===r.ok&&void 0!==r.blob;if($(t),t){try{k?.complete()}catch(e){return void i(e)}n(r.blob)}else i(new d("worker_failed",r.error??"Worker conversion failed"))},S=e=>{$();const r=e.filename?` (${e.filename}:${e.lineno})`:"";i(new d("worker_failed",`${e.message||c(s.workerUrl)}${r}`))},A=e=>{$();const r=e.data;i(new d("worker_failed",r instanceof Error?r.message:void 0!==r?String(r):c(s.workerUrl),{cause:r}))},{workerUrl:C,onProgress:L,timeoutMs:O,workerType:q,maxConcurrentWorkers:U,signal:I,...j}=s,D=`${String(C)}|${s.workerType??"classic"}`,F=b(s.maxConcurrentWorkers);W=w(D,F,(e,r)=>{if(W=e,M)r?.terminate();else{R=Date.now(),T=void 0!==r;try{h=r??new Worker(C,"module"===s.workerType?{type:"module"}:void 0)}catch(e){return $(),void i(new d("worker_create_failed",(t=e instanceof Error?e.message:String(e),`Failed to create Web Worker: ${t}`),{cause:e}))}h.addEventListener("message",x),h.addEventListener("messageerror",A),h.addEventListener("error",S);try{h.postMessage({id:v,input:o,options:j})}catch(e){$(),i(new d("worker_post_failed",(e=>`Failed to post message to Web Worker: ${e}`)(e instanceof Error?e.message:String(e)),{cause:e}))}}var t})})}function b(e){return"number"==typeof e&&Number.isInteger(e)?Math.max(1,e):g()}async function W(t,i){if(!Array.isArray(t))throw new d("invalid_input",r.InputsMustBeArray);if("undefined"==typeof Worker)throw new d("worker_unsupported",u);if(void 0!==i.decoder)throw new d("invalid_input",l);e(i),o(i),p(i.maxConcurrentWorkers),m(i.timeoutMs);const{onProgress:a,continueOnError:c,...g}=i,v=s(a);return n(t,b(i.maxConcurrentWorkers),(e,r)=>y(e,{...g,...v?{onProgress:e=>v(r,e)}:{}}),{continueOnError:!0===i.continueOnError,signal:i.signal})}export{h as __resetWorkerPool,k as __semaphoreTestHooks,y as convertHeicInWorker,W as convertManyInWorker};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keeratita/heic-converter",
|
|
3
|
-
"version": "0.6.2
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Convert HEIC images to standard web formats (JPEG, PNG, WebP, AVIF, SVG) without breaking CSP",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"node": ">=20.0.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "tsup &&
|
|
29
|
+
"build": "tsup && node build-scripts/compress-wasm.mjs",
|
|
30
30
|
"build:wasm": "bash build-scripts/build-wasm.sh",
|
|
31
31
|
"verify:wasm": "node build-scripts/verify-wasm-artifacts.mjs",
|
|
32
32
|
"wasm:hashes": "node build-scripts/verify-wasm-artifacts.mjs --write",
|
|
@@ -80,15 +80,15 @@
|
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@eslint/js": "^10.0.1",
|
|
82
82
|
"@types/node": "^26.6.5",
|
|
83
|
-
"@vitest/coverage-v8": "^5.0
|
|
83
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
84
84
|
"eslint": "^10.12.0",
|
|
85
85
|
"globals": "^17.13.0",
|
|
86
86
|
"husky": "^9.1.7",
|
|
87
87
|
"playwright": "^1.64.0",
|
|
88
88
|
"terser": "^5.51.2",
|
|
89
|
-
"tsup": "^
|
|
89
|
+
"tsup": "^9.0.0",
|
|
90
90
|
"typescript": "^6.0.3",
|
|
91
91
|
"typescript-eslint": "^8.71.1",
|
|
92
|
-
"vitest": "^5.0
|
|
92
|
+
"vitest": "^5.1.0"
|
|
93
93
|
}
|
|
94
94
|
}
|
package/dist/batch.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ConvertItemResult } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Shared bounded-concurrency batch runner backing both `convertMany` and
|
|
4
|
-
* `convertManyInWorker`. Semantics (documented on the public APIs):
|
|
5
|
-
*
|
|
6
|
-
* - Items are processed in input order by at most `concurrency` runners.
|
|
7
|
-
* - Default mode rejects with `batch_item_failed` as soon as the first
|
|
8
|
-
* failure is known; in-flight items settle in the background. The error
|
|
9
|
-
* names the first failing item and carries `itemIndex`/`itemTotal`/
|
|
10
|
-
* `failedCount`, plus up to two extra distinct failure messages.
|
|
11
|
-
* - `continueOnError` mode never rejects for item failures and never stops
|
|
12
|
-
* launching items: it fulfills with per-item results in input order.
|
|
13
|
-
* - Up-front failures thrown by `convertItem` synchronously (none today)
|
|
14
|
-
* propagate untouched.
|
|
15
|
-
*/
|
|
16
|
-
export declare function runBoundedBatch<T>(inputs: readonly unknown[], concurrency: number, convertItem: (input: unknown, index: number) => Promise<T>, options: {
|
|
17
|
-
continueOnError: true;
|
|
18
|
-
signal?: AbortSignal;
|
|
19
|
-
}): Promise<ConvertItemResult<T>[]>;
|
|
20
|
-
export declare function runBoundedBatch<T>(inputs: readonly unknown[], concurrency: number, convertItem: (input: unknown, index: number) => Promise<T>, options?: {
|
|
21
|
-
continueOnError?: false;
|
|
22
|
-
signal?: AbortSignal;
|
|
23
|
-
}): Promise<T[]>;
|
|
24
|
-
export declare function runBoundedBatch<T>(inputs: readonly unknown[], concurrency: number, convertItem: (input: unknown, index: number) => Promise<T>, options: {
|
|
25
|
-
continueOnError: boolean;
|
|
26
|
-
signal?: AbortSignal;
|
|
27
|
-
}): Promise<Array<T | ConvertItemResult<T>>>;
|
package/dist/chunk-TND3VERK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-N2LCVW2Q.js"),r={QualityInvalid:e=>`Quality must be a number between 0.0 and 1.0, got: ${e}`,BooleanOptionInvalid:(e,r)=>`${e} must be a boolean, got: ${r}`,UnsupportedInputType:e=>`Unsupported input type. Expected Blob (incl. File), ArrayBuffer, or ArrayBufferView. Got: ${e}`,DecoderInitFailed:e=>`Failed to initialize HEIC decoder: ${e} — verify heic-decoder.wasm is served (dist/heic-decoder.wasm; see the README "Serving and Locating WASM" section / locateFile option) and that your CSP allows 'wasm-unsafe-eval'`,WorkerChunkLoadFailed:e=>`Failed to load the Web Worker implementation chunk (dist/worker-*.mjs): ${e} — deploy every file in dist/ together, or use convertHeic to convert in the current thread`,NativeChunkLoadWarning:e=>`@keeratita/heic-converter: the native-decode chunk could not be loaded (${e}) — converting with the bundled decoder; serve every file in dist/ together, with dist/native-*.mjs as JavaScript`,RenderEncodeFailed:(e,r)=>`Failed to render and encode image as ${e}: ${r}`,ConcurrencyInvalid:(e,r)=>`Concurrency must be an integer between 1 and ${r}, got: ${e}`,InputsMustBeArray:"Inputs must be an array of HEIC images",OutputShapeInvalid:e=>`output must be one of 'blob', 'dataUrl', 'arrayBuffer', got: ${e}`,SignalInvalid:e=>`signal must be an AbortSignal, got: ${e}`,Aborted:"Conversion aborted (AbortSignal was aborted)",ConvertManyItemFailed:(e,r,t)=>`Conversion of item ${e} of ${r} failed: ${t}`,BatchItemProducedNoResult:(e,r)=>`Conversion of item ${e} of ${r} failed: item produced no result`,BatchEndedWithoutSettling:e=>`Batch ended without settling any of its ${e} items`,ConvertManyExtraFailures:(e,r)=>` (${e} of ${r} items failed in total)`,ConvertManyOtherErrors:e=>`; other errors: ${e.join(" | ")}`,ExifChunkLoadWarning:"@keeratita/heic-converter: the EXIF injector chunk could not be loaded — converted without metadata; serve every file in dist/ together, with dist/exif-*.mjs as JavaScript.",ScaleInvalid:e=>`Scale must be a positive finite number, got: ${e}`,MaxWidthInvalid:e=>`maxWidth must be a positive finite number, got: ${e}`,MaxHeightInvalid:e=>`maxHeight must be a positive finite number, got: ${e}`,TargetSizeTooLarge:(e,r,t)=>`Target image size ${e}x${r} exceeds the maximum supported dimension of ${t}px`,BlobToBase64FailedWithCause:e=>`Failed to convert Blob to base64 string: ${e}`,CanvasToBlobFailed:e=>`Failed to convert canvas to blob (type: ${e})`,CanvasUnsupported:"Canvas is not supported in the current environment. In a browser this requires OffscreenCanvas or HTMLCanvasElement. In Node.js there is no canvas: decode raw RGBA with LibheifDecoder and encode externally (see the Node.js section of the README).",InvalidDimensions:(e,r)=>`Invalid image dimensions: ${e}x${r}. Width and height must be positive integers.`,DataLengthMismatch:(e,r,t,n)=>`Image data length mismatch. Expected ${e} bytes for ${r}x${t}, got ${n}`,ContextUnavailable:"Failed to acquire 2D rendering context from canvas",UnsupportedFormat:e=>`Unsupported output format: ${e}`,FormatUnsupported:e=>`The current environment cannot encode '${e}' — canvas encoding produced no '${e}' image (e.g. AVIF encoding is not supported in this browser). Try 'jpeg', 'png', or 'webp' instead.`,CropInvalid:(e,r)=>`crop.${e} must be ${"width"===e||"height"===e?"a positive integer":"a non-negative integer"}, got: ${r}`,CropOutOfBounds:(e,r,t,n,o,i)=>`crop ${t}x${n} at (${e}, ${r}) exceeds the ${o}x${i} image (crop coordinates are in post-orientation display pixels)`,GlueApiMissing:e=>`The bundled decoder glue is missing required APIs (${e}) — deploy every file in dist/ from the same release; heic-decoder.wasm and its glue chunk must come from one build.`,DecoderFreedDuringDecode:"Decoder was freed before decoding completed; call initialize() again.",DecodeInputAllocFailed:e=>`Failed to allocate ${e} bytes in the WASM heap for decode input`,DecodeFailed:e=>`HEIC decoding failed (no result returned; input: ${e} bytes — is the file truncated or empty?)`,DecodeFailedWithDetail:(e,r)=>`HEIC decoding failed: ${e} (input: ${r} bytes)`,DecodeFaulted:e=>`Decoder faulted on a ${e}-byte image (out of memory, or a corrupted WebAssembly instance); retry — a faulted pooled decoder is discarded, not reused`,ProgressCallbackThrew:e=>`onProgress callback threw during decode: ${e}`};function t(e){const r=Number(e);return Number.isFinite(r)?Math.min(100,Math.max(0,r)):0}function n(t){return new e.HeicConverterError("progress_callback_failed",r.ProgressCallbackThrew(t instanceof Error?t.message:String(t)),{cause:t})}function o(e){return"function"==typeof e?e:void 0}var i=["jpeg","jpg","png","svg","webp","avif"];function a(t,n){if(void 0!==n&&"boolean"!=typeof n)throw new e.HeicConverterError("invalid_input",r.BooleanOptionInvalid(t,n))}function d(t){const n=String(t).toLowerCase();if(!i.includes(n))throw new e.HeicConverterError("invalid_format",r.UnsupportedFormat(String(t)))}function s(t){if(!t)return;const{maxWidth:n,maxHeight:o,scale:i}=t;if(void 0!==i&&("number"!=typeof i||!Number.isFinite(i)||i<=0))throw new e.HeicConverterError("invalid_resize",r.ScaleInvalid(i));if(void 0!==n&&("number"!=typeof n||!Number.isFinite(n)||n<=0))throw new e.HeicConverterError("invalid_resize",r.MaxWidthInvalid(n));if(void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<=0))throw new e.HeicConverterError("invalid_resize",r.MaxHeightInvalid(o))}function c(t){if(!t)return;const{x:n=0,y:o=0,width:i,height:a}=t;if(!Number.isInteger(i)||i<=0)throw new e.HeicConverterError("invalid_crop",r.CropInvalid("width",i));if(!Number.isInteger(a)||a<=0)throw new e.HeicConverterError("invalid_crop",r.CropInvalid("height",a));if(!Number.isInteger(n)||n<0)throw new e.HeicConverterError("invalid_crop",r.CropInvalid("x",n));if(!Number.isInteger(o)||o<0)throw new e.HeicConverterError("invalid_crop",r.CropInvalid("y",o))}exports.DEFAULT_QUALITY=.92,exports.MAX_BATCH_CONCURRENCY=64,exports.Messages=r,exports.SUPPORTED_FORMATS=i,exports.clampPercent=t,exports.progressCallbackError=n,exports.progressCallbackFor=o,exports.progressGateFor=function(e){const r=o(e);return r?function(e){let r,o=!1;return{report:n=>{if(o)return;const i=t(n);if(!(i>=100))try{e(i)}catch(e){r=r??e}},complete:()=>{if(!o){if(o=!0,void 0!==r)throw n(r);try{e(100)}catch(e){throw n(e)}}},pendingError:()=>void 0===r?void 0:n(r)}}(r):void 0},exports.runBoundedBatch=async function(t,n,o,i){const a=!0===i?.continueOnError,d=i?.signal,s=new Array(t.length);let c=0,l=!1,u=0,v=null,h=-1,p=0;const f=[];let g;const m=new Promise(e=>{g=e}),b=()=>g?.();d&&!a&&d.addEventListener("abort",b,{once:!0});const w=function(e,r){return Math.min(e,r)}(n,t.length),y=Array.from({length:w},()=>(async()=>{for(;!l&&!d?.aborted||a;){const n=c;if(c+=1,n>=t.length)return;if(a&&d?.aborted){const o=new e.HeicConverterError("aborted",r.Aborted);for(let e=n;e<t.length;e++)s[e]={index:e,ok:!1,error:o};return void(c=t.length)}try{const e=await o(t[n],n);s[n]={index:n,ok:!0,result:e},u+=1}catch(e){if(p+=1,a){s[n]={index:n,ok:!1,error:e instanceof Error?e:new Error(String(e))};continue}l?f.length<2&&f.push(e instanceof Error?e.message:String(e)):(l=!0,v=e,h=n,g?.())}}})());try{if(a)return await Promise.all(y),s;if(await Promise.race([Promise.all(y),m]),u===t.length)return s.map(n=>{if(!n||!n.ok)throw new e.HeicConverterError("batch_item_failed",r.BatchItemProducedNoResult((n?.index??0)+1,t.length));return n.result});if(d?.aborted)throw new e.HeicConverterError("aborted",r.Aborted);if(l){const n=v instanceof Error?v.message:String(v);let o=r.ConvertManyItemFailed(h+1,t.length,n);throw p>1&&(o+=r.ConvertManyExtraFailures(p,t.length),f.length>0&&(o+=r.ConvertManyOtherErrors(f))),new e.HeicConverterError("batch_item_failed",o,{cause:v,itemIndex:h,itemTotal:t.length,failedCount:p})}throw new e.HeicConverterError("batch_item_failed",r.BatchEndedWithoutSettling(t.length))}finally{d?.removeEventListener("abort",b)}},exports.throwIfAborted=function(t){if(t?.aborted)throw new e.HeicConverterError("aborted",r.Aborted)},exports.validateBatchOptions=function(e){a("continueOnError",e?.continueOnError),a("reuseDecoders",e?.reuseDecoders)},exports.validateConcurrency=function(t){if(!Number.isInteger(t)||t<1||t>64)throw new e.HeicConverterError("invalid_concurrency",r.ConcurrencyInvalid(t,64))},exports.validateConvertOptions=function(t){d(t?.to??"jpeg"),void 0!==t?.quality&&function(t){if("number"!=typeof t||!Number.isFinite(t)||t<0||t>1)throw new e.HeicConverterError("invalid_quality",r.QualityInvalid(t))}(t.quality),a("applyOrientation",t?.applyOrientation),function(t){if(void 0!==t&&"blob"!==t&&"dataUrl"!==t&&"arrayBuffer"!==t)throw new e.HeicConverterError("invalid_input",r.OutputShapeInvalid(t))}(t?.output),function(t){if(void 0!==t&&("object"!=typeof t||null===t||"function"!=typeof t.addEventListener))throw new e.HeicConverterError("invalid_input",r.SignalInvalid(t))}(t?.signal),c(t?.crop),a("preserveExif",t?.preserveExif),a("nativeDecode",t?.nativeDecode),s(t)},exports.validateCrop=c,exports.validateFormat=d,exports.validateResize=s;
|
package/dist/errors.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stable, machine-readable error codes attached to every error the library
|
|
3
|
-
* throws (as `HeicConverterError.code`). Codes are part of the public API:
|
|
4
|
-
* they are additive-only and never repurposed, so callers can branch on
|
|
5
|
-
* `error.code` instead of matching on message strings.
|
|
6
|
-
*/
|
|
7
|
-
export 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';
|
|
8
|
-
/**
|
|
9
|
-
* Error thrown by all first-party code paths. Extends `Error` so existing
|
|
10
|
-
* `instanceof Error` / message-based handling keeps working; the `code`
|
|
11
|
-
* (and, for batch failures, `itemIndex`/`itemTotal`/`failedCount`) fields
|
|
12
|
-
* add a structured discriminator without changing message text.
|
|
13
|
-
*/
|
|
14
|
-
export declare class HeicConverterError extends Error {
|
|
15
|
-
readonly code: HeicConverterErrorCode;
|
|
16
|
-
/** 0-based index of the failing input. Only set on `batch_item_failed` errors. */
|
|
17
|
-
readonly itemIndex?: number;
|
|
18
|
-
/** Total number of inputs in the batch. Only set on `batch_item_failed` errors. */
|
|
19
|
-
readonly itemTotal?: number;
|
|
20
|
-
/** How many items failed overall. Only set on `batch_item_failed` errors. */
|
|
21
|
-
readonly failedCount?: number;
|
|
22
|
-
constructor(code: HeicConverterErrorCode, message: string, options?: {
|
|
23
|
-
cause?: unknown;
|
|
24
|
-
itemIndex?: number;
|
|
25
|
-
itemTotal?: number;
|
|
26
|
-
failedCount?: number;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t,e="undefined"!=typeof document?document.currentScript:null,r=(t="undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href,async function(r={}){var n,i,a=r;a.ready=new Promise((t,e)=>{n=t,i=e});var o,s,u=Object.assign({},a),c="./this.program",f="object"==typeof window,h="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,l="";if(p){const{createRequire:t}=await(import("module"));var d=t("undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href),v=d("fs"),m=d("path");l=h?m.dirname(l)+"/":d("url").fileURLToPath(new URL("./","undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href)),o=(t,e)=>(t=W(t)?new URL(t):m.normalize(t),v.readFileSync(t,e?void 0:"utf8")),s=t=>{var e=o(t,!0);return e.buffer||(e=new Uint8Array(e)),e},!a.thisProgram&&process.argv.length>1&&(c=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(f||h)&&(h?l=self.location.href:"undefined"!=typeof document&&document.currentScript&&(l=document.currentScript.src),t&&(l=t),l=l.startsWith("blob:")?"":l.substr(0,l.replace(/[?#].*/,"").lastIndexOf("/")+1),o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},h&&(s=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}));var g,y,_=a.print||console.log.bind(console),w=a.printErr||console.error.bind(console);Object.assign(a,u),u=null,a.arguments&&a.arguments,a.thisProgram&&(c=a.thisProgram),a.quit&&a.quit,a.wasmBinary&&(g=a.wasmBinary);var R,b,A,U=!1;function E(){var t=y.buffer;a.HEAP8=R=new Int8Array(t),a.HEAP16=new Int16Array(t),a.HEAPU8=b=new Uint8Array(t),a.HEAPU16=new Uint16Array(t),a.HEAP32=new Int32Array(t),a.HEAPU32=A=new Uint32Array(t),a.HEAPF32=new Float32Array(t),a.HEAPF64=new Float64Array(t)}var P=[],C=[],S=[];function j(t){P.unshift(t)}function I(t){S.unshift(t)}var T=0,x=null;function L(t){a.onAbort?.(t),w(t="Aborted("+t+")"),U=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw i(e),e}var F,H,N=t=>t.startsWith("data:application/octet-stream;base64,"),W=t=>t.startsWith("file://");function O(t){if(t==F&&g)return new Uint8Array(g);if(s)return s(t);throw"both async and sync fetching of the wasm failed"}function q(t,e,r){return function(t){return g||!f&&!h||"function"!=typeof fetch?Promise.resolve().then(()=>O(t)):fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw`failed to load wasm binary file at '${t}'`;return e.arrayBuffer()}).catch(()=>O(t))}(t).then(t=>WebAssembly.instantiate(t,e)).then(r,t=>{w(`failed to asynchronously prepare wasm: ${t}`),L(t)})}a.locateFile?N(F="heic-decoder.wasm")||(H=F,F=a.locateFile?a.locateFile(H,l):l+H):F=new URL("heic-decoder.wasm","undefined"==typeof document?require("url").pathToFileURL(__filename).href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("heic-decoder-2EERQO7N.js",document.baseURI).href).href;var M=t=>{for(;t.length>0;)t.shift()(a)};a.noExitRuntime;var k="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,$=(t,e,r)=>{for(var n=e+r,i=e;t[i]&&!(i>=n);)++i;if(i-e>16&&t.buffer&&k)return k.decode(t.subarray(e,i));for(var a="";e<i;){var o=t[e++];if(128&o){var s=63&t[e++];if(192!=(224&o)){var u=63&t[e++];if((o=224==(240&o)?(15&o)<<12|s<<6|u:(7&o)<<18|s<<12|u<<6|63&t[e++])<65536)a+=String.fromCharCode(o);else{var c=o-65536;a+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a},B=(t,e)=>t?$(b,t,e):"",D=[],G=0,Q=0;class z{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){A[this.ptr+4>>2]=t}get_type(){return A[this.ptr+4>>2]}set_destructor(t){A[this.ptr+8>>2]=t}get_destructor(){return A[this.ptr+8>>2]}set_caught(t){t=t?1:0,R[this.ptr+12]=t}get_caught(){return 0!=R[this.ptr+12]}set_rethrown(t){t=t?1:0,R[this.ptr+13]=t}get_rethrown(){return 0!=R[this.ptr+13]}init(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)}set_adjusted_ptr(t){A[this.ptr+16>>2]=t}get_adjusted_ptr(){return A[this.ptr+16>>2]}get_exception_ptr(){if(lt(this.get_type()))return A[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var X,J=t=>{var e=Q;if(!e)return st(0),0;var r=new z(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return st(0),e;for(var i in t){var a=t[i];if(0===a||a===n)break;var o=r.ptr+16;if(pt(a,n,o))return st(a),e}return st(n),e},K=t=>{var e=(t-y.buffer.byteLength+65535)/65536;try{return y.grow(e),E(),1}catch(t){}},V={},Y=()=>{if(!Y.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var e in V)void 0===V[e]?delete t[e]:t[e]=V[e];var r=[];for(var e in t)r.push(`${e}=${t[e]}`);Y.strings=r}return Y.strings},Z=[null,[],[]],tt=(t,e)=>{var r=Z[t];0===e||10===e?((1===t?_:w)($(r,0)),r.length=0):r.push(e)},et=[],rt=t=>{var e=et[t];return e||(t>=et.length&&(et.length=t+1),et[t]=e=X.get(t)),e},nt={a:(t,e,r,n)=>{L(`Assertion failed: ${B(t)}, at: `+[e?B(e):"unknown filename",r,n?B(n):"unknown function"])},l:t=>{var e=new z(t);return e.get_caught()||(e.set_caught(!0),G--),e.set_rethrown(!1),D.push(e),ht(e.excPtr),e.get_exception_ptr()},m:()=>{ot(0,0);var t=D.pop();ft(t.excPtr),Q=0},b:()=>J([]),c:t=>J([t]),r:()=>{var t=D.pop();t||L("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||(D.push(t),t.set_rethrown(!0),t.set_caught(!1),G++),Q=e},j:(t,e,r)=>{throw new z(t).init(e,r),G++,Q=t},x:()=>G,f:t=>{throw Q||(Q=t),Q},z:(t,e,r)=>{},p:()=>{L("")},o:function(t){try{a.__progressCb&&a.__progressCb(t)}catch(t){}},D:(t,e,r)=>b.copyWithin(t,e,e+r),y:t=>{var e=b.length,r=2147483648;if((t>>>=0)>r)return!1;for(var n=(t,e)=>t+(e-t%e)%e,i=1;i<=4;i*=2){var a=e*(1+.2/i);a=Math.min(a,t+100663296);var o=Math.min(r,n(Math.max(t,a),65536));if(K(o))return!0}return!1},B:(t,e)=>{var r=0;return Y().forEach((n,i)=>{var a=e+r;A[t+4*i>>2]=a,((t,e)=>{for(var r=0;r<t.length;++r)R[e++]=t.charCodeAt(r);R[e]=0})(n,a),r+=n.length+1}),0},C:(t,e)=>{var r=Y();A[t>>2]=r.length;var n=0;return r.forEach(t=>n+=t.length+1),A[e>>2]=n,0},A:t=>52,v:function(t,e,r,n,i){return 70},s:(t,e,r,n)=>{for(var i=0,a=0;a<r;a++){var o=A[e>>2],s=A[e+4>>2];e+=8;for(var u=0;u<s;u++)tt(t,b[o+u]);i+=s}return A[n>>2]=i,0},d:function(t,e){var r=ut();try{return rt(t)(e)}catch(t){if(ct(r),t!==t+0)throw t;ot(1,0)}},e:function(t,e,r){var n=ut();try{return rt(t)(e,r)}catch(t){if(ct(n),t!==t+0)throw t;ot(1,0)}},i:function(t,e,r,n){var i=ut();try{return rt(t)(e,r,n)}catch(t){if(ct(i),t!==t+0)throw t;ot(1,0)}},n:function(t,e,r,n,i,a){var o=ut();try{return rt(t)(e,r,n,i,a)}catch(t){if(ct(o),t!==t+0)throw t;ot(1,0)}},u:function(t,e,r,n,i,a,o){var s=ut();try{return vt(t,e,r,n,i,a,o)}catch(t){if(ct(s),t!==t+0)throw t;ot(1,0)}},k:function(t){var e=ut();try{rt(t)()}catch(t){if(ct(e),t!==t+0)throw t;ot(1,0)}},E:function(t,e){var r=ut();try{rt(t)(e)}catch(t){if(ct(r),t!==t+0)throw t;ot(1,0)}},h:function(t,e){var r=ut();try{rt(t)(e)}catch(t){if(ct(r),t!==t+0)throw t;ot(1,0)}},g:function(t,e,r){var n=ut();try{rt(t)(e,r)}catch(t){if(ct(n),t!==t+0)throw t;ot(1,0)}},q:function(t,e,r,n){var i=ut();try{rt(t)(e,r,n)}catch(t){if(ct(i),t!==t+0)throw t;ot(1,0)}},t:function(t,e,r,n,i){var a=ut();try{rt(t)(e,r,n,i)}catch(t){if(ct(a),t!==t+0)throw t;ot(1,0)}},w:function(t,e,r,n){var i=ut();try{dt(t,e,r,n)}catch(t){if(ct(i),t!==t+0)throw t;ot(1,0)}}},it=function(){var t,e,r,n,o={a:nt};function s(t,e){var r;return it=t.exports,y=it.F,E(),X=it.J,r=it.G,C.unshift(r),function(){if(T--,a.monitorRunDependencies?.(T),0==T&&x){var t=x;x=null,t()}}(),it}if(T++,a.monitorRunDependencies?.(T),a.instantiateWasm)try{return a.instantiateWasm(o,s)}catch(t){w(`Module.instantiateWasm callback failed with error: ${t}`),i(t)}return(t=g,e=F,r=o,n=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||N(e)||p||"function"!=typeof fetch?q(e,r,n):fetch(e,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,r).then(n,function(t){return w(`wasm streaming compile failed: ${t}`),w("falling back to ArrayBuffer instantiation"),q(e,r,n)}))).catch(i),{}}();a._heic_decode=(t,e)=>(a._heic_decode=it.H)(t,e),a._heic_result_free=t=>(a._heic_result_free=it.I)(t),a._free=t=>(a._free=it.K)(t),a._malloc=t=>(a._malloc=it.L)(t);var at,ot=(t,e)=>(ot=it.M)(t,e),st=t=>(st=it.N)(t),ut=()=>(ut=it.O)(),ct=t=>(ct=it.P)(t),ft=t=>(ft=it.Q)(t),ht=t=>(ht=it.R)(t),pt=(t,e,r)=>(pt=it.S)(t,e,r),lt=t=>(lt=it.T)(t),dt=a.dynCall_vij=(t,e,r,n)=>(dt=a.dynCall_vij=it.U)(t,e,r,n),vt=a.dynCall_iiiiij=(t,e,r,n,i,o,s)=>(vt=a.dynCall_iiiiij=it.V)(t,e,r,n,i,o,s);function mt(){function t(){at||(at=!0,a.calledRun=!0,U||(M(C),n(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),function(){if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)I(a.postRun.shift());M(S)}()))}T>0||(function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)j(a.preRun.shift());M(P)}(),T>0||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),t()},1)):t()))}if(a.___start_em_js=91680,a.___stop_em_js=91784,x=function t(){at||mt(),at||(x=t)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return mt(),r.ready});module.exports=r;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t,r=(t=import.meta.url,async function(r={}){var e,n,i=r;i.ready=new Promise((t,r)=>{e=t,n=r});var a,o,s=Object.assign({},i),u="./this.program",c="object"==typeof window,f="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,p="";if(h){const{createRequire:t}=await(import("module"));var l=t(import.meta.url),v=l("fs"),d=l("path");p=f?d.dirname(p)+"/":l("url").fileURLToPath(new URL("./",import.meta.url)),a=(t,r)=>(t=L(t)?new URL(t):d.normalize(t),v.readFileSync(t,r?void 0:"utf8")),o=t=>{var r=a(t,!0);return r.buffer||(r=new Uint8Array(r)),r},!i.thisProgram&&process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else(c||f)&&(f?p=self.location.href:"undefined"!=typeof document&&document.currentScript&&(p=document.currentScript.src),t&&(p=t),p=p.startsWith("blob:")?"":p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1),a=t=>{var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(null),r.responseText},f&&(o=t=>{var r=new XMLHttpRequest;return r.open("GET",t,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}));var g,y,m=i.print||console.log.bind(console),_=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(u=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(g=i.wasmBinary);var w,b,A,R=!1;function P(){var t=y.buffer;i.HEAP8=w=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAPU8=b=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU32=A=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var E=[],j=[],x=[];function S(t){E.unshift(t)}function C(t){x.unshift(t)}var U=0,I=null;function H(t){i.onAbort?.(t),_(t="Aborted("+t+")"),R=!0,t+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(t);throw n(r),r}var T,W,F=t=>t.startsWith("data:application/octet-stream;base64,"),L=t=>t.startsWith("file://");function M(t){if(t==T&&g)return new Uint8Array(g);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}function k(t,r,e){return function(t){return g||!c&&!f||"function"!=typeof fetch?Promise.resolve().then(()=>M(t)):fetch(t,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw`failed to load wasm binary file at '${t}'`;return r.arrayBuffer()}).catch(()=>M(t))}(t).then(t=>WebAssembly.instantiate(t,r)).then(e,t=>{_(`failed to asynchronously prepare wasm: ${t}`),H(t)})}i.locateFile?F(T="heic-decoder.wasm")||(W=T,T=i.locateFile?i.locateFile(W,p):p+W):T=new URL("heic-decoder.wasm",import.meta.url).href;var O=t=>{for(;t.length>0;)t.shift()(i)};i.noExitRuntime;var $="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,q=(t,r,e)=>{for(var n=r+e,i=r;t[i]&&!(i>=n);)++i;if(i-r>16&&t.buffer&&$)return $.decode(t.subarray(r,i));for(var a="";r<i;){var o=t[r++];if(128&o){var s=63&t[r++];if(192!=(224&o)){var u=63&t[r++];if((o=224==(240&o)?(15&o)<<12|s<<6|u:(7&o)<<18|s<<12|u<<6|63&t[r++])<65536)a+=String.fromCharCode(o);else{var c=o-65536;a+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a},B=(t,r)=>t?q(b,t,r):"",D=[],G=0,z=0;class N{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){A[this.ptr+4>>2]=t}get_type(){return A[this.ptr+4>>2]}set_destructor(t){A[this.ptr+8>>2]=t}get_destructor(){return A[this.ptr+8>>2]}set_caught(t){t=t?1:0,w[this.ptr+12]=t}get_caught(){return 0!=w[this.ptr+12]}set_rethrown(t){t=t?1:0,w[this.ptr+13]=t}get_rethrown(){return 0!=w[this.ptr+13]}init(t,r){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(r)}set_adjusted_ptr(t){A[this.ptr+16>>2]=t}get_adjusted_ptr(){return A[this.ptr+16>>2]}get_exception_ptr(){if(pt(this.get_type()))return A[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var X,J=t=>{var r=z;if(!r)return ot(0),0;var e=new N(r);e.set_adjusted_ptr(r);var n=e.get_type();if(!n)return ot(0),r;for(var i in t){var a=t[i];if(0===a||a===n)break;var o=e.ptr+16;if(ht(a,n,o))return ot(a),r}return ot(n),r},K=t=>{var r=(t-y.buffer.byteLength+65535)/65536;try{return y.grow(r),P(),1}catch(t){}},Q={},V=()=>{if(!V.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:u||"./this.program"};for(var r in Q)void 0===Q[r]?delete t[r]:t[r]=Q[r];var e=[];for(var r in t)e.push(`${r}=${t[r]}`);V.strings=e}return V.strings},Y=[null,[],[]],Z=(t,r)=>{var e=Y[t];0===r||10===r?((1===t?m:_)(q(e,0)),e.length=0):e.push(r)},tt=[],rt=t=>{var r=tt[t];return r||(t>=tt.length&&(tt.length=t+1),tt[t]=r=X.get(t)),r},et={a:(t,r,e,n)=>{H(`Assertion failed: ${B(t)}, at: `+[r?B(r):"unknown filename",e,n?B(n):"unknown function"])},l:t=>{var r=new N(t);return r.get_caught()||(r.set_caught(!0),G--),r.set_rethrown(!1),D.push(r),ft(r.excPtr),r.get_exception_ptr()},m:()=>{at(0,0);var t=D.pop();ct(t.excPtr),z=0},b:()=>J([]),c:t=>J([t]),r:()=>{var t=D.pop();t||H("no exception to throw");var r=t.excPtr;throw t.get_rethrown()||(D.push(t),t.set_rethrown(!0),t.set_caught(!1),G++),z=r},j:(t,r,e)=>{throw new N(t).init(r,e),G++,z=t},x:()=>G,f:t=>{throw z||(z=t),z},z:(t,r,e)=>{},p:()=>{H("")},o:function(t){try{i.__progressCb&&i.__progressCb(t)}catch(t){}},D:(t,r,e)=>b.copyWithin(t,r,r+e),y:t=>{var r=b.length,e=2147483648;if((t>>>=0)>e)return!1;for(var n=(t,r)=>t+(r-t%r)%r,i=1;i<=4;i*=2){var a=r*(1+.2/i);a=Math.min(a,t+100663296);var o=Math.min(e,n(Math.max(t,a),65536));if(K(o))return!0}return!1},B:(t,r)=>{var e=0;return V().forEach((n,i)=>{var a=r+e;A[t+4*i>>2]=a,((t,r)=>{for(var e=0;e<t.length;++e)w[r++]=t.charCodeAt(e);w[r]=0})(n,a),e+=n.length+1}),0},C:(t,r)=>{var e=V();A[t>>2]=e.length;var n=0;return e.forEach(t=>n+=t.length+1),A[r>>2]=n,0},A:t=>52,v:function(t,r,e,n,i){return 70},s:(t,r,e,n)=>{for(var i=0,a=0;a<e;a++){var o=A[r>>2],s=A[r+4>>2];r+=8;for(var u=0;u<s;u++)Z(t,b[o+u]);i+=s}return A[n>>2]=i,0},d:function(t,r){var e=st();try{return rt(t)(r)}catch(t){if(ut(e),t!==t+0)throw t;at(1,0)}},e:function(t,r,e){var n=st();try{return rt(t)(r,e)}catch(t){if(ut(n),t!==t+0)throw t;at(1,0)}},i:function(t,r,e,n){var i=st();try{return rt(t)(r,e,n)}catch(t){if(ut(i),t!==t+0)throw t;at(1,0)}},n:function(t,r,e,n,i,a){var o=st();try{return rt(t)(r,e,n,i,a)}catch(t){if(ut(o),t!==t+0)throw t;at(1,0)}},u:function(t,r,e,n,i,a,o){var s=st();try{return vt(t,r,e,n,i,a,o)}catch(t){if(ut(s),t!==t+0)throw t;at(1,0)}},k:function(t){var r=st();try{rt(t)()}catch(t){if(ut(r),t!==t+0)throw t;at(1,0)}},E:function(t,r){var e=st();try{rt(t)(r)}catch(t){if(ut(e),t!==t+0)throw t;at(1,0)}},h:function(t,r){var e=st();try{rt(t)(r)}catch(t){if(ut(e),t!==t+0)throw t;at(1,0)}},g:function(t,r,e){var n=st();try{rt(t)(r,e)}catch(t){if(ut(n),t!==t+0)throw t;at(1,0)}},q:function(t,r,e,n){var i=st();try{rt(t)(r,e,n)}catch(t){if(ut(i),t!==t+0)throw t;at(1,0)}},t:function(t,r,e,n,i){var a=st();try{rt(t)(r,e,n,i)}catch(t){if(ut(a),t!==t+0)throw t;at(1,0)}},w:function(t,r,e,n){var i=st();try{lt(t,r,e,n)}catch(t){if(ut(i),t!==t+0)throw t;at(1,0)}}},nt=function(){var t,r,e,a,o={a:et};function s(t,r){var e;return nt=t.exports,y=nt.F,P(),X=nt.J,e=nt.G,j.unshift(e),function(){if(U--,i.monitorRunDependencies?.(U),0==U&&I){var t=I;I=null,t()}}(),nt}if(U++,i.monitorRunDependencies?.(U),i.instantiateWasm)try{return i.instantiateWasm(o,s)}catch(t){_(`Module.instantiateWasm callback failed with error: ${t}`),n(t)}return(t=g,r=T,e=o,a=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||F(r)||h||"function"!=typeof fetch?k(r,e,a):fetch(r,{credentials:"same-origin"}).then(t=>WebAssembly.instantiateStreaming(t,e).then(a,function(t){return _(`wasm streaming compile failed: ${t}`),_("falling back to ArrayBuffer instantiation"),k(r,e,a)}))).catch(n),{}}();i._heic_decode=(t,r)=>(i._heic_decode=nt.H)(t,r),i._heic_result_free=t=>(i._heic_result_free=nt.I)(t),i._free=t=>(i._free=nt.K)(t),i._malloc=t=>(i._malloc=nt.L)(t);var it,at=(t,r)=>(at=nt.M)(t,r),ot=t=>(ot=nt.N)(t),st=()=>(st=nt.O)(),ut=t=>(ut=nt.P)(t),ct=t=>(ct=nt.Q)(t),ft=t=>(ft=nt.R)(t),ht=(t,r,e)=>(ht=nt.S)(t,r,e),pt=t=>(pt=nt.T)(t),lt=i.dynCall_vij=(t,r,e,n)=>(lt=i.dynCall_vij=nt.U)(t,r,e,n),vt=i.dynCall_iiiiij=(t,r,e,n,a,o,s)=>(vt=i.dynCall_iiiiij=nt.V)(t,r,e,n,a,o,s);function dt(){function t(){it||(it=!0,i.calledRun=!0,R||(O(j),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)C(i.postRun.shift());O(x)}()))}U>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)S(i.preRun.shift());O(E)}(),U>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t()))}if(i.___start_em_js=91680,i.___stop_em_js=91784,I=function t(){it||dt(),it||(I=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return dt(),r.ready});export{r as default};
|
package/dist/messages/core.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized error message templates used across the library.
|
|
3
|
-
*
|
|
4
|
-
* Static messages are plain strings; dynamic messages are template
|
|
5
|
-
* functions that produce the final string at the call site. Keep all
|
|
6
|
-
* user-facing error strings here (grouped by the file that throws them)
|
|
7
|
-
* instead of inlining new ones.
|
|
8
|
-
*
|
|
9
|
-
* This module holds the strings the eagerly loaded graph throws — anything
|
|
10
|
-
* `src/index.ts`, `src/validate.ts` or the render path touches. `Messages` is
|
|
11
|
-
* one object literal, so an unused entry cannot be tree-shaken out of it:
|
|
12
|
-
* worker-only strings live in `./worker` (`WorkerMessages`) and stay inside the
|
|
13
|
-
* chunk a caller pays for only when they use those APIs. The rule is which
|
|
14
|
-
* *chunk* throws the text, not which API it mentions — `WorkerChunkLoadFailed`
|
|
15
|
-
* is here because `src/index.ts` throws it before the worker chunk exists.
|
|
16
|
-
*/
|
|
17
|
-
export declare const Messages: {
|
|
18
|
-
readonly QualityInvalid: (value: unknown) => string;
|
|
19
|
-
readonly BooleanOptionInvalid: (name: string, value: unknown) => string;
|
|
20
|
-
readonly UnsupportedInputType: (type: string) => string;
|
|
21
|
-
readonly DecoderInitFailed: (message: string) => string;
|
|
22
|
-
readonly WorkerChunkLoadFailed: (message: string) => string;
|
|
23
|
-
readonly NativeChunkLoadWarning: (message: string) => string;
|
|
24
|
-
readonly RenderEncodeFailed: (format: string, message: string) => string;
|
|
25
|
-
readonly ConcurrencyInvalid: (value: unknown, max: number) => string;
|
|
26
|
-
readonly InputsMustBeArray: "Inputs must be an array of HEIC images";
|
|
27
|
-
readonly OutputShapeInvalid: (value: unknown) => string;
|
|
28
|
-
readonly SignalInvalid: (value: unknown) => string;
|
|
29
|
-
readonly Aborted: "Conversion aborted (AbortSignal was aborted)";
|
|
30
|
-
readonly ConvertManyItemFailed: (index: number, total: number, message: string) => string;
|
|
31
|
-
/** The settled-completion tail: an entry the race recorded as ok yet carries no result. */
|
|
32
|
-
readonly BatchItemProducedNoResult: (index: number, total: number) => string;
|
|
33
|
-
/** The unreachable tail: the race settled with nothing to show for it. Names no
|
|
34
|
-
* item, because there is no failing item to name. */
|
|
35
|
-
readonly BatchEndedWithoutSettling: (total: number) => string;
|
|
36
|
-
readonly ConvertManyExtraFailures: (failedCount: number, total: number) => string;
|
|
37
|
-
readonly ConvertManyOtherErrors: (messages: string[]) => string;
|
|
38
|
-
readonly ExifChunkLoadWarning: string;
|
|
39
|
-
readonly ScaleInvalid: (value: unknown) => string;
|
|
40
|
-
readonly MaxWidthInvalid: (value: unknown) => string;
|
|
41
|
-
readonly MaxHeightInvalid: (value: unknown) => string;
|
|
42
|
-
readonly TargetSizeTooLarge: (width: number, height: number, max: number) => string;
|
|
43
|
-
readonly BlobToBase64FailedWithCause: (message: string) => string;
|
|
44
|
-
readonly CanvasToBlobFailed: (type: string) => string;
|
|
45
|
-
readonly CanvasUnsupported: string;
|
|
46
|
-
readonly InvalidDimensions: (width: number, height: number) => string;
|
|
47
|
-
readonly DataLengthMismatch: (expected: number, width: number, height: number, actual: number) => string;
|
|
48
|
-
readonly ContextUnavailable: "Failed to acquire 2D rendering context from canvas";
|
|
49
|
-
readonly UnsupportedFormat: (format: string) => string;
|
|
50
|
-
readonly FormatUnsupported: (format: string) => string;
|
|
51
|
-
readonly CropInvalid: (field: string, value: unknown) => string;
|
|
52
|
-
readonly CropOutOfBounds: (x: number, y: number, width: number, height: number, displayWidth: number, displayHeight: number) => string;
|
|
53
|
-
readonly GlueApiMissing: (missing: string) => string;
|
|
54
|
-
readonly DecoderFreedDuringDecode: "Decoder was freed before decoding completed; call initialize() again.";
|
|
55
|
-
readonly DecodeInputAllocFailed: (bytes: number) => string;
|
|
56
|
-
readonly DecodeFailed: (bytes: number) => string;
|
|
57
|
-
readonly DecodeFailedWithDetail: (detail: string, bytes: number) => string;
|
|
58
|
-
readonly DecodeFaulted: (bytes: number) => string;
|
|
59
|
-
readonly ProgressCallbackThrew: (message: string) => string;
|
|
60
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error strings thrown from `src/worker.ts`, which is the lazily loaded worker
|
|
3
|
-
* chunk. Add a string here when the *chunk* throws it — not when the API is
|
|
4
|
-
* worker-related: text that `src/index.ts` or `src/validate.ts` can reach must
|
|
5
|
-
* go to `./core`, or the eager bundle grows, because an object literal cannot
|
|
6
|
-
* be tree-shaken per property.
|
|
7
|
-
*/
|
|
8
|
-
export declare const WorkerMessages: {
|
|
9
|
-
readonly WorkerUnsupported: "Web Worker is not supported in the current environment";
|
|
10
|
-
readonly WorkerCreateFailed: (message: string) => string;
|
|
11
|
-
readonly WorkerPostFailed: (message: string) => string;
|
|
12
|
-
readonly WorkerConversionFailed: "Worker conversion failed";
|
|
13
|
-
readonly WorkerDecoderUnsupported: string;
|
|
14
|
-
readonly WorkerFailed: (workerUrl?: string | URL) => string;
|
|
15
|
-
readonly WorkerTimeout: (timeoutMs: number, stats: {
|
|
16
|
-
progressMessages: number;
|
|
17
|
-
lastPercent?: number;
|
|
18
|
-
unknownType?: string;
|
|
19
|
-
/** Replies ignored for not echoing the request id (duplicates or late replies). */
|
|
20
|
-
staleResults?: number;
|
|
21
|
-
/** Progress messages ignored for not echoing the request id. */
|
|
22
|
-
staleProgress?: number;
|
|
23
|
-
/** The lease came from the pool rather than a fresh boot. */
|
|
24
|
-
adopted?: boolean;
|
|
25
|
-
workerUrl?: string | URL;
|
|
26
|
-
/** Required, not optional: the caller knows whether a slot was granted, and
|
|
27
|
-
* guessing from an omitted field would decide the diagnosis for it. */
|
|
28
|
-
startedAt: number | undefined;
|
|
29
|
-
queueWaitMs?: number;
|
|
30
|
-
}) => string;
|
|
31
|
-
readonly MaxConcurrentWorkersInvalid: (value: unknown, max: number) => string;
|
|
32
|
-
readonly TimeoutInvalid: (value: unknown) => string;
|
|
33
|
-
};
|
package/dist/progress.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { HeicConverterError } from './errors';
|
|
2
|
-
/**
|
|
3
|
-
* Shared progress-value helpers. The public onProgress contract — "a number
|
|
4
|
-
* clamped to 0-100, the final 100% withheld until success, a throwing host
|
|
5
|
-
* callback surfaced as `progress_callback_failed`" — lives here as one
|
|
6
|
-
* implementation so the in-process path (`convertHeic`) and the worker
|
|
7
|
-
* transport cannot drift: each stage funnels host-visible percentages through
|
|
8
|
-
* `clampPercent`/`createProgressGate` and decides only *when* to surface a
|
|
9
|
-
* recorded host failure (in-process defers it to completion; the worker
|
|
10
|
-
* rejects on the spot and terminates).
|
|
11
|
-
*/
|
|
12
|
-
/** Coerce an arbitrary value to the documented 0-100 progress range. */
|
|
13
|
-
export declare function clampPercent(value: unknown): number;
|
|
14
|
-
/** The one construction of the `progress_callback_failed` contract error. */
|
|
15
|
-
export declare function progressCallbackError(error: unknown): HeicConverterError;
|
|
16
|
-
/**
|
|
17
|
-
* The host callback when it is callable, `undefined` when it is effectively
|
|
18
|
-
* absent. Everything non-function — truthy or not — counts as absent, so a
|
|
19
|
-
* malformed `onProgress` is silently ignored rather than TypeErroring later.
|
|
20
|
-
* One decision for all entry points and the worker transport.
|
|
21
|
-
*/
|
|
22
|
-
export declare function progressCallbackFor<A extends unknown[]>(value: ((...args: A) => void) | undefined): ((...args: A) => void) | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Build the gate for a host callback, or return undefined when it is
|
|
25
|
-
* effectively absent. Anything non-function counts as absent — the decision
|
|
26
|
-
* lives here once so the entry points and the worker transport cannot drift
|
|
27
|
-
* on what a malformed `onProgress` means (silently ignored, not TypeErrors
|
|
28
|
-
* surfacing as `progress_callback_failed`).
|
|
29
|
-
*/
|
|
30
|
-
export declare function progressGateFor(onProgress: ((percent: number) => void) | undefined): ProgressGate | undefined;
|
|
31
|
-
export interface ProgressGate {
|
|
32
|
-
/** Forward a clamped sub-100 percentage; a host throw is recorded, never rethrown here. */
|
|
33
|
-
report(percent: number): void;
|
|
34
|
-
/** Emit the withheld 100%, or throw the recorded host failure. Idempotent. */
|
|
35
|
-
complete(): void;
|
|
36
|
-
/** The recorded host failure, if the callback has thrown so far. */
|
|
37
|
-
pendingError(): HeicConverterError | undefined;
|
|
38
|
-
}
|
|
39
|
-
export declare function createProgressGate(onProgress: (percent: number) => void): ProgressGate;
|
package/dist/render/canvas.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { CropOptions, DecodedImage, ImageFormat, ResizeOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Maximum supported canvas dimension per side (browsers cap around this):
|
|
4
|
-
* turns absurd scale factors into a clear error instead of an allocation
|
|
5
|
-
* failure. The WASM wrapper (main.cpp) and the native Strategy apply the same
|
|
6
|
-
* cap before allocating — keep them in sync.
|
|
7
|
-
*/
|
|
8
|
-
export declare const MAX_CANVAS_DIMENSION = 16384;
|
|
9
|
-
/**
|
|
10
|
-
* Cheap probe for canvas support, safe to call before an expensive decode.
|
|
11
|
-
* Throws (unwrapped, with an actionable message) in environments with
|
|
12
|
-
* neither OffscreenCanvas nor HTMLCanvasElement — notably plain Node.js,
|
|
13
|
-
* where encoding is unsupported even though decoding works.
|
|
14
|
-
*/
|
|
15
|
-
export declare function assertEncodeEnvironment(): void;
|
|
16
|
-
/**
|
|
17
|
-
* Environment probe: some browsers cannot encode AVIF via canvas (e.g.
|
|
18
|
-
* Safari), and per spec `toBlob` silently falls back to PNG — trusting the
|
|
19
|
-
* requested type would emit a PNG under an AVIF label. Probed once. `false`
|
|
20
|
-
* is a definitive refusal (the only verdict that may produce
|
|
21
|
-
* `format_unsupported`); `undefined` is indeterminate (wedged `toBlob`,
|
|
22
|
-
* throwing canvas under memory pressure) — callers proceed and let the
|
|
23
|
-
* encode-time `blob.type` check decide.
|
|
24
|
-
*/
|
|
25
|
-
type AvifSupport = boolean | undefined;
|
|
26
|
-
/** How long the probe's toBlob may take before the attempt is deemed indeterminate. Exported so tests control the window. */
|
|
27
|
-
export declare const AVIF_PROBE_TIMEOUT_MS = 5000;
|
|
28
|
-
/**
|
|
29
|
-
* An indeterminate verdict is never cached as truth, but re-probing per call
|
|
30
|
-
* would make a starved host pay the full timeout each time. The latest "don't
|
|
31
|
-
* know" is honoured for this cooldown. Exported so tests advance past it, not
|
|
32
|
-
* around it.
|
|
33
|
-
*/
|
|
34
|
-
export declare const AVIF_INDETERMINATE_COOLDOWN_MS = 10000;
|
|
35
|
-
export declare function canEncodeAvif(): Promise<AvifSupport>;
|
|
36
|
-
/**
|
|
37
|
-
* Up-front capability gate for the chosen output format, safe to call before
|
|
38
|
-
* an expensive decode. Only a definitive `false` rejects here; indeterminate
|
|
39
|
-
* defers to the encode-time `blob.type` re-check in `renderAndEncode`.
|
|
40
|
-
*/
|
|
41
|
-
export declare function assertEncodeCapability(format: ImageFormat): Promise<void>;
|
|
42
|
-
/** @internal Reset the cached AVIF capability probe (tests only). */
|
|
43
|
-
export declare function __resetAvifProbe(): void;
|
|
44
|
-
/** @internal Re-arm the one-shot EXIF-chunk warning (tests only). */
|
|
45
|
-
export declare function __resetExifChunkWarning(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Computes the target dimensions for the given resize options.
|
|
48
|
-
* `scale` takes precedence over `maxWidth`/`maxHeight`; the latter only
|
|
49
|
-
* downscale (never upscale) while preserving the aspect ratio.
|
|
50
|
-
*/
|
|
51
|
-
export declare function computeTargetSize(width: number, height: number, resize?: ResizeOptions): {
|
|
52
|
-
width: number;
|
|
53
|
-
height: number;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Converts a Blob to a base64 data URL (`blob.arrayBuffer()` + `btoa`; both
|
|
57
|
-
* present on every host that reaches the render stage). Encoding failure is a
|
|
58
|
-
* `render_encode_failed`.
|
|
59
|
-
*/
|
|
60
|
-
export declare function blobToBase64(blob: Blob): Promise<string>;
|
|
61
|
-
/**
|
|
62
|
-
* Encodes a canvas via the encoder it exposes: `convertToBlob` for an
|
|
63
|
-
* OffscreenCanvas, `toBlob` for an HTMLCanvasElement. A null blob from the
|
|
64
|
-
* latter is a `render_encode_failed`.
|
|
65
|
-
*/
|
|
66
|
-
export declare function canvasToBlob(canvas: HTMLCanvasElement | OffscreenCanvas, type: string, quality?: number): Promise<Blob>;
|
|
67
|
-
/**
|
|
68
|
-
* Renders DecodedImage pixel data onto a canvas and encodes it into the target format.
|
|
69
|
-
*/
|
|
70
|
-
export declare function renderAndEncode(decoded: DecodedImage, format: ImageFormat, quality: number, resize?: ResizeOptions, applyOrientation?: boolean, crop?: CropOptions, preserveExif?: boolean): Promise<Blob>;
|
|
71
|
-
export {};
|
package/dist/render/exif.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Post-encode EXIF re-injection for JPEG (APP1 segment) and PNG (eXIf chunk).
|
|
3
|
-
*
|
|
4
|
-
* Canvas encoding drops all source metadata; when `preserveExif: true` these
|
|
5
|
-
* helpers splice the decoded `DecodedImage.exif` block back into the encoded
|
|
6
|
-
* bytes. Both injectors are fail-safe by design: any surprise while parsing
|
|
7
|
-
* the encoded output (or a malformed EXIF block) returns the original bytes
|
|
8
|
-
* untouched — losing metadata is always preferable to emitting a corrupt
|
|
9
|
-
* image.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Rewrite the TIFF orientation tag (274) in a `"Exif\0\0" + TIFF` block to
|
|
13
|
-
* `1` (normal) and return a modified copy. Needed because the converted
|
|
14
|
-
* raster is already upright — the EXIF/orientation transform was applied at
|
|
15
|
-
* render (or by libheif for `irot`/`imir` files) — so carrying the source
|
|
16
|
-
* tag verbatim would tell EXIF-respecting consumers to rotate the image a
|
|
17
|
-
* second time. Fail-safe: anything malformed returns the block untouched,
|
|
18
|
-
* and the input array is never mutated.
|
|
19
|
-
*/
|
|
20
|
-
export declare function normalizeOrientationTag(block: Uint8Array): Uint8Array;
|
|
21
|
-
/**
|
|
22
|
-
* Insert the EXIF block as a JPEG APP1 segment, positioned after SOI and any
|
|
23
|
-
* leading APPn/COM segments (the conventional slot right after the JFIF
|
|
24
|
-
* APP0). Returns the original bytes unchanged when the JPEG does not parse,
|
|
25
|
-
* the block is malformed, or the block exceeds the 16-bit segment length
|
|
26
|
-
* field (EXIF payloads >64 KB are rare in HEIC items and splitting across
|
|
27
|
-
* multiple APP1 segments is out of scope).
|
|
28
|
-
*/
|
|
29
|
-
export declare function injectExifIntoJpeg(jpeg: Uint8Array, exifBlock: Uint8Array): Uint8Array;
|
|
30
|
-
/**
|
|
31
|
-
* Insert the EXIF TIFF structure as a PNG `eXIf` chunk (PNG Extensions
|
|
32
|
-
* registry: chunk data is the raw TIFF without the "Exif\0\0" JPEG marker).
|
|
33
|
-
* Positioned after IHDR and before the first IDAT (or IEND when there is no
|
|
34
|
-
* IDAT); an existing eXIf chunk wins untouched. Fail-safe: unparsable PNG
|
|
35
|
-
* input is returned unchanged.
|
|
36
|
-
*/
|
|
37
|
-
export declare function injectExifIntoPng(png: Uint8Array, exifBlock: Uint8Array): Uint8Array;
|