This package is a shared library providing both the server-side (Node.js) and client-side (browser) Socket.IO implementations used throughout Cypress for real-time communication between the server, driver, and browser.

**Key Commands**

```bash
# Build all targets (browser, CJS node, ESM node)
yarn workspace @packages/socket build

# Run a specific test file
yarn workspace @packages/socket test -- <path-to-spec>

# Run tests matching a glob pattern
yarn workspace @packages/socket test -- "<glob-pattern>"

# Type-check
yarn workspace @packages/socket check-ts
```

**Architecture**

- `lib/node/` — Server-side socket implementation
  - `socket.ts` — Socket.IO server wrapper
  - `cdp-socket.ts` — CDP (Chrome DevTools Protocol) socket implementation
  - `socket-broadcaster.ts` — Broadcasts events to multiple connected sockets
- `lib/client/` — Client-side socket implementations
  - `index.ts` — Browser-compatible socket client
  - `cdp-browser.ts` — CDP client for browser contexts
- `lib/utils.ts` — Shared utility functions

**Gotchas / Notes**

- Socket.IO and engine.io packages are nohoisted to prevent version conflicts with other consumers in the monorepo.
- The package has three separate TypeScript configs: `tsconfig.browser.json`, `tsconfig.cjs.json`, and `tsconfig.esm.json`. Changes to shared code must be compatible with all three build targets.
- The `browser` field in `package.json` points to `browser/client/index.js` (compiled output); the `main` field points to `cjs/node/index.js`.
- `patch-package` runs on postinstall to apply patches to socket.io dependencies.

**Integration Points**

- Used by `@packages/server` for all WebSocket communication with the browser.
- Used by `@packages/proxy` for real-time signaling.
- Used by `@packages/driver` (browser side) to communicate with the server.

**Auto-Generated Files**

- `browser/`, `cjs/`, `esm/` — Generated by `tsc`; do not edit by hand.
