Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d9ef673

Browse files
author
Alun Turner
committed
Merge remote-tracking branch 'origin/develop' into alunturner/hide-indent-button-in-rte
2 parents 5fa367b + fa036a5 commit d9ef673

File tree

363 files changed

+1654
-1375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+1654
-1375
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@
154154
"@types/flux": "^3.1.9",
155155
"@types/fs-extra": "^11.0.0",
156156
"@types/geojson": "^7946.0.8",
157+
"@types/glob-to-regexp": "^0.4.1",
157158
"@types/jest": "^29.2.1",
158159
"@types/katex": "^0.14.0",
159160
"@types/lodash": "^4.14.168",
160161
"@types/modernizr": "^3.5.3",
161162
"@types/node": "^16",
163+
"@types/node-fetch": "^2.6.2",
162164
"@types/pako": "^2.0.0",
163165
"@types/parse5": "^6.0.0",
164166
"@types/qrcode": "^1.3.5",
@@ -168,6 +170,7 @@
168170
"@types/react-test-renderer": "^17.0.1",
169171
"@types/react-transition-group": "^4.4.0",
170172
"@types/sanitize-html": "^2.3.1",
173+
"@types/tar-js": "^0.3.2",
171174
"@types/ua-parser-js": "^0.7.36",
172175
"@types/zxcvbn": "^4.4.0",
173176
"@typescript-eslint/eslint-plugin": "^5.35.1",

src/@types/global.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ declare global {
218218
processorCtor: (new (options?: AudioWorkletNodeOptions) => AudioWorkletProcessor) & {
219219
parameterDescriptors?: AudioParamDescriptor[];
220220
},
221-
);
221+
): void;
222222

223223
// eslint-disable-next-line no-var
224224
var grecaptcha:

src/@types/opus-recorder.d.ts

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Copyright 2023 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
declare module "opus-recorder/dist/recorder.min.js" {
18+
export default class Recorder {
19+
public static isRecordingSupported(): boolean;
20+
21+
public constructor(config: {
22+
bufferLength?: number;
23+
encoderApplication?: number;
24+
encoderFrameSize?: number;
25+
encoderPath?: string;
26+
encoderSampleRate?: number;
27+
encoderBitRate?: number;
28+
maxFramesPerPage?: number;
29+
mediaTrackConstraints?: boolean;
30+
monitorGain?: number;
31+
numberOfChannels?: number;
32+
recordingGain?: number;
33+
resampleQuality?: number;
34+
streamPages?: boolean;
35+
wavBitDepth?: number;
36+
sourceNode?: MediaStreamAudioSourceNode;
37+
encoderComplexity?: number;
38+
});
39+
40+
public ondataavailable?(data: ArrayBuffer): void;
41+
42+
public readonly encodedSamplePosition: number;
43+
44+
public start(): Promise<void>;
45+
46+
public stop(): Promise<void>;
47+
48+
public close(): void;
49+
}
50+
}
51+
52+
declare module "opus-recorder/dist/encoderWorker.min.js" {
53+
const path: string;
54+
export default path;
55+
}
56+
57+
declare module "opus-recorder/dist/waveWorker.min.js" {
58+
const path: string;
59+
export default path;
60+
}
61+
62+
declare module "opus-recorder/dist/decoderWorker.min.js" {
63+
const path: string;
64+
export default path;
65+
}

src/AddThreepid.ts

+20-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
1818

19-
import { IRequestMsisdnTokenResponse, IRequestTokenResponse } from "matrix-js-sdk/src/matrix";
19+
import { IAuthData, IRequestMsisdnTokenResponse, IRequestTokenResponse } from "matrix-js-sdk/src/matrix";
2020

2121
import { MatrixClientPeg } from "./MatrixClientPeg";
2222
import Modal from "./Modal";
@@ -29,6 +29,12 @@ function getIdServerDomain(): string {
2929
return MatrixClientPeg.get().idBaseUrl.split("://")[1];
3030
}
3131

