# Module: themeBroker

Contains all the functions necessary to load and unload debugging themes.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - brokers/themeBroker.js, line 1

### Requires

- module:ruleBroker
- module:chiefConfiguration
- module:chiefData
- module:chiefTheme
- module:loggers
- module:data
- @haystacks/constants
- path

### Methods

#### (inner) addThemeData(themeData, contextName) → {boolean}

Merges application and plugin defined theme data paths with the system defined theme paths.

##### Parameters:

Name | Type | Description
--- | --- | ---
`themeData` | object | A JSON object that contains the theme data for either the application or the current plugin.
`contextName` | string | The context name where the theme data is coming from. Ex: Application, Plugin:

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 88

##### Returns:

True or False to indicate if the merge was successful or not.

Type
  boolean

#### (inner) applyTheme(themeData) → {boolean}

Takes theme data and applies it to the currently loaded debug configuration data set in the D-Data Structure configuration.debugSettings data hive.

##### Parameters:

Name | Type | Description
--- | --- | ---
`themeData` | object | All the theme debug configuration settings data that control the debug log theme colors.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 218

##### Returns:

True or False to indicate if the theme data was applied successfully or not.

Type
  boolean

#### (inner) generateThemeDataFromPath(themesRootPath) → {object}

Takes a theme root path and scans the sub-folders that it contains and converts those to theme names, then builds a JSON data object with those names and also generates paths for each one based on the input themes root path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`themesRootPath` | string | The root path that should be used when building the JSON object with the themes meta-data.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 49

##### Returns:

A JSON object that contains all of the theme names and theme paths from the input theme root path.

Type
  object

#### (inner) getNamedThemePathFromRootPath(themeName, themesRootPath) → {string|boolean}

##### Parameters:

Name | Type | Description
--- | --- | ---
`themeName` | string | The name of the theme that a path should be returned for.
`themesRootPath` | string | The root path that should be used when searching for the named theme.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 160

##### Returns:

The path of the theme relative to the input root path it if exists, or false if it does not.

Type
  string | boolean

#### (inner) getNamedThemesFromRootPath(themesRootPath) → {array.<string>}

Gets the names of the themes installed in the specified themes root path folder.

##### Parameters:

Name | Type | Description
--- | --- | ---
`themesRootPath` | string | The root path that should be used when searching for a list of themes folders.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 138

##### Returns:

The list of names for the themes that are currently installed.

Type
  array.<string>

#### (inner) initThemeData() → {void}

Initializes the theme data object on the D-data structure.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 35

##### Returns:

Type
  void

#### (inner) loadTheme(themePath) → {object}

Takes a theme path and loads all the theme data debug configuration settings for that theme.

##### Parameters:

Name | Type | Description
--- | --- | ---
`themePath` | string | The fully qualified path to the theme debug configuration settings.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 196

##### Returns:

All of the debug configuration data for a specified theme path.

Type
  object

#### (inner) removePluginThemeData(pluginName) → {boolean}

Parses through the theme data and finds the theme data associated with the named plugin. Then removes that data shredding it from existence at the edge of a black hole.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginName` | string | The name of the plugin that should have its theme data removed from the D-data structure.

Author:
  - Seth Hollingsead
Source:
  - brokers/themeBroker.js, line 239

##### Returns:

True or False to indicate if the removal of the data was completed successfully or not.

Type
  boolean