Plugin Architecture
The architecture of a plugin wrapper's code is flexible. Still, there are some simple requirements and best practices that may guide its code structure.
#
Required ExportsA plugin must export a PluginFactory
to be used by the Polywrap Client.
A PluginFactory
is a function that returns a PluginPackageManifest
and a factory
method that generates an instance of the plugin.
#
TypeScript SupportThe Polywrap CLI's codegen
and build
commands will generate a wrap
folder containing useful types.
The generated types will save you time and energy.
You won't have to manually create or update your types every time you change your schema, and your code will have fewer bugs.
You can forget about boilerplate code and focus on your plugin's logic.
While the types are not strictly required, we recommend them as a best practice.
The generated types include:
Module
- An interface containing the methods declared in the plugin's schemaArgs_*
- An interface for each method, containing the method arguments declared in the schema- Custom Types - An interface for each custom type declared in the schema
manifest
- APluginPackageManifest
for the plugin (also useful for JavaScript developers!)