@ahqstore/plugin-api / Plugin
Class: Plugin
Defined in: index.ts:253
This is the global instance of an AHQStore Plugin
import { Plugin } from "@ahqstore/plugin-api"
(async() => {
const api = new Plugin(
{
capabilities: []
}
);
// Must call after creation
// AHQ Store has a timeout after which
// it'll otherwise terminate your plugin
await api.initialize();
})()Constructors
Constructor
new Plugin(
meta):Plugin
Defined in: index.ts:289
This abstracts away the complexities of the AHQStore Plugin api
This constructor also handles the IPC communication and gives you a quick way to community via async wrappers
Use registerSearchFn, registerAppFetchFn, registerAppAssetFetchFn, registerAppVersionFetchFn to register handlers for the capability
You must call initialize afterwards
Parameters
meta
Defines the metadata for your plugin
Returns
Plugin
Methods
fetch()
fetch(
data):Promise<HTTPOutput>
Defined in: index.ts:597
Performs an HTTP request like the fetch api
The maximum size of the body is 50MB
Note
- This function consumes the body and you don't get the array buffer back
Parameters
data
Please read the information at FetchOptions
Returns
Promise<HTTPOutput>
the HTTPOutput data type
getCapabilities()
getCapabilities():
Set<Capability>
Defined in: index.ts:454
Gets the capabilities that your worker plugin is registered with
This requires you to get the plugin initialized
Returns
Set<Capability>
A list of capabilities
getHostApi()
getHostApi():
number
Defined in: index.ts:467
Gets the api version that AHQ Store Supports
This requires you to get the plugin initialized
Returns
number
API Version as number
getState()
getState(
stateId):Promise<string>
Defined in: index.ts:509
Gets the state under the stateId specified
Parameters
stateId
string
ID (file of the state)
Returns
Promise<string>
The string data of the state
getTargetApi()
getTargetApi():
number
Defined in: index.ts:477
Gets the target api that the plugin is intended to work with.
Returns
number
API Version as number
getThemeData()
getThemeData():
Promise<ThemeData>
Defined in: index.ts:551
Gets the AHQ Store Theme Data
NOTE
The returned data does not automatically update with theme changes
Returns
Promise<ThemeData>
The theme data ThemeData
hasCapability()
hasCapability(
capability):boolean
Defined in: index.ts:750
Parameters
capability
Returns
boolean
True is the capability is present
initialize()
initialize():
Promise<void>
Defined in: index.ts:427
Initializes the AHQ Store Plugin
If you don't call it, the plugin manager will kill your process
Returns
Promise<void>
Throws
If it failed to initialize
injectCustomCss()
injectCustomCss(
css):Promise<void>
Defined in: index.ts:492
Injects the provided css into the client gui application
NOTE
This modifies the already injected css to the new css data
Please note the above
Parameters
css
string
The css string to inject
Returns
Promise<void>
on()
Call Signature
on(
event,handler):UnregisterFn
Defined in: index.ts:754
Parameters
event
"themeUpdate"
handler
(data) => void
Returns
Call Signature
on(
event,handler):UnregisterFn
Defined in: index.ts:755
Parameters
event
"commonStateUpdate"
handler
(data) => void
Returns
registerAppAssetFetchFn()
registerAppAssetFetchFn(
fn):void
Defined in: index.ts:738
Register a function and overrides the current function meant to provide application metadata
Parameters
fn
The fn itself
Returns
void
registerAppFetchFn()
registerAppFetchFn(
fn):void
Defined in: index.ts:716
Register a function and overrides the current function meant to provide application metadata
Parameters
fn
The fn itself
Returns
void
registerAppVersionFetchFn()
registerAppVersionFetchFn(
fn):void
Defined in: index.ts:727
Register a function and overrides the current function meant to provide application versions
Parameters
fn
The fn itself
Returns
void
registerSearchFn()
registerSearchFn(
fn):void
Defined in: index.ts:705
Register the search function and overrides the current search function if present
You can only register it if you have Capability.AppInstallationSource
Parameters
fn
The search fn itself
Returns
void
requestRestart()
requestRestart(
desc):Promise<void>
Defined in: index.ts:572
Requests the user to restart
NOTE
This does not guarantee restart
Parameters
desc
string = "A restart is required to apply custom theme data. Are you ready?"
Explain why you would like to restart (optional, a template is already provided)
Returns
Promise<void>
setState()
setState(
stateId,stateData):Promise<string>
Defined in: index.ts:527
Sets the state under the stateId specified
Parameters
stateId
string
ID (file of the state)
stateData
string
Data of the state to update it with
Returns
Promise<string>
The string data of the state
unsafeAddCustomOnMessage()
unsafeAddCustomOnMessage(
fn):void
Defined in: index.ts:641
Experimental
Add your own custom handler to the OnMessage
Parameters
fn
Returns
void
Deprecated
This is unsafe and hence marked deprecated This is unsafe and hence marked so
getInstance()
staticgetInstance():Plugin|undefined
Defined in: index.ts:693
Returns the single instance of the Plugin. If the instance does not exist, it returns nothing.
Returns
Plugin | undefined
The single Plugin instance.