DependencyLoader

core. DependencyLoader

Handles the loading of Adapt authoring tool module dependencies.

Constructor

new DependencyLoader(app)

Description:
  • Creates a new DependencyLoader instance
Source:
Parameters:
Name Type Description
app App The main app instance

Members

app :App

Description:
  • Reference to the main app
Source:
Reference to the main app
Type:
  • App

configs :Object.<string, Object>

Description:
  • Key/value store of all the Adapt dependencies' configs. Note this includes dependencies which are not loaded as Adapt modules (i.e. `module: false`).
Source:
Key/value store of all the Adapt dependencies' configs. Note this includes dependencies which are not loaded as Adapt modules (i.e. `module: false`).
Type:
  • Object.<string, Object>

configsLoadedHook :Hook

Description:
  • Hook called once all module configs are loaded
Source:
Hook called once all module configs are loaded
Type:
  • Hook

failedModules :Array.<string>

Description:
  • List of module names which have failed to load
Source:
List of module names which have failed to load
Type:
  • Array.<string>

instances :Object.<string, Object>

Description:
  • Map of module names to their loaded instances
Source:
Map of module names to their loaded instances
Type:
  • Object.<string, Object>

moduleLoadedHook :Hook

Description:
  • Hook for individual module load
Source:
Hook for individual module load
Type:
  • Hook

name :string

Description:
  • Name of the class (convenience function to stay consistent with other classes)
Source:
Name of the class (convenience function to stay consistent with other classes)
Type:
  • string

peerDependencies :Object.<string, Array.<string>>

Description:
  • Map of module names to arrays of modules that depend on them as peer dependencies
Source:
Map of module names to arrays of modules that depend on them as peer dependencies
Type:
  • Object.<string, Array.<string>>

Methods

(async) loadConfigs() → {Promise.<void>}

Description:
  • Loads configuration files for all Adapt dependencies found in node_modules.
Source:
Returns:
Type
Promise.<void>

(async) loadModule(modName) → {Promise.<Object>}

Description:
  • Loads a single Adapt module by dynamically importing it, instantiating it, and waiting for its onReady promise. Should not need to be called directly.
Source:
Parameters:
Name Type Description
modName string Name of the module to load (e.g., 'adapt-authoring-core')
Throws:
When module already exists, is in an unknown format or cannot be initialised (or initialisation exceeds 60 second timeout)
Type
Error
Returns:
Resolves with module instance when module.onReady completes
Type
Promise.<Object>

(async) loadModuleConfig(modDir) → {Promise.<Object>}

Description:
  • Loads the relevant configuration files for an Adapt module by reading and merging package.json and adapt.json
Source:
Parameters:
Name Type Description
modDir string Absolute path to the module directory
Returns:
Resolves with configuration object
Type
Promise.<Object>

(async) loadModules(modulesopt) → {Promise.<void>}

Description:
  • Loads Adapt modules. If no list is provided, loads all configured dependencies.
Source:
Parameters:
Name Type Attributes Description
modules Array.<string> <optional>
Module names to load (defaults to all dependencies)
Throws:
When any module throws a fatal error (error.isFatal or error.cause.isFatal)
Type
Error
Returns:
Resolves when all modules have loaded or failed
Type
Promise.<void>

log(…args)

Description:
  • Logs a message using the app logger
Source:
Parameters:
Name Type Attributes Description
args * <repeatable>
Arguments to be logged

logProgress(instance)

Description:
  • Logs load progress
Source:
Parameters:
Name Type Description
instance AbstractModule The last loaded instance

(async) waitForModule(modName) → {Promise.<Object>}

Description:
  • Waits for a single module to load. Returns the instance (if loaded), or hooks into moduleLoadedHook to wait for it.
Source:
Parameters:
Name Type Description
modName string Name of module to wait for (accepts short names without 'adapt-authoring-' prefix)
Throws:
When module is missing from configs or has failed to load
Type
Error
Returns:
Resolves with module instance when module.onReady completes
Type
Promise.<Object>