Use globalThis and React.JSX in the browser code. [skip build]
This commit is contained in:
@@ -24,7 +24,7 @@ export function AngleSelector({
|
||||
onChange,
|
||||
size = 80,
|
||||
disabled = false,
|
||||
}: AngleSelectorProps): JSX.Element {
|
||||
}: AngleSelectorProps): React.JSX.Element {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ import {
|
||||
import { MessageLayout, MessageSpacing } from '../../../state/settings';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import { useEmojiUsage } from '../../../hooks/useEmojiUsage';
|
||||
import { emojis } from '../../../plugins/emoji';
|
||||
import { IEmoji, emojis } from '../../../plugins/emoji';
|
||||
import * as css from './styles.css';
|
||||
import { EventReaders } from '../../../components/event-readers';
|
||||
import { TextViewer } from '../../../components/text-viewer';
|
||||
|
||||
@@ -184,7 +184,7 @@ export const renderMatrixMention = (
|
||||
};
|
||||
|
||||
export const factoryRenderLinkifyWithMention = (
|
||||
mentionRender: (href: string) => JSX.Element | undefined,
|
||||
mentionRender: (href: string) => React.JSX.Element | undefined,
|
||||
): OptFn<(ir: IntermediateRepresentation) => any> => {
|
||||
const render: OptFn<(ir: IntermediateRepresentation) => any> = ({
|
||||
tagName,
|
||||
@@ -205,7 +205,7 @@ export const factoryRenderLinkifyWithMention = (
|
||||
return render;
|
||||
};
|
||||
|
||||
export const scaleSystemEmoji = (text: string): (string | JSX.Element)[] =>
|
||||
export const scaleSystemEmoji = (text: string): (string | React.JSX.Element)[] =>
|
||||
findAndReplace(
|
||||
text,
|
||||
EMOJI_REG_G,
|
||||
@@ -231,8 +231,8 @@ export const makeHighlightRegex = (highlights: string[]): RegExp | undefined =>
|
||||
|
||||
export const highlightText = (
|
||||
regex: RegExp,
|
||||
data: (string | JSX.Element)[],
|
||||
): (string | JSX.Element)[] =>
|
||||
data: (string | React.JSX.Element)[],
|
||||
): (string | React.JSX.Element)[] =>
|
||||
data.flatMap((text) => {
|
||||
if (typeof text !== 'string') return text;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ let handlingKeyConflict = false;
|
||||
|
||||
const deleteIndexedDB = (dbName: string): Promise<void> =>
|
||||
new Promise((resolve, reject) => {
|
||||
const request = global.indexedDB.deleteDatabase(dbName);
|
||||
const request = globalThis.indexedDB.deleteDatabase(dbName);
|
||||
request.onsuccess = () => {
|
||||
console.log(`[initMatrix] Deleted IndexedDB database: ${dbName}`);
|
||||
resolve();
|
||||
@@ -108,7 +108,7 @@ const deleteIndexedDB = (dbName: string): Promise<void> =>
|
||||
|
||||
const getAllIndexedDBNames = async (): Promise<string[]> => {
|
||||
try {
|
||||
if ('databases' in global.indexedDB) {
|
||||
if ('databases' in globalThis.indexedDB) {
|
||||
// Add timeout to prevent hanging
|
||||
const timeoutPromise = new Promise<string[]>((resolve) => {
|
||||
setTimeout(() => {
|
||||
@@ -117,7 +117,7 @@ const getAllIndexedDBNames = async (): Promise<string[]> => {
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
const databasesPromise = (global.indexedDB as any)
|
||||
const databasesPromise = (globalThis.indexedDB as any)
|
||||
.databases()
|
||||
.then((dbs: any[]) => dbs.map((db: any) => db.name).filter(Boolean));
|
||||
|
||||
@@ -300,12 +300,12 @@ export const initClient = async (session: Session): Promise<MatrixClient> => {
|
||||
|
||||
try {
|
||||
const indexedDBStore = new IndexedDBStore({
|
||||
indexedDB: global.indexedDB,
|
||||
localStorage: global.localStorage,
|
||||
indexedDB: globalThis.indexedDB,
|
||||
localStorage: globalThis.localStorage,
|
||||
dbName: storeName.sync,
|
||||
});
|
||||
|
||||
const legacyCryptoStore = new IndexedDBCryptoStore(global.indexedDB, storeName.crypto);
|
||||
const legacyCryptoStore = new IndexedDBCryptoStore(globalThis.indexedDB, storeName.crypto);
|
||||
|
||||
const mx = createClient({
|
||||
baseUrl: session.baseUrl,
|
||||
|
||||
@@ -43,7 +43,7 @@ function fetchConfig(token?: string): RequestInit | undefined {
|
||||
}
|
||||
|
||||
self.addEventListener('activate', (event: ExtendableEvent) => {
|
||||
event.waitUntil(clients.claim());
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event: FetchEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user