@@ -1875,7 +1875,7 @@ class WorkerTransport {
1875
1875
setupMessageHandler ( ) {
1876
1876
const { messageHandler, loadingTask, } = this ;
1877
1877
1878
- messageHandler . on ( 'GetReader' , function ( data , sink ) {
1878
+ messageHandler . on ( 'GetReader' , ( data , sink ) => {
1879
1879
assert ( this . _networkStream ) ;
1880
1880
this . _fullReader = this . _networkStream . getFullReader ( ) ;
1881
1881
this . _fullReader . onProgress = ( evt ) => {
@@ -1902,9 +1902,9 @@ class WorkerTransport {
1902
1902
sink . onCancel = ( reason ) => {
1903
1903
this . _fullReader . cancel ( reason ) ;
1904
1904
} ;
1905
- } , this ) ;
1905
+ } ) ;
1906
1906
1907
- messageHandler . on ( 'ReaderHeadersReady' , function ( data ) {
1907
+ messageHandler . on ( 'ReaderHeadersReady' , ( data ) => {
1908
1908
const headersCapability = createPromiseCapability ( ) ;
1909
1909
const fullReader = this . _fullReader ;
1910
1910
fullReader . headersReady . then ( ( ) => {
@@ -1932,9 +1932,9 @@ class WorkerTransport {
1932
1932
} , headersCapability . reject ) ;
1933
1933
1934
1934
return headersCapability . promise ;
1935
- } , this ) ;
1935
+ } ) ;
1936
1936
1937
- messageHandler . on ( 'GetRangeReader' , function ( data , sink ) {
1937
+ messageHandler . on ( 'GetRangeReader' , ( data , sink ) => {
1938
1938
assert ( this . _networkStream ) ;
1939
1939
const rangeReader =
1940
1940
this . _networkStream . getRangeReader ( data . begin , data . end ) ;
@@ -1970,14 +1970,14 @@ class WorkerTransport {
1970
1970
sink . onCancel = ( reason ) => {
1971
1971
rangeReader . cancel ( reason ) ;
1972
1972
} ;
1973
- } , this ) ;
1973
+ } ) ;
1974
1974
1975
- messageHandler . on ( 'GetDoc' , function ( { pdfInfo, } ) {
1975
+ messageHandler . on ( 'GetDoc' , ( { pdfInfo, } ) => {
1976
1976
this . _numPages = pdfInfo . numPages ;
1977
1977
loadingTask . _capability . resolve ( new PDFDocumentProxy ( pdfInfo , this ) ) ;
1978
- } , this ) ;
1978
+ } ) ;
1979
1979
1980
- messageHandler . on ( 'PasswordRequest' , function ( exception ) {
1980
+ messageHandler . on ( 'PasswordRequest' , ( exception ) => {
1981
1981
this . _passwordCapability = createPromiseCapability ( ) ;
1982
1982
1983
1983
if ( loadingTask . onPassword ) {
@@ -1996,34 +1996,34 @@ class WorkerTransport {
1996
1996
new PasswordException ( exception . message , exception . code ) ) ;
1997
1997
}
1998
1998
return this . _passwordCapability . promise ;
1999
- } , this ) ;
1999
+ } ) ;
2000
2000
2001
2001
messageHandler . on ( 'PasswordException' , function ( exception ) {
2002
2002
loadingTask . _capability . reject (
2003
2003
new PasswordException ( exception . message , exception . code ) ) ;
2004
- } , this ) ;
2004
+ } ) ;
2005
2005
2006
2006
messageHandler . on ( 'InvalidPDF' , function ( exception ) {
2007
2007
loadingTask . _capability . reject (
2008
2008
new InvalidPDFException ( exception . message ) ) ;
2009
- } , this ) ;
2009
+ } ) ;
2010
2010
2011
2011
messageHandler . on ( 'MissingPDF' , function ( exception ) {
2012
2012
loadingTask . _capability . reject (
2013
2013
new MissingPDFException ( exception . message ) ) ;
2014
- } , this ) ;
2014
+ } ) ;
2015
2015
2016
2016
messageHandler . on ( 'UnexpectedResponse' , function ( exception ) {
2017
2017
loadingTask . _capability . reject (
2018
2018
new UnexpectedResponseException ( exception . message , exception . status ) ) ;
2019
- } , this ) ;
2019
+ } ) ;
2020
2020
2021
2021
messageHandler . on ( 'UnknownError' , function ( exception ) {
2022
2022
loadingTask . _capability . reject (
2023
2023
new UnknownErrorException ( exception . message , exception . details ) ) ;
2024
- } , this ) ;
2024
+ } ) ;
2025
2025
2026
- messageHandler . on ( 'DataLoaded' , function ( data ) {
2026
+ messageHandler . on ( 'DataLoaded' , ( data ) => {
2027
2027
// For consistency: Ensure that progress is always reported when the
2028
2028
// entire PDF file has been loaded, regardless of how it was fetched.
2029
2029
if ( loadingTask . onProgress ) {
@@ -2033,19 +2033,19 @@ class WorkerTransport {
2033
2033
} ) ;
2034
2034
}
2035
2035
this . downloadInfoCapability . resolve ( data ) ;
2036
- } , this ) ;
2036
+ } ) ;
2037
2037
2038
- messageHandler . on ( 'StartRenderPage' , function ( data ) {
2038
+ messageHandler . on ( 'StartRenderPage' , ( data ) => {
2039
2039
if ( this . destroyed ) {
2040
2040
return ; // Ignore any pending requests if the worker was terminated.
2041
2041
}
2042
2042
2043
2043
const page = this . pageCache [ data . pageIndex ] ;
2044
2044
page . _stats . timeEnd ( 'Page Request' ) ;
2045
2045
page . _startRenderPage ( data . transparency , data . intent ) ;
2046
- } , this ) ;
2046
+ } ) ;
2047
2047
2048
- messageHandler . on ( 'commonobj' , function ( data ) {
2048
+ messageHandler . on ( 'commonobj' , ( data ) => {
2049
2049
if ( this . destroyed ) {
2050
2050
return ; // Ignore any pending requests if the worker was terminated.
2051
2051
}
@@ -2100,9 +2100,9 @@ class WorkerTransport {
2100
2100
default :
2101
2101
throw new Error ( `Got unknown common object type ${ type } ` ) ;
2102
2102
}
2103
- } , this ) ;
2103
+ } ) ;
2104
2104
2105
- messageHandler . on ( 'obj' , function ( data ) {
2105
+ messageHandler . on ( 'obj' , ( data ) => {
2106
2106
if ( this . destroyed ) {
2107
2107
// Ignore any pending requests if the worker was terminated.
2108
2108
return undefined ;
@@ -2149,9 +2149,9 @@ class WorkerTransport {
2149
2149
throw new Error ( `Got unknown object type ${ type } ` ) ;
2150
2150
}
2151
2151
return undefined ;
2152
- } , this ) ;
2152
+ } ) ;
2153
2153
2154
- messageHandler . on ( 'DocProgress' , function ( data ) {
2154
+ messageHandler . on ( 'DocProgress' , ( data ) => {
2155
2155
if ( this . destroyed ) {
2156
2156
return ; // Ignore any pending requests if the worker was terminated.
2157
2157
}
@@ -2162,11 +2162,12 @@ class WorkerTransport {
2162
2162
total : data . total ,
2163
2163
} ) ;
2164
2164
}
2165
- } , this ) ;
2165
+ } ) ;
2166
2166
2167
- messageHandler . on ( 'UnsupportedFeature' , this . _onUnsupportedFeature , this ) ;
2167
+ messageHandler . on ( 'UnsupportedFeature' ,
2168
+ this . _onUnsupportedFeature . bind ( this ) ) ;
2168
2169
2169
- messageHandler . on ( 'JpegDecode' , function ( data ) {
2170
+ messageHandler . on ( 'JpegDecode' , ( data ) => {
2170
2171
if ( this . destroyed ) {
2171
2172
return Promise . reject ( new Error ( 'Worker was destroyed' ) ) ;
2172
2173
}
@@ -2227,16 +2228,14 @@ class WorkerTransport {
2227
2228
} ;
2228
2229
img . src = imageUrl ;
2229
2230
} ) ;
2230
- } , this ) ;
2231
+ } ) ;
2231
2232
2232
- messageHandler . on ( 'FetchBuiltInCMap' , function ( data ) {
2233
+ messageHandler . on ( 'FetchBuiltInCMap' , ( data ) => {
2233
2234
if ( this . destroyed ) {
2234
2235
return Promise . reject ( new Error ( 'Worker was destroyed' ) ) ;
2235
2236
}
2236
- return this . CMapReaderFactory . fetch ( {
2237
- name : data . name ,
2238
- } ) ;
2239
- } , this ) ;
2237
+ return this . CMapReaderFactory . fetch ( data ) ;
2238
+ } ) ;
2240
2239
}
2241
2240
2242
2241
_onUnsupportedFeature ( { featureId, } ) {
0 commit comments