// Transport facade. The rest of the app (inbox-service, Messages) imports // send/poll/stream/decrypt from here and never learns which pipe carries // the bytes. Both transports expose an identical surface and both ship the // same sealed envelope from crypto.ts — only the delivery mechanism differs. // // VITE_TRANSPORT=server (default) → kez-chat server inbox over HTTP/SSE // VITE_TRANSPORT=nostr → Nostr relays // // Set it in .env / .env.local. Switching transports is build-time; there's // no reason to flip it at runtime and keeping it static lets Vite tree-shake // the unused transport out of the bundle. import * as server from "./messages.js"; import * as nostr from "./nostr-transport.js"; const TRANSPORT = (import.meta.env.VITE_TRANSPORT ?? "server") as "server" | "nostr"; const impl = TRANSPORT === "nostr" ? nostr : server; export const sendMessage = impl.sendMessage; export const pollInbox = impl.pollInbox; export const streamInbox = impl.streamInbox; export const decrypt = impl.decrypt; export type { InboxMessage, StreamHandle, SealedEnvelope, MessagePlaintext } from "./messages.js"; /** Which transport this build is using — handy for a debug line in the UI. */ export const activeTransport = TRANSPORT;