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!