import { ComponentId } from '../annotation/component'; import { Container } from '../container'; import { Prioritizeable } from '../utils/prioritizeable'; export const ProviderCreator = Symbol('ProviderCreator'); export const ComponentFilter = Symbol('ComponentFilter'); export const ComponentFilterRegistry = Symbol('ComponentFilterRegistry'); export const ComponentFilterContribution = Symbol('ComponentFilterContribution'); export interface Provider { get(recursive?: boolean): T[]; sortSync(getPriority?: Prioritizeable.GetPrioritySync, recursive?: boolean): T[]; sort(getPriority?: Prioritizeable.GetPriority , recursive?: boolean): Promise; } export interface ProviderCreator { create(id: ComponentId, container: Container): Provider; } /** * @param toTest Object that should be tested * @returns `true` if the object passes the test, `false` otherwise. */ export type ComponentFilter = (toTest: T) => boolean; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type ComponentType = ComponentId; export interface ComponentFilterRegistry { /** * Add filters to be applied for every type of component. */ addFilters(types: '*', filters: ComponentFilter[]): void; /** * Given a list of component types, register filters to apply. * @param types types for which to register the filters. */ addFilters(types: ComponentType[], filters: ComponentFilter[]): void; /** * Applies the filters for the given component type. Generic filters will be applied on any given type. * @param toFilter the elements to filter * @param type the component type for which potentially filters were registered * @returns the filtered elements */ applyFilters(toFilter: T[], type: ComponentType): T[] } /** * Register filters to remove contributions. */ export interface ComponentFilterContribution { /** * Use the registry to register your contribution filters. */ registerContributionFilters(registry: ComponentFilterRegistry): void; }