@@ -11,26 +11,29 @@ if (!global.URL.$$objects) {
11
11
return `blob:http://localhost/${ id } ` ;
12
12
} ;
13
13
14
-
15
14
try {
16
- var oldFetch = global . fetch || fetch__default ;
17
- global . fetch = function ( e , t ) {
18
- return new Promise ( function ( t , o ) {
19
- var n = new FileReader ;
20
- n . onload = function ( ) {
21
- var e = global . Response || fetch . Response ;
22
- t ( new e ( n . result , {
23
- status : 200 ,
24
- statusText : "OK"
25
- } ) )
26
- } , n . onerror = function ( ) {
27
- o ( n . error )
28
- } ;
29
- var s = e . match ( / [ ^ / ] + $ / ) [ 0 ] ;
30
- n . readAsText ( global . URL . $$objects [ s ] )
31
- } )
32
- }
33
- } catch ( err ) { }
15
+ let oldFetch = global . fetch || fetch ;
16
+ global . fetch = function ( url , opts ) {
17
+ if ( url . match ( / ^ b l o b : / ) ) {
18
+ return new Promise ( ( resolve , reject ) => {
19
+ let fr = new FileReader ( ) ;
20
+ fr . onload = ( ) => {
21
+ let Res = global . Response || Response ;
22
+ resolve ( new Res ( fr . result , { status : 200 , statusText : 'OK' } ) ) ;
23
+ } ;
24
+ fr . onerror = ( ) => {
25
+ reject ( fr . error ) ;
26
+ } ;
27
+ let id = url . match ( / [ ^ / ] + $ / ) [ 0 ] ;
28
+ fr . readAsText ( global . URL . $$objects [ id ] ) ;
29
+ } ) ;
30
+ }
31
+ return oldFetch . call ( this , url , opts ) ;
32
+ } ;
33
+ } catch ( err ) {
34
+
35
+ }
36
+
34
37
35
38
}
36
39
@@ -81,7 +84,7 @@ global.Worker = function Worker(url) {
81
84
. then ( code => {
82
85
let vars = 'var self=this,global=self' ;
83
86
for ( let k in scope ) vars += `,${ k } =self.${ k } ` ;
84
- getScopeVar = eval ( '(function() {' + vars + '; \n' + code + '\nreturn function(__){return eval(__)}})' ) . call ( scope ) ;
87
+ getScopeVar = eval ( '(function() {' + vars + '\n' + code + '\nreturn function(__){return eval(__)}})' ) . call ( scope ) ;
85
88
let q = messageQueue ;
86
89
messageQueue = null ;
87
90
q . forEach ( this . postMessage ) ;
0 commit comments