@@ -22,7 +22,7 @@ var Fetch = {
22
22
openDatabase : function ( dbname , dbversion , onsuccess , onerror ) {
23
23
try {
24
24
#if FETCH_DEBUG
25
- dbg ( ' fetch: indexedDB.open(dbname="' + dbname + ' ", dbversion="' + dbversion + ' ");' ) ;
25
+ dbg ( ` fetch: indexedDB.open(dbname="${ dbname } ", dbversion="${ dbversion } ");` ) ;
26
26
#endif
27
27
var openRequest = indexedDB . open ( dbname , dbversion ) ;
28
28
} catch ( e ) { return onerror ( e ) ; }
@@ -92,7 +92,7 @@ function fetchDeleteCachedData(db, fetch, onsuccess, onerror) {
92
92
request . onsuccess = ( event ) => {
93
93
var value = event . target . result ;
94
94
#if FETCH_DEBUG
95
- dbg ( ' fetch: Deleted file ' + pathStr + ' from IndexedDB' ) ;
95
+ dbg ( ` fetch: Deleted file ${ pathStr } from IndexedDB` ) ;
96
96
#endif
97
97
HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . data } } } >> 2 ] = 0 ;
98
98
writeI53ToI64 ( fetch + { { { C_STRUCTS . emscripten_fetch_t . numBytes } } } , 0 ) ;
@@ -105,7 +105,7 @@ function fetchDeleteCachedData(db, fetch, onsuccess, onerror) {
105
105
} ;
106
106
request . onerror = ( error ) => {
107
107
#if FETCH_DEBUG
108
- dbg ( ' fetch: Failed to delete file ' + pathStr + ' from IndexedDB! error: ' + error ) ;
108
+ dbg ( ` fetch: Failed to delete file ${ pathStr } from IndexedDB! error: ${ error } ` ) ;
109
109
#endif
110
110
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . readyState } } } >> 1 ] = 4 ; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
111
111
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = 404 ; // Mimic XHR HTTP status code 404 "Not Found"
@@ -114,7 +114,7 @@ function fetchDeleteCachedData(db, fetch, onsuccess, onerror) {
114
114
} ;
115
115
} catch ( e ) {
116
116
#if FETCH_DEBUG
117
- dbg ( ' fetch: Failed to load file ' + pathStr + ' from IndexedDB! Got exception ' + e ) ;
117
+ dbg ( ` fetch: Failed to load file ${ pathStr } from IndexedDB! Got exception ${ e } ` ) ;
118
118
#endif
119
119
onerror ( fetch , 0 , e ) ;
120
120
}
@@ -143,7 +143,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) {
143
143
var value = event . target . result ;
144
144
var len = value . byteLength || value . length ;
145
145
#if FETCH_DEBUG
146
- dbg ( ' fetch: Loaded file ' + pathStr + ' from IndexedDB, length: ' + len ) ;
146
+ dbg ( ` fetch: Loaded file ${ pathStr } from IndexedDB, length: ${ len } ` ) ;
147
147
#endif
148
148
// The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is
149
149
// freed when emscripten_fetch_close() is called.
@@ -160,7 +160,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) {
160
160
} else {
161
161
// Succeeded to load, but the load came back with the value of undefined, treat that as an error since we never store undefined in db.
162
162
#if FETCH_DEBUG
163
- dbg ( ' fetch: File ' + pathStr + ' not found in IndexedDB' ) ;
163
+ dbg ( ` fetch: File ${ pathStr } not found in IndexedDB` ) ;
164
164
#endif
165
165
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . readyState } } } >> 1 ] = 4 ; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
166
166
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = 404 ; // Mimic XHR HTTP status code 404 "Not Found"
@@ -170,7 +170,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) {
170
170
} ;
171
171
getRequest . onerror = ( error ) => {
172
172
#if FETCH_DEBUG
173
- dbg ( ' fetch: Failed to load file ' + pathStr + ' from IndexedDB!' ) ;
173
+ dbg ( ` fetch: Failed to load file ${ pathStr } from IndexedDB!` ) ;
174
174
#endif
175
175
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . readyState } } } >> 1 ] = 4 ; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
176
176
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = 404 ; // Mimic XHR HTTP status code 404 "Not Found"
@@ -179,7 +179,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) {
179
179
} ;
180
180
} catch ( e ) {
181
181
#if FETCH_DEBUG
182
- dbg ( ' fetch: Failed to load file ' + pathStr + ' from IndexedDB! Got exception ' + e ) ;
182
+ dbg ( ` fetch: Failed to load file ${ pathStr } from IndexedDB! Got exception ${ e } ` ) ;
183
183
#endif
184
184
onerror ( fetch , 0 , e ) ;
185
185
}
@@ -205,7 +205,7 @@ function fetchCacheData(/** @type {IDBDatabase} */ db, fetch, data, onsuccess, o
205
205
var putRequest = packages . put ( data , destinationPathStr ) ;
206
206
putRequest . onsuccess = ( event ) => {
207
207
#if FETCH_DEBUG
208
- dbg ( ' fetch: Stored file "' + destinationPathStr + ' " to IndexedDB cache.' ) ;
208
+ dbg ( ` fetch: Stored file "${ destinationPathStr } " to IndexedDB cache.` ) ;
209
209
#endif
210
210
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . readyState } } } >> 1 ] = 4 ; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
211
211
HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = 200 ; // Mimic XHR HTTP status code 200 "OK"
@@ -214,7 +214,7 @@ function fetchCacheData(/** @type {IDBDatabase} */ db, fetch, data, onsuccess, o
214
214
} ;
215
215
putRequest . onerror = ( error ) => {
216
216
#if FETCH_DEBUG
217
- dbg ( ' fetch: Failed to store file "' + destinationPathStr + ' " to IndexedDB cache!' ) ;
217
+ dbg ( ` fetch: Failed to store file "${ destinationPathStr } " to IndexedDB cache!` ) ;
218
218
#endif
219
219
// Most likely we got an error if IndexedDB is unwilling to store any more data for this page.
220
220
// TODO: Can we identify and break down different IndexedDB-provided errors and convert those
@@ -226,7 +226,7 @@ function fetchCacheData(/** @type {IDBDatabase} */ db, fetch, data, onsuccess, o
226
226
} ;
227
227
} catch ( e ) {
228
228
#if FETCH_DEBUG
229
- dbg ( ' fetch: Failed to store file "' + destinationPathStr + ' " to IndexedDB cache! Exception: ' + e ) ;
229
+ dbg ( ` fetch: Failed to store file "${ destinationPathStr } " to IndexedDB cache! Exception: ${ e } ` ) ;
230
230
#endif
231
231
onerror ( fetch , 0 , e ) ;
232
232
}
@@ -266,8 +266,8 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
266
266
var xhr = new XMLHttpRequest ( ) ;
267
267
xhr . withCredentials = ! ! { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . withCredentials , 'u8' ) } } } ; ;
268
268
#if FETCH_DEBUG
269
- dbg ( ' fetch: xhr.timeout: ' + xhr . timeout + ' , xhr.withCredentials: ' + xhr . withCredentials ) ;
270
- dbg ( ' fetch: xhr.open(requestMethod="' + requestMethod + ' ", url: "' + url_ + ' ", userName: ' + userNameStr + ' , password: ' + passwordStr + ');' ) ;
269
+ dbg ( ` fetch: xhr.timeout: ${ xhr . timeout } , xhr.withCredentials: ${ xhr . withCredentials } ` ) ;
270
+ dbg ( ` fetch: xhr.open(requestMethod="${ requestMethod } ", url: "${ url } ", userName: ${ userNameStr } , password: ${ passwordStr } ` ) ;
271
271
#endif
272
272
xhr . open ( requestMethod , url_ , ! fetchAttrSynchronous , userNameStr , passwordStr ) ;
273
273
if ( ! fetchAttrSynchronous ) xhr . timeout = timeoutMsecs ; // XHR timeout field is only accessible in async XHRs, and must be set after .open() but before .send().
@@ -280,7 +280,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
280
280
if ( overriddenMimeType ) {
281
281
var overriddenMimeTypeStr = UTF8ToString ( overriddenMimeType ) ;
282
282
#if FETCH_DEBUG
283
- dbg ( ' fetch: xhr.overrideMimeType("' + overriddenMimeTypeStr + ' ");' ) ;
283
+ dbg ( ` fetch: xhr.overrideMimeType("${ overriddenMimeTypeStr } ");` ) ;
284
284
#endif
285
285
xhr . overrideMimeType ( overriddenMimeTypeStr ) ;
286
286
}
@@ -294,15 +294,15 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
294
294
var keyStr = UTF8ToString ( key ) ;
295
295
var valueStr = UTF8ToString ( value ) ;
296
296
#if FETCH_DEBUG
297
- dbg ( ' fetch: xhr.setRequestHeader("' + keyStr + ' ", "' + valueStr + ' ");' ) ;
297
+ dbg ( ` fetch: xhr.setRequestHeader("${ keyStr } ", "${ valueStr } ");` ) ;
298
298
#endif
299
299
xhr . setRequestHeader ( keyStr , valueStr ) ;
300
300
}
301
301
}
302
302
303
303
var id = Fetch . xhrs . allocate ( xhr ) ;
304
304
#if FETCH_DEBUG
305
- dbg ( ' fetch: id=' + id ) ;
305
+ dbg ( ` fetch: id=${ id } ` ) ;
306
306
#endif
307
307
{ { { makeSetValue ( 'fetch' , C_STRUCTS . emscripten_fetch_t . id , 'id' , 'u32' ) } } } ;
308
308
var data = ( dataPtr && dataLength ) ? HEAPU8 . slice ( dataPtr , dataPtr + dataLength ) : null ;
@@ -320,7 +320,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
320
320
}
321
321
if ( ptrLen > 0 ) {
322
322
#if FETCH_DEBUG
323
- dbg ( ' fetch: allocating ' + ptrLen + ' bytes in Emscripten heap for xhr data' ) ;
323
+ dbg ( ` fetch: allocating ${ ptrLen } bytes in Emscripten heap for xhr data` ) ;
324
324
#endif
325
325
// The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is
326
326
// freed when emscripten_fetch_close() is called.
@@ -350,12 +350,12 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
350
350
saveResponseAndStatus ( ) ;
351
351
if ( xhr . status >= 200 && xhr . status < 300 ) {
352
352
#if FETCH_DEBUG
353
- dbg ( ' fetch: xhr of URL "' + xhr . url_ + ' " / responseURL "' + xhr . responseURL + ' " succeeded with status ' + xhr . status ) ;
353
+ dbg ( ` fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " succeeded with status ${ xhr . status } ` ) ;
354
354
#endif
355
355
if ( onsuccess ) onsuccess ( fetch , xhr , e ) ;
356
356
} else {
357
357
#if FETCH_DEBUG
358
- dbg ( ' fetch: xhr of URL "' + xhr . url_ + ' " / responseURL "' + xhr . responseURL + ' " failed with status ' + xhr . status ) ;
358
+ dbg ( ` fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " failed with status ${ xhr . status } ` ) ;
359
359
#endif
360
360
if ( onerror ) onerror ( fetch , xhr , e ) ;
361
361
}
@@ -366,7 +366,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
366
366
return ;
367
367
}
368
368
#if FETCH_DEBUG
369
- dbg ( ' fetch: xhr of URL "' + xhr . url_ + ' " / responseURL "' + xhr . responseURL + ' " finished with error, readyState ' + xhr . readyState + ' and status ' + xhr . status ) ;
369
+ dbg ( ` fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " finished with error, readyState ${ xhr . readyState } and status ${ xhr . status } ` ) ;
370
370
#endif
371
371
saveResponseAndStatus ( ) ;
372
372
if ( onerror ) onerror ( fetch , xhr , e ) ;
@@ -377,7 +377,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
377
377
return ;
378
378
}
379
379
#if FETCH_DEBUG
380
- dbg ( ' fetch: xhr of URL "' + xhr . url_ + ' " / responseURL "' + xhr . responseURL + ' " timed out, readyState ' + xhr . readyState + ' and status ' + xhr . status ) ;
380
+ dbg ( ` fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " timed out, readyState ${ xhr . readyState } and status ${ xhr . status } ` ) ;
381
381
#endif
382
382
if ( onerror ) onerror ( fetch , xhr , e ) ;
383
383
} ;
@@ -390,7 +390,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
390
390
var ptr = 0 ;
391
391
if ( ptrLen > 0 && fetchAttrLoadToMemory && fetchAttrStreamData ) {
392
392
#if FETCH_DEBUG
393
- dbg ( ' fetch: allocating ' + ptrLen + ' bytes in Emscripten heap for xhr data' ) ;
393
+ dbg ( ` fetch: allocating ${ ptrLen } bytes in Emscripten heap for xhr data` ) ;
394
394
#endif
395
395
#if ASSERTIONS
396
396
assert ( onprogress , 'When doing a streaming fetch, you should have an onprogress handler registered to receive the chunks!' ) ;
@@ -426,13 +426,13 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
426
426
if ( onreadystatechange ) onreadystatechange ( fetch , xhr , e ) ;
427
427
} ;
428
428
#if FETCH_DEBUG
429
- dbg ( ' fetch: xhr.send(data=' + data + ')' ) ;
429
+ dbg ( ` fetch: xhr.send(data=${ data } )` ) ;
430
430
#endif
431
431
try {
432
432
xhr . send ( data ) ;
433
433
} catch ( e ) {
434
434
#if FETCH_DEBUG
435
- dbg ( ' fetch: xhr failed with exception: ' + e ) ;
435
+ dbg ( ` fetch: xhr failed with exception: ${ e } ` ) ;
436
436
#endif
437
437
if ( onerror ) onerror ( fetch , xhr , e ) ;
438
438
}
@@ -467,7 +467,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
467
467
468
468
var reportSuccess = ( fetch , xhr , e ) => {
469
469
#if FETCH_DEBUG
470
- dbg ( ' fetch: operation success. e: ' + e ) ;
470
+ dbg ( ` fetch: operation success. e: ${ e } ` ) ;
471
471
#endif
472
472
{ { { runtimeKeepalivePop ( ) } } }
473
473
doCallback ( ( ) => {
@@ -485,7 +485,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
485
485
486
486
var reportError = ( fetch , xhr , e ) = > {
487
487
#if FETCH_DEBUG
488
- dbg ( ' fetch: operation failed: ' + e ) ;
488
+ dbg ( ` fetch: operation failed: ${ e } ` ) ;
489
489
#endif
490
490
{ { { runtimeKeepalivePop ( ) } } }
491
491
doCallback ( ( ) => {
@@ -496,7 +496,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
496
496
497
497
var reportReadyStateChange = ( fetch , xhr , e ) => {
498
498
#if FETCH_DEBUG
499
- dbg ( ' fetch: ready state change. e: ' + e ) ;
499
+ dbg ( ` fetch: ready state change. e: ${ e } ` ) ;
500
500
#endif
501
501
doCallback ( ( ) => {
502
502
if ( onreadystatechange ) { { { makeDynCall ( 'vp' , 'onreadystatechange' ) } } } ( fetch ) ;
@@ -506,15 +506,15 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
506
506
507
507
var performUncachedXhr = ( fetch , xhr , e ) = > {
508
508
#if FETCH_DEBUG
509
- dbg ( ' fetch: starting (uncached) XHR: ' + e ) ;
509
+ dbg ( ` fetch: starting (uncached) XHR: ${ e } ` ) ;
510
510
#endif
511
511
fetchXHR ( fetch , reportSuccess , reportError , reportProgress , reportReadyStateChange ) ;
512
512
} ;
513
513
514
514
#if FETCH_SUPPORT_INDEXEDDB
515
515
var cacheResultAndReportSuccess = ( fetch , xhr , e ) => {
516
516
#if FETCH_DEBUG
517
- dbg ( ' fetch: operation success. Caching result.. e: ' + e ) ;
517
+ dbg ( ` fetch: operation success. Caching result.. e: ${ e } ` ) ;
518
518
#endif
519
519
var storeSuccess = ( fetch , xhr , e ) => {
520
520
#if FETCH_DEBUG
@@ -541,7 +541,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
541
541
542
542
var performCachedXhr = ( fetch , xhr , e ) = > {
543
543
#if FETCH_DEBUG
544
- dbg ( ' fetch: starting (cached) XHR: ' + e ) ;
544
+ dbg ( ` fetch: starting (cached) XHR: ${ e } ` ) ;
545
545
#endif
546
546
fetchXHR ( fetch , cacheResultAndReportSuccess , reportError , reportProgress , reportReadyStateChange ) ;
547
547
} ;
@@ -583,7 +583,7 @@ function fetchGetResponseHeaders(id, dst, dstSizeBytes) {
583
583
//Delete the xhr JS object, allowing it to be garbage collected.
584
584
function fetchFree ( id ) {
585
585
#if FETCH_DEBUG
586
- dbg ( " fetch: fetchFree id:" + id ) ;
586
+ dbg ( ` fetch: fetchFree id:${ id } ` ) ;
587
587
#endif
588
588
if ( Fetch . xhrs . has ( id ) ) {
589
589
var xhr = Fetch . xhrs . get ( id ) ;
0 commit comments