Matter.Plugin

Defined in: src/core/Plugin.js:1

The Matter.Plugin module contains functions for registering and installing plugins on modules.

Methods

Matter.Plugin.dependencies

(module)

Object

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

Parameters

The module.

Returns

ObjectA dependency graph.

@ src/core/Plugin.js:179

Matter.Plugin.dependencyParse

(dependency)

Object

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

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

Returns

ObjectThe dependency parsed into its components.

@ src/core/Plugin.js:232

Matter.Plugin.isFor

(plugin, module)

Boolean

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

The plugin.

The module.

Returns

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

@ src/core/Plugin.js:94

Matter.Plugin.isPlugin

(obj)

Boolean

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

The obj to test.

Returns

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

@ src/core/Plugin.js:69

Matter.Plugin.isUsed

(module, name)

Boolean

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

Parameters

The module.

The plugin name.

Returns

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

@ src/core/Plugin.js:83

Matter.Plugin.register

(plugin)

Object

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

Parameters

The plugin to register.

Returns

ObjectThe plugin.

@ src/core/Plugin.js:17

Matter.Plugin.resolve

(dependency)

Object

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

The dependency.

Returns

ObjectThe plugin if resolved, otherwise undefined.

@ src/core/Plugin.js:48

Matter.Plugin.toString

(plugin)

String

Returns a pretty printed plugin name and version.

Parameters

The plugin.

Returns

StringPretty printed plugin name and version.

@ src/core/Plugin.js:59

Matter.Plugin.use

(module, [plugins=module.uses])

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.

Parameters

The module install plugins on.

  • [plugins=module.uses] Objectoptional

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

@ src/core/Plugin.js:108

Matter.Plugin.versionParse

(range)

Object

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
  • Exact version e.g. 1.2.3
  • Any version *

Parameters

The version string.

Returns

ObjectThe version range parsed into its components.

@ src/core/Plugin.js:261

Matter.Plugin.versionSatisfies

(version, range)

Boolean

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

The version string.

The range string.

Returns

Booleantrue if version satisfies range, otherwise false.

@ src/core/Plugin.js:302

Item Index

Methods