fix: Fix PDF export not working on Android

The request for loading the PDF worker gets canceled since it tries to load it from a `file:` url, so we need to inline the loader as a blob so that it can be loaded correctly.
This commit is contained in:
Aman Harwara
2025-02-03 15:20:33 +05:30
parent ca234cdb33
commit a0467e7c4d
7 changed files with 29 additions and 6 deletions

View File

@@ -19,7 +19,8 @@ import { $isRemoteImageNode } from '../../../Plugins/RemoteImagePlugin/RemoteIma
import { $isCollapsibleContainerNode } from '../../../Plugins/CollapsiblePlugin/CollapsibleContainerNode'
import { $isCollapsibleContentNode } from '../../../Plugins/CollapsiblePlugin/CollapsibleContentNode'
import { $isCollapsibleTitleNode } from '../../../Plugins/CollapsiblePlugin/CollapsibleTitleNode'
import { PDFDataNode, PDFWorker } from './PDFWorker'
// @ts-expect-error TS thinks there's no default export but that is added by the webpack loader.
import PDFWorker, { PDFDataNode, PDFWorkerInterface } from './PDFWorker.worker'
import { wrap } from 'comlink'
import { PrefKey, PrefValue } from '@standardnotes/snjs'
@@ -417,7 +418,8 @@ const getPDFDataNodesFromLexicalNodes = (nodes: LexicalNode[]): PDFDataNode[] =>
return nodes.map(getPDFDataNodeFromLexicalNode)
}
const PDFWorkerComlink = wrap<PDFWorker>(new Worker(new URL('./PDFWorker.tsx', import.meta.url)))
const pdfWorker = new PDFWorker()
const PDFWorkerComlink = wrap<PDFWorkerInterface>(pdfWorker)
/**
* @returns The PDF as an object url

View File

@@ -102,6 +102,6 @@ expose({
renderPDF,
})
export type PDFWorker = {
export type PDFWorkerInterface = {
renderPDF: typeof renderPDF
}