Web-based Winamp controller for CarPC � Go backend, mobile-first UI
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

40 líneas
1007B

  1. 'use strict';
  2. const CACHE = 'roadamp-v1';
  3. const SHELL = ['/', '/app.js', '/style.css', '/manifest.json', '/icon.svg'];
  4. self.addEventListener('install', e => {
  5. e.waitUntil(
  6. caches.open(CACHE)
  7. .then(c => c.addAll(SHELL))
  8. .then(() => self.skipWaiting())
  9. );
  10. });
  11. self.addEventListener('activate', e => {
  12. e.waitUntil(
  13. caches.keys()
  14. .then(keys => Promise.all(
  15. keys.filter(k => k !== CACHE).map(k => caches.delete(k))
  16. ))
  17. .then(() => self.clients.claim())
  18. );
  19. });
  20. self.addEventListener('fetch', e => {
  21. const url = new URL(e.request.url);
  22. // Pass through API calls and WebSocket upgrades uncached.
  23. if (url.pathname.startsWith('/api/') || url.pathname === '/ws') return;
  24. e.respondWith(
  25. caches.match(e.request).then(cached => {
  26. if (cached) return cached;
  27. return fetch(e.request).then(res => {
  28. const clone = res.clone();
  29. caches.open(CACHE).then(c => c.put(e.request, clone));
  30. return res;
  31. });
  32. })
  33. );
  34. });