import { type SwappedInboundMessage, type SwappedOutboundMessage, type SwappedTransport } from '@funkit/connect-core'; /** * Marker key on host → embed envelopes (see {@link buildSwappedSendScript}). * The injected bridge recognizes the mark, unwraps the payload, and delivers it * to the page; everything unmarked is embed traffic and goes to native. */ export declare const FUNKIT_ENVELOPE_KEY = "__funkitSwapped"; /** * Injected into the Swapped WebView before its content loads. Installs one * bridged `postMessage` that routes BOTH directions: * * - **embed → native**: the embed talks to its host by calling * `window.parent.postMessage(obj, origin)` (the web iframe contract); at the * top level `window.parent === window`, so overriding `window.postMessage` * intercepts those calls and forwards them — JSON-stringified — to React * Native via `window.ReactNativeWebView.postMessage`. The RN side parses + * origin-validates via {@link handleWebViewMessage}. * - **native → embed**: messages injected by {@link buildSwappedSendScript} * arrive at the same bridged function wrapped in a funkit-marked envelope * ({@link FUNKIT_ENVELOPE_KEY}); the bridge unwraps them and re-dispatches * the payload through the REAL `postMessage` (captured before the override), * so the embed's `message` listeners receive a genuine, trusted MessageEvent * with an object `event.data` — exactly what they get from an iframe parent. * * It also installs a fake `window.opener` wired to the native channel: with no * parent frame the widget posts its lifecycle messages (`SWAPPED_READY`, …) to * `opener` instead of `parent`, and a top-level WebView has neither — without * the shim those messages are silently dropped. */ export declare const SWAPPED_WEBVIEW_INJECTED_JS = "(function () {\n if (window.__funkitSwappedBridge) { return; }\n window.__funkitSwappedBridge = true;\n // The REAL postMessage, captured before the override below.\n var postToPage = window.postMessage.bind(window);\n function forwardToNative(message) {\n try {\n var data = typeof message === 'string' ? message : JSON.stringify(message);\n window.ReactNativeWebView && window.ReactNativeWebView.postMessage(data);\n } catch (e) {}\n }\n function bridged(message) {\n // funkit envelope (host \u2192 embed): unwrap + deliver to the page's listeners.\n if (message && message.__funkitSwapped) {\n try { postToPage(message.payload, '*'); } catch (e) {}\n return;\n }\n // Anything else is the embed talking to its host \u2192 forward to native.\n forwardToNative(message);\n }\n try { window.postMessage = bridged; } catch (e) {}\n // The widget only emits some messages (notably SWAPPED_ORDER_DATA, the sell\n // deposit address) when it believes it is embedded in a parent frame \u2014 on web\n // that's a real