aboutsummaryrefslogtreecommitdiffhomepage
path: root/sw.js
blob: bcf25d04fd5c8ceb9b79d0af03726a82c5e035db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// 220

const assets = [

  './',

  './manifest.json',
  './desktop/icon.png',

  './desktop/sources/links/style.css',
  './desktop/sources/links/reset.css',
  './desktop/sources/links/fonts.css',
  './desktop/sources/links/main.css',
  './desktop/sources/links/theme.css',

  './desktop/sources/scripts/lib/acels.js',
  './desktop/sources/scripts/lib/theme.js',
  './desktop/sources/scripts/lib/history.js',
  './desktop/sources/scripts/lib/source.js',
  './desktop/sources/scripts/core/library.js',
  './desktop/sources/scripts/core/io.js',
  './desktop/sources/scripts/core/operator.js',
  './desktop/sources/scripts/core/orca.js',
  './desktop/sources/scripts/core/transpose.js',
  './desktop/sources/scripts/core/io/cc.js',
  './desktop/sources/scripts/core/io/midi.js',
  './desktop/sources/scripts/core/io/mono.js',
  './desktop/sources/scripts/core/io/osc.js',
  './desktop/sources/scripts/core/io/udp.js',
  './desktop/sources/scripts/clock.js',
  './desktop/sources/scripts/commander.js',
  './desktop/sources/scripts/cursor.js',
  './desktop/sources/scripts/client.js'

];

self.addEventListener( 'install', async function () {

  const cache = await caches.open( 'Orca' );

  assets.forEach( function ( asset ) {

    cache.add( asset ).catch( function () {

      console.error( '[SW] Cound\'t cache:', asset );

    } );

  } );

} );

self.addEventListener( 'fetch', async function ( event ) {

  const request = event.request;
  event.respondWith( cacheFirst( request ) );

} );

async function cacheFirst( request ) {

  const cachedResponse = await caches.match( request );

  if ( cachedResponse === undefined ) {

    console.error( '[SW] Not cached:', request.url );
    return fetch( request );

  }

  return cachedResponse;

}