/* Copyright 2025 New Vector Ltd. SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. */ import { ThemeProvider } from "styled-components"; import compound from "@vector-im/compound-web/dist/style.css" with { type: "css" }; import type { Module, Api, ModuleFactory } from "@element-hq/element-web-module-api"; import Translations from "./translations.json"; import { ModuleConfig, CONFIG_KEY } from "./config"; import Banner from "./Banner"; import { name as ModuleName } from "../package.json"; import style from "./style.css" with { type: "css" }; class BannerModule implements Module { public static readonly moduleApiVersion = "^1.0.0"; private config?: ModuleConfig; public constructor(private api: Api) {} public async load(): Promise { document.adoptedStyleSheets.push(compound); document.adoptedStyleSheets.push(style); this.api.i18n.register(Translations); try { this.config = ModuleConfig.parse(this.api.config.get(CONFIG_KEY)); } catch (e) { console.error("Failed to init module", e); throw new Error(`Errors in module configuration for "${ModuleName}"`); } const div = document.createElement("div"); div.dataset.testid = "banner"; this.api.rootNode.before(div); const root = this.api.createRoot(div); root.render( , ); } } export default BannerModule satisfies ModuleFactory;