window.fixtureLifecycle ??= { id: crypto.randomUUID(), domReady: 0, navigated: 0, mounts: 0, pings: 0, }; document.addEventListener('DOMContentLoaded', () => { window.fixtureLifecycle.domReady++; }); let cleanup = () => {}; document.addEventListener('livewire:navigated', () => { cleanup(); const state = window.fixtureLifecycle; state.navigated++; const widget = document.querySelector('[data-post-widget]'); if (!widget) return; const controller = new AbortController(); const options = { signal: controller.signal }; document.addEventListener('fixture:ping', () => state.pings++, options); const button = widget.querySelector('[data-widget-ping]'); button.addEventListener('click', () => { document.dispatchEvent(new Event('fixture:ping')); }, options); cleanup = () => controller.abort(); state.mounts++; });