1 | import type { Profile } from '@remixproject/plugin-utils';
|
2 | import { Plugin, PluginOptions } from './abstract';
|
3 | export declare class Engine {
|
4 | private plugins;
|
5 | private events;
|
6 | private listeners;
|
7 | private eventMemory;
|
8 | private manager;
|
9 | onRegistration?(plugin: Plugin): void;
|
10 | /** Update the options of the plugin when being registered */
|
11 | setPluginOption?(profile: Profile): PluginOptions;
|
12 | /**
|
13 | * Broadcast an event to the plugin listening
|
14 | * @param emitter Plugin name that emits the event
|
15 | * @param event The name of the event
|
16 | * @param payload The content of the event
|
17 | */
|
18 | private broadcast;
|
19 | /**
|
20 | * Start listening on an event from another plugin
|
21 | * @param listener The name of the plugin that listen on the event
|
22 | * @param emitter The name of the plugin that emit the event
|
23 | * @param event The name of the event
|
24 | * @param cb Callback function to trigger when the event is trigger
|
25 | */
|
26 | private addListener;
|
27 | /**
|
28 | * Remove an event from the list of a listener's events
|
29 | * @param listener The name of the plugin that was listening on the event
|
30 | * @param emitter The name of the plugin that emitted the event
|
31 | * @param event The name of the event
|
32 | */
|
33 | private removeListener;
|
34 | /**
|
35 | * Create a listener that listen only once on an event
|
36 | * @param listener The name of the plugin that listen on the event
|
37 | * @param emitter The name of the plugin that emitted the event
|
38 | * @param event The name of the event
|
39 | * @param cb Callback function to trigger when event is triggered
|
40 | */
|
41 | private listenOnce;
|
42 | /**
|
43 | * Call a method of a plugin from another
|
44 | * @param caller The name of the plugin that calls the method
|
45 | * @param path The path of the plugin that manages the method
|
46 | * @param method The name of the method
|
47 | * @param payload The argument to pass to the method
|
48 | */
|
49 | private callMethod;
|
50 | /**
|
51 | * Create an object to easily access any registered plugin
|
52 | * @param name Name of the caller plugin
|
53 | * @note This method creates a snapshot at the time of activation
|
54 | */
|
55 | private createApp;
|
56 | /**
|
57 | * Activate a plugin by making its method and event available
|
58 | * @param name The name of the plugin
|
59 | * @note This method is trigger by the plugin manager when a plugin has been activated
|
60 | */
|
61 | private activatePlugin;
|
62 | /**
|
63 | * Deactivate a plugin by removing all its event listeners and making it inaccessible
|
64 | * @param name The name of the plugin
|
65 | * @note This method is trigger by the plugin manager when a plugin has been deactivated
|
66 | */
|
67 | private deactivatePlugin;
|
68 | /**
|
69 | * Update error message when trying to call a method when not activated
|
70 | * @param plugin The deactivated plugin to update the methods from
|
71 | */
|
72 | private updateErrorHandler;
|
73 | /**
|
74 | * Register a plugin to the engine and update the manager
|
75 | * @param plugin The plugin
|
76 | */
|
77 | register(plugins: Plugin | Plugin[]): string | string[];
|
78 | /** Register the manager */
|
79 | private registerManager;
|
80 | /** Remove plugin(s) from engine */
|
81 | remove(names: string | string[]): Promise<void> | Promise<void[]>;
|
82 | /**
|
83 | * Check is a name is already registered
|
84 | * @param name Name of the plugin
|
85 | */
|
86 | isRegistered(name: string): boolean;
|
87 | }
|