Skip to content

Commit

Permalink
Fix + update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
netpro2k committed Jul 27, 2022
1 parent ec265ea commit 2a29015
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"nipplejs": "github:mozillareality/nipplejs#mr-social-client/master",
"node-ensure": "0.0.0",
"normalize.css": "^8.0.1",
"pdfjs-dist": "^2.1.266",
"pdfjs-dist": "^2.14.305",
"phoenix": "github:gfodor/phoenix-js#master",
"prop-types": "^15.7.2",
"raven-js": "^3.20.1",
Expand Down
7 changes: 4 additions & 3 deletions src/components/media-pdf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pdfjs from "pdfjs-dist";
import * as pdfjs from "pdfjs-dist";
import { SOUND_CAMERA_TOOL_TOOK_SNAPSHOT } from "../systems/sound-effects-system";
import { scaleToAspectRatio } from "../utils/scale-to-aspect-ratio";
import { errorTexture } from "../utils/error-texture";
Expand All @@ -18,7 +18,8 @@ const TYPE_IMG_PNG = { type: "image/png" };
* name -> how to name the file
* Then the path to the worker script
*/
pdfjs.GlobalWorkerOptions.workerSrc = require("!!file-loader?outputPath=assets/js&name=[name]-[hash].js!pdfjs-dist/build/pdf.worker.min.js");
pdfjs.GlobalWorkerOptions.workerSrc =
require("!!file-loader?outputPath=assets/js&name=[name]-[hash].js!pdfjs-dist/build/pdf.worker.min.js").default;

AFRAME.registerComponent("media-pdf", {
schema: {
Expand Down Expand Up @@ -77,7 +78,7 @@ AFRAME.registerComponent("media-pdf", {

if (src !== oldData.src) {
const loadingSrc = this.data.src;
const pdf = await pdfjs.getDocument(src);
const pdf = await pdfjs.getDocument(src).promise;
if (loadingSrc !== this.data.src) return;

this.pdf = pdf;
Expand Down

0 comments on commit 2a29015

Please sign in to comment.