### Setup GBOX Dependencies Source: https://github.com/babelcloud/gbox/blob/main/README.md Installs all necessary dependencies for GBOX. Can be run interactively or non-interactively. ```bash gbox setup # Or non-interactively gbox setup -y ``` -------------------------------- ### Quick Install GBOX CLI Source: https://github.com/babelcloud/gbox/blob/main/README.md Installs the GBOX CLI. Dependencies like ADB and Appium are installed automatically when needed or can be set up later with 'gbox setup'. ```bash curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash ``` -------------------------------- ### Install GBOX CLI with all dependencies Source: https://github.com/babelcloud/gbox/blob/main/README.md Installs the GBOX CLI along with Node.js, npm, ADB, FRP client, and Appium. This is a one-step setup for all required components. ```bash curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash -s -- --with-deps ``` -------------------------------- ### Install @gbox/live-view Source: https://github.com/babelcloud/gbox/blob/main/packages/live-view/README.md Install the live-view package using npm or pnpm. ```bash npm install @gbox/live-view # or pnpm add @gbox/live-view ``` -------------------------------- ### Get Started with GBOX Source: https://github.com/babelcloud/gbox/blob/main/README.md Initial commands to log in to GBOX, connect an Android device, and export MCP configurations for IDEs. ```bash # Login to gbox.ai gbox login # Connect your Android device (dependencies will be installed automatically if missing) gbox device-connect # Export MCP config and merge into Claude Code/Cursor gbox mcp export --merge-to claude-code gbox mcp export --merge-to cursor ``` -------------------------------- ### Install GBOX CLI using NPM Source: https://github.com/babelcloud/gbox/blob/main/packages/cli-npm/README.md Use this command to install the GBOX CLI on Linux systems via NPM. ```bash npm install -g @gbox.ai/cli ``` -------------------------------- ### Install GBOX CLI using Homebrew Source: https://github.com/babelcloud/gbox/blob/main/packages/cli-npm/README.md Use this command to install the GBOX CLI on macOS systems via Homebrew. ```bash brew install gbox ``` -------------------------------- ### Development Commands Source: https://github.com/babelcloud/gbox/blob/main/packages/live-view/README.md Common commands for developing the component, including installing dependencies, running the dev server, and building. ```bash # Install dependencies pnpm install # Run development server pnpm dev # Build component library pnpm build:component # Build static site pnpm build:static # Build both pnpm build ``` -------------------------------- ### Build gbox for Current Platform Source: https://github.com/babelcloud/gbox/blob/main/README.md Use this command to build the gbox project for the platform you are currently working on. Ensure Go 1.21+ and Make are installed. ```bash # Build for current platform make build ``` -------------------------------- ### Non-Interactive GBOX CLI Installation Source: https://github.com/babelcloud/gbox/blob/main/README.md Installs the GBOX CLI without prompts. Use '--with-deps' to include all dependencies. ```bash # CLI only curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash -s -- -y # With all dependencies curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash -s -- -y --with-deps ``` -------------------------------- ### Start Port Forward Source: https://github.com/babelcloud/gbox/blob/main/packages/cli/internal/server/static/adb-expose.html Initiates a port forward connection. It sends a POST request to the /api/adb-expose/start endpoint with the box ID and local port. Handles success and error responses, updating the UI accordingly. ```javascript function startForward(boxId, localPort, remotePort) { const button = document.getElementById('expose-button'); button.disabled = true; button.textContent = 'Exposing...'; fetch('/api/adb-expose/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ box_id: boxId, local_port: localPort, remote_port: remotePort }) }) .then(res => res.json()) .then(data => { if (data.success) { loadBoxesAndForwards(); // Reload both boxes and forwards button.textContent = 'Exposed'; // Optionally disable the button after successful exposure or provide a way to remove it } else { alert('Failed to start port forward: ' + (data.error || 'Unknown error')); // Restore button state on failure button.disabled = false; button.textContent = 'Expose'; } }) .catch(err => { console.error('Failed to start port forward:', err); alert('Failed to start port forward: ' + err.message); // Restore button state on error button.disabled = false; button.textContent = 'Expose'; }); } ``` -------------------------------- ### Run MCP Server Locally Source: https://github.com/babelcloud/gbox/blob/main/README.md Starts the MCP Server service locally. Navigate to the 'packages/mcp-server' directory and use pnpm to run the development server. Requires Node.js 16.13+ and pnpm. ```bash # MCP Server cd packages/mcp-server && pnpm dev ``` -------------------------------- ### Update GBOX CLI using install script Source: https://github.com/babelcloud/gbox/blob/main/README.md Updates the GBOX CLI using the installation script. Supports interactive updates, forced updates, and skipping updates. ```bash # Interactive update curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash # Force update without prompt curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash -s -- --update # Skip update even if newer version available curl -fsSL https://raw.githubusercontent.com/babelcloud/gbox/main/install.sh | bash -s -- --update=false ``` -------------------------------- ### Run MCP Inspector Locally Source: https://github.com/babelcloud/gbox/blob/main/README.md Starts the MCP Inspector service locally. Navigate to the 'packages/mcp-server' directory and use pnpm to run the inspector. Requires Node.js 16.13+ and pnpm. ```bash # MCP Inspector cd packages/mcp-server && pnpm inspect ``` -------------------------------- ### React Component Usage Example with Specialized Hooks Source: https://github.com/babelcloud/gbox/blob/main/packages/live-view/src/hooks/README.md Demonstrates integrating multiple specialized hooks into a React component to manage various user interactions on a video element. Ensure all necessary hooks and client/enabled/isConnected variables are defined. ```typescript import { useClipboardHandler, useControlHandler, useKeyboardHandler, useWheelHandler, useMouseHandler, useClickHandler, useTouchHandler } from '../hooks'; function MyComponent() { const clipboardHandler = useClipboardHandler({ client, enabled, isConnected, onError }); const controlHandler = useControlHandler({ client, enabled, isConnected }); const keyboardHandler = useKeyboardHandler({ client, enabled, keyboardCaptureEnabled, isConnected, onClipboardPaste: clipboardHandler.handleClipboardPaste, onClipboardCopy: clipboardHandler.handleClipboardCopy, }); const wheelHandler = useWheelHandler({ client, enabled, isConnected }); const mouseHandler = useMouseHandler({ client, enabled, isConnected }); const clickHandler = useClickHandler({ client, enabled, isConnected }); const touchHandler = useTouchHandler({ client, enabled, isConnected }); return (