Skip to content

Commit 027f66d

Browse files
fix: add navigator mock required for PDF.js 5.4.54+ (closes #42)
1 parent 40e0caf commit 027f66d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/pdfjs-serverless/mocks.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ if (typeof globalThis.FinalizationRegistry === 'undefined') {
1212
}
1313
}
1414

15+
// `navigator` is not available in serverless environments.
16+
globalThis.navigator ??= {}
17+
globalThis.navigator.platform ??= ''
18+
globalThis.navigator.userAgent ??= ''
19+
1520
// Export to ensure the mocks are not removed by tree-shaking.
1621
export const mocks = true

0 commit comments

Comments
 (0)