Skip to content

Commit e812e26

Browse files
committed
Apply python formatting
1 parent 7c9983a commit e812e26

1 file changed

Lines changed: 162 additions & 110 deletions

File tree

src/clients/python/src/justbe_webview/schemas.py

Lines changed: 162 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -42,229 +42,281 @@
4242
"StartedNotification",
4343
"StringResultType",
4444
"WindowSize",
45-
"WindowSizeStates"
45+
"WindowSizeStates",
4646
]
4747

48-
class StartedNotification(msgspec.Struct, tag_field="$type", tag="started"):
48+
49+
class StartedNotification(msgspec.Struct, tag_field="$type", tag="started"):
4950
version: str
50-
"""The version of the webview binary"""
51+
"""The version of the webview binary"""
52+
5153

52-
class IpcNotification(msgspec.Struct, tag_field="$type", tag="ipc"):
54+
class IpcNotification(msgspec.Struct, tag_field="$type", tag="ipc"):
5355
message: str
54-
"""The message sent from the webview UI to the client."""
56+
"""The message sent from the webview UI to the client."""
57+
58+
59+
class ClosedNotification(msgspec.Struct, tag_field="$type", tag="closed"):
60+
pass
5561

56-
class ClosedNotification(msgspec.Struct, tag_field="$type", tag="closed"):
57-
pass
5862

59-
Notification = Union[StartedNotification, IpcNotification, ClosedNotification]
63+
Notification = Union[StartedNotification, IpcNotification, ClosedNotification]
6064
"""
6165
Messages that are sent unbidden from the webview to the client.
62-
"""
63-
class SizeWithScale(msgspec.Struct, omit_defaults=True):
66+
"""
67+
68+
69+
class SizeWithScale(msgspec.Struct, omit_defaults=True):
6470
height: float
65-
"""The height of the window in logical pixels."""
71+
"""The height of the window in logical pixels."""
6672
scaleFactor: float
67-
"""The ratio between physical and logical sizes."""
73+
"""The ratio between physical and logical sizes."""
6874
width: float
69-
"""The width of the window in logical pixels."""
75+
"""The width of the window in logical pixels."""
7076

71-
class StringResultType(msgspec.Struct, tag_field="$type", tag="string"):
77+
78+
class StringResultType(msgspec.Struct, tag_field="$type", tag="string"):
7279
value: str
7380

74-
class BooleanResultType(msgspec.Struct, tag_field="$type", tag="boolean"):
81+
82+
class BooleanResultType(msgspec.Struct, tag_field="$type", tag="boolean"):
7583
value: bool
7684

77-
class FloatResultType(msgspec.Struct, tag_field="$type", tag="float"):
85+
86+
class FloatResultType(msgspec.Struct, tag_field="$type", tag="float"):
7887
value: float
7988

80-
class SizeResultType(msgspec.Struct, tag_field="$type", tag="size"):
89+
90+
class SizeResultType(msgspec.Struct, tag_field="$type", tag="size"):
8191
value: SizeWithScale
8292

83-
ResultType = Union[StringResultType, BooleanResultType, FloatResultType, SizeResultType]
93+
94+
ResultType = Union[StringResultType, BooleanResultType, FloatResultType, SizeResultType]
8495
"""
8596
Types that can be returned from webview results.
86-
"""
87-
class AckResponse(msgspec.Struct, tag_field="$type", tag="ack"):
97+
"""
98+
99+
100+
class AckResponse(msgspec.Struct, tag_field="$type", tag="ack"):
88101
id: int
89102

90-
class ResultResponse(msgspec.Struct, tag_field="$type", tag="result"):
103+
104+
class ResultResponse(msgspec.Struct, tag_field="$type", tag="result"):
91105
id: int
92106
result: ResultType
93107

94-
class ErrResponse(msgspec.Struct, tag_field="$type", tag="err"):
108+
109+
class ErrResponse(msgspec.Struct, tag_field="$type", tag="err"):
95110
id: int
96111
message: str
97112

