vomebook commited on
Commit
16bab71
·
verified ·
1 Parent(s): 0c2cc51

Upload 2 files

Browse files
Files changed (2) hide show
  1. static/app.js +8 -1
  2. static/style.css +6 -3
static/app.js CHANGED
@@ -1381,9 +1381,16 @@ async function createPDFRangeTransport(pdfjs, url) {
1381
  const match = /^bytes\s+\d+-\d+\/(\d+)$/.exec(contentRange);
1382
  const length = match ? Number(match[1]) : 0;
1383
  if (!Number.isSafeInteger(length) || length <= 0) throw new Error("PDF range length is unavailable");
 
 
 
 
 
 
 
1384
  class URLRangeTransport extends pdfjs.PDFDataRangeTransport {
1385
  constructor() {
1386
- super(length, null, false);
1387
  this.controllers = new Set();
1388
  }
1389
 
 
1381
  const match = /^bytes\s+\d+-\d+\/(\d+)$/.exec(contentRange);
1382
  const length = match ? Number(match[1]) : 0;
1383
  if (!Number.isSafeInteger(length) || length <= 0) throw new Error("PDF range length is unavailable");
1384
+ const initialEnd = Math.min(512 * 1024, length);
1385
+ const initialResponse = await fetch(url, {
1386
+ headers: { Range: `bytes=0-${initialEnd - 1}` },
1387
+ cache: "no-store",
1388
+ });
1389
+ if (initialResponse.status !== 206) throw new Error(`PDF initial range failed: ${initialResponse.status}`);
1390
+ const initialData = new Uint8Array(await initialResponse.arrayBuffer());
1391
  class URLRangeTransport extends pdfjs.PDFDataRangeTransport {
1392
  constructor() {
1393
+ super(length, initialData, false);
1394
  this.controllers = new Set();
1395
  }
1396
 
static/style.css CHANGED
@@ -677,17 +677,19 @@ ul, li {
677
  background: #e6e6e6;
678
  }
679
 
680
- .proofread-pdf-stage.is-loading {
 
681
  padding: 0;
682
  background: #fff;
683
  align-items: stretch;
684
  }
685
 
686
- .proofread-pdf-stage.is-loading canvas {
687
  width: 100%;
688
  height: 100%;
689
  min-height: 100%;
690
  box-shadow: none;
 
691
  }
692
 
693
  .proofread-pdf-stage canvas {
@@ -1015,7 +1017,8 @@ body.mobile .proofread-pdf-stage {
1015
  -webkit-overflow-scrolling: touch;
1016
  }
1017
 
1018
- body.mobile .proofread-pdf-stage.is-loading {
 
1019
  padding: 0;
1020
  }
1021
 
 
677
  background: #e6e6e6;
678
  }
679
 
680
+ .proofread-pdf-stage.is-loading,
681
+ .proofread-pdf-stage.is-error {
682
  padding: 0;
683
  background: #fff;
684
  align-items: stretch;
685
  }
686
 
687
+ .proofread-pdf-stage.is-error canvas {
688
  width: 100%;
689
  height: 100%;
690
  min-height: 100%;
691
  box-shadow: none;
692
+ visibility: hidden;
693
  }
694
 
695
  .proofread-pdf-stage canvas {
 
1017
  -webkit-overflow-scrolling: touch;
1018
  }
1019
 
1020
+ body.mobile .proofread-pdf-stage.is-loading,
1021
+ body.mobile .proofread-pdf-stage.is-error {
1022
  padding: 0;
1023
  }
1024