2020-04-19 12:06:56 +01:00
|
|
|
/*
|
2021-04-06 12:26:50 +01:00
|
|
|
Copyright 2020-2021 The Matrix.org Foundation C.I.C.
|
2020-04-19 12:06:56 +01:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-10-09 16:59:56 +01:00
|
|
|
import "matrix-js-sdk/src/@types/global"; // load matrix-js-sdk's type extensions first
|
2020-04-19 12:06:56 +01:00
|
|
|
import * as ModernizrStatic from "modernizr";
|
2020-05-24 15:47:52 +01:00
|
|
|
import ContentMessages from "../ContentMessages";
|
2020-05-25 16:06:05 -06:00
|
|
|
import { IMatrixClientPeg } from "../MatrixClientPeg";
|
2020-05-22 12:47:40 +01:00
|
|
|
import ToastStore from "../stores/ToastStore";
|
2020-05-22 12:54:03 +01:00
|
|
|
import DeviceListener from "../DeviceListener";
|
2020-07-17 15:11:34 -06:00
|
|
|
import { RoomListStoreClass } from "../stores/room-list/RoomListStore";
|
2020-07-02 22:42:28 +01:00
|
|
|
import { PlatformPeg } from "../PlatformPeg";
|
2020-07-08 18:27:50 -06:00
|
|
|
import RoomListLayoutStore from "../stores/room-list/RoomListLayoutStore";
|
2020-07-17 13:38:08 +01:00
|
|
|
import {IntegrationManagers} from "../integrations/IntegrationManagers";
|
2020-07-12 21:13:28 +01:00
|
|
|
import {ModalManager} from "../Modal";
|
2020-07-29 10:57:14 -06:00
|
|
|
import SettingsStore from "../settings/SettingsStore";
|
2020-07-21 10:14:12 +01:00
|
|
|
import {ActiveRoomObserver} from "../ActiveRoomObserver";
|
2020-08-05 11:07:10 +01:00
|
|
|
import {Notifier} from "../Notifier";
|
2020-08-19 16:13:29 +01:00
|
|
|
import type {Renderer} from "react-dom";
|
2020-08-28 10:46:29 +01:00
|
|
|
import RightPanelStore from "../stores/RightPanelStore";
|
2020-09-08 10:19:51 +01:00
|
|
|
import WidgetStore from "../stores/WidgetStore";
|
2020-09-24 16:16:20 +01:00
|
|
|
import CallHandler from "../CallHandler";
|
2020-10-13 17:40:34 +01:00
|
|
|
import {Analytics} from "../Analytics";
|
2020-10-30 10:43:52 +00:00
|
|
|
import CountlyAnalytics from "../CountlyAnalytics";
|
2020-10-13 17:40:34 +01:00
|
|
|
import UserActivity from "../UserActivity";
|
2020-09-25 15:03:54 +01:00
|
|
|
import {ModalWidgetStore} from "../stores/ModalWidgetStore";
|
2021-01-18 17:41:42 -07:00
|
|
|
import { WidgetLayoutStore } from "../stores/widgets/WidgetLayoutStore";
|
2021-02-12 20:55:54 +00:00
|
|
|
import VoipUserMapper from "../VoipUserMapper";
|
2021-02-25 15:18:54 +00:00
|
|
|
import {SpaceStoreClass} from "../stores/SpaceStore";
|
2021-04-06 12:26:50 +01:00
|
|
|
import TypingStore from "../stores/TypingStore";
|
|
|
|
|
import { EventIndexPeg } from "../indexing/EventIndexPeg";
|
2021-04-27 23:04:49 -06:00
|
|
|
import {VoiceRecordingStore} from "../stores/VoiceRecordingStore";
|
2020-04-19 12:06:56 +01:00
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface Window {
|
|
|
|
|
Modernizr: ModernizrStatic;
|
2020-08-19 16:13:29 +01:00
|
|
|
matrixChat: ReturnType<Renderer>;
|
2020-05-25 16:06:05 -06:00
|
|
|
mxMatrixClientPeg: IMatrixClientPeg;
|
2020-04-19 12:06:56 +01:00
|
|
|
Olm: {
|
|
|
|
|
init: () => Promise<void>;
|
|
|
|
|
};
|
2020-05-22 12:47:40 +01:00
|
|
|
|
2020-07-20 20:43:49 +01:00
|
|
|
mxContentMessages: ContentMessages;
|
|
|
|
|
mxToastStore: ToastStore;
|
|
|
|
|
mxDeviceListener: DeviceListener;
|
|
|
|
|
mxRoomListStore: RoomListStoreClass;
|
|
|
|
|
mxRoomListLayoutStore: RoomListLayoutStore;
|
2020-07-21 17:56:50 +01:00
|
|
|
mxActiveRoomObserver: ActiveRoomObserver;
|
2020-07-20 20:43:49 +01:00
|
|
|
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;
|
2020-09-24 16:16:20 +01:00
|
|
|
mxCallHandler: CallHandler;
|
2020-10-13 17:40:34 +01:00
|
|
|
mxAnalytics: Analytics;
|
2020-10-29 15:53:14 +00:00
|
|
|
mxCountlyAnalytics: typeof CountlyAnalytics;
|
2020-10-13 17:40:34 +01:00
|
|
|
mxUserActivity: UserActivity;
|
2020-09-25 15:03:54 +01:00
|
|
|
mxModalWidgetStore: ModalWidgetStore;
|
2021-02-12 20:55:54 +00:00
|
|
|
mxVoipUserMapper: VoipUserMapper;
|
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;
|
2020-04-19 12:06:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Document {
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/Document/hasStorageAccess
|
|
|
|
|
hasStorageAccess?: () => Promise<boolean>;
|
2021-04-06 12:26:50 +01:00
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/Document/requestStorageAccess
|
|
|
|
|
requestStorageAccess?: () => Promise<undefined>;
|
2020-10-29 17:56:24 +00:00
|
|
|
|
|
|
|
|
// Safari & IE11 only have this prefixed: we used prefixed versions
|
|
|
|
|
// previously so let's continue to support them for now
|
|
|
|
|
webkitExitFullscreen(): Promise<void>;
|
|
|
|
|
msExitFullscreen(): Promise<void>;
|
|
|
|
|
readonly webkitFullscreenElement: Element | null;
|
|
|
|
|
readonly msFullscreenElement: Element | null;
|
2020-04-19 12:06:56 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-02 23:15:08 +01:00
|
|
|
interface Navigator {
|
|
|
|
|
userLanguage?: string;
|
2020-09-24 16:38:13 +01:00
|
|
|
// https://github.com/Microsoft/TypeScript/issues/19473
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/MediaSession
|
2020-09-24 16:16:20 +01:00
|
|
|
mediaSession: any;
|
2020-07-02 23:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-19 12:06:56 +01:00
|
|
|
interface StorageEstimate {
|
|
|
|
|
usageDetails?: {[key: string]: number};
|
|
|
|
|
}
|
2020-04-22 13:08:33 +01:00
|
|
|
|
|
|
|
|
export interface ISettledFulfilled<T> {
|
|
|
|
|
status: "fulfilled";
|
|
|
|
|
value: T;
|
|
|
|
|
}
|
|
|
|
|
export interface ISettledRejected {
|
|
|
|
|
status: "rejected";
|
|
|
|
|
reason: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface PromiseConstructor {
|
|
|
|
|
allSettled<T>(promises: Promise<T>[]): Promise<Array<ISettledFulfilled<T> | ISettledRejected>>;
|
|
|
|
|
}
|
2020-08-05 11:07:10 +01:00
|
|
|
|
|
|
|
|
interface HTMLAudioElement {
|
|
|
|
|
type?: string;
|
2021-03-09 08:08:59 +01:00
|
|
|
// sinkId & setSinkId are experimental and typescript doesn't know about them
|
|
|
|
|
sinkId: string;
|
|
|
|
|
setSinkId(outputId: string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface HTMLVideoElement {
|
|
|
|
|
type?: string;
|
|
|
|
|
// sinkId & setSinkId are experimental and typescript doesn't know about them
|
|
|
|
|
sinkId: string;
|
|
|
|
|
setSinkId(outputId: string);
|
2020-08-05 11:07:10 +01:00
|
|
|
}
|
2020-10-29 17:56:24 +00:00
|
|
|
|
|
|
|
|
interface Element {
|
|
|
|
|
// Safari & IE11 only have this prefixed: we used prefixed versions
|
|
|
|
|
// previously so let's continue to support them for now
|
|
|
|
|
webkitRequestFullScreen(options?: FullscreenOptions): Promise<void>;
|
|
|
|
|
msRequestFullscreen(options?: FullscreenOptions): Promise<void>;
|
|
|
|
|
}
|
2020-10-30 16:49:42 +00:00
|
|
|
|
2020-10-29 15:53:14 +00:00
|
|
|
interface Error {
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName
|
|
|
|
|
fileName?: string;
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber
|
|
|
|
|
lineNumber?: number;
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber
|
|
|
|
|
columnNumber?: number;
|
|
|
|
|
}
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// https://github.com/microsoft/TypeScript/issues/28308#issuecomment-650802278
|
|
|
|
|
function registerProcessor(
|
|
|
|
|
name: string,
|
|
|
|
|
processorCtor: (new (
|
|
|
|
|
options?: AudioWorkletNodeOptions
|
|
|
|
|
) => AudioWorkletProcessor) & {
|
|
|
|
|
parameterDescriptors?: AudioParamDescriptor[];
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-04-19 12:06:56 +01:00
|
|
|
}
|