Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.0 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

// Browser-only: the bundler-resolved pdfjs worker URL (Vite `?url`). Kept in
// its own module so the static import is synchronous — react-pdf's
// `<Document>` may render on first paint, before any async registration
// could settle and would silently fall back to a main-thread fake worker.
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";

/**
 * Point react-pdf's bundled pdfjs at the worker. Call at module scope in each
 * (lazy) module that renders a PDF — react-pdf ships its own pdfjs instance, and that instance
 * (not the one `./pdf` loads for text extraction) is what `<Document>` and
 * any browser code importing `pdfjs` from "react-pdf" use.
 */
export function registerReactPdfWorker(pdfjs: {
  GlobalWorkerOptions: { workerSrc: string };
}): void {
  pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
}