File size: 1,134 Bytes
f0634fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { Event } from '#/_base/event';
import type {
  FiberHandle,
  FiberProvideOptions,
  FiberState,
  ServiceClassRecipe,
  ServiceRecipe,
} from '#/_base/di/fiber';
import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation';
import type { ContributedFeatureService } from './featureServiceContribution';

export interface ManagedUnitInfo {
  readonly name: string;
  readonly state: FiberState;
  readonly uid: number | undefined;
  readonly meta: Record<string, unknown>;
}

export interface IFeatureManager {
  readonly _serviceBrand: undefined;

  provideUnit(recipe: ServiceRecipe, opts?: FiberProvideOptions): FiberHandle;
  provideUnit<T>(
    id: ServiceIdentifier<T>,
    recipe: ServiceClassRecipe,
    opts?: FiberProvideOptions,
  ): FiberHandle<T>;
  unprovideUnit(name: string): Promise<void>;
  updateUnit(name: string, config?: unknown): Promise<void>;

  units(): readonly ManagedUnitInfo[];
  contributedServices(): readonly ContributedFeatureService[];
  readonly onDidChangeUnits: Event<void>;
}

export const IFeatureManager = createDecorator<IFeatureManager>('featureManager');