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:
@@ -99,7 +99,8 @@
|
||||
"webextension-polyfill": "^0.10.0",
|
||||
"webpack": "*",
|
||||
"webpack-dev-server": "*",
|
||||
"webpack-merge": "*"
|
||||
"webpack-merge": "*",
|
||||
"worker-loader": "^3.0.8"
|
||||
},
|
||||
"lint-staged": {
|
||||
"app/**/*.{js,ts,jsx,tsx}": "eslint --cache --fix",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -102,6 +102,6 @@ expose({
|
||||
renderPDF,
|
||||
})
|
||||
|
||||
export type PDFWorker = {
|
||||
export type PDFWorkerInterface = {
|
||||
renderPDF: typeof renderPDF
|
||||
}
|
||||
@@ -92,6 +92,13 @@ module.exports = (env) => {
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.worker\.tsx?$/,
|
||||
loader: 'worker-loader',
|
||||
options: {
|
||||
inline: 'fallback',
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(js|tsx?)$/,
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user