98-
Response = Union[AckResponse, ResultResponse, ErrResponse]
113+
114+
Response = Union[AckResponse, ResultResponse, ErrResponse]
99115
"""
100116
Responses from the webview to the client.
101-
"""
102-
class NotificationMessage(msgspec.Struct, tag_field="$type", tag="notification"):
117+
"""
118+
119+
120+
class NotificationMessage(msgspec.Struct, tag_field="$type", tag="notification"):
103121
data: Notification
104122

105-
class ResponseMessage(msgspec.Struct, tag_field="$type", tag="response"):
123+
124+
class ResponseMessage(msgspec.Struct, tag_field="$type", tag="response"):
106125
data: Response
107126

108-
Message = Union[NotificationMessage, ResponseMessage]
127+
128+
Message = Union[NotificationMessage, ResponseMessage]
109129
"""
110130
Complete definition of all outbound messages from the webview to the client.
111-
"""
112-
131+
"""
113132

114133

115-
class ContentUrl(msgspec.Struct, kw_only=True, omit_defaults=True):
134+
class ContentUrl(msgspec.Struct, kw_only=True, omit_defaults=True):
116135
url: str
117-
"""Url to load in the webview. Note: Don't use data URLs here, as they are not supported. Use the `html` field instead."""
136+
"""Url to load in the webview. Note: Don't use data URLs here, as they are not supported. Use the `html` field instead."""
118137
headers: Union[dict[str, str], None] = None
119-
"""Optional headers to send with the request."""
138+
"""Optional headers to send with the request."""
120139

121-
class ContentHtml(msgspec.Struct, kw_only=True, omit_defaults=True):
140+
141+
class ContentHtml(msgspec.Struct, kw_only=True, omit_defaults=True):
122142
html: str
123-
"""Html to load in the webview."""
143+
"""Html to load in the webview."""
124144
origin: Union[str, None] = None
125-
"""What to set as the origin of the webview when loading html."""
145+
"""What to set as the origin of the webview when loading html."""
146+
126147

127-
Content = Union[ContentUrl, ContentHtml]
148+
Content = Union[ContentUrl, ContentHtml]
128149
"""
129150
The content to load into the webview.
130-
"""
131-
class Size(msgspec.Struct, omit_defaults=True):
151+
"""
152+
153+
154+
class Size(msgspec.Struct, omit_defaults=True):
132155
height: float
133-
"""The height of the window in logical pixels."""
156+
"""The height of the window in logical pixels."""
134157
width: float
135-
"""The width of the window in logical pixels."""
158+
"""The width of the window in logical pixels."""
159+
160+
161+
class WindowSizeStates(str, Enum):
162+
maximized = "maximized"
163+
fullscreen = "fullscreen"
164+
165+
166+
WindowSize = Union[WindowSizeStates, Size]
167+
136168

137-
class WindowSizeStates(str, Enum):
138-
maximized = "maximized"
139-
fullscreen = "fullscreen"
169+
class Options(msgspec.Struct, omit_defaults=True):
170+
"""
171+
Options for creating a webview.
172+
"""
140173

141-
WindowSize = Union[WindowSizeStates, Size]
142-
class Options(msgspec.Struct, omit_defaults=True):
143-
"""
144-
Options for creating a webview.
145-
"""
146174
title: str
147-
"""Sets the title of the window."""
175+
"""Sets the title of the window."""
148176
acceptFirstMouse: Union[bool, None] = None
149-
"""Sets whether clicking an inactive window also clicks through to the webview. Default is false."""
177+
"""Sets whether clicking an inactive window also clicks through to the webview. Default is false."""
150178
autoplay: Union[bool, None] = None
151-
"""When true, all media can be played without user interaction. Default is false."""
179+
"""When true, all media can be played without user interaction. Default is false."""
152180
clipboard: Union[bool, None] = None
153181
"""Enables clipboard access for the page rendered on Linux and Windows.
154182
155-
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."""
183+
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."""
156184
decorations: Union[bool, None] = None
157-
"""When true, the window will have a border, a title bar, etc. Default is true."""
185+
"""When true, the window will have a border, a title bar, etc. Default is true."""
158186
devtools: Union[bool, None] = None
159187
"""Enable or disable webview devtools.
160188
161-
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."""
189+
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."""
162190
focused: Union[bool, None] = None
163-
"""Sets whether the webview should be focused when created. Default is false."""
191+
"""Sets whether the webview should be focused when created. Default is false."""
164192
incognito: Union[bool, None] = None
165193
"""Run the WebView with incognito mode. Note that WebContext will be ingored if incognito is enabled.
166194
167-
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"""
195+
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"""
168196
initializationScript: Union[str, None] = None
169-
"""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."""
197+
"""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."""
170198
ipc: Union[bool, None] = None
171-
"""Sets whether host should be able to receive messages from the webview via `window.ipc.postMessage`."""
199+
"""Sets whether host should be able to receive messages from the webview via `window.ipc.postMessage`."""
172200
load: Union[Content, None] = None
173-
"""The content to load into the webview."""
201+
"""The content to load into the webview."""
174202
size: Union[WindowSize, None] = None
175-
"""The size of the window."""
203+
"""The size of the window."""
176204
transparent: Union[bool, None] = None
177-
"""Sets whether the window should be transparent."""
205+
"""Sets whether the window should be transparent."""
178206
userAgent: Union[str, None] = None
179-
"""Sets the user agent to use when loading pages."""
207+
"""Sets the user agent to use when loading pages."""
180208

