-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
290 lines (259 loc) · 9.93 KB
/
index.html
File metadata and controls
290 lines (259 loc) · 9.93 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, user-scalable=no" />
<!-- PWA Meta Tags -->
<meta name="theme-color" content="#FD8686" />
<meta name="description" content="Explore rich history with immersive guided audio tours" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="manifest" href="/manifest.webmanifest" />
<!-- iOS Specific -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="apple-mobile-web-app-title" content="AudioGuideKit" />
<!-- Apple touch icons - Safari uses these, not the manifest -->
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="152x152" href="/icons/icon-152x152.png" />
<link rel="apple-touch-icon" sizes="144x144" href="/icons/icon-144x144.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/icons/icon-120x120.png" />
<title>AudioGuideKit</title>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
rel="stylesheet">
<style>
/* Ensure full viewport height including safe areas */
html,
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
/* Initialize viewport height variable immediately */
:root {
--vh: 1vh;
}
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none;
/* IE and Edge */
scrollbar-width: none;
/* Firefox */
}
</style>
<script type="importmap">
{
"imports": {
"framer-motion": "https://aistudiocdn.com/framer-motion@^12.23.24",
"react-dom/": "https://aistudiocdn.com/react-dom@^19.2.0/",
"react/": "https://aistudiocdn.com/react@^19.2.0/",
"react": "https://aistudiocdn.com/react@^19.2.0"
}
}
</script>
</head>
<body>
<div id="root">
<!-- Loading indicator shown while app initializes -->
<div id="loading-screen"
style="display: flex; align-items: center; justify-content: center; height: 100dvh; font-family: 'Inter', sans-serif; color: #666;">
<div style="text-align: center;">
<div
style="width: 40px; height: 40px; border: 3px solid #f3f3f3; border-top: 3px solid #3498db; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 16px;">
</div>
<div id="loading-status">Loading...</div>
<div id="debug-info" style="margin-top: 20px; font-size: 12px; color: #999; max-width: 300px;"></div>
</div>
</div>
<style>
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</div>
<script>
// Development mode detection (hostname-based for inline scripts)
const DEV_MODE = window.location.hostname === 'localhost' ||
window.location.hostname.includes('192.168') ||
window.location.hostname.includes('127.0.0.1') ||
window.location.search.includes('debug=true');
// Visual debug helper
function updateDebugInfo(message) {
if (!DEV_MODE) return;
const debugDiv = document.getElementById('debug-info');
if (debugDiv) {
debugDiv.innerHTML += message + '<br>';
}
}
function updateLoadingStatus(message) {
if (!DEV_MODE) return;
const statusDiv = document.getElementById('loading-status');
if (statusDiv) {
statusDiv.textContent = message;
}
}
// Register service worker immediately for better offline support on iOS
if (DEV_MODE) {
console.log('[APP] Starting SW registration...');
updateDebugInfo('Starting...');
updateDebugInfo('Online: ' + (navigator.onLine ? 'YES' : 'NO'));
console.log('[APP] Online status:', navigator.onLine ? 'ONLINE' : 'OFFLINE');
console.log('[APP] Expected SW version: 1.0.3-NAVIGATION-FIX');
}
if ('serviceWorker' in navigator && !/localhost/.test(window.location)) {
navigator.serviceWorker.register('/sw.js', { scope: '/' })
.then(registration => {
if (DEV_MODE) {
console.log('[APP] ✅ SW registered successfully');
console.log('[APP] SW state:', {
installing: registration.installing ? 'yes' : 'no',
waiting: registration.waiting ? 'yes' : 'no',
active: registration.active ? 'yes' : 'no',
scope: registration.scope,
updateViaCache: registration.updateViaCache
});
if (registration.active) {
console.log('[APP] Active SW state:', registration.active.state);
console.log('[APP] Active SW URL:', registration.active.scriptURL);
}
} else {
// Minimal production logging
console.log('[APP] Service worker registered');
}
// Force update check
registration.update().then(() => {
if (DEV_MODE) {
console.log('[APP] ✅ SW update check completed');
}
}).catch(err => {
if (DEV_MODE) {
console.log('[APP] SW update check failed:', err);
}
});
// Listen for SW state changes (dev only)
if (DEV_MODE) {
registration.addEventListener('updatefound', () => {
console.log('[APP] SW update found!');
const newWorker = registration.installing;
if (newWorker) {
newWorker.addEventListener('statechange', () => {
console.log('[APP] SW state changed to:', newWorker.state);
});
}
});
}
})
.catch(err => {
// Always log errors
console.error('[APP] ❌ SW registration failed:', err);
});
// Log when SW controller changes (dev only)
if (DEV_MODE) {
navigator.serviceWorker.addEventListener('controllerchange', () => {
console.log('[APP] SW controller changed - new SW is now active');
});
}
// Check current controller (dev only)
if (DEV_MODE) {
if (navigator.serviceWorker.controller) {
console.log('[APP] Page is currently controlled by SW:', navigator.serviceWorker.controller.scriptURL);
updateDebugInfo('✅ SW Active');
} else {
console.log('[APP] ⚠️ Page is NOT controlled by any SW yet');
updateDebugInfo('⚠️ No SW');
}
}
} else {
if (DEV_MODE) {
console.log('[APP] SW not supported or running on localhost');
updateDebugInfo('❌ SW not supported');
}
}
// Monitor online/offline status (dev only)
if (DEV_MODE) {
window.addEventListener('online', () => {
console.log('[APP] Network: ONLINE');
updateDebugInfo('Network: ONLINE');
});
window.addEventListener('offline', () => {
console.log('[APP] Network: OFFLINE');
updateDebugInfo('Network: OFFLINE');
});
}
// Catch any errors during load
window.addEventListener('error', (event) => {
// Always log errors
console.error('[APP] Error:', event.error);
if (DEV_MODE) {
updateLoadingStatus('Error loading!');
updateDebugInfo('❌ ' + (event.error?.message || event.message || 'Unknown error'));
}
});
// Update loading status (dev only)
if (DEV_MODE) {
setTimeout(() => {
updateLoadingStatus('Loading React...');
}, 1000);
}
// Inspect cache contents after page loads (dev only)
if (DEV_MODE) {
window.addEventListener('load', async () => {
console.log('[APP] 🔍 Inspecting cache contents...');
try {
const cacheNames = await caches.keys();
console.log('[APP] Found caches:', cacheNames);
for (const cacheName of cacheNames) {
const cache = await caches.open(cacheName);
const requests = await cache.keys();
console.log(`[APP] Cache "${cacheName}" contains ${requests.length} entries:`);
// Log first 10 URLs from each cache
requests.slice(0, 10).forEach(req => {
console.log(` - ${req.url}`);
});
if (requests.length > 10) {
console.log(` ... and ${requests.length - 10} more`);
}
// Check specifically for CDN resources
const cdnResources = requests.filter(req =>
req.url.includes('aistudiocdn.com')
);
if (cdnResources.length > 0) {
console.log(`[APP] ✅ Found ${cdnResources.length} CDN resources in this cache`);
}
}
// Check for critical CDN resources
const criticalUrls = [
'https://aistudiocdn.com/react@^19.2.0',
'https://aistudiocdn.com/react-dom@^19.2.0',
'https://aistudiocdn.com/framer-motion@^12.23.24'
];
console.log('[APP] Checking for critical CDN resources...');
for (const url of criticalUrls) {
const response = await caches.match(url);
if (response) {
console.log(`[APP] ✅ CACHED: ${url}`);
} else {
console.log(`[APP] ❌ NOT CACHED: ${url}`);
}
}
console.log('[APP] 🔍 Cache inspection complete!');
} catch (err) {
console.error('[APP] Error inspecting caches:', err);
}
});
}
</script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>