matrix-art

An image gallery for Matrix
git clone git://archive.git.mtrnord.blog/MTRNord/matrix-art.git
Log | Files | Refs | README | LICENSE

commit 95fea732d3e65cfd0152c7d6566b71e29b2e624e
parent 6d52110ddd9c5b0dbacfe9fd8d64f7402e9f7392
Author: MTRNord <mtrnord1@gmail.com>
Date:   Thu, 31 Mar 2022 02:31:13 +0200

Setup compat

Diffstat:
Msrc/app.tsx | 4++--
Msrc/main.tsx | 7+++++++
Msrc/matrix/client.ts | 7++++++-
Mtsconfig.json | 21++++++++++++++++-----
Mvite.config.ts | 16++++++++++++----
5 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/src/app.tsx b/src/app.tsx @@ -1,7 +1,7 @@ -import { Component } from "preact"; +import { PureComponent } from 'preact/compat'; import { MatrixClient } from "./matrix/client"; -export class App extends Component { +export class App extends PureComponent { async componentDidMount() { const client = await MatrixClient.new(); await client.start(); diff --git a/src/main.tsx b/src/main.tsx @@ -8,6 +8,13 @@ import olmWasmPath from "@matrix-org/olm/olm.wasm?url"; import OlmLegacy from '@matrix-org/olm/olm_legacy.js?url'; import Olm from '@matrix-org/olm'; +if (import.meta.env.NODE_ENV === 'development') { + // Must use require here as import statements are only allowed + // to exist at top-level. + // @ts-ignore No types + import("preact/debug"); +} + function loadOlm(): Promise<void> { /* Load Olm. We try the WebAssembly version first, and then the legacy, * asm.js version if that fails. For this reason we need to wait for this diff --git a/src/matrix/client.ts b/src/matrix/client.ts @@ -33,7 +33,12 @@ export class MatrixClient { userId: user_id, accessToken: access_token, deviceId: device_id, - sessionStore: new IndexedDBStore({ indexedDB: window.indexedDB, dbName: "matrix-art-sync", localStorage: window.localStorage, workerFactory: () => new IndexedDBWorker(), }), + sessionStore: new IndexedDBStore({ + indexedDB: window.indexedDB, + dbName: "matrix-art-sync", + localStorage: window.localStorage, + workerFactory: () => new IndexedDBWorker(), + }), cryptoStore: new IndexedDBCryptoStore( window.indexedDB, "matrix-art:crypto", ), diff --git a/tsconfig.json b/tsconfig.json @@ -2,9 +2,13 @@ "compilerOptions": { "target": "ESNext", "useDefineForClassFields": true, - "lib": ["DOM", "DOM.Iterable", "ESNext"], + "lib": [ + "DOM", + "DOM.Iterable", + "ESNext" + ], "allowJs": false, - "skipLibCheck": false, + "skipLibCheck": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true, "strict": true, @@ -18,6 +22,12 @@ "jsxFactory": "h", "jsxFragmentFactory": "Fragment" }, - "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] -} + "include": [ + "src" + ], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] +} +\ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts @@ -1,7 +1,15 @@ -import { defineConfig } from 'vite' -import preact from '@preact/preset-vite' +import { defineConfig } from 'vite'; +import preact from '@preact/preset-vite'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [preact()] -}) + plugins: [preact()], + resolve: { + alias: { + react: 'preact/compat', + 'react-dom': 'preact/compat', + 'react-dom/test-utils': 'preact/test-utils', + 'react/jsx-runtime': 'preact/jsx-runtime' + } + } +});