@kinvolk/headlamp-plugin
Version:
The needed infrastructure for building Headlamp plugins.
51 lines (50 loc) • 2.44 kB
TypeScript
import { PluginInfo } from './pluginsSlice';
/**
* Load external, then local plugins. Then initialize() them in order with a Registry.
*/
export declare function initializePlugins(): Promise<unknown>;
/**
* This can be used to filter out which of the plugins we should execute.
*
* @param sources array of source to execute. Has the same order as packageInfos.
* @param packageInfos array of package.json contents
* @param appMode if we are in app mode
* @param compatibleVersion headlamp-plugin version this build is compatible with.
* If the plugin engine version is not compatible, the plugin will not be loaded.
* Can be set to a semver range, e.g. '>= 0.6.0' or '0.6.0 - 0.7.0'.
* If set to an empty string, all plugin versions will be loaded.
* @param settingsPackages the packages from settings
*
* @returns the sources to execute and incompatible PackageInfos
* with this structure { sourcesToExecute, incompatiblePackageInfos }
*/
export declare function filterSources(sources: string[], packageInfos: PluginInfo[], appMode: boolean, compatibleVersion: string, settingsPackages?: PluginInfo[]): {
sourcesToExecute: string[];
incompatiblePlugins: Record<string, PluginInfo>;
};
/**
* Gives back updates settings from the backend.
*
* If there are new plugins, it includes the new ones with isEnabled=true.
*
* If plugins are not there anymore in the backend list,
* then it removes them from the settings list of plugins.
*
* @param backendPlugins the list of plugins info from the backend.
* @param settingsPlugins the list of plugins the settings already knows about.
* @returns plugin info for the settings.
*/
export declare function updateSettingsPackages(backendPlugins: PluginInfo[], settingsPlugins: PluginInfo[]): PluginInfo[];
/**
* Get the list of plugins,
* download all the plugin source,
* download all the plugin package.json files,
* execute the plugins,
* .initialize() plugins that register (not all do).
*
* @param settingsPackages The packages settings knows about.
* @param onSettingsChange Called when the plugins are different to what is in settings.
* @param onIncompatible Called when there are incompatible plugins.
*
*/
export declare function fetchAndExecutePlugins(settingsPackages: PluginInfo[], onSettingsChange: (plugins: PluginInfo[]) => void, onIncompatible: (plugins: Record<string, PluginInfo>) => void): Promise<void>;