|
|
|
@ -331,6 +331,29 @@ export default async function RootLayout({ |
|
|
|
return false; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
// 7. Deep Lifecycle & Focus Debug Instrumentation
|
|
|
|
function logLifecycle(name, detail) { |
|
|
|
try { |
|
|
|
var bodyBg = window.getComputedStyle ? window.getComputedStyle(document.body).backgroundColor : 'unknown'; |
|
|
|
var htmlBg = window.getComputedStyle ? window.getComputedStyle(document.documentElement).backgroundColor : 'unknown'; |
|
|
|
var msg = '[WEB_DEEP_LIFECYCLE] [' + Date.now() + '] Event: ' + name + ' | visibility: ' + document.visibilityState + ' | hasFocus: ' + document.hasFocus() + ' | bodyBg: ' + bodyBg + ' | htmlBg: ' + htmlBg + (detail ? ' | ' + JSON.stringify(detail) : ''); |
|
|
|
console.log(msg); |
|
|
|
if (window.HabibApp && window.HabibApp.postMessage) { |
|
|
|
window.HabibApp.postMessage(JSON.stringify({ action: 'debug_log', message: msg })); |
|
|
|
} |
|
|
|
} catch (e) {} |
|
|
|
} |
|
|
|
|
|
|
|
['visibilitychange', 'focus', 'blur', 'pageshow', 'pagehide', 'freeze', 'resume'].forEach(function(evt) { |
|
|
|
window.addEventListener(evt, function(e) { |
|
|
|
logLifecycle(evt, { type: e.type, persisted: e.persisted }); |
|
|
|
}, true); |
|
|
|
}); |
|
|
|
|
|
|
|
document.addEventListener('visibilitychange', function() { |
|
|
|
logLifecycle('document.visibilitychange', { visibilityState: document.visibilityState }); |
|
|
|
}); |
|
|
|
})(); |
|
|
|
`,
|
|
|
|
}} |
|
|
|
|