// SPDX-FileCopyrightText: 2026 Paula Wisnievski // SPDX-License-Identifier: AGPL-3.0-or-later // what the desktop app's window (desktop/native.ts, on deno's main thread) and the client running in a worker (see // main.ts here) tell each other. the window has the os's events and the client draws into it // the window's surface, for deno's UnsafeWindowSurface. handles are pointers' addresses, pointers can't be posted export interface SurfaceHandles { system: "cocoa" | "win32" | "x11" | "wayland"; window: bigint; display: bigint; } export type WindowMessage = | { type: "start"; page: string; surface: SurfaceHandles; width: number; height: number; // what the client saved, see NativePlatform's storage storage: Record; } // in pixels, what's drawn to is this big now | { type: "resize"; width: number; height: number } // code like a KeyboardEvent's, key the letter for a shortcut (see InputManager.key_down), "" otherwise | { type: "key"; down: boolean; code: string; key: string; shortcut: boolean } | { type: "text"; text: string } // buttons numbered like the dom's | { type: "button"; down: boolean; button: number } // the cursor, in pixels from the window's top left | { type: "cursor"; x: number; y: number } // the grabbed mouse moved | { type: "look"; x: number; y: number } // down is positive, about 100 for a notch, like the dom's | { type: "scroll"; amount: number } // the window lost or got focus, losing it lets go of the mouse | { type: "focus"; focused: boolean } // whether the window can be seen | { type: "shown"; shown: boolean } // answers, by the id they were asked with | { type: "clipboard"; id: number; text: string } | { type: "answer"; id: number; yes: boolean }; export type ClientMessage = | { type: "grab"; grab: boolean } | { type: "fullscreen" } // start the client over at page, see Platform.restart | { type: "restart"; page: string } | { type: "fatal"; message: string } // a question with a yes and a no, answered with "answer" | { type: "ask"; id: number; title: string; text: string; yes: string; no: string } | { type: "read_clipboard"; id: number } | { type: "write_clipboard"; text: string } | { type: "store"; key: string; value: string };