Skip to content

Overview / MadHatter

MadHatter

Properties

PropertyTypeDefault value
formsForm<Record<string, ZodType<any, ZodTypeDef, any>>, object>[][]
hooksPartial<Hooks>{}
onPluginsSyncCallback?() => Promise<void>undefined
toolsTool[][]

Accessors

installedPlugins

get installedPlugins(): object[]

Gets a copy of the installed plugins.

Returns

object[]

Methods

executeHook()

executeHook<T>(name, ...args): ReturnType<HookTypes[T]>

Executes a hook method by name with the provided arguments.

Type Parameters

Type ParameterDefault type
T extends keyof HookTypeskeyof HookTypes

Parameters

ParameterTypeDescription
nameTThe name of the hook to execute.
...argsParameters<HookTypes[T]>The arguments to pass to the hook function.

Returns

ReturnType<HookTypes[T]>

The result of executing the hook methods sequentially.


findPlugins()

findPlugins(): Promise<void>

Finds and installs plugins present in the plugins path.

Returns

Promise<void>


getPlugin()

getPlugin(id): undefined | Plugin<Record<string, ZodType<any, ZodTypeDef, any>>, object>

Gets a plugin by its ID.

Parameters

ParameterTypeDescription
idstringThe ID of the plugin to get.

Returns

undefined | Plugin<Record<string, ZodType<any, ZodTypeDef, any>>, object>


installPlugin()

installPlugin(path): Promise<Plugin<Record<string, ZodType<any, ZodTypeDef, any>>, object>>

Installs a plugin from the specified path.

Parameters

ParameterTypeDescription
pathstringThe path to the plugin.

Returns

Promise<Plugin<Record<string, ZodType<any, ZodTypeDef, any>>, object>>

The installed plugin.


reloadPlugin()

reloadPlugin(id): Promise<void>

Reloads a plugin by its ID.

Parameters

ParameterTypeDescription
idstringThe ID of the plugin to reload.

Returns

Promise<void>


removePlugin()

removePlugin(id): Promise<void>

Removes a plugin by its ID.

Parameters

ParameterTypeDescription
idstringThe ID of the plugin to remove.

Returns

Promise<void>


syncHooksAndProcedures()

syncHooksAndProcedures(): Promise<void>

Synchronizes hooks, tools and forms. It also sorts the hooks by priority.

Returns

Promise<void>


togglePlugin()

togglePlugin(id, state?, sync?): Promise<boolean>

Toggles a plugin's state and executes corresponding hooks.

Parameters

ParameterTypeDefault valueDescription
idstringundefinedThe ID of the plugin to toggle.
state?booleanundefinedThe state to set the plugin to. Default is undefined.
sync?booleantrueWhether to synchronize hooks and tools immediately. Default is true.

Returns

Promise<boolean>


getInstance()

static getInstance(): Promise<MadHatter>

Get the Mad Hatter instance

Returns

Promise<MadHatter>

The Mad Hatter class as a singleton

Released under the GPL-3.0 License.