490
) {
491
}
493
>
494
>
export class ExtensionPointContribution<T> {
495
>
readonly description: IExtensionDescription;
496
>
readonly value: T;
497
>
498
>
constructor(description: IExtensionDescription, value: T) {
499
this.description = description;
500
this.value = value;
501
}
503
>
504
>
export interface IWillActivateEvent {
505
>
readonly event: string;
506
>
readonly activation: Promise<void>;
507
>
readonly activationKind: ActivationKind;
508
>
}
509
>
510
>
export interface IResponsiveStateChangeEvent {
511
>
extensionHostKind: ExtensionHostKind;
512
>
isResponsive: boolean;
513
>
/**
514
>
* Return the inspect port or `0`. `0` means inspection is not possible.
515
>
*/
516
>
getInspectListener(tryEnableInspector: boolean): Promise<IExtensionInspectInfo | undefined>;
517
>
}
518
>
519
>
export const enum ActivationKind {
520
>
Normal = 0,
521
>
Immediate = 1
522
>
}
523
>
524
>
export interface WillStopExtensionHostsEvent {
525
>
526
>
/**
527
>
* A human readable reason for stopping the extension hosts
528
>
* that e.g. can be shown in a confirmation dialog to the
529
>
* user.
530
>
*/
531
>
readonly reason: string;
532
>
533
>
/**
534
>
* A flag to indicate if the operation was triggered automatically
535
>
*/
536
>
readonly auto: boolean;
537
>
538
>
/**
539
>
* Allows to veto the stopping of extension hosts. The veto can be a long running
540
>
* operation.
541
>
*
542
>
* @param reason a human readable reason for vetoing the extension host stop in case
543
>
* where the resolved `value: true`.
544
>
*/
545
>
veto(value: boolean | Promise<boolean>, reason: string): void;
546
>
}
547
>
548
>
export interface IExtensionService {
549
>
readonly _serviceBrand: undefined;
550
>
551
>
/**
552
>
* An event emitted when extensions are registered after their extension points got handled.
553
>
*
554
>
* This event will also fire on startup to signal the installed extensions.
555
>
*
556
>
* @returns the extensions that got registered
557
>
*/
558
>
readonly onDidRegisterExtensions: Event<void>;
559
>
560
>
/**
561
>
* @event
562
>
* Fired when extensions status changes.
563
>
* The event contains the ids of the extensions that have changed.
564
>
*/
565
>
readonly onDidChangeExtensionsStatus: Event<ExtensionIdentifier[]>;
566
>
567
>
/**
568
>
* Fired when the available extensions change (i.e. when extensions are added or removed).
569
>
*/
570
>
readonly onDidChangeExtensions: Event<{ readonly added: readonly IExtensionDescription[]; readonly removed: readonly IExtensionDescription[] }>;
571
>
572
>
/**
573
>
* All registered extensions.
574
>
* - List will be empty initially during workbench startup and will be filled with extensions as they are registered
575
>
* - Listen to `onDidChangeExtensions` event for any changes to the extensions list. It will change as extensions get registered or de-reigstered.
576
>
* - Listen to `onDidRegisterExtensions` event or wait for `whenInstalledExtensionsRegistered` promise to get the initial list of registered extensions.
577
>
*/
578
>
readonly extensions: readonly IExtensionDescription[];
579
>
580
>
/**
581
>
* An event that is fired when activation happens.
582
>
*/
583
>
readonly onWillActivateByEvent: Event<IWillActivateEvent>;
584
>
585
>
/**
586
>
* An event that is fired when an extension host changes its
587
>
* responsive-state.
588
>
*/
589
>
readonly onDidChangeResponsiveChange: Event<IResponsiveStateChangeEvent>;
590
>
591
>
/**
592
>
* Fired before stop of extension hosts happens. Allows listeners to veto against the
593
>
* stop to prevent it from happening.
594
>
*/
595
>
readonly onWillStop: Event<WillStopExtensionHostsEvent>;
596
>
597
>
/**
598
>
* Send an activation event and activate interested extensions.
599
>
*
600
>
* This will wait for the normal startup of the extension host(s).
601
>
*
602
>
* In extraordinary circumstances, if the activation event needs to activate
603
>
* one or more extensions before the normal startup is finished, then you can use
604
>
* `ActivationKind.Immediate`. Please do not use this flag unless really necessary
605
>
* and you understand all consequences.
606
>
*/
607
>
activateByEvent(activationEvent: string, activationKind?: ActivationKind): Promise<void>;
608
>
609
>
/**
610
>
* Send an activation ID and activate interested extensions.
611
>
*
612
>
*/
613
>
activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void>;
614
>
615
>
/**
616
>
* Determine if `activateByEvent(activationEvent)` has resolved already.
617
>
*
618
>
* i.e. the activation event is finished and all interested extensions are already active.
619
>
*/
620
>
activationEventIsDone(activationEvent: string): boolean;
621
>
622
>
/**
623
>
* An promise that resolves when the installed extensions are registered after
624
>
* their extension points got handled.
625
>
*/
626
>
whenInstalledExtensionsRegistered(): Promise<boolean>;
627
>
628
>
/**
629
>
* Return a specific extension
630
>
* @param id An extension id
631
>
*/
632
>
getExtension(id: string): Promise<IExtensionDescription | undefined>;
633
>
634
>
/**
635
>
* Returns `true` if the given extension can be added. Otherwise `false`.
636
>
* @param extension An extension
637
>
*/
638
>
canAddExtension(extension: IExtensionDescription): boolean;
639
>
640
>
/**
641
>
* Returns `true` if the given extension can be removed. Otherwise `false`.
642
>
* @param extension An extension
643
>
*/
644
>
canRemoveExtension(extension: IExtensionDescription): boolean;
645
>
646
>
/**
647
>
* Read all contributions to an extension point.
648
>
*/
649
>
readExtensionPointContributions<T extends IExtensionContributions[keyof IExtensionContributions]>(extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]>;
650
>
651
>
/**
652
>
* Get information about extensions status.
653
>
*/
654
>
getExtensionsStatus(): { [id: string]: IExtensionsStatus };
655
>
656
>
/**
657
>
* Return the inspect ports (if inspection is possible) for extension hosts of kind `extensionHostKind`.
658
>
*/
659
>
getInspectPorts(extensionHostKind: ExtensionHostKind, tryEnableInspector: boolean): Promise<IExtensionInspectInfo[]>;
660
>
661
>
/**
662
>
* Stops the extension hosts.
663
>
*
664
>
* @param reason a human readable reason for stopping the extension hosts. This maybe
665
>
* can be presented to the user when showing dialogs.
666
>
*
667
>
* @param auto indicates if the operation was triggered by an automatic action
668
>
*
669
>
* @returns a promise that resolves to `true` if the extension hosts were stopped, `false`
670
>
* if the operation was vetoed by listeners of the `onWillStop` event.
671
>
*/
672
>
stopExtensionHosts(reason: string, auto?: boolean): Promise<boolean>;
673
>
674
>
/**
675
>
* Starts the extension hosts. If updates are provided, the extension hosts are started with the given updates.
676
>
*/
677
>
startExtensionHosts(updates?: { readonly toAdd: readonly IExtension[]; readonly toRemove: readonly string[] }): Promise<void>;
678
>
679
>
/**
680
>
* Modify the environment of the remote extension host
681
>
* @param env New properties for the remote extension host
682
>
*/
683
>
setRemoteEnvironment(env: { [key: string]: string | null }): Promise<void>;
684
>
}
685
>
686
>
export interface IInternalExtensionService {
687
>
_activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void>;
688
>
_onWillActivateExtension(extensionId: ExtensionIdentifier): void;
689
>
_onDidActivateExtension(extensionId: ExtensionIdentifier, codeLoadingTime: number, activateCallTime: number, activateResolvedTime: number, activationReason: ExtensionActivationReason): void;
690
>
_onDidActivateExtensionError(extensionId: ExtensionIdentifier, error: Error): void;
691
>
_onExtensionRuntimeError(extensionId: ExtensionIdentifier, err: Error): void;
692
>
}
693
>
694
>
export interface ProfileSession {
695
>
stop(): Promise<IExtensionHostProfile>;
696
>
}
697
>
698
>
export function toExtension(extensionDescription: IExtensionDescription): IExtension {
699
return {
700
type: extensionDescription.isBuiltin ? ExtensionType.System : ExtensionType.User,