Adopt shouldShowComponent customisations from legacy Module API

This commit is contained in:
Michael Telatynski
2026-03-02 14:50:09 +00:00
parent 7206db8243
commit 1a9ce45038
4 changed files with 569 additions and 479 deletions
@@ -1,479 +1,495 @@
## API Report File for "@element-hq/element-web-module-api" ## API Report File for "@element-hq/element-web-module-api"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts ```ts
import { ComponentType } from 'react'; import { ComponentType } from 'react';
import { JSX } from 'react'; import { JSX } from 'react';
import { ModuleApi } from '@matrix-org/react-sdk-module-api'; import { ModuleApi } from '@matrix-org/react-sdk-module-api';
import { Root } from 'react-dom/client'; import { Root } from 'react-dom/client';
import { RuntimeModule } from '@matrix-org/react-sdk-module-api'; import { RuntimeModule } from '@matrix-org/react-sdk-module-api';
// @public // @public
export interface AccountAuthApiExtension { export interface AccountAuthApiExtension {
overwriteAccountAuth(accountInfo: AccountAuthInfo): Promise<void>; overwriteAccountAuth(accountInfo: AccountAuthInfo): Promise<void>;
} }
// @public // @public
export interface AccountAuthInfo { export interface AccountAuthInfo {
accessToken: string; accessToken: string;
deviceId: string; deviceId: string;
homeserverUrl: string; homeserverUrl: string;
refreshToken?: string; refreshToken?: string;
userId: string; userId: string;
} }
// @public // @public
export interface AccountDataApi { export interface AccountDataApi {
delete(eventType: string): Promise<void>; delete(eventType: string): Promise<void>;
get(eventType: string): Watchable<unknown>; get(eventType: string): Watchable<unknown>;
set(eventType: string, content: unknown): Promise<void>; set(eventType: string, content: unknown): Promise<void>;
} }
// @alpha @deprecated (undocumented) // @alpha @deprecated (undocumented)
export interface AliasCustomisations { export interface AliasCustomisations {
// (undocumented) // (undocumented)
getDisplayAliasForAliasSet?(canonicalAlias: string | null, altAliases: string[]): string | null; getDisplayAliasForAliasSet?(canonicalAlias: string | null, altAliases: string[]): string | null;
} }
// Warning: (ae-incompatible-release-tags) The symbol "Api" is marked as @public, but its signature references "LegacyModuleApiExtension" which is marked as @alpha // Warning: (ae-incompatible-release-tags) The symbol "Api" is marked as @public, but its signature references "LegacyModuleApiExtension" which is marked as @alpha
// Warning: (ae-incompatible-release-tags) The symbol "Api" is marked as @public, but its signature references "LegacyCustomisationsApiExtension" which is marked as @alpha // Warning: (ae-incompatible-release-tags) The symbol "Api" is marked as @public, but its signature references "LegacyCustomisationsApiExtension" which is marked as @alpha
// //
// @public // @public
export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiExtension, DialogApiExtension, AccountAuthApiExtension, ProfileApiExtension { export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiExtension, DialogApiExtension, AccountAuthApiExtension, ProfileApiExtension {
// @alpha // @alpha
readonly builtins: BuiltinsApi; readonly builtins: BuiltinsApi;
readonly client: ClientApi; readonly client: ClientApi;
readonly config: ConfigApi; readonly config: ConfigApi;
createRoot(element: Element): Root; createRoot(element: Element): Root;
// @alpha // @alpha
readonly customComponents: CustomComponentsApi; readonly customComponents: CustomComponentsApi;
// @alpha // @alpha
readonly extras: ExtrasApi; readonly customisations: CustomisationsApi;
readonly i18n: I18nApi; // @alpha
readonly navigation: NavigationApi; readonly extras: ExtrasApi;
readonly rootNode: HTMLElement; readonly i18n: I18nApi;
readonly stores: StoresApi; readonly navigation: NavigationApi;
// @alpha readonly rootNode: HTMLElement;
readonly widgetLifecycle: WidgetLifecycleApi; readonly stores: StoresApi;
} // @alpha
readonly widgetLifecycle: WidgetLifecycleApi;
// @alpha }
export interface BuiltinsApi {
renderNotificationDecoration(roomId: string): React.ReactNode; // @alpha
renderRoomAvatar(roomId: string, size?: string): React.ReactNode; export interface BuiltinsApi {
renderRoomView(roomId: string, props?: RoomViewProps): React.ReactNode; renderNotificationDecoration(roomId: string): React.ReactNode;
} renderRoomAvatar(roomId: string, size?: string): React.ReactNode;
renderRoomView(roomId: string, props?: RoomViewProps): React.ReactNode;
// @alpha }
export type CapabilitiesApprover = (widget: WidgetDescriptor, requestedCapabilities: Set<string>) => MaybePromise<Set<string> | undefined>;
// @alpha
// @alpha @deprecated (undocumented) export type CapabilitiesApprover = (widget: WidgetDescriptor, requestedCapabilities: Set<string>) => MaybePromise<Set<string> | undefined>;
export interface ChatExportCustomisations<ExportFormat, ExportType> {
getForceChatExportParameters(): { // @alpha @deprecated (undocumented)
format?: ExportFormat; export interface ChatExportCustomisations<ExportFormat, ExportType> {
range?: ExportType; getForceChatExportParameters(): {
numberOfMessages?: number; format?: ExportFormat;
includeAttachments?: boolean; range?: ExportType;
sizeMb?: number; numberOfMessages?: number;
}; includeAttachments?: boolean;
} sizeMb?: number;
};
// @public }
export interface ClientApi {
accountData: AccountDataApi; // @public
getRoom: (id: string) => Room | null; export interface ClientApi {
} accountData: AccountDataApi;
getRoom: (id: string) => Room | null;
// @alpha @deprecated (undocumented) }
export interface ComponentVisibilityCustomisations {
shouldShowComponent?(component: "UIComponent.sendInvites" | "UIComponent.roomCreation" | "UIComponent.spaceCreation" | "UIComponent.exploreRooms" | "UIComponent.addIntegrations" | "UIComponent.filterContainer" | "UIComponent.roomOptionsMenu"): boolean; // @alpha @deprecated (undocumented)
} export interface ComponentVisibilityCustomisations {
shouldShowComponent?(component: "UIComponent.sendInvites" | "UIComponent.roomCreation" | "UIComponent.spaceCreation" | "UIComponent.exploreRooms" | "UIComponent.addIntegrations" | "UIComponent.filterContainer" | "UIComponent.roomOptionsMenu"): boolean;
// @public }
export interface Config {
// (undocumented) // @public
brand: string; export interface Config {
} // (undocumented)
brand: string;
// @public }
export interface ConfigApi {
// (undocumented) // @public
get(): Config; export interface ConfigApi {
// (undocumented) // (undocumented)
get<K extends keyof Config>(key: K): Config[K]; get(): Config;
// (undocumented) // (undocumented)
get<K extends keyof Config = never>(key?: K): Config | Config[K]; get<K extends keyof Config>(key: K): Config[K];
} // (undocumented)
get<K extends keyof Config = never>(key?: K): Config | Config[K];
// @alpha }
export interface CustomComponentsApi {
registerMessageRenderer(eventTypeOrFilter: string | ((mxEvent: MatrixEvent) => boolean), renderer: CustomMessageRenderFunction, hints?: CustomMessageRenderHints): void; // @alpha
registerRoomPreviewBar(renderer: CustomRoomPreviewBarRenderFunction): void; export interface CustomComponentsApi {
} registerMessageRenderer(eventTypeOrFilter: string | ((mxEvent: MatrixEvent) => boolean), renderer: CustomMessageRenderFunction, hints?: CustomMessageRenderHints): void;
registerRoomPreviewBar(renderer: CustomRoomPreviewBarRenderFunction): void;
// @alpha }
export type CustomMessageComponentProps = {
mxEvent: MatrixEvent; // @alpha
}; export interface CustomisationsApi {
registerShouldShowComponent(fn: (this: void, component: UIComponent) => boolean | void): void;
// @alpha }
export type CustomMessageRenderFunction = ( // @alpha
props: CustomMessageComponentProps, export type CustomMessageComponentProps = {
originalComponent?: (props?: OriginalMessageComponentProps) => React.JSX.Element) => JSX.Element; mxEvent: MatrixEvent;
};
// @alpha
export type CustomMessageRenderHints = { // @alpha
allowEditingEvent?: boolean; export type CustomMessageRenderFunction = (
allowDownloadingMedia?: (mxEvent: MatrixEvent) => Promise<boolean>; props: CustomMessageComponentProps,
}; originalComponent?: (props?: OriginalMessageComponentProps) => React.JSX.Element) => JSX.Element;
// @alpha // @alpha
export type CustomRoomPreviewBarComponentProps = { export type CustomMessageRenderHints = {
roomId?: string; allowEditingEvent?: boolean;
roomAlias?: string; allowDownloadingMedia?: (mxEvent: MatrixEvent) => Promise<boolean>;
}; };
// @alpha // @alpha
export type CustomRoomPreviewBarRenderFunction = ( export type CustomRoomPreviewBarComponentProps = {
props: CustomRoomPreviewBarComponentProps, roomId?: string;
originalComponent: (props: CustomRoomPreviewBarComponentProps) => JSX.Element) => JSX.Element; roomAlias?: string;
};
// @public
export interface DialogApiExtension { // @alpha
openDialog<M, P extends object>(initialOptions: DialogOptions, dialog: ComponentType<P & DialogProps<M>>, props: P): DialogHandle<M>; export type CustomRoomPreviewBarRenderFunction = (
} props: CustomRoomPreviewBarComponentProps,
originalComponent: (props: CustomRoomPreviewBarComponentProps) => JSX.Element) => JSX.Element;
// @public
export type DialogHandle<M> = { // @public
finished: Promise<{ export interface DialogApiExtension {
ok: boolean; openDialog<M, P extends object>(initialOptions: DialogOptions, dialog: ComponentType<P & DialogProps<M>>, props: P): DialogHandle<M>;
model: M | null; }
}>;
close(): void; // @public
}; export type DialogHandle<M> = {
finished: Promise<{
// @public ok: boolean;
export interface DialogOptions { model: M | null;
title: string; }>;
} close(): void;
};
// @public
export type DialogProps<M> = { // @public
onSubmit(model: M): void; export interface DialogOptions {
onCancel(): void; title: string;
}; }
// @alpha @deprecated (undocumented) // @public
export interface DirectoryCustomisations { export type DialogProps<M> = {
// (undocumented) onSubmit(model: M): void;
requireCanonicalAliasAccessToPublish?(): boolean; onCancel(): void;
} };
// @alpha // @alpha @deprecated (undocumented)
export interface ExtrasApi { export interface DirectoryCustomisations {
getVisibleRoomBySpaceKey(spaceKey: string, cb: () => string[]): void; // (undocumented)
setSpacePanelItem(spaceKey: string, props: SpacePanelItemProps): void; requireCanonicalAliasAccessToPublish?(): boolean;
} }
// @public // @alpha
export interface I18nApi { export interface ExtrasApi {
humanizeTime(this: void, timeMillis: number): string; getVisibleRoomBySpaceKey(spaceKey: string, cb: () => string[]): void;
get language(): string; setSpacePanelItem(spaceKey: string, props: SpacePanelItemProps): void;
register(this: void, translations: Partial<Translations>): void; }
translate(this: void, key: keyof Translations, variables?: Variables): string;
} // @public
export interface I18nApi {
// @alpha humanizeTime(this: void, timeMillis: number): string;
export type IdentityApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>; get language(): string;
register(this: void, translations: Partial<Translations>): void;
// @alpha @deprecated (undocumented) translate(this: void, key: keyof Translations, variables?: Variables): string;
export type LegacyCustomisations<T extends object> = (customisations: T) => void; }
// @alpha @deprecated (undocumented) // @alpha
export interface LegacyCustomisationsApiExtension { export type IdentityApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>;
// @deprecated (undocumented)
readonly _registerLegacyAliasCustomisations: LegacyCustomisations<AliasCustomisations>; // @alpha @deprecated (undocumented)
// @deprecated (undocumented) export type LegacyCustomisations<T extends object> = (customisations: T) => void;
readonly _registerLegacyChatExportCustomisations: LegacyCustomisations<ChatExportCustomisations<never, never>>;
// @deprecated (undocumented) // @alpha @deprecated (undocumented)
readonly _registerLegacyComponentVisibilityCustomisations: LegacyCustomisations<ComponentVisibilityCustomisations>; export interface LegacyCustomisationsApiExtension {
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyDirectoryCustomisations: LegacyCustomisations<DirectoryCustomisations>; readonly _registerLegacyAliasCustomisations: LegacyCustomisations<AliasCustomisations>;
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyLifecycleCustomisations: LegacyCustomisations<LifecycleCustomisations>; readonly _registerLegacyChatExportCustomisations: LegacyCustomisations<ChatExportCustomisations<never, never>>;
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyMediaCustomisations: LegacyCustomisations<MediaCustomisations<never, never, never>>; readonly _registerLegacyComponentVisibilityCustomisations: LegacyCustomisations<ComponentVisibilityCustomisations>;
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyRoomListCustomisations: LegacyCustomisations<RoomListCustomisations<never>>; readonly _registerLegacyDirectoryCustomisations: LegacyCustomisations<DirectoryCustomisations>;
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyUserIdentifierCustomisations: LegacyCustomisations<UserIdentifierCustomisations>; readonly _registerLegacyLifecycleCustomisations: LegacyCustomisations<LifecycleCustomisations>;
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyWidgetPermissionsCustomisations: LegacyCustomisations<WidgetPermissionsCustomisations<never, never>>; readonly _registerLegacyMediaCustomisations: LegacyCustomisations<MediaCustomisations<never, never, never>>;
// @deprecated (undocumented) // @deprecated (undocumented)
readonly _registerLegacyWidgetVariablesCustomisations: LegacyCustomisations<WidgetVariablesCustomisations>; readonly _registerLegacyRoomListCustomisations: LegacyCustomisations<RoomListCustomisations<never>>;
} // @deprecated (undocumented)
readonly _registerLegacyUserIdentifierCustomisations: LegacyCustomisations<UserIdentifierCustomisations>;
// @alpha @deprecated (undocumented) // @deprecated (undocumented)
export interface LegacyModuleApiExtension { readonly _registerLegacyWidgetPermissionsCustomisations: LegacyCustomisations<WidgetPermissionsCustomisations<never, never>>;
// @deprecated // @deprecated (undocumented)
_registerLegacyModule(LegacyModule: RuntimeModuleConstructor): Promise<void>; readonly _registerLegacyWidgetVariablesCustomisations: LegacyCustomisations<WidgetVariablesCustomisations>;
} }
// @alpha @deprecated (undocumented) // @alpha @deprecated (undocumented)
export interface LifecycleCustomisations { export interface LegacyModuleApiExtension {
// (undocumented) // @deprecated
onLoggedOutAndStorageCleared?(): void; _registerLegacyModule(LegacyModule: RuntimeModuleConstructor): Promise<void>;
} }
// @alpha // @alpha @deprecated (undocumented)
export type LocationRenderFunction = () => JSX.Element; export interface LifecycleCustomisations {
// (undocumented)
// @alpha onLoggedOutAndStorageCleared?(): void;
export interface MatrixEvent { }
content: Record<string, unknown>;
eventId: string; // @alpha
originServerTs: number; export type LocationRenderFunction = () => JSX.Element;
roomId: string;
sender: string; // @alpha
stateKey?: string; export interface MatrixEvent {
type: string; content: Record<string, unknown>;
unsigned: Record<string, unknown>; eventId: string;
} originServerTs: number;
roomId: string;
// @public sender: string;
export type MaybePromise<T> = T | PromiseLike<T>; stateKey?: string;
type: string;
// @alpha @deprecated (undocumented) unsigned: Record<string, unknown>;
export interface Media { }
// (undocumented)
downloadSource(): Promise<Response>; // @public
// (undocumented) export type MaybePromise<T> = T | PromiseLike<T>;
getSquareThumbnailHttp(dim: number): string | null;
// (undocumented) // @alpha @deprecated (undocumented)
getThumbnailHttp(width: number, height: number, mode?: "scale" | "crop"): string | null; export interface Media {
// (undocumented) // (undocumented)
getThumbnailOfSourceHttp(width: number, height: number, mode?: "scale" | "crop"): string | null; downloadSource(): Promise<Response>;
// (undocumented) // (undocumented)
readonly hasThumbnail: boolean; getSquareThumbnailHttp(dim: number): string | null;
// (undocumented) // (undocumented)
readonly isEncrypted: boolean; getThumbnailHttp(width: number, height: number, mode?: "scale" | "crop"): string | null;
// (undocumented) // (undocumented)
readonly srcHttp: string | null; getThumbnailOfSourceHttp(width: number, height: number, mode?: "scale" | "crop"): string | null;
// (undocumented) // (undocumented)
readonly srcMxc: string; readonly hasThumbnail: boolean;
// (undocumented) // (undocumented)
readonly thumbnailHttp: string | null; readonly isEncrypted: boolean;
// (undocumented) // (undocumented)
readonly thumbnailMxc: string | null | undefined; readonly srcHttp: string | null;
} // (undocumented)
readonly srcMxc: string;
// @alpha @deprecated (undocumented) // (undocumented)
export interface MediaContructable<PreparedMedia> { readonly thumbnailHttp: string | null;
// (undocumented) // (undocumented)
new (prepared: PreparedMedia): Media; readonly thumbnailMxc: string | null | undefined;
} }
// @alpha @deprecated (undocumented) // @alpha @deprecated (undocumented)
export interface MediaCustomisations<Content, Client, PreparedMedia> { export interface MediaContructable<PreparedMedia> {
// (undocumented) // (undocumented)
readonly Media: MediaContructable<PreparedMedia>; new (prepared: PreparedMedia): Media;
// (undocumented) }
mediaFromContent(content: Content, client?: Client): Media;
// (undocumented) // @alpha @deprecated (undocumented)
mediaFromMxc(mxc?: string, client?: Client): Media; export interface MediaCustomisations<Content, Client, PreparedMedia> {
} // (undocumented)
readonly Media: MediaContructable<PreparedMedia>;
// @public // (undocumented)
export interface Module { mediaFromContent(content: Content, client?: Client): Media;
// (undocumented) // (undocumented)
load(): Promise<void>; mediaFromMxc(mxc?: string, client?: Client): Media;
} }
// @public // @public
export interface ModuleFactory { export interface Module {
// (undocumented) // (undocumented)
new (api: Api): Module; load(): Promise<void>;
// (undocumented) }
readonly moduleApiVersion: string;
// (undocumented) // @public
readonly prototype: Module; export interface ModuleFactory {
} // (undocumented)
new (api: Api): Module;
// @public // (undocumented)
export class ModuleIncompatibleError extends Error { readonly moduleApiVersion: string;
constructor(pluginVersion: string); // (undocumented)
} readonly prototype: Module;
}
// @public
export class ModuleLoader { // @public
constructor(api: Api); export class ModuleIncompatibleError extends Error {
// Warning: (ae-forgotten-export) The symbol "ModuleExport" needs to be exported by the entry point index.d.ts constructor(pluginVersion: string);
// }
// (undocumented)
load(moduleExport: ModuleExport): Promise<void>; // @public
// (undocumented) export class ModuleLoader {
start(): Promise<void>; constructor(api: Api);
} // Warning: (ae-forgotten-export) The symbol "ModuleExport" needs to be exported by the entry point index.d.ts
//
// @public // (undocumented)
export interface NavigationApi { load(moduleExport: ModuleExport): Promise<void>;
openRoom(roomIdOrAlias: string, opts?: OpenRoomOptions): void; // (undocumented)
// @alpha start(): Promise<void>;
registerLocationRenderer(path: string, renderer: LocationRenderFunction): void; }
toMatrixToLink(link: string, join?: boolean): Promise<void>;
} // @public
export interface NavigationApi {
// @public openRoom(roomIdOrAlias: string, opts?: OpenRoomOptions): void;
export interface OpenRoomOptions { // @alpha
autoJoin?: boolean; registerLocationRenderer(path: string, renderer: LocationRenderFunction): void;
viaServers?: string[]; toMatrixToLink(link: string, join?: boolean): Promise<void>;
} }
// @alpha // @public
export type OriginalMessageComponentProps = { export interface OpenRoomOptions {
showUrlPreview?: boolean; autoJoin?: boolean;
}; viaServers?: string[];
}
// @alpha
export type PreloadApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>; // @alpha
export type OriginalMessageComponentProps = {
// @public showUrlPreview?: boolean;
export interface Profile { };
displayName?: string;
isGuest?: boolean; // @alpha
userId?: string; export type PreloadApprover = (widget: WidgetDescriptor) => MaybePromise<boolean | undefined>;
}
// @public
// @public export interface Profile {
export interface ProfileApiExtension { displayName?: string;
readonly profile: Watchable<Profile>; isGuest?: boolean;
} userId?: string;
}
// @public
export interface Room { // @public
getLastActiveTimestamp: () => number; export interface ProfileApiExtension {
id: string; readonly profile: Watchable<Profile>;
name: Watchable<string>; }
}
// @public
// @alpha @deprecated (undocumented) export interface Room {
export interface RoomListCustomisations<Room> { getLastActiveTimestamp: () => number;
isRoomVisible?(room: Room): boolean; id: string;
} name: Watchable<string>;
}
// @public
export interface RoomListStoreApi { // @alpha @deprecated (undocumented)
getRooms(): Watchable<Room[]>; export interface RoomListCustomisations<Room> {
waitForReady(): Promise<void>; isRoomVisible?(room: Room): boolean;
} }
// @alpha // @public
export interface RoomViewProps { export interface RoomListStoreApi {
enableReadReceiptsAndMarkersOnActivity?: boolean; getRooms(): Watchable<Room[]>;
hideComposer?: boolean; waitForReady(): Promise<void>;
hideHeader?: boolean; }
hidePinnedMessageBanner?: boolean;
hideRightPanel?: boolean; // @alpha
hideWidgets?: boolean; export interface RoomViewProps {
} enableReadReceiptsAndMarkersOnActivity?: boolean;
hideComposer?: boolean;
// @alpha @deprecated (undocumented) hideHeader?: boolean;
export type RuntimeModuleConstructor = new (api: ModuleApi) => RuntimeModule; hidePinnedMessageBanner?: boolean;
hideRightPanel?: boolean;
// @alpha hideWidgets?: boolean;
export interface SpacePanelItemProps { }
className?: string;
icon?: JSX.Element; // @alpha @deprecated (undocumented)
label: string; export type RuntimeModuleConstructor = new (api: ModuleApi) => RuntimeModule;
onSelected: () => void;
style?: React.CSSProperties; // @alpha
tooltip?: string; export interface SpacePanelItemProps {
} className?: string;
icon?: JSX.Element;
// @public label: string;
export interface StoresApi { onSelected: () => void;
roomListStore: RoomListStoreApi; style?: React.CSSProperties;
} tooltip?: string;
}
// @public
export type Translations = Record<string, { // @public
[ietfLanguageTag: string]: string; export interface StoresApi {
}>; roomListStore: RoomListStoreApi;
}
// @alpha @deprecated (undocumented)
export interface UserIdentifierCustomisations { // @public
getDisplayUserIdentifier(userId: string, opts: { export type Translations = Record<string, {
roomId?: string; [ietfLanguageTag: string]: string;
withDisplayName?: boolean; }>;
}): string | null;
} // @alpha
export const enum UIComponent {
// @public AddIntegrations = "UIComponent.addIntegrations",
export function useWatchable<T>(watchable: Watchable<T>): T; CreateRooms = "UIComponent.roomCreation",
CreateSpaces = "UIComponent.spaceCreation",
// @public ExploreRooms = "UIComponent.exploreRooms",
export type Variables = { FilterContainer = "UIComponent.filterContainer",
count?: number; InviteUsers = "UIComponent.sendInvites",
[key: string]: number | string | undefined; RoomOptionsMenu = "UIComponent.roomOptionsMenu"
}; }
// @public // @alpha @deprecated (undocumented)
export class Watchable<T> { export interface UserIdentifierCustomisations {
constructor(currentValue: T); getDisplayUserIdentifier(userId: string, opts: {
// Warning: (ae-forgotten-export) The symbol "WatchFn" needs to be exported by the entry point index.d.ts roomId?: string;
// withDisplayName?: boolean;
// (undocumented) }): string | null;
protected readonly listeners: Set<WatchFn<T>>; }
protected onFirstWatch(): void;
protected onLastWatch(): void; // @public
// (undocumented) export function useWatchable<T>(watchable: Watchable<T>): T;
unwatch(listener: (value: T) => void): void;
get value(): T; // @public
set value(value: T); export type Variables = {
// (undocumented) count?: number;
watch(listener: (value: T) => void): void; [key: string]: number | string | undefined;
} };
// @alpha // @public
export type WidgetDescriptor = { export class Watchable<T> {
id: string; constructor(currentValue: T);
templateUrl: string; // Warning: (ae-forgotten-export) The symbol "WatchFn" needs to be exported by the entry point index.d.ts
creatorUserId: string; //
type: string; // (undocumented)
origin: string; protected readonly listeners: Set<WatchFn<T>>;
roomId?: string; protected onFirstWatch(): void;
}; protected onLastWatch(): void;
// (undocumented)
// @alpha unwatch(listener: (value: T) => void): void;
export interface WidgetLifecycleApi { get value(): T;
registerCapabilitiesApprover(approver: CapabilitiesApprover): void; set value(value: T);
registerIdentityApprover(approver: IdentityApprover): void; // (undocumented)
registerPreloadApprover(approver: PreloadApprover): void; watch(listener: (value: T) => void): void;
} }
// @alpha @deprecated (undocumented) // @alpha
export interface WidgetPermissionsCustomisations<Widget, Capability> { export type WidgetDescriptor = {
preapproveCapabilities?(widget: Widget, requestedCapabilities: Set<Capability>): Promise<Set<Capability>>; id: string;
} templateUrl: string;
creatorUserId: string;
// @alpha @deprecated (undocumented) type: string;
export interface WidgetVariablesCustomisations { origin: string;
isReady?(): Promise<void>; roomId?: string;
provideVariables?(): { };
currentUserId: string;
userDisplayName?: string; // @alpha
userHttpAvatarUrl?: string; export interface WidgetLifecycleApi {
clientId?: string; registerCapabilitiesApprover(approver: CapabilitiesApprover): void;
clientTheme?: string; registerIdentityApprover(approver: IdentityApprover): void;
clientLanguage?: string; registerPreloadApprover(approver: PreloadApprover): void;
deviceId?: string; }
baseUrl?: string;
}; // @alpha @deprecated (undocumented)
} export interface WidgetPermissionsCustomisations<Widget, Capability> {
preapproveCapabilities?(widget: Widget, requestedCapabilities: Set<Capability>): Promise<Set<Capability>>;
// (No @packageDocumentation comment for this package) }
``` // @alpha @deprecated (undocumented)
export interface WidgetVariablesCustomisations {
isReady?(): Promise<void>;
provideVariables?(): {
currentUserId: string;
userDisplayName?: string;
userHttpAvatarUrl?: string;
clientId?: string;
clientTheme?: string;
clientLanguage?: string;
deviceId?: string;
baseUrl?: string;
};
}
// (No @packageDocumentation comment for this package)
```
@@ -0,0 +1,65 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
/**
* Enum of UI components which can have their behaviour tweaked
* @alpha
*/
export const enum UIComponent {
/**
* Components that lead to a user being invited.
*/
InviteUsers = "UIComponent.sendInvites",
/**
* Components that lead to a room being created that aren't already
* guarded by some other condition (ie: "only if you can edit this
* space" is *not* guarded by this component, but "start DM" is).
*/
CreateRooms = "UIComponent.roomCreation",
/**
* Components that lead to a Space being created that aren't already
* guarded by some other condition (ie: "only if you can add subspaces"
* is *not* guarded by this component, but "create new space" is).
*/
CreateSpaces = "UIComponent.spaceCreation",
/**
* Components that lead to the public room directory.
*/
ExploreRooms = "UIComponent.exploreRooms",
/**
* Components that lead to the user being able to easily add widgets
* and integrations to the room, such as from the room information card.
*/
AddIntegrations = "UIComponent.addIntegrations",
/**
* Component that lead to the user being able to search, dial, explore rooms
*/
FilterContainer = "UIComponent.filterContainer",
/**
* Components that lead the user to room options menu.
*/
RoomOptionsMenu = "UIComponent.roomOptionsMenu",
}
/**
* API for customising Element Web's components
* @alpha Subject to change.
*/
export interface CustomisationsApi {
/**
* Method to register a callback which can affect whether a given component is drawn or not.
* @param fn - the callback, if it returns true the component will be rendered, if false it will not be.
* If undefined will defer to next callback, ultimately falling through to `true` if none return false.
*/
registerShouldShowComponent(fn: (this: void, component: UIComponent) => boolean | void): void;
}
@@ -20,6 +20,7 @@ import { type BuiltinsApi } from "./builtins.ts";
import { type StoresApi } from "./stores.ts"; import { type StoresApi } from "./stores.ts";
import { type ClientApi } from "./client.ts"; import { type ClientApi } from "./client.ts";
import { type WidgetLifecycleApi } from "./widget-lifecycle.ts"; import { type WidgetLifecycleApi } from "./widget-lifecycle.ts";
import { type CustomisationsApi } from "./customisations.ts";
/** /**
* Module interface for modules to implement. * Module interface for modules to implement.
@@ -143,6 +144,12 @@ export interface Api
*/ */
readonly widgetLifecycle: WidgetLifecycleApi; readonly widgetLifecycle: WidgetLifecycleApi;
/**
* Allows modules to customise behaviour of app's components.
* @alpha Subject to change.
*/
readonly customisations: CustomisationsApi;
/** /**
* Create a ReactDOM root for rendering React components. * Create a ReactDOM root for rendering React components.
* Exposed to allow modules to avoid needing to bundle their own ReactDOM. * Exposed to allow modules to avoid needing to bundle their own ReactDOM.
@@ -23,5 +23,7 @@ export type * from "./api/builtins";
export type * from "./api/stores"; export type * from "./api/stores";
export type * from "./api/client"; export type * from "./api/client";
export type * from "./api/widget-lifecycle"; export type * from "./api/widget-lifecycle";
export type * from "./api/customisations";
export { UIComponent } from "./api/customisations";
export * from "./api/watchable"; export * from "./api/watchable";
export type * from "./utils"; export type * from "./utils";