import { PluginRegistry } from 'loop-plugin-sdk';
import { Store, Action } from 'redux';
import { GlobalState } from 'loop-plugin-sdk/loop/types/store';
import 'loop-plugin-sdk/window'
import manifest from './manifest';
import registerApp from './registerApp';

export default class Plugin {
  // @ts-ignore
  public store: Store;

  // @ts-ignore
  public registry: PluginRegistry

  public onStoreChanged: any;
  public uninitialize: any;

  public async initialize(registry: PluginRegistry, store: Store<GlobalState, Action<Record<string, unknown>>>) {
    this.store = store;
    this.registry = registry;

    await registerApp(this, registry, store)
  }
}

window.registerPlugin(manifest.id, new Plugin());
