import { lazy, type ComponentType, type LazyExoticComponent, } from "react"; import { PLATFORM_ROUTE_RUNTIME_CONTRACT } from "../../contracts/route-runtime-contract.js"; type RouteModule = Readonly<{ default: ComponentType }>; type RouteRuntime = Readonly<{ moduleId: string; Component: LazyExoticComponent; }>; function runtime( routeId: keyof typeof PLATFORM_ROUTE_RUNTIME_CONTRACT, load: () => Promise, ): RouteRuntime { return Object.freeze({ moduleId: PLATFORM_ROUTE_RUNTIME_CONTRACT[routeId].moduleId, Component: lazy(load), }); } export const PLATFORM_ROUTE_RUNTIME = { APP_HOME: runtime("APP_HOME", () => import("../pages/home-page.jsx")), EXAMPLES_UI: runtime( "EXAMPLES_UI", () => import("../examples/ui-gallery-page.jsx"), ), EXAMPLES_STATES: runtime( "EXAMPLES_STATES", () => import("../examples/state-gallery-page.jsx"), ), EXAMPLES_AUTH: runtime( "EXAMPLES_AUTH", () => import("../examples/auth-example-page.jsx"), ), NOT_FOUND: runtime( "NOT_FOUND", () => import("../pages/not-found-page.jsx"), ), } satisfies Record;