matrix-react-sdk
Version:
SDK for matrix.org using React
73 lines (72 loc) • 3.42 kB
TypeScript
import { Room, MatrixClient } from "matrix-js-sdk/src/matrix";
import { PermalinkParts } from "./PermalinkConstructor";
export declare class RoomPermalinkCreator {
private room;
private roomId;
private highestPlUserId;
private populationMap;
private bannedHostsRegexps;
private allowedHostsRegexps;
private _serverCandidates?;
private started;
constructor(room: Room | null, roomId?: string | null, shouldThrottle?: boolean);
load(): void;
start(): void;
stop(): void;
get serverCandidates(): string[] | undefined;
forEvent(eventId: string): string;
forShareableRoom(): string;
forRoom(): string;
private onRoomStateUpdate;
private fullUpdate;
private updateHighestPlUser;
private updateAllowedServers;
private updatePopulationMap;
private updateServerCandidates;
}
/**
* Creates a permalink for an Entity. If isPill is set it uses a spec-compliant
* prefix for the permalink, instead of permalink_prefix
* @param {string} entityId The entity to link to.
* @param {boolean} isPill Link should be pillifyable.
* @returns {string|null} The transformed permalink or null if unable.
*/
export declare function makeGenericPermalink(entityId: string, isPill?: boolean): string;
/**
* Creates a permalink for a User. If isPill is set it uses a spec-compliant
* prefix for the permalink, instead of permalink_prefix
* @param {string} userId The user to link to.
* @param {boolean} isPill Link should be pillifyable.
* @returns {string|null} The transformed permalink or null if unable.
*/
export declare function makeUserPermalink(userId: string, isPill?: boolean): string;
/**
* Creates a permalink for a room. If isPill is set it uses a spec-compliant
* prefix for the permalink, instead of permalink_prefix
* @param {MatrixClient} matrixClient The MatrixClient to use
* @param {string} roomId The user to link to.
* @param {boolean} isPill Link should be pillifyable.
* @returns {string|null} The transformed permalink or null if unable.
*/
export declare function makeRoomPermalink(matrixClient: MatrixClient, roomId: string, isPill?: boolean): string;
export declare function isPermalinkHost(host: string): boolean;
/**
* Transforms an entity (permalink, room alias, user ID, etc) into a local URL
* if possible. If it is already a permalink (matrix.to) it gets returned
* unchanged.
* @param {string} entity The entity to transform.
* @returns {string|null} The transformed permalink or null if unable.
*/
export declare function tryTransformEntityToPermalink(matrixClient: MatrixClient, entity: string): string | null;
/**
* Transforms a permalink (or possible permalink) into a local URL if possible. If
* the given permalink is found to not be a permalink, it'll be returned unaltered.
* @param {string} permalink The permalink to try and transform.
* @returns {string} The transformed permalink or original URL if unable.
*/
export declare function tryTransformPermalinkToLocalHref(permalink: string): string;
export declare function getPrimaryPermalinkEntity(permalink: string): string | null;
export declare function parsePermalink(fullUrl: string): PermalinkParts | null;
export declare function getServerName(userId: string): string;
export declare function getHostnameFromMatrixServerName(serverName: string): string | null;
export declare const calculateRoomVia: (room: Room) => string[];