-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
93 lines (85 loc) · 3.36 KB
/
Copy pathindex.html
File metadata and controls
93 lines (85 loc) · 3.36 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gothwad Tech AI Workstation</title>
<script>
// Gracefully capture and suppress benign iframe / developer environment errors
// so they do not trigger the platform's intrusive "App Error" overlay.
(function() {
const isBenignError = (message, source) => {
const msg = String(message || '').toLowerCase();
const src = String(source || '').toLowerCase();
return (
msg.includes('service worker') ||
msg.includes('serviceworker') ||
msg.includes('sw.js') ||
msg.includes('websocket') ||
msg.includes('web-socket') ||
msg.includes('ws://') ||
msg.includes('wss://') ||
msg.includes('[vite]') ||
msg.includes('hmr') ||
msg.includes('failed to connect to websocket') ||
src.includes('vite') ||
src.includes('hmr')
);
};
// 1. Intercept unhandled promise rejections (e.g. Vite HMR websocket closure)
window.addEventListener('unhandledrejection', (event) => {
const reason = event.reason;
const msg = reason ? (reason.message || String(reason)) : '';
if (isBenignError(msg)) {
console.warn('Suppressing benign unhandled rejection in preview iframe:', msg);
event.preventDefault();
event.stopImmediatePropagation();
}
}, true);
// 2. Intercept uncaught general errors
window.addEventListener('error', (event) => {
const msg = event.message || '';
const src = event.filename || '';
if (isBenignError(msg, src)) {
console.warn('Suppressing benign error in preview iframe:', msg);
event.preventDefault();
event.stopImmediatePropagation();
}
}, true);
// 3. Intercept console.error to downgrade benign errors to console.warn
const originalConsoleError = console.error;
console.error = function(...args) {
const combinedArgs = args.map(arg => {
try {
return typeof arg === 'object' ? JSON.stringify(arg) : String(arg);
} catch {
return String(arg);
}
}).join(' ');
if (isBenignError(combinedArgs)) {
console.warn('Downgraded benign error to warning:', ...args);
return;
}
originalConsoleError.apply(console, args);
};
})();
</script>
<link rel="manifest" href="/manifest.json" />
<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<meta name="theme-color" content="#09090b" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then((reg) => console.log('Service Worker registered successfully:', reg.scope))
.catch((err) => console.warn('Service Worker registration failed (ignoring in iframe sandbox):', err));
});
}
</script>
</body>
</html>