181209

182-
183-
184-
class GetVersionRequest(msgspec.Struct, tag_field="$type", tag="getVersion"):
210+
class GetVersionRequest(msgspec.Struct, tag_field="$type", tag="getVersion"):
185211
id: int
186-
"""The id of the request."""
212+
"""The id of the request."""
187213

188-
class EvalRequest(msgspec.Struct, tag_field="$type", tag="eval"):
214+
215+
class EvalRequest(msgspec.Struct, tag_field="$type", tag="eval"):
189216
id: int
190-
"""The id of the request."""
217+
"""The id of the request."""
191218
js: str
192-
"""The javascript to evaluate."""
219+
"""The javascript to evaluate."""
220+
193221

194-
class SetTitleRequest(msgspec.Struct, tag_field="$type", tag="setTitle"):
222+
class SetTitleRequest(msgspec.Struct, tag_field="$type", tag="setTitle"):
195223
id: int
196-
"""The id of the request."""
224+
"""The id of the request."""
197225
title: str
198-
"""The title to set."""
226+
"""The title to set."""
199227

200-
class GetTitleRequest(msgspec.Struct, tag_field="$type", tag="getTitle"):
228+
229+
class GetTitleRequest(msgspec.Struct, tag_field="$type", tag="getTitle"):
201230
id: int
202-
"""The id of the request."""
231+
"""The id of the request."""
232+
203233

204-
class SetVisibilityRequest(msgspec.Struct, tag_field="$type", tag="setVisibility"):
234+
class SetVisibilityRequest(msgspec.Struct, tag_field="$type", tag="setVisibility"):
205235
id: int
206-
"""The id of the request."""
236+
"""The id of the request."""
207237
visible: bool
208-
"""Whether the window should be visible or hidden."""
238+
"""Whether the window should be visible or hidden."""
239+
209240

210-
class IsVisibleRequest(msgspec.Struct, tag_field="$type", tag="isVisible"):
241+
class IsVisibleRequest(msgspec.Struct, tag_field="$type", tag="isVisible"):
211242
id: int
212-
"""The id of the request."""
243+
"""The id of the request."""
213244

214-
class OpenDevToolsRequest(msgspec.Struct, tag_field="$type", tag="openDevTools"):
245+
246+
class OpenDevToolsRequest(msgspec.Struct, tag_field="$type", tag="openDevTools"):
215247
id: int
216-
"""The id of the request."""
248+
"""The id of the request."""
249+
217250

218-
class GetSizeRequest(msgspec.Struct, tag_field="$type", tag="getSize"):
251+
class GetSizeRequest(msgspec.Struct, tag_field="$type", tag="getSize"):
219252
id: int
220-
"""The id of the request."""
253+
"""The id of the request."""
221254
include_decorations: Union[bool, None] = None
222-
"""Whether to include the title bar and borders in the size measurement."""
255+
"""Whether to include the title bar and borders in the size measurement."""
223256

224-
class SetSizeRequest(msgspec.Struct, tag_field="$type", tag="setSize"):
257+
258+
class SetSizeRequest(msgspec.Struct, tag_field="$type", tag="setSize"):
225259
id: int
226-
"""The id of the request."""
260+
"""The id of the request."""
227261
size: Size
228-
"""The size to set."""
262+
"""The size to set."""
263+
229264

