mirror of
https://github.com/vector-im/element-web.git
synced 2026-04-21 05:21:22 +02:00
Merge pull request #34 from element-hq/hs/modules-matrix-event
Replace matrix-js-sdk's MatrixEvent with our own representation
This commit is contained in:
commit
433e88670e
@ -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';
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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",
|
||||
@ -51,7 +50,6 @@
|
||||
"@matrix-org/react-sdk-module-api": "*",
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"matrix-js-sdk": "*",
|
||||
"matrix-web-i18n": "*",
|
||||
"react": "^19"
|
||||
},
|
||||
|
||||
@ -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.
|
||||
@ -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 = (
|
||||
/**
|
||||
@ -63,7 +63,7 @@ export type CustomMessageRenderFunction = (
|
||||
|
||||
/**
|
||||
* API for inserting custom components into Element.
|
||||
* @public
|
||||
* @alpha Subject to change.
|
||||
*/
|
||||
export interface CustomComponentsApi {
|
||||
/**
|
||||
|
||||
@ -90,7 +90,7 @@ export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiEx
|
||||
|
||||
/**
|
||||
* The custom message component API.
|
||||
* @public
|
||||
* @alpha
|
||||
*/
|
||||
readonly customComponents: CustomComponentsApi;
|
||||
/**
|
||||
|
||||
@ -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
packages/element-web-module-api/src/models/event.ts
Normal file
48
packages/element-web-module-api/src/models/event.ts
Normal file
@ -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…
x
Reference in New Issue
Block a user