### Install and Start RemoteDebug iOS WebKit Adapter (CLI) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Instructions for installing the adapter globally using npm and starting the server on a specified port. It also shows how to enable diagnostic logging. ```bash # Install the adapter globally npm install remotedebug-ios-webkit-adapter -g # Start the adapter on default port 9000 remotedebug_ios_webkit_adapter --port=9000 # Start with diagnostics logging enabled DEBUG=remotedebug remotedebug_ios_webkit_adapter --port=9000 ``` -------------------------------- ### Contribute to RemoteDebug iOS WebKit Adapter Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Commands to set up the development environment for the RemoteDebug iOS WebKit Adapter. This includes installing dependencies and starting the application for development. ```bash npm install npm start ``` -------------------------------- ### Install ios-webkit-debug-proxy and libimobiledevice on Linux Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Instructions for installing necessary dependencies on Linux to enable iOS web debugging. This typically involves using a package manager to install `ios-webkit-debug-proxy` and `libimobiledevice`. ```bash # Follow the instructions to install [ios-webkit-debug-proxy](https://github.com/google/ios-webkit-debug-proxy#installation) and [libimobiledevice](https://github.com/libimobiledevice/libimobiledevice) ``` -------------------------------- ### Install ios-webkit-debug-proxy and libimobiledevice on OSX/Mac using Homebrew Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Instructions for installing and updating `ios-webkit-debug-proxy` and `libimobiledevice` on OSX/Mac using Homebrew. This process involves unlinking, uninstalling, and then installing the latest versions from HEAD. ```bash brew update brew unlink libimobiledevice ios-webkit-debug-proxy usbmuxd brew uninstall --force libimobiledevice ios-webkit-debug-proxy usbmuxd brew install --HEAD usbmuxd brew install --HEAD libimobiledevice brew install --HEAD ios-webkit-debug-proxy ``` -------------------------------- ### Install ios-webkit-debug-proxy and libimobiledevice on Windows using Scoop Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Steps to install `ios-webkit-debug-proxy` and `libimobiledevice` on Windows using the Scoop package manager. This allows for setting up the necessary tools for iOS web debugging on Windows. ```bash scoop bucket add extras scoop install ios-webkit-debug-proxy ``` -------------------------------- ### Initialize and Start Proxy Server (TypeScript) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt TypeScript code to initialize and start the RemoteDebug iOS WebKit Adapter server using the `ProxyServer` class. It includes error handling and graceful shutdown. ```typescript import { ProxyServer } from './server'; const server = new ProxyServer(); // Start server on port 9000 server.run(9000).then(port => { console.log(`remotedebug-ios-webkit-adapter is listening on port ${port}`); }).catch(err => { console.error('remotedebug-ios-webkit-adapter failed to run:', err); process.exit(1); }); // Handle graceful shutdown process.on('SIGINT', () => { server.stop(); process.exit(); }); ``` -------------------------------- ### List Available Debug Targets (HTTP GET /json) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Demonstrates how to retrieve a list of all debuggable targets (pages, tabs) on connected iOS devices by making an HTTP GET request to the /json endpoint. Includes an example response. ```bash # Get all available debug targets curl http://localhost:9000/json # Example response: # [ # { # "description": "", # "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/", # "id": "page-1", # "title": "Example Page", # "type": "page", # "url": "https://example.com", # "webSocketDebuggerUrl": "ws://localhost:9000/ios/ios_DEVICE_ID/page-1", # "adapterType": "_ios", # "metadata": { # "deviceId": "abc123", # "deviceName": "iPhone 12", # "deviceOSVersion": "14.5.0", # "version": "14.5.0" # } # } # ] ``` -------------------------------- ### Get Protocol Version (HTTP GET /json/version) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Retrieves information about the browser and protocol version by making an HTTP GET request to the /json/version endpoint. Includes an example response. ```bash curl http://localhost:9000/json/version # Response: # { # "Browser": "Safari/RemoteDebug iOS Webkit Adapter", # "Protocol-Version": "1.2", # "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0)... # "WebKit-Version": "537.36 (@da59d418f54604ba2451cd0ef3a9cd42c05ca530)" # } ``` -------------------------------- ### Run RemoteDebug iOS WebKit Adapter Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Command to start the RemoteDebug iOS WebKit Adapter. It listens on a specified port (defaulting to 9000) and automatically starts `ios-webkit-debug-proxy`. ```bash remotedebug_ios_webkit_adapter --port=9000 ``` -------------------------------- ### Install RemoteDebug iOS WebKit Adapter Globally Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Command to install the RemoteDebug iOS WebKit Adapter globally using npm. This makes the `remotedebug_ios_webkit_adapter` command available in your terminal. ```bash npm install remotedebug-ios-webkit-adapter -g ``` -------------------------------- ### GET /json/version - Get Protocol Version Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Fetches information about the adapter's protocol version, browser details, and user agent string. ```APIDOC ## GET /json/version ### Description Returns information about the browser and protocol version supported by the adapter. ### Method GET ### Endpoint /json/version ### Parameters #### Query Parameters None ### Request Example ```bash curl http://localhost:9000/json/version ``` ### Response #### Success Response (200) - **Browser** (string) - The name of the browser or adapter. - **Protocol-Version** (string) - The version of the Chrome DevTools Protocol. - **User-Agent** (string) - The User-Agent string reported by the adapter. - **WebKit-Version** (string) - The WebKit version used by the adapter. #### Response Example ```json { "Browser": "Safari/RemoteDebug iOS Webkit Adapter", "Protocol-Version": "1.2", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "WebKit-Version": "537.36 (@da59d418f54604ba2451cd0ef3a9cd42c05ca530)" } ``` ``` -------------------------------- ### Retrieve Debug Targets with Adapter (TypeScript) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt TypeScript code showing how to use the `Adapter` class to start the adapter and then retrieve a list of available debug targets. It iterates through the targets and logs their details. ```typescript import { Adapter } from './adapters/adapter'; const adapter = new Adapter('/ios', 'ws://localhost:9000', { port: 9222, baseUrl: 'http://127.0.0.1', path: '/json', pollingInterval: 3000 }); adapter.start().then(() => { return adapter.getTargets(); }).then((targets) => { targets.forEach(target => { console.log(`Target: ${target.title}`); console.log(`URL: ${target.url}`); console.log(`WebSocket: ${target.webSocketDebuggerUrl}`); }); }).catch(err => { console.error('Error getting targets:', err); }); ``` -------------------------------- ### Force Device Refresh (HTTP GET /refresh) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Triggers a refresh of the connected devices and their debug targets by making an HTTP GET request to the /refresh endpoint. Includes an example response. ```bash curl http://localhost:9000/refresh # Response: # { # "status": "ok" # } ``` -------------------------------- ### VS Code launch.json Configuration for iOS Web Debugging Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Example configuration for VS Code's `launch.json` file to attach to an iOS web application using the RemoteDebug adapter. It specifies the debugger type, request method, port, and URL pattern. ```json { "version": "0.2.0", "configurations": [ { "name": "iOS Web", "type": "chrome", "request": "attach", "port": 9000, "url": "http://localhost:8080/*", "webRoot": "${workspaceRoot}/src" } ] } ``` -------------------------------- ### TypeScript Logging and Error Handling in Adapter Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt TypeScript examples demonstrating diagnostic logging and error handling within the adapter. It shows how to enable debug logs using environment variables and how to log general errors using the Logger class. ```typescript import { Logger, debug } from './logger'; // Enable debug logging with environment variable // DEBUG=remotedebug npm start // Log debug messages (only shown when DEBUG=remotedebug) debug('server.run, port=%s', serverPort); debug('adapter.getTargets, metadata=%o', metadata); // Log errors (always shown) Logger.error('No endpoint url found for id', targetId); Logger.error('Unhandled message from target', rawMessage); // Example error handling in adapter adapter.getTargets().then((targets) => { console.log(`Found ${targets.length} targets`); }).catch(err => { console.error('Failed to get targets:', err); // Error: ios_webkit_debug_proxy not found // Error: Device not trusted // Error: Connection refused }); ``` -------------------------------- ### IOSProtocol Message Transformation Example Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Demonstrates how the IOSProtocol adapter transforms Chrome DevTools Protocol messages to WebKit Inspector Protocol messages. This is crucial for ensuring compatibility between the two protocols. The example highlights transformations for commands like DOM.setInspectMode and property mappings for CSS properties. Dependencies include IOSProtocol, IOS9Protocol, and Target classes. ```typescript import { IOSProtocol } from './protocols/ios/ios'; import { IOS9Protocol } from './protocols/ios/ios9'; import { Target } from './protocols/target'; const target = new Target('page-1'); // Create protocol adapter based on iOS version const protocol = new IOS9Protocol(target); // The protocol automatically transforms messages // Example: Chrome sends DOM.setInspectMode // { // id: 1, // method: 'DOM.setInspectMode', // params: { mode: 'searchForNode', highlightConfig: {...} } // } // IOSProtocol transforms to: // { // id: 1, // method: 'DOM.setInspectModeEnabled', // params: { enabled: true } // } // CSS property mapping example // Chrome format: {disabled: true, important: false} // WebKit format: {status: 'disabled', priority: ''} ``` -------------------------------- ### Establish WebSocket Debug Session (JavaScript) Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Demonstrates how to establish a WebSocket connection to a specific debug target and send Chrome DevTools Protocol commands, such as enabling the DOM domain and getting the document. Includes event handling for messages and errors. ```javascript const WebSocket = require('ws'); // Connect to a specific target const ws = new WebSocket('ws://localhost:9000/ios/ios_DEVICE_ID/page-1'); ws.on('open', () => { // Enable the DOM domain ws.send(JSON.stringify({ id: 1, method: 'DOM.enable', params: {} })); // Get the document ws.send(JSON.stringify({ id: 2, method: 'DOM.getDocument', params: {} })); }); ws.on('message', (data) => { const message = JSON.parse(data); console.log('Response:', message); // {id: 2, result: {root: {nodeId: 1, nodeType: 9, ...}}} }); ws.on('error', (error) => { console.error('WebSocket error:', error); }); ``` -------------------------------- ### GET /json - List Available Debug Targets Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Retrieves a list of all debuggable targets, such as web pages and tabs, on connected iOS devices. This endpoint is crucial for discovering what can be debugged. ```APIDOC ## GET /json ### Description Returns a list of all debuggable targets (pages, tabs) on connected iOS devices. ### Method GET ### Endpoint /json ### Parameters #### Query Parameters None ### Request Example ```bash curl http://localhost:9000/json ``` ### Response #### Success Response (200) - **Array of Target Objects** (Array) - A list of objects, each representing a debuggable target. - **description** (string) - Description of the target. - **devtoolsFrontendUrl** (string) - URL to the Chrome DevTools frontend for this target. - **id** (string) - Unique identifier for the target. - **title** (string) - The title of the page or tab. - **type** (string) - The type of the target (e.g., "page"). - **url** (string) - The current URL of the target. - **webSocketDebuggerUrl** (string) - The WebSocket URL to establish a debugging session. - **adapterType** (string) - The type of adapter used (e.g., "_ios"). - **metadata** (object) - Additional metadata about the device. - **deviceId** (string) - The unique ID of the iOS device. - **deviceName** (string) - The name of the iOS device. - **deviceOSVersion** (string) - The operating system version of the iOS device. - **version** (string) - The version of the target or device. #### Response Example ```json [ { "description": "", "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/", "id": "page-1", "title": "Example Page", "type": "page", "url": "https://example.com", "webSocketDebuggerUrl": "ws://localhost:9000/ios/ios_DEVICE_ID/page-1", "adapterType": "_ios", "metadata": { "deviceId": "abc123", "deviceName": "iPhone 12", "deviceOSVersion": "14.5.0", "version": "14.5.0" } } ] ``` ``` -------------------------------- ### TypeScript Screencast Session for iOS Screen Mirroring Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt TypeScript code to initiate and manage a screencast session for mirroring an iOS device screen within Chrome DevTools. It utilizes the ScreencastSession class for starting, acknowledging frames, and stopping the mirror. ```typescript import { ScreencastSession } from './protocols/ios/screencast'; import { Target } from './protocols/target'; const target = new Target('page-1'); // Start screencast with specific parameters const screencast = new ScreencastSession( target, 'jpeg', // format 80, // quality (0-100) 800, // maxWidth 600 // maxHeight ); screencast.start(); // Handle frame acknowledgment screencast.ackFrame(frameNumber); // Stop screencast screencast.stop(); ``` -------------------------------- ### GET /refresh - Force Device Refresh Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Triggers a manual refresh of the connected iOS devices and their debuggable targets. ```APIDOC ## GET /refresh ### Description Forces the adapter to refresh the list of connected devices and targets. ### Method GET ### Endpoint /refresh ### Parameters #### Query Parameters None ### Request Example ```bash curl http://localhost:9000/refresh ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the refresh operation (e.g., "ok"). #### Response Example ```json { "status": "ok" } ``` ``` -------------------------------- ### Chrome DevTools Network Target Configuration Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Bash commands and instructions to configure Chrome DevTools to connect to iOS Safari via the remotedebug adapter. This involves starting the adapter and adding its address to Chrome's inspectable targets. ```bash # 1. Start the adapter remotedebug_ios_webkit_adapter --port=9000 # 2. Open Chrome and navigate to: chrome://inspect # 3. Click "Configure" next to "Discover network targets" # 4. Add: localhost:9000 # 5. Your iOS devices will appear under "Remote Target" ``` -------------------------------- ### Configure iOS Proxy with IOSAdapter.getProxySettings() Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Retrieves the configuration settings for the ios-webkit-debug-proxy. It allows specifying custom proxy paths, ports, and arguments. The function returns a Promise that resolves with the proxy settings or rejects if the proxy is not found. Dependencies include the IOSAdapter class. ```typescript import { IOSAdapter } from './adapters/iosAdapter'; // Get proxy settings with custom port IOSAdapter.getProxySettings({ proxyPath: null, proxyPort: 9100, proxyArgs: null }).then((settings) => { console.log('Proxy path:', settings.proxyPath); console.log('Proxy port:', settings.proxyPort); console.log('Proxy args:', settings.proxyArgs); // proxyArgs: ['--no-frontend', '--config=null:9100,:9101-9201'] }).catch(err => { console.error('Error:', err); // "ios_webkit_debug_proxy not found. Please install..." }); ``` -------------------------------- ### Enable Diagnostics Logging for RemoteDebug Adapter Source: https://github.com/remotedebug/remotedebug-ios-webkit-adapter/blob/master/README.md Command to enable detailed debugging logs for the RemoteDebug adapter. This is useful for troubleshooting and understanding the adapter's behavior. ```bash DEBUG=remotedebug npm start ``` -------------------------------- ### Connect to WebKit Target with Target.connectTo() Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Establishes a connection to a WebKit debug target and facilitates message bridging between a client WebSocket and the target. It requires target data including its ID, title, URL, and WebSocket debugger URL. A client WebSocket connection is also needed to initiate the message forwarding. Dependencies include the Target class and the 'ws' library. ```typescript import { Target } from './protocols/target'; import * as WebSocket from 'ws'; // Create target with target data const target = new Target('page-1', { id: 'page-1', title: 'Example Page', url: 'https://example.com', type: 'page', webSocketDebuggerUrl: 'ws://localhost:9222/devtools/page/1', description: '', devtoolsFrontendUrl: '', faviconUrl: '', adapterType: '_ios' }); // Client websocket (from Chrome DevTools) const clientWs = new WebSocket('ws://localhost:9000/page-1'); // Connect to actual iOS target target.connectTo('ws://localhost:9222/devtools/page/1', clientWs); // Forward messages from client to target clientWs.on('message', (msg) => { target.forward(msg); }); ``` -------------------------------- ### Adapter.getTargets() - Retrieve Debug Targets Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt A programmatic method to fetch available debug targets directly from an adapter instance within a Node.js application. ```APIDOC ## Adapter.getTargets() ### Description Fetches all available debug targets from a specific adapter instance programmatically. Useful for integrating into Node.js applications. ### Method TypeScript/JavaScript Function ### Endpoint N/A (Programmatic method) ### Parameters - **adapter** (object) - An instance of the Adapter class. - **start()**: Method to initialize and start the adapter. - **getTargets()**: Method to retrieve the list of debug targets. ### Request Example ```typescript import { Adapter } from './adapters/adapter'; // Assuming path to adapter class // Configuration for the adapter (example values) const adapterConfig = { port: 9222, // Port for the adapter's server baseUrl: 'http://127.0.0.1', // Base URL for the adapter's HTTP endpoint path: '/json', // Path for the JSON endpoint pollingInterval: 3000 // How often to poll for new targets (in ms) }; // Initialize the adapter for iOS debugging const adapter = new Adapter('/ios', 'ws://localhost:9000', adapterConfig); async function listTargets() { try { await adapter.start(); // Start the adapter server console.log('Adapter started successfully.'); const targets = await adapter.getTargets(); // Get the list of targets console.log('Available Debug Targets:'); targets.forEach(target => { console.log(`- Title: ${target.title}`); console.log(` URL: ${target.url}`); console.log(` WebSocket: ${target.webSocketDebuggerUrl}`); console.log(` ID: ${target.id}`); console.log(` Device: ${target.metadata.deviceName} (${target.metadata.deviceOSVersion})`); }); } catch (err) { console.error('Error managing adapter or getting targets:', err); } finally { // It's good practice to stop the adapter when done, though not shown in original example // await adapter.stop(); } } listTargets(); ``` ### Response #### Success Response (from getTargets()) - **targets** (Array) - An array of objects, where each object represents a debuggable target. The structure of `TargetObject` is similar to the response of the `/json` endpoint. #### Response Example (from getTargets()) ```json [ { "description": "", "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/...?ws=localhost:9000/ios/ios_DEVICE_ID/page-1", "id": "page-1", "title": "My Web App", "type": "page", "url": "http://localhost:3000", "webSocketDebuggerUrl": "ws://localhost:9000/ios/ios_DEVICE_ID/page-1", "adapterType": "_ios", "metadata": { "deviceId": "ios_DEVICE_ID", "deviceName": "iPhone 13 Pro", "deviceOSVersion": "15.0.0", "version": "15.0.0" } } ] ``` ``` -------------------------------- ### VS Code Debugger Configuration for iOS Safari Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt JSON configuration for Visual Studio Code to attach to and debug iOS web applications. It specifies the debugger type, request method, port, URL, and workspace mapping. Requires the adapter to be running and accessible. ```json { "version": "0.2.0", "configurations": [ { "name": "iOS Web", "type": "chrome", "request": "attach", "port": 9000, "url": "http://localhost:8080/*", "webRoot": "${workspaceRoot}/src", "sourceMaps": true, "diagnosticLogging": true }, { "name": "iOS Safari", "type": "chrome", "request": "attach", "port": 9000, "webRoot": "${workspaceRoot}" } ] } ``` -------------------------------- ### Send Command to Target with Target.callTarget() Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Sends a protocol command to the connected iOS target and returns a Promise that resolves with the command's result. This function allows direct interaction with the target, enabling actions like retrieving style sheets, evaluating JavaScript, or requesting DOM nodes. Dependencies include the Target class. ```typescript import { Target } from './protocols/target'; const target = new Target('page-1'); // Get all style sheets target.callTarget('CSS.getAllStyleSheets', {}).then((result) => { console.log('Style sheets:', result.headers); result.headers.forEach(header => { console.log(`Sheet: ${header.sourceURL}`); }); }).catch(err => { console.error('Error:', err); }); // Evaluate JavaScript on the page target.callTarget('Runtime.evaluate', { expression: 'document.title', contextId: 1 }).then((result) => { console.log('Page title:', result.result.value); }).catch(err => { console.error('Evaluation error:', err); }); // Get DOM node for coordinates target.callTarget('Runtime.evaluate', { expression: 'document.elementFromPoint(100, 100)' }).then((obj) => { return target.callTarget('DOM.requestNode', { objectId: obj.result.objectId }); }).then((result) => { console.log('Node ID:', result.nodeId); }); ``` -------------------------------- ### WebSocket Connection - Establish Debug Session Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Establishes a WebSocket connection to a specific debug target for sending Chrome DevTools Protocol commands and receiving responses. ```APIDOC ## WebSocket Connection ### Description Connect to a specific target via WebSocket to send Chrome DevTools Protocol commands and establish a debugging session. ### Method WebSocket ### Endpoint ws://[HOST]:[PORT]/ios/[DEVICE_ID]/[TARGET_ID] - **[HOST]**: The host address where the adapter is running (e.g., localhost). - **[PORT]**: The port the adapter is listening on (default 9000). - **[DEVICE_ID]**: The unique identifier for the iOS device. - **[TARGET_ID]**: The unique identifier for the specific target on the device. ### Parameters #### Connection Parameters (in WebSocket URL) - **DEVICE_ID** (string) - The unique identifier for the iOS device. - **TARGET_ID** (string) - The unique identifier for the target (e.g., "page-1"). ### Request Example (Sending Commands) ```javascript const WebSocket = require('ws'); // Example: Connect to a specific target const ws = new WebSocket('ws://localhost:9000/ios/ios_DEVICE_ID/page-1'); ws.on('open', () => { console.log('WebSocket connection opened'); // Enable the DOM domain to interact with the DOM ws.send(JSON.stringify({ id: 1, // Unique ID for this message method: 'DOM.enable', params: {} })); // Request the root document node ws.send(JSON.stringify({ id: 2, method: 'DOM.getDocument', params: {} })); }); ws.on('message', (data) => { const message = JSON.parse(data); console.log('Received message:', message); // Process the response, e.g., for id: 2 if (message.id === 2 && message.result) { console.log('Document root node:', message.result.root); } }); ws.on('error', (error) => { console.error('WebSocket error:', error); }); ws.on('close', () => { console.log('WebSocket connection closed'); }); ``` ### Response #### Success Response (on message) - **JSON object** - Received from the debugging client, containing command results or events. - **id** (number) - The ID of the command this is a response to. - **result** (object) - The result of the command (if successful). - **method** (string) - For event notifications. - **params** (object) - Parameters for event notifications. #### Response Example (for DOM.getDocument) ```json { "id": 2, "result": { "root": { "nodeId": 1, "nodeType": 9, "nodeName": "#document", "documentURL": "https://example.com", "baseURL": "https://example.com", "publicId": "", "systemId": "", "compatMode": "CSS1Compat", "childNodeCount": 1, "children": [ { "nodeId": 2, "nodeType": 1, "nodeName": "HTML", "backendNodeId": 2, "childNodeCount": 1, "children": [ { "nodeId": 3, "nodeType": 1, "nodeName": "HEAD", "backendNodeId": 3, "childNodeCount": 2, "children": [ { "nodeId": 4, "nodeType": 7, "nodeName": "#text", "value": "\n ", "backendNodeId": 4 }, { "nodeId": 5, "nodeType": 1, "nodeName": "TITLE", "backendNodeId": 5, "childNodeCount": 1, "children": [ { "nodeId": 6, "nodeType": 3, "nodeName": "#text", "value": "Example Page Title", "backendNodeId": 6 } ] } ] } ] } ] } } } ``` ``` -------------------------------- ### Intercept Protocol Messages with Target.addMessageFilter() Source: https://context7.com/remotedebug/remotedebug-ios-webkit-adapter/llms.txt Adds a filter to intercept and optionally transform protocol messages exchanged between tools and the target. Filters can be used to modify messages before they are sent or to prevent them from being sent altogether. This is useful for adapting message formats between different protocol versions or for implementing custom logic. Dependencies include the Target class. ```typescript import { Target } from './protocols/target'; const target = new Target('page-1'); // Intercept CSS.setStyleTexts to transform Chrome format to WebKit format target.addMessageFilter('tools::CSS.setStyleTexts', async (msg) => { console.log('Intercepting setStyleTexts:', msg); // Transform message const transformedMsg = { id: msg.id, method: 'CSS.setStyleText', params: { styleId: { styleSheetId: msg.params.edits[0].styleSheetId, ordinal: 0 }, text: msg.params.edits[0].text } }; return transformedMsg; }); // Return null to prevent message from being sent target.addMessageFilter('tools::Debugger.canSetScriptSource', async (msg) => { // Reply with false (iOS doesn't support live edit) target.fireResultToTools(msg.id, { result: false }); return null; }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.