Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

desktopBrowser.ts

29 lines1.0 KB

1import * as Schema from "effect/Schema";
2​
3import { TrimmedNonEmptyString } from "./baseSchemas.ts";
4​
5const TabKey = {
6 threadId: TrimmedNonEmptyString,
7 tabId: TrimmedNonEmptyString,
8};
9​
10export const DesktopBrowserEvent = Schema.Union([
11 Schema.Struct({ type: Schema.Literal("attached"), ...TabKey }),
12 /** Its `<webview>` went away: closed, crashed, swapped, or devtools took the debugger. */
13 Schema.Struct({ type: Schema.Literal("detached"), ...TabKey }),
14 Schema.Struct({ type: Schema.Literal("cdp"), ...TabKey, message: Schema.String }),
15]);
16export type DesktopBrowserEvent = typeof DesktopBrowserEvent.Type;
17​
18export const DesktopBrowserCommand = Schema.Union([
19 Schema.Struct({ type: Schema.Literal("cdp"), ...TabKey, message: Schema.String }),
20 Schema.Struct({ type: Schema.Literal("release"), ...TabKey }),
21 Schema.Struct({
22 type: Schema.Literal("pointer"),
23 ...TabKey,
24 phase: Schema.Literals(["move", "click"]),
25 x: Schema.Finite,
26 y: Schema.Finite,
27 }),
28]);
29export type DesktopBrowserCommand = typeof DesktopBrowserCommand.Type;