2020-03-25 13:53:28 +00:00
|
|
|
/*
|
2024-09-06 15:44:31 +01:00
|
|
|
Copyright 2020-2024 New Vector Ltd.
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2020, 2021 The Matrix.org Foundation C.I.C.
|
2020-03-25 13:53:28 +00:00
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-06 15:44:31 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2020-03-25 13:53:28 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-08-23 10:04:25 +01:00
|
|
|
// eslint-disable-next-line no-restricted-imports
|
2020-10-09 16:59:56 +01:00
|
|
|
import "matrix-js-sdk/src/@types/global"; // load matrix-js-sdk's type extensions first
|
2021-07-09 11:49:05 +01:00
|
|
|
import "@types/modernizr";
|
2021-06-22 20:41:26 +01:00
|
|
|
|
2025-02-06 23:54:18 +00:00
|
|
|
import type { ModuleLoader } from "@element-hq/element-web-module-api";
|
2021-10-15 17:04:34 +02:00
|
|
|
import type { logger } from "matrix-js-sdk/src/logger";
|
2025-02-05 13:25:06 +00:00
|
|
|
import type ContentMessages from "../ContentMessages";
|
|
|
|
|
import { type IMatrixClientPeg } from "../MatrixClientPeg";
|
|
|
|
|
import type ToastStore from "../stores/ToastStore";
|
|
|
|
|
import type DeviceListener from "../DeviceListener";
|
|
|
|
|
import { type RoomListStore } from "../stores/room-list/Interface";
|
|
|
|
|
import { type PlatformPeg } from "../PlatformPeg";
|
|
|
|
|
import type RoomListLayoutStore from "../stores/room-list/RoomListLayoutStore";
|
|
|
|
|
import { type IntegrationManagers } from "../integrations/IntegrationManagers";
|
|
|
|
|
import { type ModalManager } from "../Modal";
|
|
|
|
|
import type SettingsStore from "../settings/SettingsStore";
|
|
|
|
|
import { type Notifier } from "../Notifier";
|
|
|
|
|
import type RightPanelStore from "../stores/right-panel/RightPanelStore";
|
|
|
|
|
import type WidgetStore from "../stores/WidgetStore";
|
|
|
|
|
import type LegacyCallHandler from "../LegacyCallHandler";
|
|
|
|
|
import type UserActivity from "../UserActivity";
|
|
|
|
|
import { type ModalWidgetStore } from "../stores/ModalWidgetStore";
|
|
|
|
|
import { type WidgetLayoutStore } from "../stores/widgets/WidgetLayoutStore";
|
|
|
|
|
import { type SpaceStoreClass } from "../stores/spaces/SpaceStore";
|
|
|
|
|
import type TypingStore from "../stores/TypingStore";
|
|
|
|
|
import { type EventIndexPeg } from "../indexing/EventIndexPeg";
|
|
|
|
|
import { type VoiceRecordingStore } from "../stores/VoiceRecordingStore";
|
|
|
|
|
import type PerformanceMonitor from "../performance";
|
|
|
|
|
import type UIStore from "../stores/UIStore";
|
|
|
|
|
import { type SetupEncryptionStore } from "../stores/SetupEncryptionStore";
|
|
|
|
|
import { type RoomScrollStateStore } from "../stores/RoomScrollStateStore";
|
|
|
|
|
import { type ConsoleLogger, type IndexedDBLogStore } from "../rageshake/rageshake";
|
|
|
|
|
import type ActiveWidgetStore from "../stores/ActiveWidgetStore";
|
|
|
|
|
import type AutoRageshakeStore from "../stores/AutoRageshakeStore";
|
|
|
|
|
import { type IConfigOptions } from "../IConfigOptions";
|
|
|
|
|
import { type MatrixDispatcher } from "../dispatcher/dispatcher";
|
|
|
|
|
import { type DeepReadonly } from "./common";
|
|
|
|
|
import type MatrixChat from "../components/structures/MatrixChat";
|
|
|
|
|
import { type InitialCryptoSetupStore } from "../stores/InitialCryptoSetupStore";
|
2025-02-06 23:54:18 +00:00
|
|
|
import { type ModuleApiType } from "../modules/Api.ts";
|
2025-03-10 18:03:06 +05:30
|
|
|
import type { RoomListStoreV3Class } from "../stores/room-list-v3/RoomListStoreV3.ts";
|
2020-04-19 12:06:56 +01:00
|
|
|
|
2021-07-19 22:43:11 +01:00
|
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
2020-04-05 00:05:59 +01:00
|
|
|
|
2021-01-13 15:39:18 +00:00
|
|
|
type ElectronChannel =
|
|
|
|
|
| "app_onAction"
|
|
|
|
|
| "before-quit"
|
|
|
|
|
| "check_updates"
|
|
|
|
|
| "install_update"
|
|
|
|
|
| "ipcCall"
|
|
|
|
|
| "ipcReply"
|
|
|
|
|
| "loudNotification"
|
|
|
|
|
| "preferences"
|
|
|
|
|
| "seshat"
|
|
|
|
|
| "seshatReply"
|
|
|
|
|
| "setBadgeCount"
|
|
|
|
|
| "update-downloaded"
|
|
|
|
|
| "userDownloadCompleted"
|
2023-07-14 22:05:23 +02:00
|
|
|
| "userDownloadAction"
|
2024-07-04 11:58:32 -06:00
|
|
|
| "openDesktopCapturerSourcePicker"
|
|
|
|
|
| "userAccessToken"
|
2024-10-15 12:38:16 +01:00
|
|
|
| "homeserverUrl"
|
2025-09-15 18:14:37 +01:00
|
|
|
| "serverSupportedVersions"
|
|
|
|
|
| "showToast";
|
2021-01-13 15:39:18 +00:00
|
|
|
|
2020-04-05 00:55:36 +01:00
|
|
|
declare global {
|
2025-08-27 14:13:00 +01:00
|
|
|
// use `number` as the return type in all cases for globalThis.set{Interval,Timeout},
|
|
|
|
|
// so we don't accidentally use the methods on NodeJS.Timeout - they only exist in a subset of environments.
|
|
|
|
|
// The overload for clear{Interval,Timeout} is resolved as expected.
|
|
|
|
|
// We use `ReturnType<typeof setTimeout>` in the code to be agnostic of if this definition gets loaded.
|
|
|
|
|
function setInterval(handler: TimerHandler, timeout: number, ...arguments: any[]): number;
|
|
|
|
|
function setTimeout(handler: TimerHandler, timeout: number, ...arguments: any[]): number;
|
|
|
|
|
|
2020-04-05 00:55:36 +01:00
|
|
|
interface Window {
|
2026-01-20 12:29:18 +00:00
|
|
|
mxSendRageshake: (text: string, withLogs?: boolean) => Promise<void>;
|
2021-10-15 17:04:34 +02:00
|
|
|
matrixLogger: typeof logger;
|
2024-11-13 14:16:29 +00:00
|
|
|
matrixChat?: MatrixChat;
|
2024-10-15 14:57:26 +01:00
|
|
|
mxSendSentryReport: (userText: string, issueUrl: string, error: Error) => Promise<void>;
|
|
|
|
|
mxLoginWithAccessToken: (hsUrl: string, accessToken: string) => Promise<void>;
|
|
|
|
|
mxAutoRageshakeStore?: AutoRageshakeStore;
|
|
|
|
|
mxDispatcher: MatrixDispatcher;
|
2020-05-25 16:06:05 -06:00
|
|
|
mxMatrixClientPeg: IMatrixClientPeg;
|
2023-04-26 10:36:00 +01:00
|
|
|
mxReactSdkConfig: DeepReadonly<IConfigOptions>;
|
2020-05-22 12:47:40 +01:00
|
|
|
|
2021-12-13 11:22:53 +00:00
|
|
|
// https://docs.microsoft.com/en-us/previous-versions/hh772328(v=vs.85)
|
|
|
|
|
// we only ever check for its existence, so we can ignore its actual type
|
|
|
|
|
MSStream?: unknown;
|
|
|
|
|
|
2020-07-20 20:43:49 +01:00
|
|
|
mxContentMessages: ContentMessages;
|
|
|
|
|
mxToastStore: ToastStore;
|
|
|
|
|
mxDeviceListener: DeviceListener;
|
2022-08-09 20:46:59 +01:00
|
|
|
mxRoomListStore: RoomListStore;
|
2025-10-28 20:18:07 +05:30
|
|
|
getRoomListStoreV3: () => RoomListStoreV3Class;
|
2020-07-20 20:43:49 +01:00
|
|
|
mxRoomListLayoutStore: RoomListLayoutStore;
|
|
|
|
|
mxPlatformPeg: PlatformPeg;
|
|
|
|
|
mxIntegrationManagers: typeof IntegrationManagers;
|
2020-07-12 21:13:28 +01:00
|
|
|
singletonModalManager: ModalManager;
|
2020-07-29 10:57:14 -06:00
|
|
|
mxSettingsStore: SettingsStore;
|
2020-08-05 11:07:10 +01:00
|
|
|
mxNotifier: typeof Notifier;
|
2020-08-28 10:46:29 +01:00
|
|
|
mxRightPanelStore: RightPanelStore;
|
2020-09-07 16:19:42 +01:00
|
|
|
mxWidgetStore: WidgetStore;
|
2021-01-18 17:41:42 -07:00
|
|
|
mxWidgetLayoutStore: WidgetLayoutStore;
|
2022-08-30 15:13:39 -04:00
|
|
|
mxLegacyCallHandler: LegacyCallHandler;
|
2020-10-13 17:40:34 +01:00
|
|
|
mxUserActivity: UserActivity;
|
2020-09-25 15:03:54 +01:00
|
|
|
mxModalWidgetStore: ModalWidgetStore;
|
2021-02-25 15:18:54 +00:00
|
|
|
mxSpaceStore: SpaceStoreClass;
|
2021-04-27 23:04:49 -06:00
|
|
|
mxVoiceRecordingStore: VoiceRecordingStore;
|
2021-04-06 12:26:50 +01:00
|
|
|
mxTypingStore: TypingStore;
|
|
|
|
|
mxEventIndexPeg: EventIndexPeg;
|
2021-05-19 10:07:02 +01:00
|
|
|
mxPerformanceMonitor: PerformanceMonitor;
|
|
|
|
|
mxPerformanceEntryNames: any;
|
2021-05-27 12:36:16 +01:00
|
|
|
mxUIStore: UIStore;
|
2021-06-14 20:58:20 +01:00
|
|
|
mxSetupEncryptionStore?: SetupEncryptionStore;
|
2024-12-11 13:10:27 +00:00
|
|
|
mxInitialCryptoStore?: InitialCryptoSetupStore;
|
2021-07-03 12:17:38 +01:00
|
|
|
mxRoomScrollStateStore?: RoomScrollStateStore;
|
2021-09-26 19:57:02 +02:00
|
|
|
mxActiveWidgetStore?: ActiveWidgetStore;
|
2021-07-19 15:41:44 +02:00
|
|
|
mxOnRecaptchaLoaded?: () => void;
|
2025-02-06 23:54:18 +00:00
|
|
|
mxModuleLoader: ModuleLoader;
|
|
|
|
|
mxModuleApi: ModuleApiType;
|
2020-04-08 16:31:58 +01:00
|
|
|
|
|
|
|
|
// electron-only
|
2021-02-08 15:12:30 +00:00
|
|
|
electron?: Electron;
|
2020-05-13 05:19:08 +01:00
|
|
|
// opera-only
|
2021-02-08 15:12:30 +00:00
|
|
|
opera?: any;
|
2020-05-13 05:19:08 +01:00
|
|
|
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/InstallTrigger
|
|
|
|
|
InstallTrigger: any;
|
2020-04-05 00:55:36 +01:00
|
|
|
}
|
2020-06-02 16:58:05 +01:00
|
|
|
|
2021-02-08 15:12:30 +00:00
|
|
|
interface Electron {
|
2025-06-10 08:41:23 +01:00
|
|
|
// Legacy
|
2021-02-08 15:12:30 +00:00
|
|
|
on(channel: ElectronChannel, listener: (event: Event, ...args: any[]) => void): void;
|
|
|
|
|
send(channel: ElectronChannel, ...args: any[]): void;
|
2025-06-10 08:41:23 +01:00
|
|
|
// Initialisation
|
2025-05-22 11:24:53 +01:00
|
|
|
initialise(): Promise<{
|
|
|
|
|
protocol: string;
|
|
|
|
|
sessionId: string;
|
2025-07-17 13:59:17 +01:00
|
|
|
supportsBadgeOverlay: boolean;
|
2025-05-22 11:24:53 +01:00
|
|
|
config: IConfigOptions;
|
2025-06-10 08:41:23 +01:00
|
|
|
supportedSettings: Record<string, boolean>;
|
2025-05-22 11:24:53 +01:00
|
|
|
}>;
|
2025-06-10 08:41:23 +01:00
|
|
|
// Settings
|
|
|
|
|
setSettingValue(settingName: string, value: any): Promise<void>;
|
|
|
|
|
getSettingValue(settingName: string): Promise<any>;
|
2021-02-08 15:12:30 +00:00
|
|
|
}
|
2022-02-11 13:03:51 +00:00
|
|
|
|
2021-09-02 14:10:28 +02:00
|
|
|
interface DesktopCapturerSource {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
thumbnailURL: string;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 18:17:52 +02:00
|
|
|
interface GetSourcesOptions {
|
|
|
|
|
types: Array<string>;
|
|
|
|
|
thumbnailSize?: {
|
|
|
|
|
height: number;
|
|
|
|
|
width: number;
|
|
|
|
|
};
|
|
|
|
|
fetchWindowIcons?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 12:06:56 +01:00
|
|
|
interface StorageEstimate {
|
2021-07-19 15:41:44 +02:00
|
|
|
usageDetails?: { [key: string]: number };
|
2020-04-19 12:06:56 +01:00
|
|
|
}
|
2020-04-22 13:08:33 +01:00
|
|
|
|
2021-04-19 21:54:08 -06:00
|
|
|
// https://github.com/microsoft/TypeScript/issues/28308#issuecomment-650802278
|
|
|
|
|
interface AudioWorkletProcessor {
|
|
|
|
|
readonly port: MessagePort;
|
|
|
|
|
process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://github.com/microsoft/TypeScript/issues/28308#issuecomment-650802278
|
|
|
|
|
const AudioWorkletProcessor: {
|
|
|
|
|
prototype: AudioWorkletProcessor;
|
|
|
|
|
new (options?: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-13 11:22:53 +00:00
|
|
|
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1029#issuecomment-881509595
|
|
|
|
|
interface AudioParamDescriptor {
|
|
|
|
|
readonly port: MessagePort;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 15:46:45 +02:00
|
|
|
/**
|
|
|
|
|
* In future, browsers will support focusVisible option.
|
|
|
|
|
* See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#focusvisible
|
|
|
|
|
*/
|
|
|
|
|
interface FocusOptions {
|
|
|
|
|
focusVisible: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 21:54:08 -06:00
|
|
|
// https://github.com/microsoft/TypeScript/issues/28308#issuecomment-650802278
|
|
|
|
|
function registerProcessor(
|
|
|
|
|
name: string,
|
|
|
|
|
processorCtor: (new (options?: AudioWorkletNodeOptions) => AudioWorkletProcessor) & {
|
|
|
|
|
parameterDescriptors?: AudioParamDescriptor[];
|
|
|
|
|
},
|
2023-02-13 11:39:16 +00:00
|
|
|
): void;
|
2021-07-19 15:41:44 +02:00
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-var
|
|
|
|
|
var grecaptcha:
|
|
|
|
|
| undefined
|
|
|
|
|
| {
|
|
|
|
|
reset: (id: string) => void;
|
|
|
|
|
render: (
|
|
|
|
|
divId: string,
|
|
|
|
|
options: {
|
|
|
|
|
sitekey: string;
|
2021-07-19 16:27:39 +02:00
|
|
|
callback: (response: string) => void;
|
2021-07-19 16:34:07 +02:00
|
|
|
},
|
2021-07-19 15:41:44 +02:00
|
|
|
) => string;
|
|
|
|
|
isReady: () => boolean;
|
|
|
|
|
};
|
2021-09-26 16:04:28 +02:00
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-var, camelcase
|
|
|
|
|
var mx_rage_logger: ConsoleLogger;
|
|
|
|
|
// eslint-disable-next-line no-var, camelcase
|
|
|
|
|
var mx_rage_initPromise: Promise<void>;
|
|
|
|
|
// eslint-disable-next-line no-var, camelcase
|
|
|
|
|
var mx_rage_initStoragePromise: Promise<void>;
|
|
|
|
|
// eslint-disable-next-line no-var, camelcase
|
|
|
|
|
var mx_rage_store: IndexedDBLogStore;
|
2020-03-25 13:53:28 +00:00
|
|
|
}
|
2020-05-20 19:56:54 +01:00
|
|
|
|
2021-07-19 22:43:11 +01:00
|
|
|
/* eslint-enable @typescript-eslint/naming-convention */
|