From ae9c42add07d86ebebaf16cfc29eb24964f30a7a Mon Sep 17 00:00:00 2001 From: mortezaei Date: Mon, 17 Aug 2026 18:16:12 +0330 Subject: [PATCH] feat: expose and trigger web ready announcement bridge for entry route navigation --- src/app/layout.tsx | 6 ++++-- src/components/Componentes/entry-route-resolver.tsx | 9 +++++++++ src/types/window.d.ts | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 2077197..e10e978 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -236,7 +236,7 @@ export default async function RootLayout({ root.dataset.webBootstrap = 'pending'; } - // 4. Instant web_ready Announcement + // 4. Instant web_ready Announcement Bridge function announce() { if (window.__habibWebReadySent || !window.HabibApp || !window.HabibApp.postMessage) return false; window.__habibWebReadySent = true; @@ -247,13 +247,15 @@ export default async function RootLayout({ return true; } + window.__announceHabibWebReady = announce; + function tryAnnounce() { if (!announce()) return false; setTimeout(function() { if (root.dataset.webBootstrap === 'pending') { root.dataset.webBootstrap = 'ready'; } - }, 3000); + }, 2500); return true; } diff --git a/src/components/Componentes/entry-route-resolver.tsx b/src/components/Componentes/entry-route-resolver.tsx index dd95254..bda5667 100644 --- a/src/components/Componentes/entry-route-resolver.tsx +++ b/src/components/Componentes/entry-route-resolver.tsx @@ -33,7 +33,14 @@ export default function EntryRouteResolver({ useEffect(() => { let isActive = true; + const announceReady = () => { + if (typeof window !== "undefined") { + window.__announceHabibWebReady?.(); + } + }; + const goToIntro = () => { + announceReady(); if (!anonymousEntryVisible) { router.replace(localizePath("/intro", locale)); } @@ -49,6 +56,7 @@ export default function EntryRouteResolver({ const cachedEntryPath = getCachedMarriageEntryPath(); if (cachedEntryPath) { + announceReady(); router.replace(localizePath(cachedEntryPath, locale)); return; } @@ -67,6 +75,7 @@ export default function EntryRouteResolver({ return; } + announceReady(); router.replace(localizePath(getSubmitPath(profile), locale)); } catch (error) { console.warn("Could not resolve entry route", error); diff --git a/src/types/window.d.ts b/src/types/window.d.ts index 3ed3342..20fdafa 100644 --- a/src/types/window.d.ts +++ b/src/types/window.d.ts @@ -87,6 +87,7 @@ declare global { sendToFlutter?: (action: string, data?: Record) => void; __HABIB_BOOTSTRAP__?: NonNullable; __habibWebReadySent?: boolean; + __announceHabibWebReady?: () => boolean; } }