remix-project icon indicating copy to clipboard operation
remix-project copied to clipboard

implement ts plugin api in core plugins

Open bunsenstraat opened this issue 2 years ago • 0 comments

Defining plugin plugins like this will actually allow type checking on calls, events etc. We can always make an internal RemixApi definition that allows internal plugins to call methods that we don't expose to the public webclient api. This is an example how to do it in the config plugin.

const profile: Profile = {
  name: 'config',
  displayName: 'Config',
  description: 'Config',
  methods: ['getAppParameter', 'setAppParameter']
}

interface configPluginApi {
  methods: {
    getAppParameter(name: string): void
    setAppParameter(name: string, value: any): void
  },
  events: StatusEvents
}

interface IInternalRemixApi extends IRemixApi {
  config: configPluginApi
}

type internalRemixApi = Readonly<IInternalRemixApi>;

export class ConfigPlugin extends Plugin<configPluginApi, internalRemixApi> implements MethodApi<configPluginApi> {
  constructor() {
    super(profile)
  }

bunsenstraat avatar Jul 08 '22 08:07 bunsenstraat