@@ -79,6 +79,8 @@ import { XRef } from "./xref.js";
7979const LETTER_SIZE_MEDIABOX = [ 0 , 0 , 612 , 792 ] ;
8080
8181class Page {
82+ #resourcesPromise = null ;
83+
8284 constructor ( {
8385 pdfManager,
8486 xref,
@@ -108,7 +110,6 @@ class Page {
108110 this . systemFontCache = systemFontCache ;
109111 this . nonBlendModesSet = nonBlendModesSet ;
110112 this . evaluatorOptions = pdfManager . evaluatorOptions ;
111- this . resourcesPromise = null ;
112113 this . xfaFactory = xfaFactory ;
113114
114115 const idCounters = {
@@ -400,7 +401,10 @@ class Page {
400401
401402 async loadResources ( keys ) {
402403 // TODO: add async `#getInheritableProperty` and remove this.
403- await ( this . resourcesPromise ??= this . pdfManager . ensure ( this , "resources" ) ) ;
404+ await ( this . #resourcesPromise ??= this . pdfManager . ensure (
405+ this ,
406+ "resources"
407+ ) ) ;
404408
405409 await ObjectLoader . load ( this . resources , keys , this . xref ) ;
406410 }
@@ -876,6 +880,10 @@ function find(stream, signature, limit = 1024, backwards = false) {
876880 * The `PDFDocument` class holds all the (worker-thread) data of the PDF file.
877881 */
878882class PDFDocument {
883+ #pagePromises = new Map ( ) ;
884+
885+ #version = null ;
886+
879887 constructor ( pdfManager , stream ) {
880888 if ( typeof PDFJSDev === "undefined" || PDFJSDev . test ( "TESTING" ) ) {
881889 assert (
@@ -892,8 +900,6 @@ class PDFDocument {
892900 this . pdfManager = pdfManager ;
893901 this . stream = stream ;
894902 this . xref = new XRef ( stream , pdfManager ) ;
895- this . _pagePromises = new Map ( ) ;
896- this . _version = null ;
897903
898904 const idCounters = {
899905 font : 0 ,
@@ -1014,7 +1020,7 @@ class PDFDocument {
10141020 }
10151021
10161022 if ( PDF_VERSION_REGEXP . test ( version ) ) {
1017- this . _version = version ;
1023+ this . #version = version ;
10181024 } else {
10191025 warn ( `Invalid PDF header version: ${ version } ` ) ;
10201026 }
@@ -1347,7 +1353,7 @@ class PDFDocument {
13471353 * the catalog, if present, should overwrite the version from the header.
13481354 */
13491355 get version ( ) {
1350- return this . catalog . version || this . _version ;
1356+ return this . catalog . version || this . #version ;
13511357 }
13521358
13531359 get formInfo ( ) {
@@ -1554,7 +1560,7 @@ class PDFDocument {
15541560 }
15551561
15561562 getPage ( pageIndex ) {
1557- const cachedPromise = this . _pagePromises . get ( pageIndex ) ;
1563+ const cachedPromise = this . #pagePromises . get ( pageIndex ) ;
15581564 if ( cachedPromise ) {
15591565 return cachedPromise ;
15601566 }
@@ -1588,7 +1594,7 @@ class PDFDocument {
15881594 } )
15891595 ) ;
15901596
1591- this . _pagePromises . set ( pageIndex , promise ) ;
1597+ this . #pagePromises . set ( pageIndex , promise ) ;
15921598 return promise ;
15931599 }
15941600
@@ -1603,7 +1609,7 @@ class PDFDocument {
16031609 // Clear out the various caches to ensure that we haven't stored any
16041610 // inconsistent and/or incorrect state, since that could easily break
16051611 // subsequent `this.getPage` calls.
1606- this . _pagePromises . delete ( 0 ) ;
1612+ this . #pagePromises . delete ( 0 ) ;
16071613 await this . cleanup ( ) ;
16081614
16091615 throw new XRefParseException ( ) ;
@@ -1642,7 +1648,7 @@ class PDFDocument {
16421648 // Clear out the various caches to ensure that we haven't stored any
16431649 // inconsistent and/or incorrect state, since that could easily break
16441650 // subsequent `this.getPage` calls.
1645- this . _pagePromises . delete ( numPages - 1 ) ;
1651+ this . #pagePromises . delete ( numPages - 1 ) ;
16461652 await this . cleanup ( ) ;
16471653
16481654 if ( reason instanceof XRefEntryException && ! recoveryMode ) {
@@ -1689,7 +1695,7 @@ class PDFDocument {
16891695 ) ;
16901696 }
16911697
1692- this . _pagePromises . set ( pageIndex , promise ) ;
1698+ this . #pagePromises . set ( pageIndex , promise ) ;
16931699 }
16941700 catalog . setActualNumPages ( pagesTree . size ) ;
16951701 }
0 commit comments