@enplug/sdk-player
Advanced tools
Comparing version
{ | ||
"name": "@enplug/sdk-player", | ||
"version": "0.8.3", | ||
"version": "0.8.4-beta1", | ||
"description": "Enplug Player SDK", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.ts", |
@@ -21,3 +21,3 @@ /** | ||
private playerEvents: PlayerEvents; | ||
private destroyCallbackFn: Function; | ||
private destroyCallbackFn: () => void; | ||
@@ -67,6 +67,6 @@ constructor() { } | ||
/** | ||
* Sets function which will be called when destroy event is received. | ||
* Sets function which will be called when the underlying app calls its done() callback following the destroy event. | ||
* @param {Function} callbackFn | ||
*/ | ||
setDestroyHandler(callbackFn: Function) { | ||
setDestroyHandler(callbackFn: () => void) { | ||
this.destroyCallbackFn = callbackFn; | ||
@@ -73,0 +73,0 @@ } |
@@ -88,3 +88,2 @@ /** | ||
console.log(`[<% app_name %>|enplug-offline-worker] URL to cache: ${cacheUrl}`); | ||
var cacheRequest = new Request(cacheUrl, { | ||
@@ -143,6 +142,27 @@ mode: 'cors' | ||
(error) => { | ||
console.error('[<% app_name %>|enplug-offline-worker] Fetched failed.', error, cachedResponse); | ||
console.error('[enplug-graphics-player-app|enplug-offline-worker] Fetched failed.', error, cachedResponse); | ||
if (cachedResponse) { | ||
return cachedResponse; | ||
} | ||
// When a cors request fails, attempt to fetch using no-cors. | ||
var noCorsRequest = new Request(event.request.url, { | ||
mode: 'no-cors' | ||
}); | ||
return fetch(noCorsRequest).then((noCorsResponse) => { | ||
if (noCorsResponse) { | ||
var noCorsResponseToCache = noCorsResponse.clone(); | ||
caches.open(config.cacheVersion).then( | ||
// Cache response and update the time of caching this particular request. | ||
(cache) => { | ||
console.log(`[enplug-graphics-player-app|enplug-offline-worker] Caching ${cacheUrl}.`); | ||
cache.put(cacheRequest, noCorsResponseToCache); | ||
setCachedTime(cacheUrl); | ||
}, | ||
(error) => console.warn(`[enplug-graphics-player-app|enplug-offline-worker] Unable to cache no-cors response ${cacheUrl}`, error) | ||
); | ||
return noCorsResponse; | ||
} | ||
}); | ||
}); | ||
@@ -149,0 +169,0 @@ })); |
Sorry, the diff of this file is not supported yet
95318
1.04%1074
1.7%2
100%