This commit is contained in:
David Langley
2026-03-13 16:19:27 +00:00
parent 610a9494d1
commit c058c187c4
6 changed files with 22 additions and 19 deletions
@@ -30,7 +30,7 @@ export default class WidgetLifecycleModule implements Module {
public constructor(private api: ModuleApi) {}
public async load(): Promise<void> {
if (!this.api.widgetLifecycle?.registerPreloadApprover) {
if (!this.api.widgetLifecycle) {
throw new Error(
"Widget lifecycle API is not available. Update Element Web to a build that provides widget lifecycle module support.",
);
@@ -32,16 +32,16 @@ const ModuleConfigSchema = z.partial(
/** Map from URL patterns to their widget approval configuration. */
export type WidgetLifecycleModuleConfig = Record<string, WidgetConfiguration>;
/**
* Parse and validate the widget lifecycle module configuration.
* Returns an empty config if the input is falsy; throws on schema violations.
*/
declare module "@element-hq/element-web-module-api" {
export interface Config {
[CONFIG_KEY]: z.input<typeof ModuleConfigSchema>;
}
}
/**
* Parse and validate the widget lifecycle module configuration.
* Returns an empty config if the input is falsy; throws on schema violations.
*/
export const parseWidgetLifecycleConfig = (value: unknown): WidgetLifecycleModuleConfig => {
if (!value) return {};