-
-
Notifications
You must be signed in to change notification settings - Fork 74
feat: add client-based clipboard sync (HTTP-safe fallback without HTTPS) #318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
342cfca
dcb1686
d5fd9a1
070fe2d
544bd76
3368723
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ export interface InputMessage { | |
| | "move" | ||
| | "paste" | ||
| | "copy" | ||
| | "clipboard-push" | ||
| | "clipboard-pull" | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| | "click" | ||
| | "scroll" | ||
| | "key" | ||
|
|
@@ -34,7 +36,10 @@ export class InputHandler { | |
| private throttleMs: number | ||
| private modifier: Key | ||
|
|
||
| constructor(throttleMs = 8) { | ||
| constructor( | ||
| private sendToClient: (msg: any) => void, | ||
| throttleMs = 8 | ||
| ) { | ||
|
||
| mouse.config.mouseSpeed = 1000 | ||
| this.modifier = os.platform() === "darwin" ? Key.LeftSuper : Key.LeftControl | ||
| this.throttleMs = throttleMs | ||
|
|
@@ -196,6 +201,36 @@ export class InputHandler { | |
| break | ||
| } | ||
|
|
||
| case "clipboard-push": { | ||
| if (msg.text) { | ||
| // TEMP: fallback using typing instead of real clipboard | ||
| await keyboard.type(msg.text) | ||
| } | ||
| break | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| case "clipboard-pull": { | ||
| // simulate Ctrl+C to get current clipboard | ||
| try { | ||
| await keyboard.pressKey(this.modifier, Key.C) | ||
| } finally { | ||
| await Promise.allSettled([ | ||
| keyboard.releaseKey(Key.C), | ||
| keyboard.releaseKey(this.modifier), | ||
| ]) | ||
| } | ||
|
|
||
| // small delay to allow clipboard update | ||
| await new Promise((r) => setTimeout(r, 100)) | ||
|
|
||
| // ❗ send back to client (IMPORTANT) | ||
| this.sendToClient({ | ||
| type: "clipboard-text", | ||
| text: "TEMP_CLIPBOARD_DATA", // ⚠️ temporary (we’ll improve later) | ||
| }) | ||
|
||
| break | ||
| } | ||
|
|
||
| case "scroll": { | ||
| const MAX_SCROLL = 100 | ||
| const promises: Promise<unknown>[] = [] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.