Package class structure refactor
Refactor wasm wrapper and plugin classes and add support for WrapPackage
IWrapper
This is an instance of a wrapper (plugin or wasm) In the case of plugins it has state, this could be true of wasm in the future as well
interface IWrapper {
package: WrapPackage;
invoke(options: InvokeOptions<Uri>, client: Client): Promise<InvokeResult<unknown>>;
}
IWrapPackage
This is the representation of a Wrapper's Build Artifacts (wrap package)
All methods return promises, so the package does not need to live in memory for there to be in instance of it
It is responsible for knowing how to create an instance of a wrapper (IWrapper)
The createWrapper method takes a client and uris used in resolution (e.g. ["ens/test.eth", "ipfs/Qmsdas"])
because those two things are needed to get the appropriate environment variables for the wrapper.
interface IWrapPackage {
getManifest(): Promise<WrapManifest>;
getAbi(): Promise<WrapAbi>;
createWrapper(client: Client, uris: Uri[]): Promise<IWrapper>;
}
IWasmPackage
This is the wasm version of IWrapPackage.
It has an additional method getWasmModule because wasm wrappers have a wasm module.
interface IWasmPackage extends IWrapPackage {
getWasmModule(): Promise<ArrayBuffer>;
}
IPluginPackage
This is the plugin version of IWrapPackage.
interface IPluginPackage extends IWrapPackage {
}
IInterfacePackage
This is the interface version of IWrapPackage.
Not sure hot the createWrapper method would work for this package.
interface IInterfacePackage extends IWrapPackage {
}
WasmPackage
This is a base implementation of the IWasmPackage.
You only need to pass in a IWasmPackageReader in the constructor and it will create a IWasmPackage.
The methods are not implemented in this example, but in reality they would be. They all depend on this.reader
class WasmPackage implements IWasmPackage {
constructor(public readonly reader: IWasmPackageReader) {
}
getManifest(): Promise<WrapManifest>;
getAbi(): Promise<WrapAbi>;
getWasmModule(): Promise<ArrayBuffer>;
createWrapper(client: Client, uris: Uri[]): Promise<Wrapper>;
}
IWasmPackageReader
This is a service that can fetch files for a single wasm wrapper.
interface IWasmPackageReader {
getFile(options: GetFileOptions): Promise<ArrayBuffer | undefined>;
}
Blocked by:
- [ ] #1102
Closed by: https://github.com/polywrap/toolchain/pull/1169