-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update imports and generated schema types
- Loading branch information
Showing
6 changed files
with
478 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// DO NOT EDIT: This file is auto-generated by generate-schema/index.ts | ||
import { z } from "npm:zod"; | ||
|
||
/** | ||
* Messages that are sent unbidden from the webview to the client. | ||
*/ | ||
export type Notification = | ||
| { | ||
$type: "started"; | ||
/** The version of the webview binary */ | ||
version: string; | ||
} | ||
| { | ||
$type: "ipc"; | ||
/** The message sent from the webview UI to the client. */ | ||
message: string; | ||
} | ||
| { | ||
$type: "closed"; | ||
}; | ||
|
||
/** | ||
* Types that can be returned from webview results. | ||
*/ | ||
export type ResultType = | ||
| { | ||
$type: "string"; | ||
|
||
value: string; | ||
} | ||
| { | ||
$type: "boolean"; | ||
|
||
value: boolean; | ||
} | ||
| { | ||
$type: "float"; | ||
|
||
value: number; | ||
} | ||
| { | ||
$type: "size"; | ||
|
||
value: { | ||
/** The height of the window in logical pixels. */ | ||
height: number; | ||
/** The ratio between physical and logical sizes. */ | ||
scale_factor: number; | ||
/** The width of the window in logical pixels. */ | ||
width: number; | ||
}; | ||
}; | ||
|
||
/** | ||
* Responses from the webview to the client. | ||
*/ | ||
export type Response = | ||
| { | ||
$type: "ack"; | ||
|
||
id: string; | ||
} | ||
| { | ||
$type: "result"; | ||
|
||
id: string; | ||
|
||
result: ResultType; | ||
} | ||
| { | ||
$type: "err"; | ||
|
||
id: string; | ||
|
||
message: string; | ||
}; | ||
|
||
/** | ||
* Complete definition of all outbound messages from the webview to the client. | ||
*/ | ||
export type WebViewMessage = | ||
| { | ||
$type: "notification"; | ||
|
||
data: Notification; | ||
} | ||
| { | ||
$type: "response"; | ||
|
||
data: Response; | ||
}; | ||
|
||
export const Notification: z.ZodType<Notification> = z.discriminatedUnion( | ||
"$type", | ||
[ | ||
z.object({ $type: z.literal("started"), version: z.string() }), | ||
z.object({ $type: z.literal("ipc"), message: z.string() }), | ||
z.object({ $type: z.literal("closed") }), | ||
], | ||
); | ||
|
||
export const ResultType: z.ZodType<ResultType> = z.discriminatedUnion("$type", [ | ||
z.object({ $type: z.literal("string"), value: z.string() }), | ||
z.object({ $type: z.literal("boolean"), value: z.boolean() }), | ||
z.object({ $type: z.literal("float"), value: z.number() }), | ||
z.object({ | ||
$type: z.literal("size"), | ||
value: z.object({ | ||
height: z.number(), | ||
scale_factor: z.number(), | ||
width: z.number(), | ||
}), | ||
}), | ||
]); | ||
|
||
export const Response: z.ZodType<Response> = z.discriminatedUnion("$type", [ | ||
z.object({ $type: z.literal("ack"), id: z.string() }), | ||
z.object({ $type: z.literal("result"), id: z.string(), result: ResultType }), | ||
z.object({ $type: z.literal("err"), id: z.string(), message: z.string() }), | ||
]); | ||
|
||
export const WebViewMessage: z.ZodType<WebViewMessage> = z.discriminatedUnion( | ||
"$type", | ||
[ | ||
z.object({ $type: z.literal("notification"), data: Notification }), | ||
z.object({ $type: z.literal("response"), data: Response }), | ||
], | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// DO NOT EDIT: This file is auto-generated by generate-schema/index.ts | ||
import { z } from "npm:zod"; | ||
|
||
export type WindowSizeStates = "maximized" | "fullscreen"; | ||
export type WindowSize = WindowSizeStates | { | ||
height: number; | ||
width: number; | ||
}; | ||
|
||
/** | ||
* Options for creating a webview. | ||
*/ | ||
export type WebViewOptions = | ||
& { | ||
/** Sets whether clicking an inactive window also clicks through to the webview. Default is false. */ | ||
acceptFirstMouse?: boolean; | ||
/** When true, all media can be played without user interaction. Default is false. */ | ||
autoplay?: boolean; | ||
/** | ||
* Enables clipboard access for the page rendered on Linux and Windows. | ||
* | ||
* macOS doesn’t provide such method and is always enabled by default. But your app will still need to add menu item accelerators to use the clipboard shortcuts. | ||
*/ | ||
clipboard?: boolean; | ||
/** When true, the window will have a border, a title bar, etc. Default is true. */ | ||
decorations?: boolean; | ||
/** | ||
* Enable or disable webview devtools. | ||
* | ||
* Note this only enables devtools to the webview. To open it, you can call `webview.open_devtools()`, or right click the page and open it from the context menu. | ||
*/ | ||
devtools?: boolean; | ||
/** Sets whether the webview should be focused when created. Default is false. */ | ||
focused?: boolean; | ||
/** | ||
* Run the WebView with incognito mode. Note that WebContext will be ingored if incognito is enabled. | ||
* | ||
* Platform-specific: - Windows: Requires WebView2 Runtime version 101.0.1210.39 or higher, does nothing on older versions, see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039 | ||
*/ | ||
incognito?: boolean; | ||
/** Run JavaScript code when loading new pages. When the webview loads a new page, this code will be executed. It is guaranteed that the code is executed before window.onload. */ | ||
initializationScript?: string; | ||
/** Sets whether host should be able to receive messages from the webview via `window.ipc.postMessage`. */ | ||
ipc?: boolean; | ||
/** The size of the window. */ | ||
size?: WindowSize; | ||
/** Sets the title of the window. */ | ||
title: string; | ||
/** Sets whether the window should be transparent. */ | ||
transparent?: boolean; | ||
/** Sets the user agent to use when loading pages. */ | ||
userAgent?: string; | ||
} | ||
& ( | ||
| { | ||
/** Optional headers to send with the request. */ | ||
headers?: Record<string, string>; | ||
/** Url to load in the webview. Note: Don't use data URLs here, as they are not supported. Use the `html` field instead. */ | ||
url: string; | ||
} | ||
| { | ||
/** Html to load in the webview. */ | ||
html: string; | ||
/** What to set as the origin of the webview when loading html. */ | ||
origin?: string; | ||
} | ||
); | ||
|
||
export const WindowSizeStates: z.ZodType<WindowSizeStates> = z.enum([ | ||
"maximized", | ||
"fullscreen", | ||
]); | ||
export const WindowSize: z.ZodType<WindowSize> = z.union([ | ||
WindowSizeStates, | ||
z.object({ height: z.number(), width: z.number() }), | ||
]); | ||
|
||
export const WebViewOptions: z.ZodType<WebViewOptions> = z.intersection( | ||
z.object({ | ||
acceptFirstMouse: z.boolean().optional(), | ||
autoplay: z.boolean().optional(), | ||
clipboard: z.boolean().optional(), | ||
decorations: z.boolean().optional(), | ||
devtools: z.boolean().optional(), | ||
focused: z.boolean().optional(), | ||
incognito: z.boolean().optional(), | ||
initializationScript: z.string(), | ||
ipc: z.boolean().optional(), | ||
size: WindowSize.optional(), | ||
title: z.string(), | ||
transparent: z.boolean().optional(), | ||
userAgent: z.string(), | ||
}), | ||
z.union([ | ||
z.object({ | ||
headers: z.record(z.string(), z.string()).optional(), | ||
url: z.string(), | ||
}), | ||
z.object({ html: z.string(), origin: z.string() }), | ||
]), | ||
); |
Oops, something went wrong.