contains functions for registering and installing plugins on modules.

Hierarchy

  • default

Constructors

Properties

_registry: Record<string, IPlugin> = {}

Methods

  • Recursively finds all of a module's dependencies and returns a flat dependency graph.

    Parameters

    • m: Dependency

      The module.

    • Optional tracked: {
          [_: string]: string[];
      }
      • [_: string]: string[]

    Returns {
        [_: string]: string[];
    }

    A dependency graph.

    • [_: string]: string[]
  • Parses a dependency string into its components. The dependency is a string of the format 'module-name' or 'module-name@version'. See documentation for Plugin.versionParse for a description of the format. This function can also handle dependencies that are already resolved (e.g. a module object).

    Parameters

    • dependency: Dependency

      The dependency of the format 'module-name' or 'module-name@version'.

    Returns {
        name: string;
        range: string;
    }

    The dependency parsed into its components.

    • name: string
    • range: string
  • Returns true if plugin.for is applicable to module by comparing against module.name and module.version. If plugin.for is not specified then it is assumed to be applicable. The value of plugin.for is a string of the format 'module-name' or 'module-name@version'.

    Parameters

    • plugin: IPlugin

      The plugin.

    • m: {
          name?: string;
          [_: string]: any;
      }

      The module.

      • [_: string]: any
      • Optional name?: string

    Returns boolean

    true if plugin.for is applicable to module, otherwise false.

  • Returns true if the object meets the minimum standard to be considered a plugin. This means it must define the following properties:

    • name
    • version
    • install

    Parameters

    • obj: any

      The obj to test.

    Returns obj is IPlugin

    true if the object can be considered a plugin otherwise false.

  • Returns true if a plugin with the given name been installed on module.

    Type Parameters

    • T extends {
          used: string[];
      }

    Parameters

    • m: T

      The module.

    • name: string

      The plugin name.

    Returns boolean

    true if a plugin with the given name been installed on module, otherwise false.

  • Registers a plugin object so it can be resolved later by name.

    Type Parameters

    • T

    Parameters

    • plugin: T

      The plugin to register.

    Returns T

    The plugin.

  • Resolves a dependency to a plugin object from the registry if it exists. The dependency may contain a version, but only the name matters when resolving.

    Parameters

    • dependency: string

      The dependency.

    Returns IPlugin

    The plugin if resolved, otherwise undefined.

  • Returns a pretty printed plugin name and version.

    Parameters

    • plugin: string | IPlugin

      The plugin.

    Returns string

    Pretty printed plugin name and version.

  • Installs the plugins by calling plugin.install on each plugin specified in plugins if passed, otherwise module.uses. For installing plugins on Matter see the convenience function Matter.use. Plugins may be specified either by their name or a reference to the plugin object. Plugins themselves may specify further dependencies, but each plugin is installed only once. Order is important, a topological sort is performed to find the best resulting order of installation. This sorting attempts to satisfy every dependency's requested ordering, but may not be exact in all cases. This function logs the resulting status of each dependency in the console, along with any warnings.

    • A green tick ✅ indicates a dependency was resolved and installed.
    • An orange diamond 🔶 indicates a dependency was resolved but a warning was thrown for it or one if its dependencies.
    • A red cross ❌ indicates a dependency could not be resolved. Avoid calling this function multiple times on the same module unless you intend to manually control installation order.

    Type Parameters

    Parameters

    • m: {
          uses?: T[];
          [_: string]: any;
      }

      The module install plugins on.

      • [_: string]: any
      • Optional uses?: T[]
    • Optional plugins: T[]

      {} The plugins to install on module (optional, defaults to module.uses).

    Returns void

  • Parses a version string into its components. Versions are strictly of the format x.y.z (as in semver). Versions may optionally have a prerelease tag in the format x.y.z-alpha. Ranges are a strict subset of npm ranges. Only the following range types are supported:

    • Tilde ranges e.g. ~1.2.3
    • Caret ranges e.g. ^1.2.3
    • Greater than ranges e.g. >1.2.3
    • Greater than or equal ranges e.g. >=1.2.3
    • Exact version e.g. 1.2.3
    • Any version *

    Parameters

    • range: string

      The version string.

    Returns ParsedVersion

    The version range parsed into its components.

  • Returns true if version satisfies the given range. See documentation for Plugin.versionParse for a description of the format. If a version or range is not specified, then any version (*) is assumed to satisfy.

    Parameters

    • version: string

      The version string.

    • range: string

      The range string.

    Returns boolean

    true if version satisfies range, otherwise false.

Generated using TypeDoc