@ -686,265 +686,9 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
@@ -686,265 +686,9 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
} ) ( ) ;
( function checkPromise ( ) {
if ( globalScope . Promise ) {
if ( typeof globalScope . Promise . all !== 'function' ) {
globalScope . Promise . all = function ( iterable ) {
var count = 0 ,
results = [ ] ,
resolve ,
reject ;
var promise = new globalScope . Promise ( function ( resolve _ , reject _ ) {
resolve = resolve _ ;
reject = reject _ ;
} ) ;
iterable . forEach ( function ( p , i ) {
count ++ ;
p . then ( function ( result ) {
results [ i ] = result ;
count -- ;
if ( count === 0 ) {
resolve ( results ) ;
}
} , reject ) ;
} ) ;
if ( count === 0 ) {
resolve ( results ) ;
}
return promise ;
} ;
}
if ( typeof globalScope . Promise . resolve !== 'function' ) {
globalScope . Promise . resolve = function ( value ) {
return new globalScope . Promise ( function ( resolve ) {
resolve ( value ) ;
} ) ;
} ;
}
if ( typeof globalScope . Promise . reject !== 'function' ) {
globalScope . Promise . reject = function ( reason ) {
return new globalScope . Promise ( function ( resolve , reject ) {
reject ( reason ) ;
} ) ;
} ;
}
if ( typeof globalScope . Promise . prototype . catch !== 'function' ) {
globalScope . Promise . prototype . catch = function ( onReject ) {
return globalScope . Promise . prototype . then ( undefined , onReject ) ;
} ;
}
return ;
}
var STATUS _PENDING = 0 ;
var STATUS _RESOLVED = 1 ;
var STATUS _REJECTED = 2 ;
var REJECTION _TIMEOUT = 500 ;
var HandlerManager = {
handlers : [ ] ,
running : false ,
unhandledRejections : [ ] ,
pendingRejectionCheck : false ,
scheduleHandlers : function scheduleHandlers ( promise ) {
if ( promise . _status === STATUS _PENDING ) {
return ;
}
this . handlers = this . handlers . concat ( promise . _handlers ) ;
promise . _handlers = [ ] ;
if ( this . running ) {
return ;
}
this . running = true ;
setTimeout ( this . runHandlers . bind ( this ) , 0 ) ;
} ,
runHandlers : function runHandlers ( ) {
var RUN _TIMEOUT = 1 ;
var timeoutAt = Date . now ( ) + RUN _TIMEOUT ;
while ( this . handlers . length > 0 ) {
var handler = this . handlers . shift ( ) ;
var nextStatus = handler . thisPromise . _status ;
var nextValue = handler . thisPromise . _value ;
try {
if ( nextStatus === STATUS _RESOLVED ) {
if ( typeof handler . onResolve === 'function' ) {
nextValue = handler . onResolve ( nextValue ) ;
}
} else if ( typeof handler . onReject === 'function' ) {
nextValue = handler . onReject ( nextValue ) ;
nextStatus = STATUS _RESOLVED ;
if ( handler . thisPromise . _unhandledRejection ) {
this . removeUnhandeledRejection ( handler . thisPromise ) ;
}
}
} catch ( ex ) {
nextStatus = STATUS _REJECTED ;
nextValue = ex ;
}
handler . nextPromise . _updateStatus ( nextStatus , nextValue ) ;
if ( Date . now ( ) >= timeoutAt ) {
break ;
}
}
if ( this . handlers . length > 0 ) {
setTimeout ( this . runHandlers . bind ( this ) , 0 ) ;
return ;
}
this . running = false ;
} ,
addUnhandledRejection : function addUnhandledRejection ( promise ) {
this . unhandledRejections . push ( {
promise : promise ,
time : Date . now ( )
} ) ;
this . scheduleRejectionCheck ( ) ;
} ,
removeUnhandeledRejection : function removeUnhandeledRejection ( promise ) {
promise . _unhandledRejection = false ;
for ( var i = 0 ; i < this . unhandledRejections . length ; i ++ ) {
if ( this . unhandledRejections [ i ] . promise === promise ) {
this . unhandledRejections . splice ( i ) ;
i -- ;
}
}
} ,
scheduleRejectionCheck : function scheduleRejectionCheck ( ) {
var _this = this ;
if ( this . pendingRejectionCheck ) {
return ;
}
this . pendingRejectionCheck = true ;
setTimeout ( function ( ) {
_this . pendingRejectionCheck = false ;
var now = Date . now ( ) ;
for ( var i = 0 ; i < _this . unhandledRejections . length ; i ++ ) {
if ( now - _this . unhandledRejections [ i ] . time > REJECTION _TIMEOUT ) {
var unhandled = _this . unhandledRejections [ i ] . promise . _value ;
var msg = 'Unhandled rejection: ' + unhandled ;
if ( unhandled . stack ) {
msg += '\n' + unhandled . stack ;
}
try {
throw new Error ( msg ) ;
} catch ( _ ) {
console . warn ( msg ) ;
}
_this . unhandledRejections . splice ( i ) ;
i -- ;
}
}
if ( _this . unhandledRejections . length ) {
_this . scheduleRejectionCheck ( ) ;
}
} , REJECTION _TIMEOUT ) ;
}
} ;
var Promise = function Promise ( resolver ) {
this . _status = STATUS _PENDING ;
this . _handlers = [ ] ;
try {
resolver . call ( this , this . _resolve . bind ( this ) , this . _reject . bind ( this ) ) ;
} catch ( e ) {
this . _reject ( e ) ;
}
} ;
Promise . all = function Promise _all ( promises ) {
var resolveAll , rejectAll ;
var deferred = new Promise ( function ( resolve , reject ) {
resolveAll = resolve ;
rejectAll = reject ;
} ) ;
var unresolved = promises . length ;
var results = [ ] ;
if ( unresolved === 0 ) {
resolveAll ( results ) ;
return deferred ;
}
function reject ( reason ) {
if ( deferred . _status === STATUS _REJECTED ) {
return ;
}
results = [ ] ;
rejectAll ( reason ) ;
}
for ( var i = 0 , ii = promises . length ; i < ii ; ++ i ) {
var promise = promises [ i ] ;
var resolve = function ( i ) {
return function ( value ) {
if ( deferred . _status === STATUS _REJECTED ) {
return ;
}
results [ i ] = value ;
unresolved -- ;
if ( unresolved === 0 ) {
resolveAll ( results ) ;
}
} ;
} ( i ) ;
if ( Promise . isPromise ( promise ) ) {
promise . then ( resolve , reject ) ;
} else {
resolve ( promise ) ;
}
}
return deferred ;
} ;
Promise . isPromise = function Promise _isPromise ( value ) {
return value && typeof value . then === 'function' ;
} ;
Promise . resolve = function Promise _resolve ( value ) {
return new Promise ( function ( resolve ) {
resolve ( value ) ;
} ) ;
} ;
Promise . reject = function Promise _reject ( reason ) {
return new Promise ( function ( resolve , reject ) {
reject ( reason ) ;
} ) ;
} ;
Promise . prototype = {
_status : null ,
_value : null ,
_handlers : null ,
_unhandledRejection : null ,
_updateStatus : function Promise _ _updateStatus ( status , value ) {
if ( this . _status === STATUS _RESOLVED || this . _status === STATUS _REJECTED ) {
return ;
}
if ( status === STATUS _RESOLVED && Promise . isPromise ( value ) ) {
value . then ( this . _updateStatus . bind ( this , STATUS _RESOLVED ) , this . _updateStatus . bind ( this , STATUS _REJECTED ) ) ;
return ;
}
this . _status = status ;
this . _value = value ;
if ( status === STATUS _REJECTED && this . _handlers . length === 0 ) {
this . _unhandledRejection = true ;
HandlerManager . addUnhandledRejection ( this ) ;
}
HandlerManager . scheduleHandlers ( this ) ;
} ,
_resolve : function Promise _resolve ( value ) {
this . _updateStatus ( STATUS _RESOLVED , value ) ;
} ,
_reject : function Promise _reject ( reason ) {
this . _updateStatus ( STATUS _REJECTED , reason ) ;
} ,
then : function Promise _then ( onResolve , onReject ) {
var nextPromise = new Promise ( function ( resolve , reject ) {
this . resolve = resolve ;
this . reject = reject ;
} ) ;
this . _handlers . push ( {
thisPromise : this ,
onResolve : onResolve ,
onReject : onReject ,
nextPromise : nextPromise
} ) ;
HandlerManager . scheduleHandlers ( this ) ;
return nextPromise ;
} ,
catch : function Promise _catch ( onReject ) {
return this . then ( undefined , onReject ) ;
}
} ;
globalScope . Promise = Promise ;
globalScope . Promise = require ( 'core-js/fn/promise' ) ;
} ) ( ) ;
( function checkWeakMap ( ) {
if ( globalScope . WeakMap ) {