export interface MosaicPlugin {
  /** Called when the plugin is loaded/reloaded */
  onLoad(): Promise<void>;

  /** Called before the plugin is unloaded during reload */
  onUnload(): Promise<void>;

  /** Plugin identifier for registry */
  readonly pluginName: string;
}

export function isMosaicPlugin(obj: unknown): obj is MosaicPlugin {
  return (
    typeof obj === 'object' &&
    obj !== null &&
    typeof (obj as MosaicPlugin).onLoad === 'function' &&
    typeof (obj as MosaicPlugin).onUnload === 'function' &&
    typeof (obj as MosaicPlugin).pluginName === 'string'
  );
}
