Hi, I’m an author of an figwire - lightweight typescript friendly library for seamless communication between plugin and UI layers.
https://www.npmjs.com/package/figwire
Â
How does it work:
- For the work on the plugin side use imports from `figwire/plugin`, and for the work on the ui side use imports from `figwire/ui`Â
- On the one side you define the methods that will be available on the other side:
const pluginApi = defineApi({
greet: (name: string) => `Hello ${name}!`
});Â
-
Export the type for these definitions:
export type PluginAPIDefinition = typeof pluginApi;Â
- Provide the type for the client on the other side:
const pluginApiClient = client<PluginAPIDefinition>();Â
-
Use the methods using typescript suggestions:
const greeting = await pluginApiClient.greet('Johnny Jeep');
Â
And that’s it.
Â
It’s an early release, therefore I am open to suggestions.
Please let me know what you think!
Â
