From 200d52a1621ecdc5790cd80d4a5d94762a2ed32c Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Thu, 23 Oct 2025 12:32:01 +0530 Subject: [PATCH] Add Stores API --- .../element-web-module-api/src/api/index.ts | 6 ++++ .../element-web-module-api/src/api/stores.ts | 35 +++++++++++++++++++ packages/element-web-module-api/src/index.ts | 1 + 3 files changed, 42 insertions(+) create mode 100644 packages/element-web-module-api/src/api/stores.ts diff --git a/packages/element-web-module-api/src/api/index.ts b/packages/element-web-module-api/src/api/index.ts index f95479012c..f99a8bbbe8 100644 --- a/packages/element-web-module-api/src/api/index.ts +++ b/packages/element-web-module-api/src/api/index.ts @@ -17,6 +17,7 @@ import { AccountAuthApiExtension } from "./auth.ts"; import { ProfileApiExtension } from "./profile.ts"; import { ExtrasApi } from "./extras.ts"; import { BuiltinsApi } from "./builtins.ts"; +import { StoresApi } from "./stores.ts"; import { ClientApi } from "./client.ts"; /** @@ -124,6 +125,11 @@ export interface Api */ readonly extras: ExtrasApi; + /** + * Allows modules to access a limited functionality of certain stores from Element Web. + */ + readonly stores: StoresApi; + /** * Access some very specific functionality from the client. */ diff --git a/packages/element-web-module-api/src/api/stores.ts b/packages/element-web-module-api/src/api/stores.ts new file mode 100644 index 0000000000..469a52bdd2 --- /dev/null +++ b/packages/element-web-module-api/src/api/stores.ts @@ -0,0 +1,35 @@ +/* +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 type { Room } from "../models/Room"; + +/** + * Provides some basic functionality of the Room List Store from element-web. + * @public + */ +export interface RoomListStoreApi { + /** + * Get a flat list of sorted room from the RLS. + */ + getRooms(): Room[]; + + /** + * Returns a promise that resolves when RLS is ready. + */ + waitForReady(): Promise; +} + +/** + * Provides access to certain stores from element-web. + * @public + */ +export interface StoresApi { + /** + * Use this to access limited functionality of the RLS from element-web. + */ + getRoomListStore(): RoomListStoreApi; +} diff --git a/packages/element-web-module-api/src/index.ts b/packages/element-web-module-api/src/index.ts index 64f2002a27..52a0593bc5 100644 --- a/packages/element-web-module-api/src/index.ts +++ b/packages/element-web-module-api/src/index.ts @@ -20,5 +20,6 @@ export type * from "./api/dialog"; export type * from "./api/profile"; export type * from "./api/navigation"; export type * from "./api/builtins"; +export type * from "./api/stores"; export type * from "./api/client"; export * from "./api/watchable";