Something went wrong. Try again.
Synapse is a study workspace. Organize courses read and annotate the material, train with generated exercises and watch your progress forked from denishovart.com/synapse
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829// pdf.js, loaded on demand (it weighs ~350 KiB, so the viewer and the ingest// path pull it only when needed). It is imported as a bundled dependency, so// the same code path works in dev, in the built browser app, in the desktop// and mobile shells, and in the static web client - no server-served /vendor// route and nothing for Vite's dev transform to choke on.//// The worker is bundled too, addressed with the Vite `?url` + import.meta.url// idiom, so it loads relative to wherever the app is served.import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
let loading: Promise<void> | null = null;
/** Idempotent: resolves once window.pdfjsLib is available. */export function ensurePdfjs(): Promise<void> { if ((window as unknown as { pdfjsLib?: unknown }).pdfjsLib) return Promise.resolve(); if (!loading) { loading = import('pdfjs-dist') .then((pdfjsLib) => { pdfjsLib.GlobalWorkerOptions.workerSrc = workerUrl; (window as unknown as { pdfjsLib?: unknown }).pdfjsLib = pdfjsLib; }) .catch((e) => { loading = null; // allow a retry on the next viewer mount throw e; }); } return loading;}