"use client" // How this module's interactive components reach the API: through a transport the app provides // (apps/web/src/ui/transport.tsx). A module may not import the app, and a server component cannot // hand a function to a client one, so the seam is a context -- the same one every module with a // client component declares for itself, until `@conusai-kit/ui/data` is the one shared facade. import { createContext, type ReactElement, type ReactNode, useContext } from "react" export type Transport = (procedure: string, input: unknown) => Promise export type DescribeError = (error: unknown) => string interface Provided { readonly call: Transport readonly describe: DescribeError } const TransportContext = createContext(undefined) export function TransportProvider({ call, describe, children }: Provided & { children: ReactNode }): ReactElement { return {children} } export function useTransport(): Provided { const provided = useContext(TransportContext) if (!provided) throw new Error("branding: wrap the page in a TransportProvider (apps/web/src/ui/transport.tsx)") return provided }