Constructor
new Base(pkgName, app)
Constructor.
| Name | Type | Description |
|---|---|---|
pkgName | string | Package name (the one in package.json) |
app | Object | App instance reference. Useful to call app method inside a plugin |
- Source
Members
dependencies :Array.<string>
Array of plugin dependencies. If your plugin depends on other plugins, you can specify their package names here e.g. ['bajo-config', 'bajo-cli'], NOT the plugin name/namespace
- Array.<string>
- Source
pkg :object
Package information from package.json. It will be automatically loaded by the framework during plugin initialization
- object
- Source
Methods
(async) dispose() → {Promise.<void>}
Dispose internal references.
- Source
- Type:
- Promise.<void>
(async) exit() → {Promise.<void>}
Upon app termination, this method will be called first. Mostly useful for system cleanup, delete temporary files, freeing resources etc.
- Source
- Type:
- Promise.<void>
(async) init() → {Promise.<void>}
Plugin initialization. This method will be called by the framework during boot process, after configuration is loaded.
- Source
- Type:
- Promise.<void>
(async) loadConfig() → {Promise.<void>}
Load plugin configuration. This method will be called by the framework during boot process.
- Source
- Type:
- Promise.<void>
(async) start() → {Promise.<void>}
Plugin start. This method will be called by the framework during boot process, after initialization. You still can modifiy your plugin's configuration here before it is deep frozen.
- Source
- Type:
- Promise.<void>
(async) stop() → {Promise.<void>}
Reserved for future use. This method will be called before plugin is stopped.
- Source
- Type:
- Promise.<void>
Type Definitions
package·json
To be recognized as a valid Bajo plugin, your package must be an ES6 module and have a package.json file with the additional bajo property and at least the type property set to plugin.
Other than type, you might need to specify these additional properties:
type:string, must be set topluginalias:string, the alias name of your plugin. Must be unique among all plugins. If it is missing, it will be generated by Bajo as camel-cased version of your plugin namespace.dependencies:array, if your plugin requires one or more other plugins to work, you need to put their package names in this arrayappletSupport:boolean, if your plugin doesn't support applet mode, set this tofalseto skipinit()andstart()of your plugin
Example:
{
"name": "my-plugin",
"version": "1.0.0",
"description": "My Bajo plugin",
"type": "module",
"main": "index.js",
"bajo": {
"type": "plugin",
"alias": "myplugin",
"dependencies": ["bajo-config", "bajo-cli"]
}
}
...
Note: The dot symbol in
package.jsonhas been replaced with·symbol because of JSDoc theme limitation
Warning: Do not confuse with your app's package.json specification, since this one is for plugin while the other is for app.
- Source