Remote component

Scan the code and the panel below is on your phone. It's streamed over WebRTC, and your taps and typing on the phone are sent back and applied to the element on this page. The phone doesn't need HTML-in-canvas, and this one element is all it receives.

Living room

Queue

    Not shared yet.

    Show the code one element on another device
    1. Wrap the part of the page to share in <live-region>.
    2. Share its surface in a room. room is a short random code. The link in the QR code is the viewer page with that code after the #.
    3. The phone's page: a <live-view>. It needs no HTML-in-canvas.
    4. The phone's page: join the same room.
    5. Inside shareInRoom(): a WebRTC video track of the surface for each viewer, with a data channel for input, and relayed JPEGs when WebRTC can't connect.
    6. Inside <live-region>: a shadow root with a drawable canvas and a slot. Your markup is slotted into the canvas, so it can be drawn without being moved.
    7. Inside: on every paint event, draw the element.
    8. Inside: copy the pixels to a second canvas, and black out private fields. That second canvas is the only thing that ever leaves the page.
    9. Inside: hand the copy out as an ImageBitmap or a MediaStream.
    10. Inside: replay the input that comes back on the real elements.
    11. The whole library.

    How it travels

    1. Capture. The panel sits in a <live-region>, whose shadow root paints it through an HTML-in-canvas canvas. Every paint copies the result to a second canvas, and captureStream() turns that into a video track. There's no screen-capture prompt, and nothing outside the element is in the picture.
    2. Introduce. Both ends open a WebSocket to a room on the Worker (a Durable Object), which relays the WebRTC offer, answer and ICE candidates.
    3. Stream. Video goes peer to peer. Input comes back on an RTCDataChannel as normalised coordinates and keys, and is replayed on the element.
    4. Fall back. If the peers can't connect, the phone asks for relayed frames instead: JPEGs sent through the same WebSocket at a few frames a second.

    Live checks

    ResultExperimentDetail

    Findings