32+
export type Binding = {
33+
bind: boolean;
34+
label: string;
35+
errorTitle: string;
36+
};
37+
3238
/**
3339
* Allows a user to add a third party identifier to their homeserver and,
3440
* optionally, the identity servers.
@@ -178,7 +184,7 @@ export default class AddThreepid {
178184
* with a "message" property which contains a human-readable message detailing why
179185
* the request failed.
180186
*/
181-
public async checkEmailLinkClicked(): Promise<any[]> {
187+
public async checkEmailLinkClicked(): Promise<[boolean, IAuthData | Error | null]> {
182188
try {
183189
if (await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind()) {
184190
if (this.bind) {
@@ -220,16 +226,19 @@ export default class AddThreepid {
220226
continueKind: "primary",
221227
},
222228
};
223-
const { finished } = Modal.createDialog(InteractiveAuthDialog, {
224-
title: _t("Add Email Address"),
225-
matrixClient: MatrixClientPeg.get(),
226-
authData: e.data,
227-
makeRequest: this.makeAddThreepidOnlyRequest,
228-
aestheticsForStagePhases: {
229-
[SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
230-
[SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
229+
const { finished } = Modal.createDialog<[boolean, IAuthData | Error | null]>(
230+
InteractiveAuthDialog,
231+
{
232+
title: _t("Add Email Address"),
233+
matrixClient: MatrixClientPeg.get(),
234+
authData: e.data,
235+
makeRequest: this.makeAddThreepidOnlyRequest,
236+
aestheticsForStagePhases: {
237+
[SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
238+
[SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
239+
},
231240
},
232-
});
241+
);
233242
return finished;
234243
}
235244
}

src/AsyncWrapper.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ interface IState {
4242
export default class AsyncWrapper extends React.Component<IProps, IState> {
4343
private unmounted = false;
4444

45-
public state = {
46-
component: null,
47-
error: null,
48-
};
45+
public state: IState = {};
4946

5047
public componentDidMount(): void {
5148
// XXX: temporary logging to try to diagnose

src/BasePlatform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export default abstract class BasePlatform {
197197
room: Room,
198198
ev?: MatrixEvent,
199199
): Notification {
200-
const notifBody = {
200+
const notifBody: NotificationOptions = {
201201
body: msg,
202202
silent: true, // we play our own sounds
203203
};

src/HtmlUtils.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ const transformTags: IExtendedSanitizeOptions["transformTags"] = {
228228

229229
// Sanitise and transform data-mx-color and data-mx-bg-color to their CSS
230230
// equivalents
231-
const customCSSMapper = {
231+
const customCSSMapper: Record<string, string> = {
232232
"data-mx-color": "color",
233233
"data-mx-bg-color": "background-color",
234234
// $customAttributeKey: $cssAttributeKey

src/IConfigOptions.ts

+8
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,18 @@ export interface IConfigOptions {
169169
inline?: {
170170
left?: string;
171171
right?: string;
172+
pattern?: {
173+
tex?: string;
174+
latex?: string;
175+
};
172176
};
173177
display?: {
174178
left?: string;
175179
right?: string;
180+
pattern?: {
181+
tex?: string;
182+
latex?: string;
183+
};
176184
};
177185
};
178186

src/Keyboard.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
1818

19+
import React from "react";
20+
1921
export const Key = {
2022
HOME: "Home",
2123
END: "End",
@@ -76,7 +78,7 @@ export const Key = {
7678

7779
export const IS_MAC = navigator.platform.toUpperCase().includes("MAC");
7880

79-
export function isOnlyCtrlOrCmdKeyEvent(ev: KeyboardEvent): boolean {
81+
export function isOnlyCtrlOrCmdKeyEvent(ev: React.KeyboardEvent | KeyboardEvent): boolean {
8082
if (IS_MAC) {
8183
return ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey;
8284
} else {

src/LegacyCallHandler.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ export default class LegacyCallHandler extends EventEmitter {
158158
private transferees = new Map<string, MatrixCall>(); // callId (target) -> call (transferee)
159159
private audioPromises = new Map<AudioID, Promise<void>>();
160160
private audioElementsWithListeners = new Map<HTMLMediaElement, boolean>();
161-
private supportsPstnProtocol = null;
162-
private pstnSupportPrefixed = null; // True if the server only support the prefixed pstn protocol
163-
private supportsSipNativeVirtual = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
161+
private supportsPstnProtocol: boolean | null = null;
162+
private pstnSupportPrefixed: boolean | null = null; // True if the server only support the prefixed pstn protocol
163+
private supportsSipNativeVirtual: boolean | null = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
164164

165165
// Map of the asserted identity users after we've looked them up using the API.
166166
// We need to be be able to determine the mapped room synchronously, so we
@@ -187,7 +187,7 @@ export default class LegacyCallHandler extends EventEmitter {
187187
// check asserted identity: if we're not obeying asserted identity,
188188
// this map will never be populated, but we check anyway for sanity
189189
if (this.shouldObeyAssertedfIdentity()) {
190-
const nativeUser = this.assertedIdentityNativeUsers[call.callId];
190+
const nativeUser = this.assertedIdentityNativeUsers.get(call.callId);
191191
if (nativeUser) {
192192
const room = findDMForUser(MatrixClientPeg.get(), nativeUser);
193193
if (room) return room.roomId;
@@ -466,8 +466,8 @@ export default class LegacyCallHandler extends EventEmitter {
466466
return this.getAllActiveCallsNotInRoom(roomId);
467467
}
468468

469-
public getTransfereeForCallId(callId: string): MatrixCall {
470-
return this.transferees[callId];
469+
public getTransfereeForCallId(callId: string): MatrixCall | undefined {
470+
return this.transferees.get(callId);
471471
}
472472

473473
public play(audioId: AudioID): void {
@@ -621,7 +621,7 @@ export default class LegacyCallHandler extends EventEmitter {
621621
logger.log(`Asserted identity ${newAssertedIdentity} mapped to ${newNativeAssertedIdentity}`);
622622

623623
if (newNativeAssertedIdentity) {
624-
this.assertedIdentityNativeUsers[call.callId] = newNativeAssertedIdentity;
624+
this.assertedIdentityNativeUsers.set(call.callId, newNativeAssertedIdentity);
625625

626626
// If we don't already have a room with this user, make one. This will be slightly odd
627627
// if they called us because we'll be inviting them, but there's not much we can do about
@@ -917,7 +917,7 @@ export default class LegacyCallHandler extends EventEmitter {
917917
return;
918918
}
919919
if (transferee) {
920-
this.transferees[call.callId] = transferee;
920+
this.transferees.set(call.callId, transferee);
921921
}
922922

923923
this.setCallListeners(call);

src/Login.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ export default class Login {
9191
}
9292

9393
public loginViaPassword(
94-
username: string,
95-
phoneCountry: string,
96-
phoneNumber: string,
94+
username: string | undefined,
95+
phoneCountry: string | undefined,
96+
phoneNumber: string | undefined,
9797
password: string,
9898
): Promise<IMatrixClientCreds> {
99-
const isEmail = username.indexOf("@") > 0;
99+
const isEmail = username?.indexOf("@") > 0;
100100

101101
let identifier;
102102
if (phoneCountry && phoneNumber) {

src/MediaDeviceHandler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export enum MediaDeviceHandlerEvent {
3737
}
3838

3939
export default class MediaDeviceHandler extends EventEmitter {
40-
private static internalInstance;
40+
private static internalInstance?: MediaDeviceHandler;
4141

4242
public static get instance(): MediaDeviceHandler {
4343
if (!MediaDeviceHandler.internalInstance) {
@@ -67,7 +67,7 @@ export default class MediaDeviceHandler extends EventEmitter {
6767
public static async getDevices(): Promise<IMediaDevices> {
6868
try {
6969
const devices = await navigator.mediaDevices.enumerateDevices();
70-
const output = {
70+
const output: Record<MediaDeviceKindEnum, MediaDeviceInfo[]> = {
7171
[MediaDeviceKindEnum.AudioOutput]: [],
7272
[MediaDeviceKindEnum.AudioInput]: [],
7373
[MediaDeviceKindEnum.VideoInput]: [],

src/NodeAnimator.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React from "react";
17+
import React, { ReactInstance } from "react";
1818
import ReactDom from "react-dom";
1919

2020
interface IChildProps {
@@ -41,7 +41,7 @@ interface IProps {
4141
* automatic positional animation, look at react-shuffle or similar libraries.
4242
*/
4343
export default class NodeAnimator extends React.Component<IProps> {
44-
private nodes = {};
44+
private nodes: Record<string, ReactInstance> = {};
4545
private children: { [key: string]: React.DetailedReactHTMLElement<any, HTMLElement> };
4646
public static defaultProps: Partial<IProps> = {
4747
startStyles: [],
@@ -65,7 +65,7 @@ export default class NodeAnimator extends React.Component<IProps> {
6565
*/
6666
private applyStyles(node: HTMLElement, styles: React.CSSProperties): void {
6767
Object.entries(styles).forEach(([property, value]) => {
68-
node.style[property] = value;
68+
node.style[property as keyof Omit<CSSStyleDeclaration, "length" | "parentRule">] = value;
6969
});
7070
}
7171

0 commit comments

Comments
 (0)