veyrix

Veyrix IDE is a lightweight, p...
Log | Files | Refs | README | LICENSE

sw.js (1598B)


      1 const CACHE_NAME = 'veyrix-ide-v1';
      2 const ASSETS = [
      3     '../index.html',
      4     './manifest.json',
      5     './veyrix.svg',
      6     'https://cdn.tailwindcss.com',
      7     'https://cdnjs.cloudflare.com/ajax/libs/ace/1.32.6/ace.js',
      8     'https://cdnjs.cloudflare.com/ajax/libs/ace/1.32.6/ext-beautify.js',
      9     'https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.5.0/lz-string.min.js'
     10 ];
     11 
     12 self.addEventListener('install', event => {
     13     event.waitUntil(
     14         caches.open(CACHE_NAME)
     15             .then(cache => cache.addAll(ASSETS))
     16             .then(() => self.skipWaiting())
     17     );
     18 });
     19 
     20 self.addEventListener('activate', event => {
     21     event.waitUntil(
     22         caches.keys().then(cacheNames => {
     23             return Promise.all(
     24                 cacheNames.map(cache => {
     25                     if (cache !== CACHE_NAME) {
     26                         return caches.delete(cache);
     27                     }
     28                 })
     29             );
     30         })
     31     );
     32 });
     33 
     34 self.addEventListener('fetch', event => {
     35     // Exclude Firebase Firestore/Auth network calls from caching to ensure live syncing works
     36     if (event.request.url.includes('firestore.googleapis.com') || 
     37         event.request.url.includes('identitytoolkit.googleapis.com')) {
     38         return;
     39     }
     40 
     41     event.respondWith(
     42         caches.match(event.request).then(response => {
     43             return response || fetch(event.request).catch(() => {
     44                 if (event.request.mode === 'navigate') {
     45                     return caches.match('../index.html');
     46                 }
     47             });
     48         })
     49     );
     50 });
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror