# 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:configurator
- 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 71

##### 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 283

##### 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 113

##### Returns:

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

Type
  object

#### (inner) getNamedThemePath(themeName) → {string|boolean}

Takes a named theme and validates that the theme name exists, then returns the path to that theme.

##### Parameters:

Name | Type | Description
--- | --- | ---
`themeName` | string | The name of the theme that a path should be returned for.

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

##### Returns:

The path of the theme, if it exists, or false if it does not.

Type
  string | boolean

#### (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 225

##### 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) getNamedThemes() → {array.<string>}

Gets the names of the themes installed in the resources/themes folder.

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

##### Returns:

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

Type
  array.<string>

#### (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 170

##### Returns:

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

Type
  array.<string>

#### (inner) initThemePathData() → {object}

Scans the themes folder and determines all of the available themes, their paths and saves that data to the D-data structure.

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

##### Returns:

The JSON object that contains all of the theme names and theme paths.

Type
  object

#### (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 261

##### Returns:

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

Type
  object