Mailspring/docs/PackageManager.html

605 lines
22 KiB
HTML

---
layout: docs
title: PackageManager
edit_url: "https://github.com/nylas/N1/blob/master/src/package-manager.coffee"
---
<h2>Summary</h2>
<div class="markdown-from-sourecode">
<p><p>Package manager for coordinating the lifecycle of Atom packages.</p>
<p>An instance of this class is always available as the <code>atom.packages</code> global.</p>
<p>Packages can be loaded, activated, and deactivated, and unloaded:</p>
<ul>
<li>Loading a package reads and parses the package&#39;s metadata and resources
such as keymaps, menus, stylesheets, etc.</li>
<li>Activating a package registers the loaded resources and calls <code>activate()</code>
on the package&#39;s main module.</li>
<li>Deactivating a package unregisters the package&#39;s resources and calls
<code>deactivate()</code> on the package&#39;s main module.</li>
<li>Unloading a package removes it completely from the package manager.</li>
</ul>
<p>Packages can be enabled/disabled via the <code>core.disabledPackages</code> config
settings and also by calling <code>enablePackage()/disablePackage()</code>.</p>
</p>
</div>
<ul>
<li><a href="#Event Subscription">Event Subscription</a></li>
<li><a href="#Package system data">Package system data</a></li>
<li><a href="#General package data">General package data</a></li>
<li><a href="#Enabling and disabling packages">Enabling and disabling packages</a></li>
<li><a href="#Accessing active packages">Accessing active packages</a></li>
<li><a href="#Accessing loaded packages">Accessing loaded packages</a></li>
<li><a href="#Accessing available packages">Accessing available packages</a></li>
</ul>
<h3>Instance Methods</h3>
<h4 id=onDidLoadInitialPackages class="function-name">
onDidLoadInitialPackages(<span class="args"><span class="arg">callback</span></span>) <a href="#onDidLoadInitialPackages" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Invoke the given callback when all packages have been loaded.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>callback</em>
</td>
<td class="markdown-from-sourecode">
<p><a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function'>Function</a></p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to unsubscribe.</p>
</td></tr>
</table>
<h4 id=onDidActivateInitialPackages class="function-name">
onDidActivateInitialPackages(<span class="args"><span class="arg">callback</span></span>) <a href="#onDidActivateInitialPackages" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Invoke the given callback when all packages have been activated.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>callback</em>
</td>
<td class="markdown-from-sourecode">
<p><a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function'>Function</a></p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to unsubscribe.</p>
</td></tr>
</table>
<h4 id=onDidActivatePackage class="function-name">
onDidActivatePackage(<span class="args"><span class="arg">callback</span></span>) <a href="#onDidActivatePackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Invoke the given callback when a package is activated.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>callback</em>
</td>
<td class="markdown-from-sourecode">
<p>A <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function'>Function</a> to be invoked when a package is activated.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to unsubscribe.</p>
</td></tr>
</table>
<h4 id=onDidDeactivatePackage class="function-name">
onDidDeactivatePackage(<span class="args"><span class="arg">callback</span></span>) <a href="#onDidDeactivatePackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Invoke the given callback when a package is deactivated.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>callback</em>
</td>
<td class="markdown-from-sourecode">
<p>A <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function'>Function</a> to be invoked when a package is deactivated.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to unsubscribe.</p>
</td></tr>
</table>
<h4 id=onDidLoadPackage class="function-name">
onDidLoadPackage(<span class="args"><span class="arg">callback</span></span>) <a href="#onDidLoadPackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Invoke the given callback when a package is loaded.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>callback</em>
</td>
<td class="markdown-from-sourecode">
<p>A <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function'>Function</a> to be invoked when a package is loaded.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to unsubscribe.</p>
</td></tr>
</table>
<h4 id=onDidUnloadPackage class="function-name">
onDidUnloadPackage(<span class="args"><span class="arg">callback</span></span>) <a href="#onDidUnloadPackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Invoke the given callback when a package is unloaded.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>callback</em>
</td>
<td class="markdown-from-sourecode">
<p>A <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/function'>Function</a> to be invoked when a package is unloaded.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to unsubscribe.</p>
</td></tr>
</table>
<h4 id=getApmPath class="function-name">
getApmPath(<span class="args"></span>) <a href="#getApmPath" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get the path to the apm command.</p>
<p>Return a <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> file path to apm. </p>
</p>
</div>
<h4 id=getPackageDirPaths class="function-name">
getPackageDirPaths(<span class="args"></span>) <a href="#getPackageDirPaths" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get the paths being used to look for packages.</p>
</p>
</div>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns an <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> directory paths.</p>
</td></tr>
</table>
<h4 id=resolvePackagePath class="function-name">
resolvePackagePath(<span class="args"><span class="arg">name</span></span>) <a href="#resolvePackagePath" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Resolve the given package name to a path on disk.</p>
<p>Return a <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> folder path or undefined if it could not be resolved. </p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<h4 id=isBundledPackage class="function-name">
isBundledPackage(<span class="args"><span class="arg">name</span></span>) <a href="#isBundledPackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Is the package with the given name bundled with Atom?</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean'>Boolean</a>.</p>
</td></tr>
</table>
<h4 id=enablePackage class="function-name">
enablePackage(<span class="args"></span>) <a href="#enablePackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Enable the package with the given name.</p>
</p>
</div>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns the {Package} that was enabled or null if it isn&#39;t loaded.</p>
</td></tr>
</table>
<h4 id=disablePackage class="function-name">
disablePackage(<span class="args"></span>) <a href="#disablePackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Disable the package with the given name.</p>
</p>
</div>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns the {Package} that was disabled or null if it isn&#39;t loaded.</p>
</td></tr>
</table>
<h4 id=isPackageDisabled class="function-name">
isPackageDisabled(<span class="args"><span class="arg">name</span></span>) <a href="#isPackageDisabled" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Is the package with the given name disabled?</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean'>Boolean</a>.</p>
</td></tr>
</table>
<h4 id=getActivePackages class="function-name">
getActivePackages(<span class="args"></span>) <a href="#getActivePackages" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get an <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of all the active {Package}s. </p>
</p>
</div>
<h4 id=getActivePackage class="function-name">
getActivePackage(<span class="args"><span class="arg">name</span></span>) <a href="#getActivePackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get the active {Package} with the given name.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Package} or .</p>
</td></tr>
</table>
<h4 id=isPackageActive class="function-name">
isPackageActive(<span class="args"><span class="arg">name</span></span>) <a href="#isPackageActive" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Is the {Package} with the given name active?</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean'>Boolean</a>.</p>
</td></tr>
</table>
<h4 id=getLoadedPackages class="function-name">
getLoadedPackages(<span class="args"></span>) <a href="#getLoadedPackages" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get an <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of all the loaded {Package}s </p>
</p>
</div>
<h4 id=getLoadedPackage class="function-name">
getLoadedPackage(<span class="args"><span class="arg">name</span></span>) <a href="#getLoadedPackage" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get the loaded {Package} with the given name.</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a {Package} or .</p>
</td></tr>
</table>
<h4 id=isPackageLoaded class="function-name">
isPackageLoaded(<span class="args"><span class="arg">name</span></span>) <a href="#isPackageLoaded" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Is the package with the given name loaded?</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>name</em>
</td>
<td class="markdown-from-sourecode">
<p>The <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a> package name.</p>
</td>
</tr>
</table>
<strong>Returns</strong>
<table class="arguments">
<tr>
<th>Return Values</th>
</tr>
<tr><td class="markdown-from-sourecode"><p>Returns a <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean'>Boolean</a>.</p>
</td></tr>
</table>
<h4 id=getAvailablePackagePaths class="function-name">
getAvailablePackagePaths(<span class="args"></span>) <a href="#getAvailablePackagePaths" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get an <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a>s of all the available package paths.</p>
<p>If the optional windowType is passed, it will only load packages
that declare that windowType in their package.json </p>
</p>
</div>
<h4 id=getAvailablePackageNames class="function-name">
getAvailablePackageNames(<span class="args"></span>) <a href="#getAvailablePackageNames" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get an <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a>s of all the available package names. </p>
</p>
</div>
<h4 id=getAvailablePackageMetadata class="function-name">
getAvailablePackageMetadata(<span class="args"></span>) <a href="#getAvailablePackageMetadata" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Get an <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'>String</a>s of all the available package metadata. </p>
</p>
</div>