Skip to content

Commit b2e6948

Browse files
committed
Await the proxied onProgress inside the worker
1 parent 570c536 commit b2e6948

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pdf/src/PdfComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ export default {
88
totalContents: { type: Number, default: 0 },
99
type: { type: String, default: '' },
1010
},
11-
beforeCreate() {
11+
async beforeCreate() {
1212
Object.entries(this.$options?.pdfStyle || []).forEach(([selector, rules]) => {
1313
styleStore[selector] = styleStore[selector] || {}
1414
Object.assign(styleStore[selector], rules)
1515
})
1616

1717
if (this.index !== -1) {
18-
this.$onProgress('assembleContent', {
18+
await this.$onProgress('assembleContent', {
1919
content: this.index + 1,
2020
totalContents: this.totalContents,
2121
type: this.$tc(`print.${camelCase(this.type)}.title`),

pdf/src/renderer/reactPdfRenderer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ const fontStore = new FontStore()
88
export async function renderPdfStructureToReactPdf(
99
pdfStructure,
1010
compress = true,
11-
onProgress = () => {}
11+
onProgress = async () => {}
1212
) {
1313
await onProgress('layoutDocument')
1414

1515
let page = 0
16-
addEventListener('layoutPage', () => {
16+
addEventListener('layoutPage', async () => {
1717
page++
18-
onProgress('layoutPage', { page })
18+
await onProgress('layoutPage', { page })
1919
})
2020

2121
const layout = await layoutDocument(pdfStructure, fontStore)
@@ -37,9 +37,9 @@ export async function renderPdfStructureToReactPdf(
3737
pageMode,
3838
})
3939

40-
ctx.on('pageAdded', () => {
40+
ctx.on('pageAdded', async () => {
4141
page++
42-
onProgress('renderingPdfPage', { page, totalPages })
42+
await onProgress('renderingPdfPage', { page, totalPages })
4343
})
4444

4545
return renderPDF(ctx, layout)

pdf/src/renderer/vueRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { nodeOps } from './nodeOps.js'
33
// eslint-disable-next-line vue/prefer-import-from-vue
44
import { createRenderer } from '@vue/runtime-core'
55

6-
export function renderVueToPdfStructure(root, props = {}, onProgress = () => {}) {
6+
export function renderVueToPdfStructure(root, props = {}, onProgress = async () => {}) {
77
// We need a "root container" (normally the <div id="app"> DOM element).
88
// Vue uses this to keep track of which running Vue app this is.
99
const container = {}

0 commit comments

Comments
 (0)