| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Brandon Scott <xeon.productions@gmail.com> | 
					
						
							|  |  |  |  * Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com> | 
					
						
							| 
									
										
										
										
											2021-09-04 11:45:36 +01:00
										 |  |  |  * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-25 12:18:30 +02:00
										 |  |  | #include "ConnectionFromClient.h"
 | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  | #include <LibJS/Console.h>
 | 
					
						
							|  |  |  | #include <LibJS/Forward.h>
 | 
					
						
							|  |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							|  |  |  | #include <WebContent/Forward.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace WebContent { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class WebContentConsoleClient final : public JS::ConsoleClient { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-02-25 12:18:30 +02:00
										 |  |  |     WebContentConsoleClient(JS::Console&, WeakPtr<JS::Interpreter>, ConnectionFromClient&); | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-04 11:45:36 +01:00
										 |  |  |     void handle_input(String const& js_source); | 
					
						
							|  |  |  |     void send_messages(i32 start_index); | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2021-12-08 19:24:17 +00:00
										 |  |  |     virtual void clear() override; | 
					
						
							| 
									
										
										
										
											2021-12-22 12:32:15 +00:00
										 |  |  |     virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, PrinterArguments) override; | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-25 12:18:30 +02:00
										 |  |  |     ConnectionFromClient& m_client; | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  |     WeakPtr<JS::Interpreter> m_interpreter; | 
					
						
							| 
									
										
										
										
											2021-09-03 10:16:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  |     void clear_output(); | 
					
						
							| 
									
										
										
										
											2021-09-04 11:45:36 +01:00
										 |  |  |     void print_html(String const& line); | 
					
						
							| 
									
										
										
										
											2021-12-22 12:32:15 +00:00
										 |  |  |     void begin_group(String const& label, bool start_expanded); | 
					
						
							|  |  |  |     virtual void end_group() override; | 
					
						
							| 
									
										
										
										
											2021-09-04 11:45:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     struct ConsoleOutput { | 
					
						
							|  |  |  |         enum class Type { | 
					
						
							|  |  |  |             HTML, | 
					
						
							| 
									
										
										
										
											2021-12-22 12:32:15 +00:00
										 |  |  |             Clear, | 
					
						
							|  |  |  |             BeginGroup, | 
					
						
							|  |  |  |             BeginGroupCollapsed, | 
					
						
							|  |  |  |             EndGroup, | 
					
						
							| 
									
										
										
										
											2021-09-04 11:45:36 +01:00
										 |  |  |         }; | 
					
						
							|  |  |  |         Type type; | 
					
						
							| 
									
										
										
										
											2021-12-22 12:32:15 +00:00
										 |  |  |         String data; | 
					
						
							| 
									
										
										
										
											2021-09-04 11:45:36 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  |     Vector<ConsoleOutput> m_message_log; | 
					
						
							| 
									
										
										
										
											2021-02-27 21:44:49 -06:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |