1 | import type { Profile } from '@remixproject/plugin-utils';
|
2 | import { Plugin } from "./abstract";
|
3 | export declare type BasePluginManager = {
|
4 | getProfile(name: string): Promise<Profile>;
|
5 | updateProfile(profile: Partial<Profile>): Promise<any>;
|
6 | activatePlugin(name: string): Promise<any>;
|
7 | deactivatePlugin(name: string): Promise<any>;
|
8 | isActive(name: string): Promise<boolean>;
|
9 | canCall(from: Profile, to: Profile, method: string): Promise<boolean>;
|
10 | toggleActive(name: string): any;
|
11 | addProfile(profiles: Partial<Profile> | Partial<Profile>[]): any;
|
12 | canActivatePlugin(from: Profile, to: Profile, method?: string): Promise<boolean>;
|
13 | canDeactivatePlugin(from: Profile, to: Profile): Promise<boolean>;
|
14 | } & Plugin;
|
15 | interface ManagerProfile extends Profile {
|
16 | name: 'manager';
|
17 | }
|
18 | export declare class PluginManager extends Plugin implements BasePluginManager {
|
19 | protected profiles: Record<string, Profile>;
|
20 | protected actives: string[];
|
21 | protected onPluginActivated?(profile: Profile): any;
|
22 | protected onPluginDeactivated?(profile: Profile): any;
|
23 | protected onProfileAdded?(profile: Profile): any;
|
24 | constructor(profile?: ManagerProfile);
|
25 | /** Return the name of the caller. If no request provided, this mean that the method has been called from the IDE so we use "manager" */
|
26 | get requestFrom(): string;
|
27 | /** Run engine activation. Implemented by Engine */
|
28 | private engineActivatePlugin;
|
29 | /** Run engine deactivation. Implemented by Engine */
|
30 | private engineDeactivatePlugin;
|
31 | /**
|
32 | * Get the profile if it's registered.
|
33 | * @param name The name of the plugin
|
34 | * @note This method can be overrided
|
35 | */
|
36 | getProfile(name: string): Promise<Profile<any>>;
|
37 | /** Get all the profiles of the manager */
|
38 | getProfiles(): Profile<any>[];
|
39 | /** Get all active profiles of the manager */
|
40 | getActiveProfiles(): Profile<any>[];
|
41 | /**
|
42 | * Update the profile of the plugin
|
43 | * @param profile The Updated version of the plugin
|
44 | * @note Only the caller plugin should be able to update its profile
|
45 | */
|
46 | updateProfile(to: Partial<Profile>): Promise<void>;
|
47 | /**
|
48 | * Add a profile to the list of profile
|
49 | * @param profile The profile to add
|
50 | * @note This method should only be used by the engine
|
51 | */
|
52 | addProfile(profiles: Profile | Profile[]): void | void[];
|
53 | /**
|
54 | * Verify if a plugin is currently active
|
55 | * @param name Name of the plugin
|
56 | */
|
57 | isActive(name: string): Promise<boolean>;
|
58 | /**
|
59 | * Check if caller can activate plugin and activate it if authorized
|
60 | * @param name The name of the plugin to activate
|
61 | */
|
62 | activatePlugin(names: string | string[]): Promise<unknown>;
|
63 | /**
|
64 | * Check if caller can deactivate plugin and deactivate it if authorized
|
65 | * @param name The name of the plugin to activate
|
66 | */
|
67 | deactivatePlugin(names: string | string[]): Promise<unknown>;
|
68 | /**
|
69 | * Activate or deactivate by bypassing permission
|
70 | * @param name The name of the plugin to activate
|
71 | * @note This method should ONLY be used by the IDE
|
72 | */
|
73 | toggleActive(names: string | string[]): Promise<void | void[]>;
|
74 | /**
|
75 | * Check if a plugin can activate another
|
76 | * @param from Profile of the caller plugin
|
77 | * @param to Profile of the target plugin
|
78 | * @note This method should be overrided
|
79 | */
|
80 | canActivatePlugin(from: Profile, to: Profile): Promise<boolean>;
|
81 | /**
|
82 | * Check if a plugin can deactivate another
|
83 | * @param from Profile of the caller plugin
|
84 | * @param to Profile of the target plugin
|
85 | * @note This method should be overrided
|
86 | */
|
87 | canDeactivatePlugin(from: Profile, to: Profile): Promise<boolean>;
|
88 | /**
|
89 | * Check if a plugin can call a method of another
|
90 | * @param from Profile of the caller plugin
|
91 | * @param to Profile of the target plugin
|
92 | * @param method Method targetted by the caller
|
93 | * @param message Method provided by the targetted method plugin
|
94 | */
|
95 | canCall(from: Profile, to: Profile, method: string, message?: string): Promise<boolean>;
|
96 | /**
|
97 | * Check if a plugin can update profile of another one
|
98 | * @param from Profile of the caller plugin
|
99 | * @param to Updates on the profile of the target plugin
|
100 | * @note This method can be overrided
|
101 | */
|
102 | canUpdateProfile(from: Profile, to: Partial<Profile>): Promise<boolean>;
|
103 | }
|
104 | export {};
|