1
- const version = '2.7.1 ' ;
2
- const hash = '0be8e ' ;
1
+ const version = '2.8.0 ' ;
2
+ const hash = '214c4 ' ;
3
3
const cacheName = `pwa-tunime-${ hash } -v${ version } ` ;
4
4
const appShellFilesToCache = [
5
5
// Директория: /images/genres
@@ -28,15 +28,22 @@ const appShellFilesToCache = [
28
28
"/images/icons/logo-x384-o.png" ,
29
29
"/images/icons/logo-x512-b.png" ,
30
30
"/images/icons/logo-x512-o.png" ,
31
+ // Директория: /images/seasons
32
+ "/images/seasons/autum.webp" ,
33
+ "/images/seasons/spring.webp" ,
34
+ "/images/seasons/summer.webp" ,
35
+ "/images/seasons/winter.webp" ,
31
36
// Директория: /images
32
37
"/images/anime-not.png" ,
33
38
"/images/ava.jpeg" ,
34
39
"/images/black-bg-player.png" ,
35
40
"/images/collections.png" ,
41
+ "/images/endlist.png" ,
36
42
"/images/error-trailers.png" ,
37
43
"/images/icon-web.png" ,
38
44
"/images/login-icon.png" ,
39
45
"/images/logo-login.png" ,
46
+ "/images/noanime.png" ,
40
47
"/images/player-icon.png" ,
41
48
"/images/popup.png" ,
42
49
"/images/preview-image.png" ,
@@ -48,11 +55,13 @@ const appShellFilesToCache = [
48
55
"/javascript/library/hls.js" ,
49
56
"/javascript/library/jqery.min.js" ,
50
57
"/javascript/library/jsyaml.js" ,
58
+ "/javascript/library/md5.wasm.min.js" ,
51
59
"/javascript/library/rxjs.umd.min.js" ,
52
60
"/javascript/library/swiper-bundle.min.js" ,
53
61
// Директория: /javascript/modules
54
62
"/javascript/modules/ActionVerify.js" ,
55
63
"/javascript/modules/AnimeCard.js" ,
64
+ "/javascript/modules/api.jikan.js" ,
56
65
"/javascript/modules/Collection.js" ,
57
66
"/javascript/modules/EventTools.js" ,
58
67
"/javascript/modules/functions.js" ,
@@ -64,6 +73,7 @@ const appShellFilesToCache = [
64
73
"/javascript/modules/ShikiUSR.js" ,
65
74
"/javascript/modules/TDatabase.js" ,
66
75
"/javascript/modules/TDownload.js" ,
76
+ "/javascript/modules/tun.cache.js" ,
67
77
"/javascript/modules/TunimeApi.js" ,
68
78
"/javascript/modules/Windows.js" ,
69
79
// Директория: /javascript/pages/downloads
@@ -103,11 +113,17 @@ const appShellFilesToCache = [
103
113
"/javascript/pages/player/mod_stream.js" ,
104
114
"/javascript/pages/player/mod_ui.js" ,
105
115
// Директория: /javascript/pages/search
116
+ "/javascript/pages/search/mod_card.js" ,
117
+ "/javascript/pages/search/mod_genres.js" ,
106
118
"/javascript/pages/search/mod_history.js" ,
107
- "/javascript/pages/search/mod_list.js" ,
108
119
"/javascript/pages/search/mod_popular.js" ,
109
120
"/javascript/pages/search/mod_search.js" ,
110
- "/javascript/pages/search/mod_searchState.js" ,
121
+ "/javascript/pages/search/mod_seasons.js" ,
122
+ "/javascript/pages/search/mod_studios.js" ,
123
+ "/javascript/pages/search/mod_voicelist.js" ,
124
+ "/javascript/pages/search/mod_w_filter.js" ,
125
+ "/javascript/pages/search/mod_w_genres.js" ,
126
+ "/javascript/pages/search/mod_w_season.js" ,
111
127
// Директория: /javascript/pages/settings
112
128
"/javascript/pages/settings/mod_cleardb.js" ,
113
129
"/javascript/pages/settings/mod_select.js" ,
@@ -124,14 +140,14 @@ const appShellFilesToCache = [
124
140
"/javascript/pages/user/mod_stats.js" ,
125
141
"/javascript/pages/user/mod_w_anime.js" ,
126
142
// Директория: /javascript/pages/watch
143
+ "/javascript/pages/watch/mod.chronology.js" ,
144
+ "/javascript/pages/watch/mod.resource.js" ,
127
145
"/javascript/pages/watch/mod_collection.js" ,
128
146
"/javascript/pages/watch/mod_dbanime.js" ,
129
147
"/javascript/pages/watch/mod_download.js" ,
130
- "/javascript/pages/watch/mod_franchise.js" ,
131
148
"/javascript/pages/watch/mod_history.js" ,
132
149
"/javascript/pages/watch/mod_player.js" ,
133
150
"/javascript/pages/watch/mod_private.js" ,
134
- "/javascript/pages/watch/mod_resource.js" ,
135
151
"/javascript/pages/watch/mod_scrolling.js" ,
136
152
"/javascript/pages/watch/mod_transition.js" ,
137
153
"/javascript/pages/watch/mod_translation.js" ,
@@ -153,8 +169,10 @@ const appShellFilesToCache = [
153
169
"/javascript/services/dispatcher.js" ,
154
170
"/javascript/services/installing.js" ,
155
171
"/javascript/services/update.js" ,
172
+ // Директория: /javascript/utils
173
+ "/javascript/utils/auth.login.js" ,
174
+ "/javascript/utils/auth.logout.js" ,
156
175
// Директория: /javascript
157
- "/javascript/kodik.js" ,
158
176
"/javascript/menu.js" ,
159
177
"/javascript/parametrs.js" ,
160
178
"/javascript/server.js" ,
@@ -197,11 +215,50 @@ const servers = [
197
215
"https://tunime-hujg.onrender.com"
198
216
] ;
199
217
200
- self . addEventListener ( 'install' , async event => {
201
- event . waitUntil ( caches . open ( cacheName ) . then ( ( cache ) => {
202
- console . log ( '[SW]: Caching App Shell' ) ;
203
- return cache . addAll ( appShellFilesToCache ) ;
204
- } ) . catch ( ( err ) => { console . log ( 'Не удалось установить файл' , err ) } ) ) ;
218
+ self . addEventListener ( 'install' , event => {
219
+ const broadcast = new BroadcastChannel ( 'tun.update' ) ;
220
+ broadcast . postMessage ( {
221
+ type : 'NEW_VERSION' , payload : {
222
+ version,
223
+ hash,
224
+ cacheName
225
+ }
226
+ } ) ;
227
+ event . waitUntil (
228
+ caches . open ( cacheName ) . then ( async ( cache ) => {
229
+ console . log ( '[SW]: Caching App Shell' ) ;
230
+
231
+ const total = appShellFilesToCache . length ;
232
+ let processed = 0 ;
233
+
234
+ for ( let i = 0 ; i < total ; i ++ ) {
235
+ const file = appShellFilesToCache [ i ] ;
236
+ let success = true ;
237
+ try {
238
+ await cache . add ( file ) ;
239
+ } catch ( err ) {
240
+ success = false ;
241
+ }
242
+
243
+ processed ++ ;
244
+ const percent = ( ( processed / total ) * 100 ) . toFixed ( 2 ) ;
245
+
246
+ broadcast . postMessage ( {
247
+ type : 'CACHE_PROGRESS' , payload : {
248
+ total,
249
+ processed,
250
+ percent,
251
+ file,
252
+ success
253
+ }
254
+ } ) ;
255
+ }
256
+
257
+ console . log ( '[SW]: Caching complete.' ) ;
258
+ } ) . catch ( ( err ) => {
259
+ console . error ( '[SW]: Failed to open cache' , err ) ;
260
+ } )
261
+ ) ;
205
262
206
263
setTimeout ( ( ) => {
207
264
self . skipWaiting ( ) ;
@@ -252,17 +309,23 @@ self.addEventListener('fetch', event => {
252
309
} ) ;
253
310
254
311
self . addEventListener ( 'message' , async event => {
312
+ const call = {
313
+ 215 : async ( client ) => {
314
+ client . postMessage ( JSON . stringify ( { id : 215 , val : version } ) ) ;
315
+ } ,
316
+ 221 : async ( client ) => {
317
+ await self . skipWaiting ( ) ;
318
+ client . postMessage ( JSON . stringify ( { id : 221 , val : 'ok' } ) ) ;
319
+ } ,
320
+ 216 : async ( client ) => {
321
+ client . postMessage ( JSON . stringify ( { id : 216 , val : hash } ) ) ;
322
+ } ,
323
+ 220 : async ( client ) => {
324
+ client . postMessage ( JSON . stringify ( { id : 220 , val : { ver : version , hash : hash } } ) ) ;
325
+ }
326
+ } ;
327
+
255
328
const client = event . source ;
256
- if ( event . data . id === 215 ) {
257
- client . postMessage ( JSON . stringify ( { id : 215 , val : version } ) ) ;
258
- } else if ( event . data . id === 221 ) {
259
- await self . skipWaiting ( ) ;
260
- client . postMessage ( JSON . stringify ( { id : 221 , val : 'ok' } ) ) ;
261
- } else if ( event . data . id === 216 ) {
262
- const client = event . source ;
263
- client . postMessage ( JSON . stringify ( { id : 216 , val : hash } ) ) ;
264
- } else if ( event . data . id === 220 ) {
265
- const client = event . source ;
266
- client . postMessage ( JSON . stringify ( { id : 220 , val : { ver : version , hash : hash } } ) ) ;
267
- }
329
+ const id = event . data . id ;
330
+ if ( call [ id ] ) return call [ id ] ( client ) ;
268
331
} ) ;
0 commit comments