diff --git a/frontend/src/extensions.ts b/frontend/src/extensions.ts index c562b2e4d..2e166827a 100644 --- a/frontend/src/extensions.ts +++ b/frontend/src/extensions.ts @@ -84,6 +84,7 @@ class ExtensionApi { export interface ExtensionContext { api: ExtensionApi; + getExt: (name: string) => Promise; } /** @@ -121,12 +122,16 @@ export class ExtensionData implements Required { } } -async function loadExtensionModule(name: string): Promise { +async function loadExtensionModule( + name: string, + getExtension: (name: string) => Promise, +): Promise { const url = urlFor(`extension_js_module/${name}.js`, undefined, false); const mod = await (import(url) as Promise<{ default?: ExtensionModule }>); if (typeof mod.default === "object") { const context: ExtensionContext = { api: new ExtensionApi(name), + getExt: getExtension, }; return new ExtensionData(context, mod.default); } @@ -144,7 +149,7 @@ async function getExt(name: string): Promise { if (loaded_ext) { return loaded_ext; } - const ext = loadExtensionModule(name); + const ext = loadExtensionModule(name, getExt); loaded_extensions.set(name, ext); (await ext).init(); return ext;