Skip to main content

Marshal API

Marshal has a few methods and properties open to let you manage your plugins or extends manager itself.

Methods

addScope()

Manually add new scoped variable:

marshal.addScope('version', '1.0.0');

asset()

Retrieve path to the asset based on the module.

marshal.asset(pluginInstance, 'folder/image.png')

get()

Retrieve instance by their constraint name.

marshal.get<Marshal>('boardmeister/marshal')

getMappedInstance()

Retrieve instance registration configuration by passing the module.

marshal.getMappedInstance(pluginInstance)

getModuleConstraint()

Retrieve instance constraint by passing the registration config.

marshal.getMappedInstance({
entry: {
//...
namespace: 'boardmeister',
name: 'marshal'
},
//...
})

getResourceUrl()

Retrieve path to the resource based on the module.

marshal.getResourceUrl(pluginInstance, 'component/label.js')

import()

Returns a promise which imports components from the passed source but with set scoped variables. This is basically import but with injected variables. Useful when lazy loading components.

It accepts two arguments:

  • path to the resource
  • additional object to be included as a scoped variables
await marshal.import(marshal.getResourceUrl(pluginInstance, 'component/userDetails.js'), {
userId: 1234,
})

load()

Loads all registered plugins.

await marshal.load()

register()

Register new plugin. Read more

marshal.register({
entry: {
source: 'http://cdn.boardmeister.com/plugin/boardmeister/menu-manager',
namespace: 'boardmeister',
name: 'menu-manager',
version: '1.0.0',
},
type: 'module',
})

Properties

instanceMap

instanceMap is a WeakMap of initialized module to their registration config.


loaded

loaded property holds all loaded and initialized plugins.


registered

registered property holds all registered and not loaded plugins.


scope

scope holds all scoped objects.


tagMap

tagMap maps tags to related plugins.


static version

Marshal.version holds the version of the manager.