diff --git a/src/utils/images-to-pdf/images-to-pdf.ts b/src/utils/images-to-pdf/images-to-pdf.ts index 68a54ac4..167b05cd 100644 --- a/src/utils/images-to-pdf/images-to-pdf.ts +++ b/src/utils/images-to-pdf/images-to-pdf.ts @@ -5,7 +5,10 @@ export type ImageInfo = { dpi: number; }; -export async function imagesToPDF(images: ImageInfo[]): Promise { +export async function imagesToPDF( + images: ImageInfo[], + signal?: AbortSignal +): Promise { const jsPDF = (await import("jspdf")).default; const doc = new jsPDF({ @@ -14,6 +17,10 @@ export async function imagesToPDF(images: ImageInfo[]): Promise { doc.deletePage(1); // delete the default page for (const image of images) { + if (signal?.aborted) { + throw new DOMException("Aborted", "AbortError"); + } + const { blob, width, height, dpi } = image; const buffer = new Uint8Array(await blob.arrayBuffer()); const physicalWidth = width / dpi; diff --git a/src/utils/images-to-pdf/index.ts b/src/utils/images-to-pdf/index.ts index 328e83de..b2f2591a 100644 --- a/src/utils/images-to-pdf/index.ts +++ b/src/utils/images-to-pdf/index.ts @@ -1 +1 @@ -export { imagesToPDFWithWorker as imagesToPDF } from "./images-to-pdf-with-worker"; +export { imagesToPDF as imagesToPDF } from "./images-to-pdf"; diff --git a/vite.config.ts b/vite.config.ts index a8b0f218..4d6b0e4c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -41,9 +41,9 @@ export default defineConfig({ "@": path.resolve(__dirname, "src"), }, }, - worker: { - format: "es", - }, + // worker: { + // format: "es", + // }, /* remove the need to specify .vue files https://vitejs.dev/config/#resolve-extensions resolve: { extensions: [