import { lazy } from "react"; import { ModuleId } from "./registry"; /* ------------------------------------------------------------------ */ /* Code-split module pages. Chunks are preloaded on hub mount and on */ /* menu-button hover so the launch animation never janks on fetch. */ /* ------------------------------------------------------------------ */ // Module E pages (mint theme namespace) export const EDashboard = lazy(() => import("../pages/Dashboard")); export const ECampaigns = lazy(() => import("../pages/Campaigns")); export const ECampaignDetail = lazy(() => import("../pages/CampaignDetail")); export const ELeads = lazy(() => import("../pages/Leads")); export const EEmailAccounts = lazy(() => import("../pages/EmailAccounts")); export const EWarmup = lazy(() => import("../pages/Warmup")); export const EInbox = lazy(() => import("../pages/Inbox")); export const EWebhooks = lazy(() => import("../pages/Webhooks")); export const EAnalytics = lazy(() => import("../pages/Analytics")); export const EClients = lazy(() => import("../pages/Clients")); export const EPricing = lazy(() => import("../pages/Pricing")); export const ESettings = lazy(() => import("../pages/Settings")); // Module S pages (prod indigo namespace) export const SDashboard = lazy(() => import("./s/pages/Dashboard")); export const SCampaigns = lazy(() => import("./s/pages/Campaigns")); export const SCampaignDetail = lazy(() => import("./s/pages/CampaignDetail")); export const SLeads = lazy(() => import("./s/pages/Leads")); export const SEmailAccounts = lazy(() => import("./s/pages/EmailAccounts")); export const SWarmup = lazy(() => import("./s/pages/Warmup")); export const SInbox = lazy(() => import("./s/pages/Inbox")); export const SWebhooks = lazy(() => import("./s/pages/Webhooks")); export const SAnalytics = lazy(() => import("./s/pages/Analytics")); export const SClients = lazy(() => import("./s/pages/Clients")); export const SSettings = lazy(() => import("./s/pages/Settings")); const E_IMPORTS = [ () => import("../pages/Dashboard"), () => import("../pages/Campaigns"), () => import("../pages/CampaignDetail"), () => import("../pages/Leads"), () => import("../pages/EmailAccounts"), () => import("../pages/Warmup"), () => import("../pages/Inbox"), () => import("../pages/Webhooks"), () => import("../pages/Analytics"), () => import("../pages/Clients"), () => import("../pages/Pricing"), () => import("../pages/Settings"), ]; const S_IMPORTS = [ () => import("./s/pages/Dashboard"), () => import("./s/pages/Campaigns"), () => import("./s/pages/CampaignDetail"), () => import("./s/pages/Leads"), () => import("./s/pages/EmailAccounts"), () => import("./s/pages/Warmup"), () => import("./s/pages/Inbox"), () => import("./s/pages/Webhooks"), () => import("./s/pages/Analytics"), () => import("./s/pages/Clients"), () => import("./s/pages/Settings"), ]; const preloaded = new Set(); /** Warm every chunk of a module before its launch animation starts. */ export function preloadModulePages(id: ModuleId): void { if (preloaded.has(id)) return; preloaded.add(id); const imports = id === "e" ? E_IMPORTS : S_IMPORTS; imports.forEach((fn) => { fn().catch(() => { // Preload is best-effort; the Suspense boundary handles real failures. }); }); }