Plugins
Covers Engine Plugin SDK 2.0.0 · Interface Plugin SDK 0.2.0
registerPlugin
Registers an interface plugin definition with the browser plugin host.
Import
import { registerPlugin } from "@dartwic/interface-sdk/runtime";Declaration
export function registerPlugin(pluginDefinition: InterfacePluginDefinition) {
const plugin = definePlugin(pluginDefinition);
const pluginId = String(plugin?.id ?? "").trim();
if (!pluginId) {
throw new Error("registerPlugin(...) requires a plugin definition with an id.");
}
const registry = (window.__dartwicPluginRegistry__ = window.__dartwicPluginRegistry__ || {});
registry[pluginId] = {
createPlugin(hostApi: InterfacePluginHostApi) {
setHostApi(hostApi);
return createInterfacePlugin(plugin);
}
};
}