230-
class FullscreenRequest(msgspec.Struct, tag_field="$type", tag="fullscreen"):
265+
class FullscreenRequest(msgspec.Struct, tag_field="$type", tag="fullscreen"):
231266
id: int
232-
"""The id of the request."""
267+
"""The id of the request."""
233268
fullscreen: Union[bool, None] = None
234-
"""Whether to enter fullscreen mode. If left unspecified, the window will enter fullscreen mode if it is not already in fullscreen mode or exit fullscreen mode if it is currently in fullscreen mode."""
269+
"""Whether to enter fullscreen mode. If left unspecified, the window will enter fullscreen mode if it is not already in fullscreen mode or exit fullscreen mode if it is currently in fullscreen mode."""
235270

236-
class MaximizeRequest(msgspec.Struct, tag_field="$type", tag="maximize"):
271+
272+
class MaximizeRequest(msgspec.Struct, tag_field="$type", tag="maximize"):
237273
id: int
238-
"""The id of the request."""
274+
"""The id of the request."""
239275
maximized: Union[bool, None] = None
240-
"""Whether to maximize the window. If left unspecified, the window will be maximized if it is not already maximized or restored if it was previously maximized."""
276+
"""Whether to maximize the window. If left unspecified, the window will be maximized if it is not already maximized or restored if it was previously maximized."""
277+
241278

242-
class MinimizeRequest(msgspec.Struct, tag_field="$type", tag="minimize"):
279+
class MinimizeRequest(msgspec.Struct, tag_field="$type", tag="minimize"):
243280
id: int
244-
"""The id of the request."""
281+
"""The id of the request."""
245282
minimized: Union[bool, None] = None
246-
"""Whether to minimize the window. If left unspecified, the window will be minimized if it is not already minimized or restored if it was previously minimized."""
283+
"""Whether to minimize the window. If left unspecified, the window will be minimized if it is not already minimized or restored if it was previously minimized."""
284+
247285

248-
class LoadHtmlRequest(msgspec.Struct, tag_field="$type", tag="loadHtml"):
286+
class LoadHtmlRequest(msgspec.Struct, tag_field="$type", tag="loadHtml"):
249287
html: str
250-
"""HTML to set as the content of the webview."""
288+
"""HTML to set as the content of the webview."""
251289
id: int
252-
"""The id of the request."""
290+
"""The id of the request."""
253291
origin: Union[str, None] = None
254-
"""What to set as the origin of the webview when loading html. If not specified, the origin will be set to the value of the `origin` field when the webview was created."""
292+
"""What to set as the origin of the webview when loading html. If not specified, the origin will be set to the value of the `origin` field when the webview was created."""
255293

256-
class LoadUrlRequest(msgspec.Struct, tag_field="$type", tag="loadUrl"):
294+
295+
class LoadUrlRequest(msgspec.Struct, tag_field="$type", tag="loadUrl"):
257296
id: int
258-
"""The id of the request."""
297+
"""The id of the request."""
259298
url: str
260-
"""URL to load in the webview."""
299+
"""URL to load in the webview."""
261300
headers: Union[dict[str, str], None] = None
262-
"""Optional headers to send with the request."""
263-
264-
Request = Union[GetVersionRequest, EvalRequest, SetTitleRequest, GetTitleRequest, SetVisibilityRequest, IsVisibleRequest, OpenDevToolsRequest, GetSizeRequest, SetSizeRequest, FullscreenRequest, MaximizeRequest, MinimizeRequest, LoadHtmlRequest, LoadUrlRequest]
301+
"""Optional headers to send with the request."""
302+
303+
304+
Request = Union[
305+
GetVersionRequest,
306+
EvalRequest,
307+
SetTitleRequest,
308+
GetTitleRequest,
309+
SetVisibilityRequest,
310+
IsVisibleRequest,
311+
OpenDevToolsRequest,
312+
GetSizeRequest,
313+
SetSizeRequest,
314+
FullscreenRequest,
315+
MaximizeRequest,
316+
MinimizeRequest,
317+
LoadHtmlRequest,
318+
LoadUrlRequest,
319+
]
265320
"""
266321
Explicit requests from the client to the webview.
267-
"""
268-
269-
270-
322+
"""

0 commit comments

Comments
 (0)