Refactor of the plugins context

This commit is contained in:
alonso.torres 2024-04-02 09:58:21 +02:00 committed by Andrey Antukh
parent 5a34c25926
commit 127b481c38
12 changed files with 285 additions and 186 deletions

View file

@ -1,16 +0,0 @@
export class PluginsElement extends HTMLElement {
connectedCallback() {
console.log('PluginsElement.connectedCallback');
}
}
customElements.define('penpot-plugins', PluginsElement);
// Alternative to message passing
export function initialize(api) {
console.log("PluginsRuntime:initialize", api)
api.addListener("foobar", "page", (page) => {
console.log("Page Changed:", page.name);
});
};

View file

@ -23,6 +23,7 @@
{{/isDebug}}
<link rel="icon" href="images/favicon.png" />
<script type="importmap">
{"imports": {"plugins-runtime": "http://localhost:4200/index.mjs"}}
</script>
@ -58,10 +59,7 @@
<script type="module">
import * as runtime from "plugins-runtime";
// console.log(globalThis.app.plugins);
runtime.initialize(globalThis.app.plugins);
runtime.initialize(globalThis.app.plugins.api);
</script>
</body>
</html>