// True when this frame has its own TON Connect bridge at window[jsBridgeKey]. // Lets BridgeChild keep an in-frame extension provider instead of shimming it to // the parent. Duplicated here to avoid depending on injected-connector. interface TonConnectBridgeShape { connect: unknown send: unknown listen: unknown } export function hasInFrameTonBridge(jsBridgeKey: string): boolean { if (typeof window === 'undefined' || !jsBridgeKey) return false const root = (window as unknown as Record)[jsBridgeKey] if (!root || typeof root !== 'object') return false const bridge = (root as Record)['tonconnect'] if (!bridge || typeof bridge !== 'object') return false const candidate = bridge as Partial return ( typeof candidate.connect === 'function' && typeof candidate.send === 'function' && typeof candidate.listen === 'function' ) }