chore: upgrade i18next 26, prettier 3, fontsource-variable, domhandler 6, lint-staged 17

- i18next 23->26 + react-i18next 15->17
- prettier 2->3, reformat all files
- replace @fontsource/inter with @fontsource-variable/inter 5, update import path
- domhandler 5->6 (aligns with transitive deps)
- lint-staged 16->17
This commit is contained in:
Lotus Bot
2026-05-21 23:30:50 -04:00
parent b3666fa876
commit 61a1f008d0
363 changed files with 1443 additions and 1419 deletions
+4 -4
View File
@@ -39,7 +39,7 @@ export class ASCIILexicalTable {
console.warn(
`[!] Warning: ASCIILexicalTable size is larger than the Number.MAX_SAFE_INTEGER: ${this.size()} > ${
Number.MAX_SAFE_INTEGER
}`
}`,
);
}
}
@@ -333,7 +333,7 @@ export class ASCIILexicalTable {
const findNextFilledKey = (
fromIndex: number,
keys: Array<string | undefined>
keys: Array<string | undefined>,
): [number, string] | [-1, undefined] => {
for (let j = fromIndex; j < keys.length; j += 1) {
const key = keys[j];
@@ -347,7 +347,7 @@ const findNextFilledKey = (
export const orderKeys = (
lex: ASCIILexicalTable,
keys: Array<string | undefined>
keys: Array<string | undefined>,
): Array<string> | undefined => {
const newKeys: string[] = [];
@@ -368,7 +368,7 @@ export const orderKeys = (
const generatedKeys = lex.nBetween(
keyToGenerateCount,
key ?? lex.first(),
nextKey ?? lex.last()
nextKey ?? lex.last(),
);
if (generatedKeys) {
collectedKeys.push(...generatedKeys);
+4 -4
View File
@@ -14,18 +14,18 @@ export type AsyncSearchOption = {
export type MatchHandler<TSearchItem extends object | string | number> = (
item: TSearchItem,
query: string
query: string,
) => boolean;
export type ResultHandler<TSearchItem extends object | string | number> = (
results: TSearchItem[],
query: string
query: string,
) => void;
export type AsyncSearchHandler = (query: string) => void;
export type TerminateAsyncSearch = () => void;
export const normalize = (str: string, options?: NormalizeOption) => {
let nStr = str.normalize(options?.normalizeUnicode ?? true ? 'NFKC' : 'NFC');
let nStr = str.normalize((options?.normalizeUnicode ?? true) ? 'NFKC' : 'NFC');
if (!options?.caseSensitive) nStr = nStr.toLocaleLowerCase();
if (options?.ignoreWhitespace ?? true) nStr = nStr.replace(/\s/g, '');
return nStr;
@@ -40,7 +40,7 @@ export const AsyncSearch = <TSearchItem extends object | string | number>(
list: TSearchItem[],
match: MatchHandler<TSearchItem>,
onResult: ResultHandler<TSearchItem>,
options?: AsyncSearchOption
options?: AsyncSearchOption,
): [AsyncSearchHandler, TerminateAsyncSearch] => {
let resultList: TSearchItem[] = [];
+1 -1
View File
@@ -3,7 +3,7 @@ import { encode, isBlurhashValid } from 'blurhash';
export const encodeBlurHash = (
img: HTMLImageElement | HTMLVideoElement,
width?: number,
height?: number
height?: number,
): string | undefined => {
const imgWidth = img instanceof HTMLVideoElement ? img.videoWidth : img.width;
const imgHeight = img instanceof HTMLVideoElement ? img.videoHeight : img.height;
+1 -1
View File
@@ -52,7 +52,7 @@ export const fulfilledPromiseSettledResult = <T>(prs: PromiseSettledResult<T>[])
}, []);
export const promiseFulfilledResult = <T>(
settledResult: PromiseSettledResult<T>
settledResult: PromiseSettledResult<T>,
): T | undefined => {
if (settledResult.status === 'fulfilled') return settledResult.value;
return undefined;
+3 -3
View File
@@ -4,13 +4,13 @@ export type DisposeCallback<DisposeArgs extends unknown[] = [], DisposeReturn =
export type DisposableContext<
DisposableArgs extends unknown[] = [],
DisposeArgs extends unknown[] = [],
DisposeReturn = void
DisposeReturn = void,
> = (...args: DisposableArgs) => DisposeCallback<DisposeArgs, DisposeReturn>;
export const disposable = <
DisposableArgs extends unknown[],
DisposeArgs extends unknown[] = [],
DisposeReturn = void
DisposeReturn = void,
>(
context: DisposableContext<DisposableArgs, DisposeArgs, DisposeReturn>
context: DisposableContext<DisposableArgs, DisposeArgs, DisposeReturn>,
) => context;
+4 -4
View File
@@ -13,7 +13,7 @@ export const editableActiveElement = (): boolean =>
export const isIntersectingScrollView = (
scrollElement: HTMLElement,
childElement: HTMLElement
childElement: HTMLElement,
): boolean => {
const scrollTop = scrollElement.offsetTop + scrollElement.scrollTop;
const scrollBottom = scrollTop + scrollElement.offsetHeight;
@@ -38,7 +38,7 @@ export const isInScrollView = (scrollElement: HTMLElement, childElement: HTMLEle
export const canFitInScrollView = (
scrollElement: HTMLElement,
childElement: HTMLElement
childElement: HTMLElement,
): boolean => childElement.offsetHeight < scrollElement.offsetHeight;
export type FilesOrFile<T extends boolean | undefined = undefined> = T extends true ? File[] : File;
@@ -56,7 +56,7 @@ export const getFilesFromFileList = (fileList: FileList): File[] => {
export const selectFile = <M extends boolean | undefined = undefined>(
accept: string,
multiple?: M
multiple?: M,
): Promise<FilesOrFile<M> | undefined> =>
new Promise((resolve) => {
const input = document.createElement('input');
@@ -147,7 +147,7 @@ export const getThumbnail = (
img: HTMLImageElement | SVGImageElement | HTMLVideoElement,
width: number,
height: number,
thumbnailMimeType?: string
thumbnailMimeType?: string,
): Promise<Blob | undefined> =>
new Promise((resolve) => {
const canvas = document.createElement('canvas');
+2 -2
View File
@@ -1,6 +1,6 @@
export type ReplaceCallback<R> = (
match: RegExpExecArray | RegExpMatchArray,
pushIndex: number
pushIndex: number,
) => R;
export type ConvertPartCallback<R> = (text: string, pushIndex: number) => R;
@@ -8,7 +8,7 @@ export const findAndReplace = <ReplaceReturnType, ConvertReturnType>(
text: string,
regex: RegExp,
replace: ReplaceCallback<ReplaceReturnType>,
convertPart: ConvertPartCallback<ConvertReturnType>
convertPart: ConvertPartCallback<ConvertReturnType>,
): Array<ReplaceReturnType | ConvertReturnType> => {
const result: Array<ReplaceReturnType | ConvertReturnType> = [];
let lastEnd = 0;
+1 -1
View File
@@ -3,7 +3,7 @@ import { CryptoApi } from 'matrix-js-sdk/lib/crypto-api';
export const verifiedDevice = async (
api: CryptoApi,
userId: string,
deviceId: string
deviceId: string,
): Promise<boolean | null> => {
const status = await api.getDeviceVerificationStatus(userId, deviceId);
+1 -1
View File
@@ -2,7 +2,7 @@ import { AuthType, IAuthData, UIAFlow } from 'matrix-js-sdk';
export const getSupportedUIAFlows = (uiaFlows: UIAFlow[], supportedStages: string[]): UIAFlow[] => {
const supportedUIAFlows = uiaFlows.filter((flow) =>
flow.stages.every((stage) => supportedStages.includes(stage))
flow.stages.every((stage) => supportedStages.includes(stage)),
);
return supportedUIAFlows;
+11 -11
View File
@@ -43,7 +43,7 @@ export const getCanonicalAliasRoomId = (mx: MatrixClient, alias: string): string
?.find(
(room) =>
room.getCanonicalAlias() === alias &&
getStateEvent(room, StateEvent.RoomTombstone) === undefined
getStateEvent(room, StateEvent.RoomTombstone) === undefined,
)?.roomId;
export const getCanonicalAliasOrRoomId = (mx: MatrixClient, roomId: string): string => {
@@ -105,7 +105,7 @@ export const getThumbnailContent = (thumbnailInfo: {
};
export const encryptFile = async (
file: File | Blob
file: File | Blob,
): Promise<{
encInfo: EncryptedAttachmentInfo;
file: File;
@@ -126,7 +126,7 @@ export const encryptFile = async (
export const decryptFile = async (
dataBuffer: ArrayBuffer,
type: string,
encInfo: EncryptedAttachmentInfo
encInfo: EncryptedAttachmentInfo,
): Promise<Blob> => {
const dataArray = await decryptAttachment(dataBuffer, encInfo);
const blob = new Blob([dataArray], { type });
@@ -148,7 +148,7 @@ export type ContentUploadOptions = {
export const uploadContent = async (
mx: MatrixClient,
file: TUploadContent,
options: ContentUploadOptions
options: ContentUploadOptions,
) => {
const { name, fileType, hideFilename, onProgress, onPromise, onSuccess, onError } = options;
@@ -186,7 +186,7 @@ export const getDMRoomFor = (mx: MatrixClient, userId: string): Room | undefined
(room) =>
room.getMyMembership() === Membership.Join &&
room.hasEncryptionStateEvent() &&
room.getMembers().length <= 2
room.getMembers().length <= 2,
);
return dmLikeRooms.find((room) => room.getMember(userId));
@@ -220,7 +220,7 @@ export const guessDmRoomUserId = (room: Room, myUserId: string): string => {
// if there are no joined members other than us, use the oldest member
const member1 = getOldestMember(
room.getLiveTimeline().getState(EventTimeline.FORWARDS)?.getMembers() ?? []
room.getLiveTimeline().getState(EventTimeline.FORWARDS)?.getMembers() ?? [],
);
return member1?.userId ?? myUserId;
};
@@ -228,7 +228,7 @@ export const guessDmRoomUserId = (room: Room, myUserId: string): string => {
export const addRoomIdToMDirect = async (
mx: MatrixClient,
roomId: string,
userId: string
userId: string,
): Promise<void> => {
const mDirectsEvent = mx.getAccountData(AccountDataEvent.Direct as any);
let userIdToRoomIds: Record<string, string[]> = {};
@@ -284,7 +284,7 @@ export const mxcUrlToHttp = (
height?: number,
resizeMethod?: string,
allowDirectLinks?: boolean,
allowRedirects?: boolean
allowRedirects?: boolean,
): string | null =>
mx.mxcUrlToHttp(
mxcUrl,
@@ -293,7 +293,7 @@ export const mxcUrlToHttp = (
resizeMethod,
allowDirectLinks,
allowRedirects,
useAuthentication
useAuthentication,
);
export const downloadMedia = async (src: string): Promise<Blob> => {
@@ -305,7 +305,7 @@ export const downloadMedia = async (src: string): Promise<Blob> => {
export const downloadEncryptedMedia = async (
src: string,
decryptContent: (buf: ArrayBuffer) => Promise<Blob>
decryptContent: (buf: ArrayBuffer) => Promise<Blob>,
): Promise<Blob> => {
const encryptedContent = await downloadMedia(src);
const decryptedContent = await decryptContent(await encryptedContent.arrayBuffer());
@@ -316,7 +316,7 @@ export const downloadEncryptedMedia = async (
export const rateLimitedActions = async <T, R = void>(
data: T[],
callback: (item: T, index: number) => Promise<R>,
maxRetryCount?: number
maxRetryCount?: number,
) => {
let retryCount = 0;
+1 -1
View File
@@ -21,6 +21,6 @@ export async function markAsRead(mx: MatrixClient, roomId: string, privateReceip
await mx.sendReadReceipt(
latestEvent,
privateReceipt ? ReceiptType.ReadPrivate : ReceiptType.Read
privateReceipt ? ReceiptType.ReadPrivate : ReceiptType.Read,
);
}
+1 -1
View File
@@ -22,5 +22,5 @@ export const EMOJI_PATTERN = `[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u
// Thumbs up emoji found to have Variation Selector 16 at the end
// so included variation selector pattern in regex
export const JUMBO_EMOJI_REG = new RegExp(
`^(((${EMOJI_PATTERN})|(:.+?:))(${VARIATION_SELECTOR_PATTERN}|\\s)*){1,10}$`
`^(((${EMOJI_PATTERN})|(:.+?:))(${VARIATION_SELECTOR_PATTERN}|\\s)*){1,10}$`,
);
+20 -19
View File
@@ -33,7 +33,7 @@ import {
export const getStateEvent = (
room: Room,
eventType: StateEvent,
stateKey = ''
stateKey = '',
): MatrixEvent | undefined =>
room.getLiveTimeline().getState(EventTimeline.FORWARDS)?.getStateEvents(eventType, stateKey) ??
undefined;
@@ -43,7 +43,7 @@ export const getStateEvents = (room: Room, eventType: StateEvent): MatrixEvent[]
export const getAccountData = (
mx: MatrixClient,
eventType: AccountDataEvent
eventType: AccountDataEvent,
): MatrixEvent | undefined => mx.getAccountData(eventType as any);
export const getMDirects = (mDirectEvent: MatrixEvent): Set<string> => {
@@ -127,7 +127,7 @@ export const getSpaceChildren = (room: Room) =>
export const mapParentWithChildren = (
roomToParents: RoomToParents,
roomId: string,
children: string[]
children: string[],
) => {
const allParents = getAllParents(roomToParents, roomId);
children.forEach((childId) => {
@@ -153,7 +153,7 @@ export const getRoomToParents = (mx: MatrixClient): RoomToParents => {
export const getOrphanParents = (roomToParents: RoomToParents, roomId: string): string[] => {
const parents = getAllParents(roomToParents, roomId);
const orphanParents = Array.from(parents).filter(
(parentRoomId) => !roomToParents.has(parentRoomId)
(parentRoomId) => !roomToParents.has(parentRoomId),
);
return orphanParents;
@@ -261,7 +261,7 @@ export const getUnreadInfos = (mx: MatrixClient): UnreadInfo[] => {
export const getRoomIconSrc = (
icons: Record<IconName, IconSrc>,
roomType?: string,
joinRule?: JoinRule
joinRule?: JoinRule,
): IconSrc => {
if (roomType === RoomType.Space) {
if (joinRule === JoinRule.Public) return icons.SpaceGlobe;
@@ -302,11 +302,12 @@ export const getRoomAvatarUrl = (
mx: MatrixClient,
room: Room,
size: 32 | 96 = 32,
useAuthentication = false
useAuthentication = false,
): string | undefined => {
const mxcUrl = room.getMxcAvatarUrl();
return mxcUrl
? mx.mxcUrlToHttp(mxcUrl, size, size, 'crop', undefined, false, useAuthentication) ?? undefined
? (mx.mxcUrlToHttp(mxcUrl, size, size, 'crop', undefined, false, useAuthentication) ??
undefined)
: undefined;
};
@@ -314,7 +315,7 @@ export const getDirectRoomAvatarUrl = (
mx: MatrixClient,
room: Room,
size: 32 | 96 = 32,
useAuthentication = false
useAuthentication = false,
): string | undefined => {
const mxcUrl = room.getAvatarFallbackMember()?.getMxcAvatarUrl();
@@ -349,10 +350,10 @@ export const parseReplyFormattedBody = (
roomId: string,
userId: string,
eventId: string,
formattedBody: string
formattedBody: string,
): string => {
const replyToLink = `<a href="https://matrix.to/#/${encodeURIComponent(
roomId
roomId,
)}/${encodeURIComponent(eventId)}">In reply to</a>`;
const userLink = `<a href="https://matrix.to/#/${encodeURIComponent(userId)}">${userId}</a>`;
@@ -369,7 +370,7 @@ export const getMemberDisplayName = (room: Room, userId: string): string | undef
export const getMemberSearchStr = (
member: RoomMember,
query: string,
mxIdToName: (mxId: string) => string
mxIdToName: (mxId: string) => string,
): string[] => [
member.rawDisplayName === member.userId ? mxIdToName(member.userId) : member.rawDisplayName,
query.startsWith('@') || query.indexOf(':') > -1 ? member.userId : mxIdToName(member.userId),
@@ -408,7 +409,7 @@ export const getEventReactions = (timelineSet: EventTimelineSet, eventId: string
timelineSet.relations.getChildEventsForEvent(
eventId,
RelationType.Annotation,
EventType.Reaction
EventType.Reaction,
);
export const getEventEdits = (timelineSet: EventTimelineSet, eventId: string, eventType: string) =>
@@ -416,7 +417,7 @@ export const getEventEdits = (timelineSet: EventTimelineSet, eventId: string, ev
export const getLatestEdit = (
targetEvent: MatrixEvent,
editEvents: MatrixEvent[]
editEvents: MatrixEvent[],
): MatrixEvent | undefined => {
const eventByTargetSender = (rEvent: MatrixEvent) =>
rEvent.getSender() === targetEvent.getSender();
@@ -426,7 +427,7 @@ export const getLatestEdit = (
export const getEditedEvent = (
mEventId: string,
mEvent: MatrixEvent,
timelineSet: EventTimelineSet
timelineSet: EventTimelineSet,
): MatrixEvent | undefined => {
const edits = getEventEdits(timelineSet, mEventId, mEvent.getType());
return edits && getLatestEdit(mEvent, edits.getRelations());
@@ -447,7 +448,7 @@ export const canEditEvent = (mx: MatrixClient, mEvent: MatrixEvent) => {
export const getLatestEditableEvt = (
timeline: EventTimeline,
canEdit: (mEvent: MatrixEvent) => boolean
canEdit: (mEvent: MatrixEvent) => boolean,
): MatrixEvent | undefined => {
const events = timeline.getEvents();
@@ -477,7 +478,7 @@ export const getMentionContent = (userIds: string[], room: boolean): IMentions =
export const getCommonRooms = (
mx: MatrixClient,
rooms: string[],
otherUserId: string
otherUserId: string,
): string[] => {
const commonRooms: string[] = [];
@@ -523,7 +524,7 @@ export const getAllVersionsRoomCreator = (room: Room): Set<string> => {
export const guessPerfectParent = (
mx: MatrixClient,
roomId: string,
parents: string[]
parents: string[],
): string | undefined => {
if (parents.length === 1) {
return parents[0];
@@ -539,7 +540,7 @@ export const guessPerfectParent = (
const powerLevels = getStateEvent(
r,
StateEvent.RoomPowerLevels
StateEvent.RoomPowerLevels,
)?.getContent<IPowerLevelsContent>();
const { users_default: usersDefault, users } = powerLevels ?? {};
@@ -562,7 +563,7 @@ export const guessPerfectParent = (
parents.forEach((parentId) => {
const parentSpecialUsers = getSpecialUsers(parentId);
const matchedUsersCount = parentSpecialUsers.filter((userId) =>
roomSpecialUsers.includes(userId)
roomSpecialUsers.includes(userId),
).length;
if (matchedUsersCount > score) {
+1 -1
View File
@@ -1,4 +1,4 @@
export const webRTCSupported = () =>
['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].some(
(item) => item in window
(item) => item in window,
);