File tree Expand file tree Collapse file tree
extensions/matrix/src/matrix/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,21 @@ import type { CoreConfig } from "../../types.js";
33import type { MatrixClient } from "../sdk.js" ;
44import { LogService } from "../sdk/logger.js" ;
55import { resolveMatrixAuth , resolveMatrixAuthContext } from "./config.js" ;
6- import { createMatrixClient } from "./create-client.js" ;
76import type { MatrixAuth } from "./types.js" ;
87
8+ type MatrixCreateClientDeps = {
9+ createMatrixClient : typeof import ( "./create-client.js" ) . createMatrixClient ;
10+ } ;
11+
12+ let matrixCreateClientDepsPromise : Promise < MatrixCreateClientDeps > | undefined ;
13+
14+ async function loadMatrixCreateClientDeps ( ) : Promise < MatrixCreateClientDeps > {
15+ matrixCreateClientDepsPromise ??= import ( "./create-client.js" ) . then ( ( runtime ) => ( {
16+ createMatrixClient : runtime . createMatrixClient ,
17+ } ) ) ;
18+ return await matrixCreateClientDepsPromise ;
19+ }
20+
921type SharedMatrixClientState = {
1022 client : MatrixClient ;
1123 key : string ;
@@ -38,6 +50,7 @@ async function createSharedMatrixClient(params: {
3850 auth : MatrixAuth ;
3951 timeoutMs ?: number ;
4052} ) : Promise < SharedMatrixClientState > {
53+ const { createMatrixClient } = await loadMatrixCreateClientDeps ( ) ;
4154 const client = await createMatrixClient ( {
4255 homeserver : params . auth . homeserver ,
4356 userId : params . auth . userId ,
You can’t perform that action at this time.
0 commit comments