Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/element-web-module-api/element-web-module-api.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
```ts

import { JSX } from 'react';
import { MatrixEvent } from 'matrix-js-sdk/lib/matrix';
import { ModuleApi } from '@matrix-org/react-sdk-module-api';
import { Root } from 'react-dom/client';
import { RuntimeModule } from '@matrix-org/react-sdk-module-api';
Expand All @@ -23,6 +22,7 @@ export interface AliasCustomisations {
export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiExtension {
readonly config: ConfigApi;
createRoot(element: Element): Root;
// @alpha
readonly customComponents: CustomComponentsApi;
readonly i18n: I18nApi;
readonly rootNode: HTMLElement;
Expand Down Expand Up @@ -60,10 +60,8 @@ export interface ConfigApi {
get<K extends keyof Config = never>(key?: K): Config | Config[K];
}

// @public
// @alpha
export interface CustomComponentsApi {
// Warning: (ae-incompatible-release-tags) The symbol "registerMessageRenderer" is marked as @public, but its signature references "CustomMessageRenderFunction" which is marked as @alpha
// Warning: (ae-incompatible-release-tags) The symbol "registerMessageRenderer" is marked as @public, but its signature references "CustomMessageRenderHints" which is marked as @alpha
registerMessageRenderer(eventTypeOrFilter: string | ((mxEvent: MatrixEvent) => boolean), renderer: CustomMessageRenderFunction, hints?: CustomMessageRenderHints): void;
}

Expand Down Expand Up @@ -134,6 +132,18 @@ export interface LifecycleCustomisations {
onLoggedOutAndStorageCleared?(): void;
}

// @alpha
export interface MatrixEvent {
content: Record<string, unknown>;
eventId: string;
originServerTs: number;
roomId: string;
sender: string;
stateKey?: string;
type: string;
unsigned: Record<string, unknown>;
}

// @alpha @deprecated (undocumented)
export interface Media {
// (undocumented)
Expand Down
2 changes: 0 additions & 2 deletions packages/element-web-module-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@types/react-dom": "^19.0.4",
"@types/semver": "^7.5.8",
"@vitest/coverage-v8": "^3.0.4",
"matrix-js-sdk": "^37.5.0",
"matrix-web-i18n": "^3.3.0",
"semver": "^7.6.3",
"typescript": "^5.7.3",
Expand All @@ -51,7 +50,6 @@
"@matrix-org/react-sdk-module-api": "*",
"@types/react": "*",
"@types/react-dom": "*",
"matrix-js-sdk": "*",
"matrix-web-i18n": "*",
"react": "^19"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Please see LICENSE files in the repository root for full details.
*/

import type { JSX } from "react";
import type { MatrixEvent } from "matrix-js-sdk/lib/matrix";
import type { MatrixEvent } from "../models/event";

/**
* Properties for all message components.
Expand Down Expand Up @@ -48,7 +48,7 @@ export type CustomMessageRenderHints = {

/**
* Function used to render a message component.
* @alpha Unlikely to change
* @alpha Subject to change.
*/
export type CustomMessageRenderFunction = (
/**
Expand All @@ -63,7 +63,7 @@ export type CustomMessageRenderFunction = (

/**
* API for inserting custom components into Element.
* @public
* @alpha Subject to change.
*/
export interface CustomComponentsApi {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/element-web-module-api/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiEx

/**
* The custom message component API.
* @public
* @alpha
*/
readonly customComponents: CustomComponentsApi;
/**
Expand Down
1 change: 1 addition & 0 deletions packages/element-web-module-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { ModuleLoader, ModuleIncompatibleError } from "./loader";
export type { Api, Module, ModuleFactory } from "./api";
export type { Config, ConfigApi } from "./api/config";
export type { I18nApi, Variables, Translations } from "./api/i18n";
export type * from "./models/event";
export type * from "./api/custom-components";
export type * from "./api/legacy-modules";
export type * from "./api/legacy-customisations";
48 changes: 48 additions & 0 deletions packages/element-web-module-api/src/models/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
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.
*/

/**
* Representation of a Matrix event, as specified by the client server specification.
* @alpha Subject to change.
* @see https://spec.matrix.org/v1.14/client-server-api/#room-event-format
*/
export interface MatrixEvent {
/**
* The event ID of this event.
*/
eventId: string;
/**
* The room ID which contains this event.
*/
roomId: string;
/**
* The Matrix ID of the user who sent this event.
*/
sender: string;
/**
* The content of the event.
* If the event was encrypted, this is the decrypted content.
*/
content: Record<string, unknown>;
/**
* Contains optional extra information about the event.
*/
unsigned: Record<string, unknown>;
/**
* The type of the event.
*/
type: string;
/**
* The state key of the event.
* If this key is set, including `""` then the event is a state event.
*/
stateKey?: string;
/**
* Timestamp (in milliseconds since the unix epoch) on originating homeserver when this event was sent.
*/
originServerTs: number;
}
Loading