mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-21 06:02:34 -05:00
feat(plugins-runtime): add close callback to load api
This commit is contained in:
parent
b4d0463548
commit
aeddab7917
1 changed files with 10 additions and 3 deletions
|
@ -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 {
|
try {
|
||||||
const context = contextBuilder && contextBuilder(manifest.pluginId);
|
const context = contextBuilder && contextBuilder(manifest.pluginId);
|
||||||
|
|
||||||
|
@ -50,6 +53,7 @@ export const loadPlugin = async function (manifest: Manifest) {
|
||||||
manifest,
|
manifest,
|
||||||
() => {
|
() => {
|
||||||
plugins = plugins.filter((api) => api !== plugin);
|
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) {
|
export const ɵloadPlugin = async function (
|
||||||
loadPlugin(manifest);
|
manifest: Manifest,
|
||||||
|
closeCallback?: () => void
|
||||||
|
) {
|
||||||
|
loadPlugin(manifest, closeCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ɵloadPluginByUrl = async function (manifestUrl: string) {
|
export const ɵloadPluginByUrl = async function (manifestUrl: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue