/** * Shared runtime bridge for `window.eekoSDK`. * * This module exports the bridge's **source code as a string constant** so * that both the production widget-host worker and the local-dev CLI can * serve / inject it without bundler gymnastics. The bridge is a vanilla * IIFE with zero imports. * * Transport selection: * - If `window.__EEKO_DEV__` is set (by `@eeko/cli`'s Vite plugin) * → WebSocket to the CLI's local dev server. * - Otherwise → `window.addEventListener('message', …)` for parent-frame * postMessage envelopes from the overlay app. * * @example * // In widget-host (Cloudflare Worker): * import { RUNTIME_BRIDGE_JS } from '@eeko/sdk/runtime-bridge' * return new Response(RUNTIME_BRIDGE_JS, { headers: { 'Content-Type': 'application/javascript' } }) * * @example * // In @eeko/cli Vite plugin: * import { RUNTIME_BRIDGE_JS } from '@eeko/sdk/runtime-bridge' * return `` */ /** * Shape of the `window.__EEKO_DEV__` global that the CLI's Vite plugin sets * before the bridge loads. Exported so the CLI plugin can typecheck its config. */ interface EekoDevGlobal { wsUrl: string; } /** * The full shipped runtime served at the iframe's `/_runtime/sdk.js`: the * bridge IIFE followed by the declarative interaction interpreter IIFE. The * interpreter runs after `window.eekoSDK` exists (so it can register handlers) * and before the author's `script.js`, and no-ops on widgets with no * `interactions`. The export name is unchanged so widget-host and the CLI need * no injection change. */ declare const RUNTIME_BRIDGE_JS: string; export { type EekoDevGlobal, RUNTIME_BRIDGE_JS };