(
pluginId: string,
entry: UIExtensionManifestEntry,
moduleLoader: (modulePath: string) => Promise<{ default: ComponentType<SlotComponentProps> }>,
)
| 12 | * Returns a SlotContribution if successful, null if the module fails to load. |
| 13 | */ |
| 14 | export 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. |
no test coverage detected