test(pdf-renderer): guard init() against repeated calls — libLoader must fire once
Adds idempotency test: calling init() twice must invoke libLoader only once. Adds `if (pdfjsReady) return;` guard to satisfy the contract. Addresses Felix Brandt round-4 suggestion on PR #536. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ export function createPdfRenderer(libLoader: LibLoader = defaultLibLoader) {
|
||||
let pdfjsLib: typeof import('pdfjs-dist') | null = null;
|
||||
|
||||
async function init(): Promise<void> {
|
||||
if (pdfjsReady) return;
|
||||
const [lib, { default: workerUrl }] = await libLoader();
|
||||
lib.GlobalWorkerOptions.workerSrc = workerUrl;
|
||||
pdfjsLib = lib;
|
||||
|
||||
Reference in New Issue
Block a user