import { ModelHub, ModelServiceContribution } from '@eclipse-emfcloud/model-service';
import { ContributionProvider, Stopwatch } from '@theia/core';
import { ModelHubTracker, ModelHubTrackingSubscription } from '../common/model-hub-tracker';
import { ModelHubLifecycleContribution } from './model-hub-lifecycle-contribution';
/**
 * A mediator service that creates and manages instances of the
 * {@link ModelHub}, binding the application-defined
 * {@link ModelServiceContribution}s into them.
 * Clients will never have to interact with this service.
 */
export interface ModelHubManager<K = string> {
    /**
     * Gets the model hub for a given `context`. If no such hub yet
     * exists, it is created.
     *
     * @param context the model hub context that defines, in some application-specific way,
     *   the scope of the models managed in the hub
     * @returns the `context`'s model hub
     *
     * @see {@link provideModelHub}
     * @see {@link initializeContext}
     */
    getModelHub(context: string): ModelHub<K, string>;
    /**
     * Initializes the given model hub context.
     * If initialization already took place, this will be a no-op.
     *
     * @param context a model hub context to initialize
     * @returns a promise that resolves when the model hub is ready to use
     *  or rejects if initialization either fails or times out
     */
    initializeContext(context: string): Promise<ModelHub<K, string>>;
    /**
     * Provide a model hub for the given `context` that is asynchronously
     * initialized. If initialization fails (including by timeout), then
     * the resulting project will be rejected.
     */
    provideModelHub(context: string): Promise<ModelHub<K, string>>;
    /**
     * Destroys the model hub, if any, for the given `context`.
     * Should only be done for a `context` that is known no longer
     * to be legitimately usable.
     *
     * @param context a context no longer in use
     */
    disposeContext(context: string): void;
}
/** Service identifier for the Model Hub manager. */
export declare const ModelHubManager: unique symbol;
/**
 * Factory type for ModelServiceContributions. This Factory returns a new
 * list of contribution instances every time it is invoked, ensuring
 * that Contributions are not used in multiple contexts at the same time.
 */
export type ModelServiceContributionFactory<K = string> = () => ModelServiceContribution<K>[];
/**
 * Dependency injection symbol for ModelServiceContributionFactory.
 */
export declare const ModelServiceContributionFactory: unique symbol;
export declare class DefaultModelHubManager<K = string> implements ModelHubManager<K>, ModelHubTracker {
    protected modelServiceContributionFactory: ModelServiceContributionFactory;
    protected modelHubLifecycleContributions: ContributionProvider<ModelHubLifecycleContribution<K>>;
    protected stopwatch: Stopwatch | undefined;
    private readonly initializationTimeoutMs;
    private readonly modelHubs;
    private readonly trackingSubscriptions;
    private readonly defaultModelHubLifecycle;
    getModelHub(context: string): ModelHub<K, string>;
    provideModelHub(context: string): Promise<ModelHub<K, string>>;
    disposeContext(context: string): void;
    /**
     * Creates and initializes a new model hub for a given `context`.
     *
     * @param context the model hub context that defines, in some application-specific way, the scope of the models managed in the hub
     * @returns the `context`'s model hub
     */
    createModelHub(context: string): ModelHub<K, string>;
    initializeContext(context: string): Promise<ModelHub<K, string>>;
    private notifyModelHubCreated;
    private notifyModelHubDestroyed;
    trackModelHubs(): ModelHubTrackingSubscription;
    isModelHubAvailable(context: string): boolean;
}
//# sourceMappingURL=model-hub-manager.d.ts.map