0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-04 13:50:13 -05:00

feat(plugins-runtime): add close callback to load api

This commit is contained in:
alonso.torres 2024-10-10 13:10:07 +02:00 committed by Alonso Torres
parent b4d0463548
commit aeddab7917

View file

@ -35,7 +35,10 @@ window.addEventListener('message', (event) => {
}
});
export const loadPlugin = async function (manifest: Manifest) {
export const loadPlugin = async function (
manifest: Manifest,
closeCallback?: () => void
) {
try {
const context = contextBuilder && contextBuilder(manifest.pluginId);
@ -50,6 +53,7 @@ export const loadPlugin = async function (manifest: Manifest) {
manifest,
() => {
plugins = plugins.filter((api) => api !== plugin);
closeCallback && closeCallback();
}
);
@ -60,8 +64,11 @@ export const loadPlugin = async function (manifest: Manifest) {
}
};
export const ɵloadPlugin = async function (manifest: Manifest) {
loadPlugin(manifest);
export const ɵloadPlugin = async function (
manifest: Manifest,
closeCallback?: () => void
) {
loadPlugin(manifest, closeCallback);
};
export const ɵloadPluginByUrl = async function (manifestUrl: string) {