2021-02-28 03:44:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Brandon Scott <xeon.productions@gmail.com>
|
|
|
|
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
2021-09-04 10:45:36 +00:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
2021-02-28 03:44:49 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-28 03:44:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ClientConnection.h"
|
|
|
|
#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:
|
2021-09-03 09:16:36 +00:00
|
|
|
WebContentConsoleClient(JS::Console&, WeakPtr<JS::Interpreter>, ClientConnection&);
|
2021-02-28 03:44:49 +00:00
|
|
|
|
2021-09-04 10:45:36 +00:00
|
|
|
void handle_input(String const& js_source);
|
|
|
|
void send_messages(i32 start_index);
|
2021-02-28 03:44:49 +00:00
|
|
|
|
|
|
|
private:
|
2021-12-08 19:24:17 +00:00
|
|
|
virtual void clear() override;
|
2021-12-10 13:48:38 +00:00
|
|
|
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, Variant<Vector<JS::Value>, JS::Console::Trace>) override;
|
2021-02-28 03:44:49 +00:00
|
|
|
|
|
|
|
ClientConnection& m_client;
|
|
|
|
WeakPtr<JS::Interpreter> m_interpreter;
|
2021-09-03 09:16:36 +00:00
|
|
|
JS::Handle<ConsoleGlobalObject> m_console_global_object;
|
|
|
|
|
2021-02-28 03:44:49 +00:00
|
|
|
void clear_output();
|
2021-09-04 10:45:36 +00:00
|
|
|
void print_html(String const& line);
|
|
|
|
|
|
|
|
struct ConsoleOutput {
|
|
|
|
enum class Type {
|
|
|
|
HTML,
|
|
|
|
Clear
|
|
|
|
};
|
|
|
|
Type type;
|
|
|
|
String html;
|
|
|
|
};
|
|
|
|
Vector<ConsoleOutput> m_message_log;
|
2021-02-28 03:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|