aoc-toolkit 0.1.0-alpha.4

A toolkit for solving Advent of Code problems
Documentation
const api = globalThis.browser ?? globalThis.chrome;

const NATIVE_HOST = "dev.kyrboforge.aoc_toolkit";

const status = document.querySelector("#status");
const connect = document.querySelector("#connect");

async function connectToHost() {
    connect.disabled = true;

    status.textContent = "Connecting to AOC Toolkit...";

    try {
        const response = await api.runtime.sendNativeMessage(
            NATIVE_HOST,
            { type: "ping" }
        );

        if (
            response?.type !== "pong" ||
            response?.protocol_version !== 1
        ) {
            throw new Error("Unsupported native host response");
        }

        status.textContent =
            "Connected to AOC Toolkit. Protocol v1.";
    } catch (error) {
        status.textContent =
            `Connection failed: ${error.message}`;
    } finally {
        connect.disabled = false;
    }
}

connect.addEventListener("click", connectToHost);