From 8a53006eadc3392b1acf00641cf18b1c10758e35 Mon Sep 17 00:00:00 2001 From: litruv Date: Sun, 1 Nov 2026 09:09:00 +1100 Subject: [PATCH] Use globalThis and React.JSX in the browser code. [skip build] --- src/app/components/AngleSelector.tsx | 2 +- src/app/features/room/message/Message.tsx | 2 +- src/app/plugins/react-custom-html-parser.tsx | 8 ++++---- src/client/initMatrix.ts | 12 ++++++------ src/sw.ts | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/app/components/AngleSelector.tsx b/src/app/components/AngleSelector.tsx index 2be1848d..3a5913ef 100644 --- a/src/app/components/AngleSelector.tsx +++ b/src/app/components/AngleSelector.tsx @@ -24,7 +24,7 @@ export function AngleSelector({ onChange, size = 80, disabled = false, -}: AngleSelectorProps): JSX.Element { +}: AngleSelectorProps): React.JSX.Element { const containerRef = useRef(null); const [isDragging, setIsDragging] = useState(false); diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index a81a989f..3955623a 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -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'; diff --git a/src/app/plugins/react-custom-html-parser.tsx b/src/app/plugins/react-custom-html-parser.tsx index e771c370..9030649a 100644 --- a/src/app/plugins/react-custom-html-parser.tsx +++ b/src/app/plugins/react-custom-html-parser.tsx @@ -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; diff --git a/src/client/initMatrix.ts b/src/client/initMatrix.ts index 2035e751..d9461c6d 100644 --- a/src/client/initMatrix.ts +++ b/src/client/initMatrix.ts @@ -90,7 +90,7 @@ let handlingKeyConflict = false; const deleteIndexedDB = (dbName: string): Promise => 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 => const getAllIndexedDBNames = async (): Promise => { try { - if ('databases' in global.indexedDB) { + if ('databases' in globalThis.indexedDB) { // Add timeout to prevent hanging const timeoutPromise = new Promise((resolve) => { setTimeout(() => { @@ -117,7 +117,7 @@ const getAllIndexedDBNames = async (): Promise => { }, 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 => { 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, diff --git a/src/sw.ts b/src/sw.ts index 96f9244a..b2965f25 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -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) => {