import { Plugin } from '@nuxt/types';
import { ProjectSettingsRegistry } from "~/registry/projectSettings";
import { ProjectViewRegistry } from "~/registry/projectViews";
import { TaskActionRegistry } from "~/registry/taskActions";
import { LanguageRegistry } from "~/registry/languages";

export interface Registries {
	projectSettings: ProjectSettingsRegistry,
	projectViews: ProjectViewRegistry,
	taskActions: TaskActionRegistry,
	languages: LanguageRegistry,
}

const plugin: Plugin = (context, inject) => {

	// Registry definition
	const registries: Registries = {
		projectSettings: new ProjectSettingsRegistry(context),
		projectViews: new ProjectViewRegistry(context),
		taskActions: new TaskActionRegistry(context),
		languages: new LanguageRegistry(context),
	};

	// TODO Temporary until extension system is implemented
	for(const registry of Object.values(registries)) {
		registry.complete();
	}

	inject('registries', registries);
};

export default plugin;