import type { IServiceScope } from './IServiceScope'; import type ServiceScope from './ServiceScope'; /** * This is a callback that is used by ServiceKey.createCustom(). * @public */ export type ServiceCreator = ((serviceScope: IServiceScope) => T) | ((serviceScope: ServiceScope) => T); /** * This is a constructor definition for the Service isntance. * @public */ export type ServiceClassConstructor = (new (serviceScope: IServiceScope) => T) | (new (serviceScope: ServiceScope) => T); /** * This is a type definition for the Service. * @public */ export type ServiceClass = { new (serviceScope: IServiceScope): T; } | { new (serviceScope: ServiceScope): T; }; /** * The ServiceKey is a lookup key that is used when calling {@link ServiceScope.consume} * to fetch a dependency. * * @remarks * Every service key also provides a default implementation of the dependency, which will * be automatically created in the root scope if the dependency is not found. Providing a default * implementation ensures that new dependencies can be safely introduced without inadvertently * breaking components that are loaded by an older host that does not provide the new dependency. * * @public */ export interface IServiceKey { /** * A unique identifier for this service key. * * @remarks * This identifier is an automatically generated string that will be unique for the lifetime * of the page. Callers should not make assumptions about the formatting of this string. It is * currently based on a global counter, but this may change in the future. * * The ServiceScope uses this identifier internally as a dictionary key for finding services. * The ServiceKey is meant to be unique, even if multiple instances of the same library are * loaded on the same page, even if the same name was passed to ServiceKey.create(). * This is because each call to ServiceKey.create() could potentially provide a different * defaultCreator implementation, whereas one of the design goals of ServiceScope is that * the order in which libraries are loaded should never affect the resulting tree of scopes. */ readonly id: string; /** * A flag that indicates whether this service key is a root service. * * @internal */ readonly _isRootService: boolean; /** * The name of the service. * * @remarks * This name is used for logging and diagnostic purposes only. To make it unique, the * recommended convention is the package name, followed by a period, followed by the * class or interface name. * * The system does not assume that this string is unique. Instead, the {@link ServiceKey.id} * is used wherever a lookup key is needed. */ readonly name: string; /** * A callback function that constructs the default instance of this service. */ readonly defaultCreator: ServiceCreator; } //# sourceMappingURL=IServiceKey.d.ts.map