UNPKG

3.79 kBTypeScriptView Raw
1import { Disposable, Package } from '../index';
2
3/** Package manager for coordinating the lifecycle of Atom packages. */
4export interface PackageManager {
5 // Event Subscription
6 /** Invoke the given callback when all packages have been loaded. */
7 onDidLoadInitialPackages(callback: () => void): Disposable;
8
9 /** Invoke the given callback when all packages have been activated. */
10 onDidActivateInitialPackages(callback: () => void): Disposable;
11
12 /** Invoke the given callback when a package is activated. */
13 onDidActivatePackage(callback: (package: Package) => void): Disposable;
14
15 /** Invoke the given callback when a package is deactivated. */
16 onDidDeactivatePackage(callback: (package: Package) => void): Disposable;
17
18 /** Invoke the given callback when a package is loaded. */
19 onDidLoadPackage(callback: (package: Package) => void): Disposable;
20
21 /** Invoke the given callback when a package is unloaded. */
22 onDidUnloadPackage(callback: (package: Package) => void): Disposable;
23
24 /** Undocumented: invoke the given callback when an activation hook is triggered */
25 onDidTriggerActivationHook(hook: string, callback: () => void): Disposable;
26
27 // Package System Data
28 /** Get the path to the apm command. */
29 getApmPath(): string;
30
31 /** Get the paths being used to look for packages. */
32 getPackageDirPaths(): string[];
33
34 // General Package Data
35 /** Resolve the given package name to a path on disk. */
36 resolvePackagePath(name: string): string | undefined;
37
38 /** Is the package with the given name bundled with Atom? */
39 isBundledPackage(name: string): boolean;
40
41 // Enabling and Disabling Packages
42 /** Enable the package with the given name. */
43 enablePackage(name: string): Package | undefined;
44
45 /** Disable the package with the given name. */
46 disablePackage(name: string): Package | undefined;
47
48 /** Is the package with the given name disabled? */
49 isPackageDisabled(name: string): boolean;
50
51 // Accessing Active Packages
52 /** Get an Array of all the active Packages. */
53 getActivePackages(): Package[];
54
55 /** Get the active Package with the given name. */
56 getActivePackage(name: string): Package | undefined;
57
58 /** Is the Package with the given name active? */
59 isPackageActive(name: string): boolean;
60
61 /** Returns a boolean indicating whether package activation has occurred. */
62 hasActivatedInitialPackages(): boolean;
63
64 // Accessing Loaded Packages
65 /** Get an Array of all the loaded Packages. */
66 getLoadedPackages(): Package[];
67
68 /** Get the loaded Package with the given name. */
69 getLoadedPackage(name: string): Package | undefined;
70
71 /** Is the package with the given name loaded? */
72 isPackageLoaded(name: string): boolean;
73
74 /** Returns a boolean indicating whether package loading has occurred. */
75 hasLoadedInitialPackages(): boolean;
76
77 // Accessing Available Packages
78 /** Returns an Array of strings of all the available package paths. */
79 getAvailablePackagePaths(): string[];
80
81 /** Returns an Array of strings of all the available package names. */
82 getAvailablePackageNames(): string[];
83
84 /** Returns an Array of strings of all the available package metadata. */
85 getAvailablePackageMetadata(): string[];
86
87 /** Activate a single package by name or path. */
88 activatePackage(nameOrPath: string): Promise<Package>;
89
90 /** Deactivate a single package by name or path. */
91 deactivatePackage(nameOrPath: string, suppressSerialization?: boolean): Promise<void>;
92
93 /** Triggers the given package activation hook. */
94 triggerActivationHook(hook: string): void;
95
96 /** Trigger all queued activation hooks immediately. */
97 triggerDeferredActivationHooks(): void;
98}