All files / worker index.ts

75% Statements 18/24
60% Branches 3/5
100% Functions 2/2
75% Lines 18/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37  1x 1x   1x   1x 1x             1x 3x 3x   3x       1x     1x   1x 1x 1x   1x   1x 1x 1x  
/** biome-ignore-all lint/suspicious/noConsole: error dedection */
import path from 'node:path';
import { fileURLToPath } from 'node:url';
 
let runtimeDirname: string;
 
if (typeof __dirname !== 'undefined') {
	runtimeDirname = __dirname;
} else {
	// ESM ortamı
	const __filename = fileURLToPath(import.meta.url);
	runtimeDirname = path.dirname(__filename);
}
 
(async () => {
	try {
		await import('pdfjs-dist/legacy/build/pdf.worker.mjs');
		//console.log('pdf.worker loaded.\n');
	} catch (err) {
		console.error('pdf.worker load error!..\n', err);
		// fallback veya graceful degradation
	}
})();
 
// @ts-expect-error: importing worker as data URL via esbuild query parameter
import DataUrl from 'pdfjs-dist/legacy/build/pdf.worker.min.mjs?dataurl';
 
export function getData(): string {
	return DataUrl;
}
 
export { CanvasFactory } from './canvas.js';
 
export function getPath(): string {
	return path.resolve(runtimeDirname, '../pdf.worker.mjs');
}