forked from ahmet360/oldGBA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.js
153 lines (142 loc) · 4.42 KB
/
service-worker.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
let CACHE_NAME = 'V1';
let urlsToCache = [
'./',
'./emulator.html',
'./export.html',
'./gb.html',
'./gba-2.html',
'./gba.html',
'./gbc.html',
'./gbindex.html',
'./index_beta.html',
'./info.html',
'./n64.html',
'./nds.html',
'./nds2.html',
'./nes.html',
'./nesindex.html',
'./offline.html',
'./recommendations.html',
'./romindex.html',
'./segamd.html',
'./settings.html',
'./snes.html',
'./testlaunch.html',
'./update.html',
'./user_css/home.css',
'./user_css/index.css',
'./user_css/main.css',
'./user_css/player.css',
'./user_css/popup.css',
'./user_css/rec.css',
'./user_css/themes.css',
'./user_scripts/theme.js',
'./user_scripts/player-theme.js',
'./user_scripts/popup.js',
'./data/js/loadgame/loadGbagame.js',
'./data/js/loadgame/loadGbgame.js',
'./data/js/loadgame/loadGbcgame.js',
'./data/js/loadgame/loadAtari52game.js',
'./data/js/loadgame/loadN64game.js',
'./data/js/loadgame/loadNdsgame.js',
'./data/js/loadgame/loadNesgame.js',
'./data/js/loadgame/loadPsxgame.js',
'./data/js/loadgame/loadSnesgame.js',
'./data/js/loadgame/loadSegaMDgame.js',
'./data/js/type.js',
'./data/js/loadtype.js',
'./data/js/swap.js',
'./data/loader.js',
'./IodineGBA/includes/TypedArrayShim.js',
'./IodineGBA/core/Cartridge.js',
'./IodineGBA/core/DMA.js',
'./IodineGBA/core/Emulator.js',
'./IodineGBA/core/Graphics.js',
'./IodineGBA/core/RunLoop.js',
'./IodineGBA/core/Memory.js',
'./IodineGBA/core/IRQ.js',
'./IodineGBA/core/JoyPad.js',
'./IodineGBA/core/Serial.js',
'./IodineGBA/core/Sound.js',
'./IodineGBA/core/Timer.js',
'./IodineGBA/core/Wait.js',
'./IodineGBA/core/CPU.js',
'./IodineGBA/core/Saves.js',
'./IodineGBA/core/sound/FIFO.js',
'./IodineGBA/core/sound/Channel1.js',
'./IodineGBA/core/sound/Channel2.js',
'./IodineGBA/core/sound/Channel3.js',
'./IodineGBA/core/sound/Channel4.js',
'./IodineGBA/core/CPU/ARM.js',
'./IodineGBA/core/CPU/THUMB.js',
'./IodineGBA/core/CPU/CPSR.js',
'./IodineGBA/core/graphics/Renderer.js',
'./IodineGBA/core/graphics/RendererProxy.js',
'./IodineGBA/core/graphics/BGTEXT.js',
'./IodineGBA/core/graphics/BG2FrameBuffer.js',
'./IodineGBA/core/graphics/BGMatrix.js',
'./IodineGBA/core/graphics/AffineBG.js',
'./IodineGBA/core/graphics/ColorEffects.js',
'./IodineGBA/core/graphics/Mosaic.js',
'./IodineGBA/core/graphics/OBJ.js',
'./IodineGBA/core/graphics/OBJWindow.js',
'./IodineGBA/core/graphics/Window.js',
'./IodineGBA/core/graphics/Compositor.js',
'./IodineGBA/core/memory/DMA0.js',
'./IodineGBA/core/memory/DMA1.js',
'./IodineGBA/core/memory/DMA2.js',
'./IodineGBA/core/memory/DMA3.js',
'./IodineGBA/core/cartridge/SaveDeterminer.js',
'./IodineGBA/core/cartridge/SRAM.js',
'./IodineGBA/core/cartridge/FLASH.js',
'./IodineGBA/core/cartridge/EEPROM.js',
'./user_scripts/XAudioJS/swfobject.js',
'./user_scripts/XAudioJS/resampler.js',
'./user_scripts/XAudioJS/XAudioServer.js',
'./user_scripts/IodineGBAROMLoadGlueCode.js',
'./user_scripts/IodineGBAJoyPadGlueCode.js',
'./user_scripts/IodineGBASavesGlueCode.js',
'./user_scripts/IodineGBAGraphicsGlueCode.js',
'./user_scripts/IodineGBAAudioGlueCode.js',
'./user_scripts/IodineGBACoreGlueCode.js',
'./user_scripts/base64.js',
'./Binaries/gb.ico'
];
self.addEventListener('install', function(event) {
// Perform install steps
// Perform install steps
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener("fetch", function (event) {
event.respondWith(
caches.match(event.request)
.then(function (response) {
if (response) {
return response;
}
return fetch(event.request);
})
);
});
self.addEventListener("activate", event => {
// delete any unexpected caches
event.waitUntil(
caches
.keys()
.then(keys => keys.filter(key => key !== CACHE_NAME))
.then(keys =>
Promise.all(
keys.map(key => {
console.log(`Deleting cache ${key}`);
return caches.delete(key);
})
)
)
);
});