Skip to content

Conversation

@adamziel
Copy link
Collaborator

Motivation for the change, related issues

An experiment to make Playground share-able with others via a PHP relay. Client A creates a Playground and starts a sharing session by starting a long-polling loop to relay.php. Client B receives that link and loads an iframe from relay.php. All the PHP requests are relayed to Client A and served using their Playground.

Possible follow-ups:

  • Direct Peer-to-peer support
  • Retaining the shared Playground so that I can keep using it once Peer A goes offline

Implementation details

Testing Instructions (or ideally a Blueprint)

Enables sharing a Playground instance with others through an HTTP long-polling relay. The host browser processes WordPress requests and sends responses back through the relay to guest browsers.

Key components:
- Relay middleware for Vite dev server
- TunnelHost class for host-side request processing
- SharedPlaygroundViewer for guest-side rendering
- Share modal UI with copy-to-clipboard functionality
- URL rewriting for HTML, CSS, and redirect headers
The sharing feature now persists when the modal is closed, allowing
users to share their Playground in the background. A status indicator
in the toolbar shows when sharing is active. Clicking it reopens the
share modal for management.

Also adds a PHP implementation of the relay server for production
deployments where Node.js isn't available. The JavaScript relay
continues to be used for development.
The php-relay-middleware and relay-middleware files use Node.js modules
(fs) and should not be exported from the client-facing barrel file.
This was causing "fs.readFileSync" errors in the browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants