MCPcopy Create free account
hub / github.com/TabularisDB/tabularis / loadUIExtensionModule

Function loadUIExtensionModule

src/utils/pluginModuleLoader.ts:14–49  ·  view source on GitHub ↗
(
  pluginId: string,
  entry: UIExtensionManifestEntry,
  moduleLoader: (modulePath: string) => Promise<{ default: ComponentType<SlotComponentProps> }>,
)

Source from the content-addressed store, hash-verified

12 * Returns a SlotContribution if successful, null if the module fails to load.
13 */
14export async function loadUIExtensionModule(
15 pluginId: string,
16 entry: UIExtensionManifestEntry,
17 moduleLoader: (modulePath: string) => Promise<{ default: ComponentType<SlotComponentProps> }>,
18): Promise<SlotContribution | null> {
19 const slotName = validateSlotName(entry.slot);
20 if (!slotName) {
21 console.warn(
22 `[PluginSlot] Plugin "${pluginId}" declares unknown slot "${entry.slot}". Skipping.`,
23 );
24 return null;
25 }
26
27 try {
28 const mod = await moduleLoader(entry.module);
29 if (!mod.default || typeof mod.default !== "function") {
30 console.warn(
31 `[PluginSlot] Plugin "${pluginId}" module "${entry.module}" does not export a default component. Skipping.`,
32 );
33 return null;
34 }
35
36 return {
37 pluginId,
38 slot: slotName,
39 component: mod.default,
40 order: entry.order,
41 };
42 } catch (err) {
43 console.error(
44 `[PluginSlot] Failed to load UI extension module "${entry.module}" for plugin "${pluginId}":`,
45 err,
46 );
47 return null;
48 }
49}
50
51/**
52 * Loads all UI extension modules declared in a plugin manifest.

Callers 2

loadPluginUIExtensionsFunction · 0.85

Calls 1

validateSlotNameFunction · 0.85

Tested by

no test coverage detected