1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix pdfjs import

This commit is contained in:
Bill Thornton 2020-11-20 23:28:21 -05:00
parent 79d92c01da
commit b9b3ed00ea

View file

@ -7,6 +7,7 @@ import { appRouter } from '../../components/appRouter';
import './style.css'; import './style.css';
import '../../elements/emby-button/paper-icon-button-light'; import '../../elements/emby-button/paper-icon-button-light';
import { Events } from 'jellyfin-apiclient'; import { Events } from 'jellyfin-apiclient';
import { GlobalWorkerOptions, getDocument } from 'pdfjs-dist';
export class PdfPlayer { export class PdfPlayer {
constructor() { constructor() {
@ -189,13 +190,12 @@ export class PdfPlayer {
const apiClient = ServerConnections.getApiClient(serverId); const apiClient = ServerConnections.getApiClient(serverId);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
import('pdfjs-dist').then(({default: pdfjs}) => {
const downloadHref = apiClient.getItemDownloadUrl(item.Id); const downloadHref = apiClient.getItemDownloadUrl(item.Id);
this.bindEvents(); this.bindEvents();
pdfjs.GlobalWorkerOptions.workerSrc = appRouter.baseUrl() + '/libraries/pdf.worker.js'; GlobalWorkerOptions.workerSrc = appRouter.baseUrl() + '/libraries/pdf.worker.js';
const downloadTask = pdfjs.getDocument(downloadHref); const downloadTask = getDocument(downloadHref);
downloadTask.promise.then(book => { downloadTask.promise.then(book => {
if (this.cancellationToken) return; if (this.cancellationToken) return;
this.book = book; this.book = book;
@ -212,7 +212,6 @@ export class PdfPlayer {
return resolve(); return resolve();
}); });
}); });
});
} }
next() { next() {