| 
									
										
										
										
											2025-03-04 08:45:36 -05:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/JsonValue.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:48:14 -04:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-04 08:45:36 -05:00
										 |  |  | #include <AK/Time.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:48:14 -04:00
										 |  |  | #include <AK/Variant.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-04 08:45:36 -05:00
										 |  |  | #include <AK/Vector.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-04 08:48:20 -05:00
										 |  |  | #include <LibIPC/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-04 08:45:36 -05:00
										 |  |  | #include <LibJS/Console.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace WebView { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:48:14 -04:00
										 |  |  | struct ConsoleLog { | 
					
						
							| 
									
										
										
										
											2025-03-04 08:45:36 -05:00
										 |  |  |     JS::Console::LogLevel level; | 
					
						
							|  |  |  |     Vector<JsonValue> arguments; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:48:14 -04:00
										 |  |  | struct StackFrame { | 
					
						
							|  |  |  |     Optional<String> function; | 
					
						
							|  |  |  |     Optional<String> file; | 
					
						
							|  |  |  |     Optional<size_t> line; | 
					
						
							|  |  |  |     Optional<size_t> column; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ConsoleError { | 
					
						
							|  |  |  |     String name; | 
					
						
							|  |  |  |     String message; | 
					
						
							|  |  |  |     Vector<StackFrame> trace; | 
					
						
							|  |  |  |     bool inside_promise { false }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ConsoleOutput { | 
					
						
							|  |  |  |     UnixDateTime timestamp; | 
					
						
							|  |  |  |     Variant<ConsoleLog, ConsoleError> output; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-04 08:45:36 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2025-03-04 08:48:20 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace IPC { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:48:14 -04:00
										 |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<void> encode(Encoder&, WebView::ConsoleLog const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<WebView::ConsoleLog> decode(Decoder&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<void> encode(Encoder&, WebView::StackFrame const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<WebView::StackFrame> decode(Decoder&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<void> encode(Encoder&, WebView::ConsoleError const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<WebView::ConsoleError> decode(Decoder&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-04 08:48:20 -05:00
										 |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<void> encode(Encoder&, WebView::ConsoleOutput const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | ErrorOr<WebView::ConsoleOutput> decode(Decoder&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |