Labs/Jetpack/Reboot/JEP/105: Difference between revisions

From MozillaWiki
< Labs‎ | Jetpack‎ | Reboot‎ | JEP
Jump to navigation Jump to search
 
(12 intermediate revisions by 3 users not shown)
Line 2: Line 2:


* Champion: Aza Raskin - aza@mozilla.com
* Champion: Aza Raskin - aza@mozilla.com
* Status: Accepted/In-Queue
* Peeps: Dietrich Ayala, Myk Melez
* Bug Ticket:
* Status: Implementation in Progress
* Bug Ticket: {{bug|549324}}
* Type: API
* Type: API
* Difficulty: 4


=== Proposal ===
=== Proposal ===


This JEP describes an API for handling the life-cycle of Jetpacks. In particular, it gives a Jetpack methods for registering event handlers for various install and uninstall states.
This JEP describes an API for handling the life-cycle of add-ons. In particular, it provides callback APIs for responding to various install and uninstall events.
 
In addition to the event handlers, it provides a more declarative format.
 
==== Events ====


All methods of an add-on introspecting and interacting with its environmental metas using the Jetpack API live in the "me" module.
==== API ====


The event handlers can be used as follows:
All methods involving introspection and interaction with an add-on's environment live in the "self" module.


<pre class="brush:js;">
<pre class="brush:js;">
me = require("me");
let self = require("self");
 
me.onFirstRun( function )
me.onInstall( function )
me.onUninstall( function )
</pre>
 
The <code>me.onFirstRun</code> gets called on the first run of an extension. If an extension is uninstalled and reinstalled (and the original data wasn't removed via a purge event) then the callback(s) passed to <code>onFirstRun</code> aren't called.
 
The rest of the event handlers should be self-explanatory.


Because Jetpacks are easily installed and uninstalled, the concepts of disabling/enabling an extension have been removed.
self.onInstall( function )


==== Declarative ====
self.onUpgrade( function )


The first-run experience is coded inside of <code>manifest</code>, the feature's manifest, which is (not un-coincidentally) where the settings are placed.
self.onUninstall( function )
 
<pre class="brush:js;">
var manifest = {
  firstRunPage: stringOrXml,
  uninstallPage: stringOrXml
}
</pre>
</pre>


=== Difficulty ===
The <code>onInstall</code> handler gets called on the first run of an extension. If an extension is uninstalled and reinstalled it gets called again (as the act of uninstalling removes all data associated with the add-on). <code>onUpgrade</code> get's called when an extension is upgraded.
 
Rating: '''Easy'''
 
=== Key Issues ===


Nothing is passed to the <code>onInstall</code> handler. An object which contains version info for the add-on prior to being updated gets passed to <code>onUpgrade</code>.


=== Dependencies & Requirements ===
The <code>onUninstall</code> handler is called when the add-on is uninstalled, giving add-ons the opportunity to clean up files, preferences, annotations <strike>or to flip the bird at the user on the way out</strike>.
* Dependent on JEP 106


'''Enable/Disable'''
There's no need for explicit support for enabling and disabling of add-ons here. When an add-on is disabled, any callbacks the code registered with require("unload").when() or require("unload").ensure() are automatically called, and when an addon is enabled, its code is re-evaluated and its exports.main() is called.


=== Internal Methods ===
=== Use Cases ===
* What methods, mechanisms, or resources does this provide internally within the Jetpack platform code.
 
 
=== Minimum Base API Methods ===
 
<pre class="brush:js">
me = require("me");
me.onInstall(function);
me.onUninstall(function);
</pre>


Everything else is sugar.
* Show a welcome page/tutorial when you install an add-on.
* Show a set of tooltips for the UI that an extension has added, in vivo to the interface.
* Give a survey when you uninstall an add-on.
* Clean up preferences, files, annotations, when you uninstall an add-on.

Latest revision as of 22:36, 6 May 2010

JEP 105 - Life-cycle

  • Champion: Aza Raskin - aza@mozilla.com
  • Peeps: Dietrich Ayala, Myk Melez
  • Status: Implementation in Progress
  • Bug Ticket: bug 549324
  • Type: API

Proposal

This JEP describes an API for handling the life-cycle of add-ons. In particular, it provides callback APIs for responding to various install and uninstall events.

API

All methods involving introspection and interaction with an add-on's environment live in the "self" module.

let self = require("self");

self.onInstall( function )

self.onUpgrade( function )

self.onUninstall( function )

The onInstall handler gets called on the first run of an extension. If an extension is uninstalled and reinstalled it gets called again (as the act of uninstalling removes all data associated with the add-on). onUpgrade get's called when an extension is upgraded.

Nothing is passed to the onInstall handler. An object which contains version info for the add-on prior to being updated gets passed to onUpgrade.

The onUninstall handler is called when the add-on is uninstalled, giving add-ons the opportunity to clean up files, preferences, annotations or to flip the bird at the user on the way out.

Enable/Disable There's no need for explicit support for enabling and disabling of add-ons here. When an add-on is disabled, any callbacks the code registered with require("unload").when() or require("unload").ensure() are automatically called, and when an addon is enabled, its code is re-evaluated and its exports.main() is called.

Use Cases

  • Show a welcome page/tutorial when you install an add-on.
  • Show a set of tooltips for the UI that an extension has added, in vivo to the interface.
  • Give a survey when you uninstall an add-on.
  • Clean up preferences, files, annotations, when you uninstall an add-on.