2021-02-28 00:44:49 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Brandon Scott <xeon.productions@gmail.com>
|
|
|
|
|
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
2021-09-04 07:45:36 -03:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
2021-02-28 00:44:49 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-28 00:44:49 -03: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 06:16:36 -03:00
|
|
|
WebContentConsoleClient(JS::Console&, WeakPtr<JS::Interpreter>, ClientConnection&);
|
2021-02-28 00:44:49 -03:00
|
|
|
|
2021-09-04 07:45:36 -03:00
|
|
|
void handle_input(String const& js_source);
|
|
|
|
|
void send_messages(i32 start_index);
|
2021-02-28 00:44:49 -03:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual JS::Value log() override;
|
|
|
|
|
virtual JS::Value info() override;
|
|
|
|
|
virtual JS::Value debug() override;
|
|
|
|
|
virtual JS::Value warn() override;
|
|
|
|
|
virtual JS::Value error() override;
|
|
|
|
|
virtual JS::Value clear() override;
|
|
|
|
|
virtual JS::Value trace() override;
|
|
|
|
|
virtual JS::Value count() override;
|
|
|
|
|
virtual JS::Value count_reset() override;
|
2021-04-18 12:08:14 -03:00
|
|
|
virtual JS::Value assert_() override;
|
2021-02-28 00:44:49 -03:00
|
|
|
|
|
|
|
|
ClientConnection& m_client;
|
|
|
|
|
WeakPtr<JS::Interpreter> m_interpreter;
|
2021-09-03 06:16:36 -03:00
|
|
|
JS::Handle<ConsoleGlobalObject> m_console_global_object;
|
|
|
|
|
|
2021-02-28 00:44:49 -03:00
|
|
|
void clear_output();
|
2021-09-04 07:45:36 -03: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 00:44:49 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|