From b0c81d53d922d94ac29388412805eeb067f739e1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 29 Jan 2025 08:35:40 +0000 Subject: [PATCH] Iterate --- packages/element-web-module-api/src/api.ts | 17 ++++++++++++++++- packages/element-web-module-api/src/index.ts | 2 +- .../src/legacy-customisations.ts | 10 +++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/element-web-module-api/src/api.ts b/packages/element-web-module-api/src/api.ts index b016b796c9..06ddcaf26b 100644 --- a/packages/element-web-module-api/src/api.ts +++ b/packages/element-web-module-api/src/api.ts @@ -53,4 +53,19 @@ export function isModule(module: unknown): module is ModuleExport { ); } -export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiExtension {} +export interface Config { + // The branding name of the application + brand: string; + // Other config options are available but not specified in the types as that would make it difficult to change for element-web + // they are accessible at runtime all the same, see list at https://github.com/element-hq/element-web/blob/develop/docs/config.md +} + +export interface ConfigApi { + get(): Config; + get(key: K): Config[K]; + get(key?: K): Config | Config[K]; +} + +export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiExtension { + config: ConfigApi; +} diff --git a/packages/element-web-module-api/src/index.ts b/packages/element-web-module-api/src/index.ts index d105ffdb8a..0b2bf9435c 100644 --- a/packages/element-web-module-api/src/index.ts +++ b/packages/element-web-module-api/src/index.ts @@ -6,6 +6,6 @@ Please see LICENSE files in the repository root for full details. */ export { ModuleLoader, ModuleIncompatibleError } from "./loader"; -export type { Api, Module, ModuleFactory } from "./api"; +export type { Api, Module, ModuleFactory, Config, ConfigApi } from "./api"; export type * from "./legacy-modules"; export type * from "./legacy-customisations"; diff --git a/packages/element-web-module-api/src/legacy-customisations.ts b/packages/element-web-module-api/src/legacy-customisations.ts index 753f8ff107..bc1d963cd4 100644 --- a/packages/element-web-module-api/src/legacy-customisations.ts +++ b/packages/element-web-module-api/src/legacy-customisations.ts @@ -77,12 +77,12 @@ export interface Media { downloadSource(): Promise; } -export interface MediaContructable { - new (prepared: { mxc: string; thumbnail?: Thumbnail; file?: File }): Media; +export interface MediaContructable { + new (prepared: PreparedMedia): Media; } -export interface MediaCustomisations { - readonly Media: MediaContructable; +export interface MediaCustomisations { + readonly Media: MediaContructable; mediaFromContent(content: Content, client?: Client): Media; mediaFromMxc(mxc?: string, client?: Client): Media; } @@ -182,7 +182,7 @@ export interface LegacyCustomisationsApiExtension { /** * @deprecated */ - readonly _registerLegacyMediaCustomisations: LegacyCustomisations>; + readonly _registerLegacyMediaCustomisations: LegacyCustomisations>; /** * @deprecated */