From bd3b5ade4cad1a2322716cce811cce8db397d246 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 18 Mar 2025 19:15:42 -0400 Subject: updated and fixed breaking pdfjs-dist --- src/client/views/pdf/PDFViewer.tsx | 6 +++++- src/typings/index.d.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 83b3dffe5..f6f319831 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -2,7 +2,11 @@ import { action, computed, IReactionDisposer, makeObservable, observable, Observ import { observer } from 'mobx-react'; import * as Pdfjs from 'pdfjs-dist'; import * as PDFJSViewer from 'pdfjs-dist/web/pdf_viewer.mjs'; -import 'pdfjs-dist/webpack.mjs'; // sets the PDF workerSrc +import { GlobalWorkerOptions } from 'pdfjs-dist/build/pdf.mjs'; +if (typeof window !== 'undefined' && 'Worker' in window) { + GlobalWorkerOptions.workerSrc = 'files/pdf.worker.min.mjs'; +} +export * from 'pdfjs-dist/build/pdf.mjs'; import * as React from 'react'; import { addStyleSheet, addStyleSheetRule, clearStyleSheetRules, ClientUtils, returnAll, returnFalse, returnNone, returnZero, smoothScroll } from '../../../ClientUtils'; import { CreateLinkToActiveAudio, Doc, DocListCast, Opt } from '../../../fields/Doc'; diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index dbfabed51..abcec13c0 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -11,6 +11,7 @@ declare module 'bezier-curve'; declare module 'fit-curve'; declare module 'iink-js'; declare module 'pdfjs-dist/web/pdf_viewer'; +declare module 'pdfjs-dist/build/pdf.mjs'; declare module 'react-jsx-parser'; declare module 'type_decls.d'; declare module 'standard-http-error'; -- cgit v1.2.3-70-g09d2