Skip to content

initial implementation of screen sharing via cf workers - #10

Open
silicakes wants to merge 13 commits into
mainfrom
support-screen-streaming
Open

initial implementation of screen sharing via cf workers#10
silicakes wants to merge 13 commits into
mainfrom
support-screen-streaming

Conversation

@silicakes

Copy link
Copy Markdown
Owner

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 12, 2025

Copy link
Copy Markdown

Deploying deluge-extensions with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0ba9ff7
Status: ✅  Deploy successful!
Preview URL: https://5489b55a.deluge-extensions.pages.dev
Branch Preview URL: https://support-screen-streaming.deluge-extensions.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 12, 2025

Copy link
Copy Markdown

Deploying dex-beta with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0ba9ff7
Status: ✅  Deploy successful!
Preview URL: https://6828b2a7.dex-beta.pages.dev
Branch Preview URL: https://support-screen-streaming.dex-beta.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements screen sharing/streaming functionality using Cloudflare Workers and Durable Objects, allowing users to share their Deluge display to viewers on devices without WebMIDI support (like iOS).

Key Changes

  • Adds WebSocket-based relay infrastructure (Cloudflare Worker + Durable Object and local Node.js relay)
  • Implements viewer mode for displaying shared screens without WebMIDI
  • Adds room-based streaming with optional password protection and viewer cap

Reviewed changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
worker/wrangler.toml Cloudflare Worker configuration for screen streaming relay
worker/src/index.ts Durable Object implementation for room management and frame relay
server/relay.mjs Local Node.js relay server for development/LAN testing
functions/_worker.ts Cloudflare Pages integration wrapper for the relay
src/main.tsx Entry point modified to support viewer mode routing via roomId param
src/lib/screenStreaming/* Core utilities for room codes, password tokens, codec, and WebSocket URL building
src/services/screenStreamingStreamer.ts Streamer-side service managing MIDI subscription and frame encoding
src/components/screenStreaming/* UI components for streaming modal, viewer app, and QR code generation
src/lib/fullscreen.ts Enhanced wake lock management for both fullscreen and visibility changes
src/lib/display.ts Added polling state check function
docs/screen-streaming.md Comprehensive documentation for the screen streaming feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

): DisplaySysexFrame {
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
if (bytes.length < STREAM_HEADER_BYTES) {
throw new Error("frame too short");

Copilot AI Dec 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "frame too short" is vague. Consider making it more descriptive, such as "Frame is too short (minimum 11 bytes required)" to help with debugging.

Suggested change
throw new Error("frame too short");
throw new Error(`Frame is too short (minimum ${STREAM_HEADER_BYTES} bytes required)`);

Copilot uses AI. Check for mistakes.
throw new Error("frame too short");
}
if (bytes[0] !== STREAM_MAGIC_0 || bytes[1] !== STREAM_MAGIC_1) {
throw new Error("bad magic");

Copilot AI Dec 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "bad magic" is unclear. Consider making it more descriptive, such as "Invalid frame magic bytes (expected 'DX')" to aid debugging.

Suggested change
throw new Error("bad magic");
throw new Error(
`Invalid frame magic bytes (expected 0x${STREAM_MAGIC_0.toString(16).padStart(2, "0")}, 0x${STREAM_MAGIC_1.toString(16).padStart(2, "0")}; got 0x${bytes[0].toString(16).padStart(2, "0")}, 0x${bytes[1].toString(16).padStart(2, "0")})`
);

Copilot uses AI. Check for mistakes.
for (let x = 0; x < qr.size; x++) {
if (!qr.getModule(x, y)) continue;
modules.push(
<rect x={x + border} y={y + border} width="1" height="1" />,

Copilot AI Dec 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rect elements generated in a loop lack unique key props. In Preact/React, list items should have a unique key to help with efficient rendering. Consider adding a key based on x and y coordinates.

Suggested change
<rect x={x + border} y={y + border} width="1" height="1" />,
<rect key={`${x},${y}`} x={x + border} y={y + border} width="1" height="1" />,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants