1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 11:08:09 +01:00

Move magical-non-bootstrappable manifest directives to config.json.

This commit is contained in:
Kris Maglione
2014-02-18 22:38:58 -08:00
parent e1cc311f7f
commit 8d6ea20cc4
3 changed files with 43 additions and 41 deletions

45
common/bootstrap.js vendored
View File

@@ -215,32 +215,28 @@ let JSMLoader = {
function init() { function init() {
debug("bootstrap: init"); debug("bootstrap: init");
let manifestURI = getURI("chrome.manifest"); let manifest = JSON.parse(httpGet(getURI("config.json"))
let manifest = httpGet(manifestURI) .responseText);
.responseText
.replace(/#(resource)#/g, "$1")
.replace(/^\s*|\s*$|#.*/g, "")
.replace(/^\s*\n/gm, "");
for each (let line in manifest.split("\n")) { if (!manifest.categories)
let fields = line.split(/\s+/); manifest.categories = [];
switch (fields[0]) {
case "category":
categoryManager.addCategoryEntry(fields[1], fields[2], fields[3], false, true);
categories.push([fields[1], fields[2]]);
break;
case "component":
components[fields[1]] = new FactoryProxy(getURI(fields[2]).spec, fields[1]);
break;
case "contract":
components[fields[2]].contractID = fields[1];
break;
case "resource": for (let [classID, { contract, path, category }] of Iterator(manifest.components || {})) {
moduleName = moduleName || fields[1]; components[classID] = new FactoryProxy(getURI(path).spec, classID, contract);
resources.push(fields[1]); if (category)
resourceProto.setSubstitution(fields[1], getURI(fields[2])); manifest.categories.push([category[0], category[1], contract]);
} }
for (let [category, id, value] of manifest.categories) {
categoryManager.addCategoryEntry(category, id, value,
false, true);
categories.push([category, id]);
}
for (let [pkg, path] in Iterator(manifest.resources || {})) {
moduleName = moduleName || pkg;
resources.push(pkg);
resourceProto.setSubstitution(pkg, getURI(path));
} }
JSMLoader.config = JSON.parse(httpGet("resource://dactyl-local/config.json").responseText); JSMLoader.config = JSON.parse(httpGet("resource://dactyl-local/config.json").responseText);
@@ -381,9 +377,10 @@ function startup(data, reason) {
* @param {string} url The URL of the module housing the real factory. * @param {string} url The URL of the module housing the real factory.
* @param {string} classID The CID of the class this factory represents. * @param {string} classID The CID of the class this factory represents.
*/ */
function FactoryProxy(url, classID) { function FactoryProxy(url, classID, contractID) {
this.url = url; this.url = url;
this.classID = Components.ID(classID); this.classID = Components.ID(classID);
this.contractID = contractID;
} }
FactoryProxy.prototype = { FactoryProxy.prototype = {
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory), QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),

View File

@@ -1,17 +1 @@
resource dactyl ../common/modules/
resource dactyl-common ../common/
resource dactyl-content ../common/content/
resource dactyl-skin ../common/skin/
resource dactyl-locale ../common/locale/
resource dactyl-local ./
resource dactyl-local-content content/
resource dactyl-local-skin skin/
resource dactyl-local-locale locale/
content dactyl ../common/content/ content dactyl ../common/content/
component {16dc34f7-6d22-4aa4-a67f-2921fb5dcb69} components/commandline-handler.js
contract @mozilla.org/commandlinehandler/general-startup;1?type=dactyl {16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}
category command-line-handler m-dactyl @mozilla.org/commandlinehandler/general-startup;1?type=dactyl

View File

@@ -9,6 +9,27 @@
"resource://dactyl/" "resource://dactyl/"
], ],
"resources": {
"dactyl": "../common/modules/",
"dactyl-common": "../common/",
"dactyl-content": "../common/content/",
"dactyl-skin": "../common/skin/",
"dactyl-locale": "../common/locale/",
"dactyl-local": "./",
"dactyl-local-content": "content/",
"dactyl-local-skin": "skin/",
"dactyl-local-locale": "locale/"
},
"components": {
"{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}": {
"path": "components/commandline-handler.js",
"contract": "@mozilla.org/commandlinehandler/general-startup;1?type=dactyl",
"category": ["command-line-handler", "m-dactyl"]
}
},
"autocommands": { "autocommands": {
"BookmarkAdd": "Triggered after a page is bookmarked", "BookmarkAdd": "Triggered after a page is bookmarked",
"BookmarkChange": "Triggered after a page's bookmark is changed", "BookmarkChange": "Triggered after a page's bookmark is changed",