Confirmed users
471
edits
(→JEP 106 - Registered Jetpack URLs: added bug ticket) |
(update with current plan) |
||
Line 70: | Line 70: | ||
* When an exception occurs and we need put a "filename" property onto the exception object, we can use <tt>jetpack://$JETPACKID/jsfilename</tt> for debugging purposes. It would not necessarily be possible to paste this into the addressbar and see the source code in question, though (this sounds useful, but I think it's also important to allow add-ons to keep their resources private, so maybe only allow this to work in a debug console of some sort). It might be best for these URLs to have a different protocol, maybe <tt>jetpack-exception://</tt>, to distinguish it from the URLs managed by the "publisher" feature. | * When an exception occurs and we need put a "filename" property onto the exception object, we can use <tt>jetpack://$JETPACKID/jsfilename</tt> for debugging purposes. It would not necessarily be possible to paste this into the addressbar and see the source code in question, though (this sounds useful, but I think it's also important to allow add-ons to keep their resources private, so maybe only allow this to work in a debug console of some sort). It might be best for these URLs to have a different protocol, maybe <tt>jetpack-exception://</tt>, to distinguish it from the URLs managed by the "publisher" feature. | ||
--[[User:Warner|Brian Warner]] 06:28, 16 February 2010 (UTC) | --[[User:Warner|Brian Warner]] 06:28, 16 February 2010 (UTC) | ||
Our current plan: | |||
* The Jetpack ID will be made available to add-ons through the "self" package: | |||
var my_id = require("self").id; | |||
* The add-on package's `data` directory will contain the bundled resources. So if the main add-on code lives in PKGROOT/lib/main.js , a typical resource would live in PKGROOT/data/icon.png | |||
* The "self" package has a `data` property which provides access to these resources: | |||
var data = require("self").data; | |||
var text = data.load("foo.txt"); // contents of PKGROOT/data/foo.txt | |||
var icon_url = data.url("icon.png"); | |||
* The URL method will return a URL instance that can be used to load the given resource. This URL can only be used by content frames opened by the same package which provided the resource: it does not provide a way for add-ons to publish data to anyone else (we'll offer some other mechanism for that in the future). | |||
* We expect the URL to look like `resource://jetpack/$JID/main.html`, but the actual syntax is opaque and private: add-on code should not depend upon the details. The only promise made by `data.url()` is that relative links should work correctly: PKGROOT/data/page.html can reference PKGROOT/data/image.png with a normal `<img src="image.png"/>` tag. | |||
* An NSIContentPolicy object will be used to enforce the non-sharedness of these resource URLs. This may not be enforced right away, but eventually it will. | |||
--[[User:Warner|Brian Warner]] 22:49, 9 April 2010 (UTC) |