diff --git a/iframe-fetch-client/MESSAGING_PROTOCOL.md b/iframe-fetch-client/MESSAGING_PROTOCOL.md index 0f1328b5..150486ae 100644 --- a/iframe-fetch-client/MESSAGING_PROTOCOL.md +++ b/iframe-fetch-client/MESSAGING_PROTOCOL.md @@ -371,85 +371,4 @@ const decodedBytes = new Uint8Array(atob(encodedBody).split('').map(c => c.charC ## Console Logging Implementation -The iframe client automatically intercepts console messages and forwards them to the parent. The implementation (in `_iframe-client/main.js`) overrides console methods: - -```javascript -class ConsoleInterceptor { - constructor() { - this.originalConsole = {}; - this.methods = ['log', 'warn', 'error', 'info', 'debug']; - this.init(); - } - - init() { - // Store original methods - this.methods.forEach(method => { - if (typeof console[method] === 'function') { - this.originalConsole[method] = console[method]; - } - }); - - // Override console methods - this.methods.forEach(method => { - if (typeof console[method] === 'function') { - console[method] = (...args) => { - // Call original method - try { - this.originalConsole[method](...args); - } catch (e) { - // Continue if original fails - } - - // Send to parent - this.sendConsoleMessage(method, ...args); - }; - } - }); - } - - sendConsoleMessage(level, ...args) { - const message = args.map(arg => { - if (arg === undefined) return 'undefined'; - if (arg === null) return 'null'; - if (typeof arg === 'object') { - try { - return JSON.stringify(arg, (key, value) => { - if (value instanceof Error) { - return { - name: value.name, - message: value.message, - stack: value.stack - }; - } - return value; - }); - } catch { - return String(arg); - } - } - return String(arg); - }).join(' '); - - try { - window.parent.postMessage({ - jsonrpc: "2.0", - method: "console", - params: { level, message } - }, "*"); - } catch (error) { - // Retry once after delay if postMessage fails - setTimeout(() => { - try { - window.parent.postMessage({ - jsonrpc: "2.0", - method: "console", - params: { level: "error", message: `[DELAYED] ${message}` } - }, "*"); - } catch { - // Give up if retry fails - } - }, 100); - } - } -} -``` \ No newline at end of file +The iframe client automatically intercepts console messages and forwards them to the parent. The implementation (in `_iframe-client/main.js`) overrides console methods. \ No newline at end of file