-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
103 lines (95 loc) · 2.76 KB
/
Copy pathsw.js
File metadata and controls
103 lines (95 loc) · 2.76 KB
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
const CACHE_NAME = 'auditors-guide-cache-v2';
const urlsToCache = [
'/',
'index.html',
'index.tsx',
'App.tsx',
'types.ts',
'mockData.ts',
'services/geminiService.ts',
'services/googleDriveService.ts',
'services/googleDrivePickerService.ts',
'components/AdminPanel.tsx',
'components/AppCatalog.tsx',
'components/AuditLog.tsx',
'components/ChangePasswordModal.tsx',
'components/ChatAssistant.tsx',
'components/ConfirmRoleChangeModal.tsx',
'components/CreateTemplateModal.tsx',
'components/Dashboard.tsx',
'components/DocumentDetailModal.tsx',
'components/DocumentManager.tsx',
'components/DocumentPreview.tsx',
'components/EditDocumentModal.tsx',
'components/Header.tsx',
'components/icons.tsx',
'components/IncidentManager.tsx',
'components/InspectionForm.tsx',
'components/InspectionManager.tsx',
'components/InspectionPlanner.tsx',
'components/InviteUserModal.tsx',
'components/Login.tsx',
'components/ManageAreasModal.tsx',
'components/Reporting.tsx',
'components/SaveSopModal.tsx',
'components/Scheduler.tsx',
'components/Settings.tsx',
'components/Sidebar.tsx',
'components/SopGenerator.tsx',
'components/SopLibrary.tsx',
'components/SopTemplates.tsx',
'components/StartInspectionModal.tsx',
'components/TeamManager.tsx',
'components/UploadPreviewModal.tsx',
'components/UserProfile.tsx',
'https://cdn.tailwindcss.com'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
// Cache hit - return response
if (response) {
return response;
}
const fetchRequest = event.request.clone();
return fetch(fetchRequest).then(
response => {
// Check if we received a valid response. Allow 'cors' for CDN resources.
if(!response || response.status !== 200 || !['basic', 'cors'].includes(response.type)) {
return response;
}
const responseToCache = response.clone();
caches.open(CACHE_NAME)
.then(cache => {
cache.put(event.request, responseToCache);
});
return response;
}
);
})
);
});
self.addEventListener('activate', event => {
const cacheWhitelist = [CACHE_NAME];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
});