WPMInterface

WPMv2. WPMInterface

Internal WPM interface that is provided for every package that is installed via WPMv2. Is accessed as just wpm, when inside package code.

Methods

(static) onAllInstalled(callback)

Description:
  • Registers a callback to be called when all packages are installed. (When installing multiple packages at the same time.)
Source:
Example
wpm.onAllInstalled(()=>{
    //All packages are installed
});
Parameters:
Name Type Description
callback method

(static) onInstalled(callback)

Description:
  • Registers a callback to be called when this package is installed.
Source:
Example
wpm.onInstalled(()=>{
    //Package is now installed
});
Parameters:
Name Type Description
callback method

(static) onRemoved(callback)

Description:
  • Registers a callback to be called when this package is removed.
Source:
Example
wpm.onRemoved(({detail: packageName})=>{
    //Package is removed, packageName is provided for ease of access, will be same as the package this callback was registered from.
});
Parameters:
Name Type Description
callback method

(static) onRemovedAny(callback)

Description:
  • Registers a callback to be called when any package is removed.
Source:
Example
wpm.onRemovedAny(({detail: packageName})=>{
     //Package with name "packageName" has been removed
});
Parameters:
Name Type Description
callback method

(static) readMetadata(packageNameopt) → {json}

Description:
  • Reads metadata from the given package. If no packagename is given, metadata from the current package is read.
Source:
Example
let metadata = wpm.readMetadata();
Parameters:
Name Type Attributes Description
packageName string <optional>
The package to read metadata from
Returns:
Type
json

(static) requireExternal(urls) → {Promise.<void>}

Description:
  • Fetches and evaluates external javascript, or loads css. The server response header Content-Type will be used to determine if its a JS or CSS.
Source:
Example
await wpm.requireExternal("https://some.site.com/someScript.js");
//someScript.js has now been parsed and evaluated
Parameters:
Name Type Description
urls string | Array.<string> The URLs to the wanted JS, CSS
Returns:
- Resolves when all scripts/styles are fetched and evaluated/loaded
Type
Promise.<void>