mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-10 18:55:46 +01:00
Merge addon-common module loading code to fix Minefield.
--HG-- extra : rebase_source : 6b5f0dc0a575a6d21892e18cbb56ab0230382356
This commit is contained in:
@@ -7,11 +7,13 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("addons", {
|
||||
exports: ["AddonManager", "Addons", "Addon", "addons"],
|
||||
require: ["services"]
|
||||
}, this);
|
||||
require: ["services", "util"]
|
||||
});
|
||||
|
||||
this.lazyRequire("completion", ["completion"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var callResult = function callResult(method) {
|
||||
let args = Array.slice(arguments, 1);
|
||||
@@ -496,7 +498,7 @@ var Addons = Module("addons", {
|
||||
});
|
||||
|
||||
if (!services.has("extensionManager"))
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm", this);
|
||||
else
|
||||
var AddonManager = {
|
||||
PERM_CAN_UNINSTALL: 1,
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://dactyl/bootstrap.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
||||
try {
|
||||
var ctypes;
|
||||
Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
@@ -27,116 +26,28 @@ if (!XPCNativeWrapper.unwrap)
|
||||
return obj.wrappedJSObject;
|
||||
return obj;
|
||||
};
|
||||
if (!Object.create)
|
||||
Object.create = function create(proto, props) {
|
||||
let obj = { __proto__: proto };
|
||||
for (let k in properties(props || {}))
|
||||
Object.defineProperty(obj, k, props[k]);
|
||||
return obj;
|
||||
};
|
||||
if (!Object.defineProperty)
|
||||
Object.defineProperty = function defineProperty(obj, prop, desc) {
|
||||
try {
|
||||
let value = desc.value;
|
||||
if ("value" in desc)
|
||||
if (desc.writable && !__lookupGetter__.call(obj, prop)
|
||||
&& !__lookupSetter__.call(obj, prop))
|
||||
try {
|
||||
obj[prop] = value;
|
||||
}
|
||||
catch (e if e instanceof TypeError) {}
|
||||
else {
|
||||
__defineGetter__.call(obj, prop, function () value);
|
||||
if (desc.writable)
|
||||
__defineSetter__.call(obj, prop, function (val) { value = val; });
|
||||
}
|
||||
|
||||
if ("get" in desc)
|
||||
__defineGetter__.call(obj, prop, desc.get);
|
||||
if ("set" in desc)
|
||||
__defineSetter__.call(obj, prop, desc.set);
|
||||
}
|
||||
catch (e) {
|
||||
throw e.stack ? e : Error(e);
|
||||
}
|
||||
};
|
||||
if (!Object.defineProperties)
|
||||
Object.defineProperties = function defineProperties(obj, props) {
|
||||
for (let [k, v] in Iterator(props))
|
||||
Object.defineProperty(obj, k, v);
|
||||
};
|
||||
if (!Object.freeze)
|
||||
Object.freeze = function freeze(obj) {};
|
||||
if (!Object.getPropertyDescriptor)
|
||||
Object.getPropertyDescriptor = function getPropertyDescriptor(obj, prop) {
|
||||
try {
|
||||
let desc = {
|
||||
configurable: true,
|
||||
enumerable: propertyIsEnumerable.call(obj, prop)
|
||||
};
|
||||
var get = __lookupGetter__.call(obj, prop),
|
||||
set = __lookupSetter__.call(obj, prop);
|
||||
if (!get && !set) {
|
||||
desc.value = obj[prop];
|
||||
desc.writable = true;
|
||||
}
|
||||
if (get)
|
||||
desc.get = get;
|
||||
if (set)
|
||||
desc.set = set;
|
||||
return desc;
|
||||
}
|
||||
catch (e) {
|
||||
throw e.stack ? e : Error(e);
|
||||
}
|
||||
};
|
||||
if (!Object.getOwnPropertyDescriptor)
|
||||
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(obj, prop) {
|
||||
if (hasOwnProperty.call(obj, prop))
|
||||
return Object.getPropertyDescriptor(obj, prop);
|
||||
};
|
||||
if (!Object.getOwnPropertyNames)
|
||||
Object.getOwnPropertyNames = function getOwnPropertyNames(obj, _debugger) {
|
||||
try {
|
||||
// This is an ugly and unfortunately necessary hack.
|
||||
if (hasOwnProperty.call(obj, "__iterator__")) {
|
||||
var oldIter = obj.__iterator__;
|
||||
delete obj.__iterator__;
|
||||
}
|
||||
let res = [k for (k in obj) if (hasOwnProperty.call(obj, k))];
|
||||
if (oldIter !== undefined) {
|
||||
obj.__iterator__ = oldIter;
|
||||
res.push("__iterator__");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
catch (e) {
|
||||
throw e.stack ? e : Error(e);
|
||||
}
|
||||
};
|
||||
if (!Object.getPrototypeOf)
|
||||
Object.getPrototypeOf = function getPrototypeOf(obj) obj.__proto__;
|
||||
if (!Object.keys)
|
||||
Object.keys = function keys(obj)
|
||||
Object.getOwnPropertyNames(obj).filter(function (k) propertyIsEnumerable.call(obj, k));
|
||||
|
||||
let getGlobalForObject = Cu.getGlobalForObject || function (obj) obj.__parent__;
|
||||
|
||||
let jsmodules = {
|
||||
lazyRequire: function lazyRequire(module, names, target) {
|
||||
for each (let name in names)
|
||||
memoize(target || this, name, function (name) require(module)[name]);
|
||||
}
|
||||
};
|
||||
function require(module, target) JSMLoader.load(module, target);
|
||||
|
||||
function lazyRequire(module, names, target) {
|
||||
for each (let name in names)
|
||||
memoize(target || this, name, function (name) require(module)[name]);
|
||||
}
|
||||
|
||||
let jsmodules = { lazyRequire: lazyRequire };
|
||||
jsmodules.jsmodules = jsmodules;
|
||||
|
||||
function toString() "[module-global " + this.NAME + "]";
|
||||
|
||||
let use = {};
|
||||
let loaded = {};
|
||||
let currentModule;
|
||||
let global = this;
|
||||
function defineModule(name, params, module) {
|
||||
if (!module)
|
||||
module = getGlobalForObject(params);
|
||||
module = this;
|
||||
|
||||
module.NAME = name;
|
||||
module.EXPORTED_SYMBOLS = params.exports || [];
|
||||
@@ -147,8 +58,7 @@ function defineModule(name, params, module) {
|
||||
defineModule.prefix += " ";
|
||||
|
||||
for (let [, mod] in Iterator(params.require || []))
|
||||
require(module, mod, null, name);
|
||||
module.__proto__ = jsmodules;
|
||||
require(mod, module);
|
||||
|
||||
module._lastModule = currentModule;
|
||||
currentModule = module;
|
||||
@@ -196,11 +106,11 @@ function endModule() {
|
||||
defineModule.loadLog.push("(End " + currentModule.NAME + ")");
|
||||
|
||||
loaded[currentModule.NAME] = 1;
|
||||
require(jsmodules, currentModule.NAME);
|
||||
require(currentModule.NAME, jsmodules);
|
||||
currentModule = currentModule._lastModule;
|
||||
}
|
||||
|
||||
function require(obj, name, from, targetName) {
|
||||
function require_(obj, name, from, targetName) {
|
||||
try {
|
||||
if (arguments.length === 1)
|
||||
[obj, name] = [{}, obj];
|
||||
@@ -230,7 +140,7 @@ function require(obj, name, from, targetName) {
|
||||
defineModule("base", {
|
||||
// sed -n 's/^(const|var|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt
|
||||
exports: [
|
||||
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "JSMLoader", "Object",
|
||||
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "JSMLoader",
|
||||
"Set", "Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMShim", "XPCOMUtils",
|
||||
"XPCSafeJSObjectWrapper", "array", "bind", "call", "callable", "ctypes", "curry",
|
||||
"debuggerProperties", "defineModule", "deprecated", "endModule", "forEach", "isArray",
|
||||
@@ -238,10 +148,12 @@ defineModule("base", {
|
||||
"iterOwnProperties", "keys", "memoize", "octal", "properties", "require", "set", "update",
|
||||
"values", "withCallerGlobal"
|
||||
]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
this.lazyRequire("messages", ["_", "Messages"]);
|
||||
this.lazyRequire("util", ["util"]);
|
||||
this.lazyRequire("services", ["services"]);
|
||||
this.lazyRequire("util", ["FailedAssertion", "util"]);
|
||||
|
||||
/**
|
||||
* Returns a list of all of the top-level properties of an object, by
|
||||
@@ -653,7 +565,7 @@ function memoize(obj, key, getter) {
|
||||
}
|
||||
}
|
||||
|
||||
let sandbox = Cu.Sandbox(this);
|
||||
let sandbox = Cu.Sandbox(Cu.getGlobalForObject(this));
|
||||
sandbox.__proto__ = this;
|
||||
/**
|
||||
* Wraps a function so that when called, the global object of the caller
|
||||
@@ -666,7 +578,7 @@ var withCallerGlobal = Cu.evalInSandbox(<![CDATA[
|
||||
fn.apply(this,
|
||||
[Class.objectGlobal(withCallerGlobal_wrapped.caller)]
|
||||
.concat(Array.slice(arguments))))
|
||||
]]>, Cu.Sandbox(this), "1.8");
|
||||
]]>, Cu.Sandbox(Cu.getGlobalForObject(this)), "1.8");
|
||||
|
||||
/**
|
||||
* Updates an object with the properties of another object. Getters
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("bookmarkcache", {
|
||||
exports: ["Bookmark", "BookmarkCache", "Keyword", "bookmarkcache"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("storage", ["storage"]);
|
||||
|
||||
|
||||
@@ -4,200 +4,18 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
try {
|
||||
var EXPORTED_SYMBOLS = ["require"];
|
||||
|
||||
let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
// Deal with cross-compartment XML passing issues.
|
||||
function create(proto) Object.create(proto);
|
||||
function import(obj) {
|
||||
let res = {};
|
||||
for each (let key in Object.getOwnPropertyNames(obj))
|
||||
Object.defineProperty(res, key, Object.getOwnPropertyDescriptor(obj, key));
|
||||
return res;
|
||||
}
|
||||
|
||||
var EXPORTED_SYMBOLS = ["JSMLoader"];
|
||||
// Deal with subScriptLoader prepending crap to loaded URLs
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
function loadSubScript() Services.scriptloader.loadSubScript.apply(null, arguments);
|
||||
|
||||
var BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
|
||||
var JSMLoader = BOOTSTRAP_CONTRACT in Components.classes &&
|
||||
Components.classes[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
||||
|
||||
if (JSMLoader && JSMLoader.bump === 6)
|
||||
JSMLoader.global = this;
|
||||
else
|
||||
JSMLoader = {
|
||||
bump: 6,
|
||||
|
||||
builtin: Cu.Sandbox(this),
|
||||
|
||||
canonical: {},
|
||||
|
||||
factories: [],
|
||||
|
||||
name: "dactyl",
|
||||
|
||||
global: this,
|
||||
|
||||
globals: JSMLoader ? JSMLoader.globals : {},
|
||||
|
||||
io: Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService),
|
||||
|
||||
loader: Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader),
|
||||
|
||||
manager: Components.manager.QueryInterface(Ci.nsIComponentRegistrar),
|
||||
|
||||
modules: JSMLoader && JSMLoader.modules || {},
|
||||
|
||||
stale: JSMLoader ? JSMLoader.stale : {},
|
||||
|
||||
suffix: "",
|
||||
|
||||
times: {
|
||||
all: 0,
|
||||
add: function add(major, minor, delta) {
|
||||
this.all += delta;
|
||||
|
||||
this[major] = (this[major] || 0) + delta;
|
||||
if (minor) {
|
||||
minor = ":" + minor;
|
||||
this[minor] = (this[minor] || 0) + delta;
|
||||
this[major + minor] = (this[major + minor] || 0) + delta;
|
||||
}
|
||||
},
|
||||
clear: function clear() {
|
||||
for (let key in this)
|
||||
if (typeof this[key] !== "number")
|
||||
delete this[key];
|
||||
}
|
||||
},
|
||||
|
||||
init: function init(suffix) {
|
||||
this.initialized = true;
|
||||
this.suffix = suffix || "";
|
||||
|
||||
let base = this.load("base.jsm", this.global);
|
||||
this.global.EXPORTED_SYMBOLS = base.EXPORTED_SYMBOLS;
|
||||
this.global.JSMLoader = this;
|
||||
base.JSMLoader = this;
|
||||
},
|
||||
|
||||
getTarget: function getTarget(url) {
|
||||
if (url.indexOf(":") === -1)
|
||||
url = "resource://dactyl" + this.suffix + "/" + url;
|
||||
|
||||
let chan = this.io.newChannel(url, null, null);
|
||||
chan.cancel(Cr.NS_BINDING_ABORTED);
|
||||
return chan.name;
|
||||
},
|
||||
|
||||
load: function load(name, target) {
|
||||
let url = name;
|
||||
if (url.indexOf(":") === -1)
|
||||
url = "resource://dactyl" + this.suffix + "/" + url;
|
||||
let targetURL = this.getTarget(url);
|
||||
|
||||
let stale = this.stale[name] || this.stale[targetURL];
|
||||
if (stale) {
|
||||
delete this.stale[name];
|
||||
delete this.stale[targetURL];
|
||||
|
||||
let loadURL = url.replace(RegExp("^(resource://dactyl)/"), "$1" + this.suffix + "/");
|
||||
|
||||
let global = this.globals[name];
|
||||
if (stale === targetURL)
|
||||
this.loadSubScript(loadURL, global.global || global);
|
||||
}
|
||||
|
||||
try {
|
||||
let now = Date.now();
|
||||
this.modules[url] = true;
|
||||
let global = Cu.import(url, target);
|
||||
|
||||
if (!(name in this.globals))
|
||||
this.times.add("require", name, Date.now() - now);
|
||||
|
||||
return this.globals[name] = global;
|
||||
}
|
||||
catch (e) {
|
||||
dump("Importing " + url + ": " + e + "\n" + (e.stack || Error().stack));
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
|
||||
loadSubScript: function loadSubScript(script) {
|
||||
let now = Date.now();
|
||||
this.loader.loadSubScript.apply(this.loader, arguments);
|
||||
this.times.add("loadSubScript", script, Date.now() - now);
|
||||
},
|
||||
|
||||
cleanup: function unregister() {
|
||||
for each (let factory in this.factories)
|
||||
this.manager.unregisterFactory(factory.classID, factory);
|
||||
this.factories = {};
|
||||
},
|
||||
|
||||
purge: function purge() {
|
||||
dump("dactyl: JSMLoader: purge\n");
|
||||
|
||||
this.bootstrap = null;
|
||||
|
||||
if (Cu.unload) {
|
||||
Object.keys(this.modules).reverse().forEach(function (url) {
|
||||
try {
|
||||
Cu.unload(url);
|
||||
}
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (let [url, global] in Iterator(this.globals)) {
|
||||
if (url === "bootstrap.jsm" || url === "resource://dactyl/bootstrap.jsm")
|
||||
continue;
|
||||
|
||||
let target = this.getTarget(url);
|
||||
this.stale[url] = target;
|
||||
this.stale[target] = target;
|
||||
|
||||
for each (let prop in Object.getOwnPropertyNames(global))
|
||||
try {
|
||||
if (!(prop in this.builtin) &&
|
||||
["JSMLoader", "Set", "set", "EXPORTED_SYMBOLS"].indexOf(prop) < 0 &&
|
||||
!global.__lookupGetter__(prop))
|
||||
global[prop] = undefined;
|
||||
}
|
||||
catch (e) {
|
||||
dump("Deleting property " + prop + " on " + url + ":\n " + e + "\n");
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Factory: function Factory(clas) ({
|
||||
__proto__: clas.prototype,
|
||||
|
||||
createInstance: function (outer, iid) {
|
||||
try {
|
||||
if (outer != null)
|
||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||
if (!clas.instance)
|
||||
clas.instance = new clas();
|
||||
return clas.instance.QueryInterface(iid);
|
||||
}
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
registerFactory: function registerFactory(factory) {
|
||||
if (Set.has(this.factories, factory.contractID))
|
||||
this.manager.unregisterFactory(this.factories[factory.contractID].classID,
|
||||
this.factories[factory.contractID]);
|
||||
|
||||
this.manager.registerFactory(factory.classID,
|
||||
String(factory.classID),
|
||||
factory.contractID,
|
||||
factory);
|
||||
this.factories[factory.contractID] = factory;
|
||||
}
|
||||
};
|
||||
|
||||
}catch(e){ dump(e + "\n" + (e.stack || Error().stack)); Components.utils.reportError(e) }
|
||||
|
||||
// vim: set fdm=marker sw=4 sts=4 et ft=javascript:
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
//
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
try {"use strict";
|
||||
// "use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("buffer", {
|
||||
exports: ["Buffer", "buffer"],
|
||||
require: ["prefs", "services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("finder", ["RangeFind"]);
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
this.lazyRequire("storage", ["storage"]);
|
||||
this.lazyRequire("template", ["template"]);
|
||||
lazyRequire("bookmarkcache", ["bookmarkcache"]);
|
||||
lazyRequire("finder", ["RangeFind"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("storage", ["storage"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
/**
|
||||
* A class to manage the primary web content buffer. The name comes
|
||||
@@ -2529,7 +2529,7 @@ Buffer.addPageInfoSection("s", "Security", function (verbose) {
|
||||
}
|
||||
});
|
||||
|
||||
} catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
// catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
|
||||
endModule();
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("cache", {
|
||||
exports: ["Cache", "cache"],
|
||||
require: ["config", "services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("storage", ["File"]);
|
||||
|
||||
var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
||||
init: function init() {
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("commands", {
|
||||
exports: ["ArgType", "Command", "Commands", "CommandOption", "Ex", "commands"],
|
||||
require: ["contexts", "messages", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("help", ["help"]);
|
||||
lazyRequire("options", ["Option"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
/**
|
||||
* A structure representing the options available for a command.
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("completion", {
|
||||
exports: ["CompletionContext", "Completion", "completion"]
|
||||
}, this);
|
||||
|
||||
lazyRequire("messages", ["_", "messages"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
/**
|
||||
* Creates a new completion context.
|
||||
*
|
||||
|
||||
@@ -7,18 +7,17 @@
|
||||
/* use strict */
|
||||
|
||||
let global = this;
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("config", {
|
||||
exports: ["ConfigBase", "Config", "config"],
|
||||
require: ["dom", "io", "protocol", "services", "util", "template"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("addons", ["AddonManager"]);
|
||||
this.lazyRequire("cache", ["cache"]);
|
||||
this.lazyRequire("highlight", ["highlight"]);
|
||||
this.lazyRequire("messages", ["_"]);
|
||||
this.lazyRequire("prefs", ["localPrefs", "prefs"]);
|
||||
this.lazyRequire("storage", ["storage", "File"]);
|
||||
lazyRequire("addons", ["AddonManager"]);
|
||||
lazyRequire("cache", ["cache"]);
|
||||
lazyRequire("highlight", ["highlight"]);
|
||||
lazyRequire("messages", ["_"]);
|
||||
lazyRequire("prefs", ["localPrefs", "prefs"]);
|
||||
lazyRequire("storage", ["storage", "File"]);
|
||||
|
||||
function AboutHandler() {}
|
||||
AboutHandler.prototype = {
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("contexts", {
|
||||
exports: ["Contexts", "Group", "contexts"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("commands", ["ArgType", "CommandOption", "commands"]);
|
||||
lazyRequire("options", ["Option"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("storage", ["File"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var Const = function Const(val) Class.Property({ enumerable: true, value: val });
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("dom", {
|
||||
exports: ["$", "DOM", "NS", "XBL", "XHTML", "XUL"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("highlight", ["highlight"]);
|
||||
|
||||
var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
||||
var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("downloads", {
|
||||
exports: ["Download", "Downloads", "downloads"]
|
||||
}, this);
|
||||
exports: ["Download", "Downloads", "downloads"],
|
||||
require: ["util"]
|
||||
});
|
||||
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
|
||||
Cu.import("resource://gre/modules/DownloadUtils.jsm", this);
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("finder", {
|
||||
exports: ["RangeFind", "RangeFinder", "rangefinder"],
|
||||
require: ["prefs"]
|
||||
}, this);
|
||||
require: ["prefs", "util"]
|
||||
});
|
||||
|
||||
this.lazyRequire("buffer", ["Buffer"]);
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("buffer", ["Buffer"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
|
||||
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("help", {
|
||||
exports: ["help"],
|
||||
require: ["cache", "dom", "protocol", "services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("completion", ["completion"]);
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("completion", ["completion"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var HelpBuilder = Class("HelpBuilder", {
|
||||
init: function init() {
|
||||
@@ -202,7 +202,6 @@ var Help = Module("Help", {
|
||||
|
||||
return '<?xml version="1.0"?>\n' +
|
||||
'<?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>\n' +
|
||||
'<!DOCTYPE document SYSTEM "resource://dactyl-content/dactyl.dtd">\n' +
|
||||
<document xmlns={NS} xmlns:dactyl={NS}
|
||||
name="versions" title={config.appName + " Versions"}>
|
||||
<h1 tag="versions news NEWS">{config.appName} Versions</h1>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("highlight", {
|
||||
exports: ["Highlight", "Highlights", "highlight"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("styles", ["Styles", "styles"]);
|
||||
lazyRequire("styles", ["Styles", "styles"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var Highlight = Struct("class", "selector", "sites",
|
||||
"defaultExtends", "defaultValue",
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("io", {
|
||||
exports: ["IO", "io"],
|
||||
require: ["services"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
this.lazyRequire("contexts", ["Contexts", "contexts"]);
|
||||
lazyRequire("config", ["config"]);
|
||||
lazyRequire("contexts", ["Contexts", "contexts"]);
|
||||
lazyRequire("storage", ["File", "storage"]);
|
||||
lazyRequire("styles", ["styles"]);
|
||||
|
||||
// TODO: why are we passing around strings rather than file objects?
|
||||
/**
|
||||
|
||||
@@ -8,10 +8,11 @@ let { getOwnPropertyNames } = Object;
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("javascript", {
|
||||
exports: ["JavaScript", "javascript"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
let isPrototypeOf = Object.prototype.isPrototypeOf;
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("main", {
|
||||
exports: ["ModuleBase"],
|
||||
require: ["config", "overlay", "services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
var BASE = "resource://dactyl-content/";
|
||||
|
||||
@@ -130,7 +129,7 @@ var Modules = function Modules(window) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
require(jsmodules, script);
|
||||
require(script, jsmodules);
|
||||
}
|
||||
catch (e) {
|
||||
util.dump("Loading script " + script + ":");
|
||||
@@ -150,7 +149,7 @@ var Modules = function Modules(window) {
|
||||
wantXrays: false });
|
||||
|
||||
// Hack:
|
||||
sandbox.Object = jsmodules.Object;
|
||||
// sandbox.Object = jsmodules.Object;
|
||||
sandbox.File = jsmodules.File;
|
||||
sandbox.Math = jsmodules.Math;
|
||||
sandbox.__proto__ = proto || modules;
|
||||
@@ -181,7 +180,7 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
|
||||
|
||||
defineModule.time("load", null, function _load() {
|
||||
config.modules.global
|
||||
.forEach(function (name) defineModule.time("load", name, require, null, modules.jsmodules, name));
|
||||
.forEach(function (name) defineModule.time("load", name, require, null, name, modules.jsmodules));
|
||||
|
||||
config.modules.window
|
||||
.forEach(function (name) defineModule.time("load", name, modules.load, modules, name));
|
||||
|
||||
@@ -4,13 +4,10 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("messages", {
|
||||
exports: ["Messages", "messages", "_"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
var Messages = Module("messages", {
|
||||
|
||||
@@ -206,6 +203,6 @@ var { _ } = messages;
|
||||
|
||||
endModule();
|
||||
|
||||
} catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
// catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
|
||||
|
||||
@@ -8,13 +8,18 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("options", {
|
||||
exports: ["Option", "Options", "ValueError", "options"],
|
||||
require: ["contexts", "messages", "storage"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
lazyRequire("cache", ["cache"]);
|
||||
lazyRequire("config", ["config"]);
|
||||
lazyRequire("commands", ["Commands"]);
|
||||
lazyRequire("completion", ["CompletionContext"]);
|
||||
lazyRequire("prefs", ["prefs"]);
|
||||
lazyRequire("styles", ["Styles"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
/** @scope modules */
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("overlay", {
|
||||
exports: ["overlay"],
|
||||
require: ["util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("highlight", ["highlight"]);
|
||||
|
||||
var getAttr = function getAttr(elem, ns, name)
|
||||
elem.hasAttributeNS(ns, name) ? elem.getAttributeNS(ns, name) : null;
|
||||
@@ -224,7 +225,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
iterator = ([elem.@id, elem.elements(), elem.@*::*.(function::name() != "id")] for each (elem in obj[key]));
|
||||
|
||||
for (let [elem, xml, attr] in iterator) {
|
||||
if (elem = doc.getElementById(elem)) {
|
||||
if (elem = doc.getElementById(String(elem))) {
|
||||
let node = DOM.fromXML(xml, doc, obj.objects);
|
||||
if (!(node instanceof Ci.nsIDOMDocumentFragment))
|
||||
elems.push(node);
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("prefs", {
|
||||
exports: ["Prefs", "localPrefs", "prefs"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("messages", ["_"]);
|
||||
lazyRequire("messages", ["_"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
ORIGINAL: "extensions.dactyl.original.",
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("protocol", {
|
||||
exports: ["LocaleChannel", "Protocol", "RedirectChannel", "StringChannel", "XMLChannel"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
|
||||
|
||||
@@ -224,6 +223,7 @@ XMLChannel.prototype = {
|
||||
this.writes.push(services.io.newChannel(url, null, this.uri).open());
|
||||
}
|
||||
catch (e) {
|
||||
util.dump("addChannel('" + url + "'):");
|
||||
util.reportError(e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -12,15 +12,14 @@
|
||||
// FIXME:
|
||||
// - finish 1.9.0 support if we're going to support sanitizing in Melodactyl
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("sanitizer", {
|
||||
exports: ["Range", "Sanitizer", "sanitizer"],
|
||||
require: ["config", "prefs", "services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("messages", ["_"]);
|
||||
this.lazyRequire("storage", ["storage"]);
|
||||
this.lazyRequire("template", ["teplate"]);
|
||||
lazyRequire("messages", ["_"]);
|
||||
lazyRequire("storage", ["storage"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
let tmp = {};
|
||||
JSMLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
try {
|
||||
|
||||
var global = this;
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("services", {
|
||||
exports: ["services"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
/**
|
||||
* A lazily-instantiated XPCOM class and service cache.
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("storage", {
|
||||
exports: ["File", "Storage", "storage"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
this.lazyRequire("io", ["IO"]);
|
||||
lazyRequire("config", ["config"]);
|
||||
lazyRequire("io", ["IO"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
|
||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
var myObject = JSON.parse("{}").constructor;
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
/* use strict */
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("styles", {
|
||||
exports: ["Style", "Styles", "styles"],
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("contexts", ["Contexts"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||
var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
/* use strict */
|
||||
|
||||
let global = this;
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("template", {
|
||||
exports: ["Binding", "Template", "template"],
|
||||
require: ["util"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
lazyRequire("help", ["help"]);
|
||||
|
||||
default xml namespace = XHTML;
|
||||
|
||||
@@ -282,7 +283,8 @@ var Template = Module("Template", {
|
||||
}
|
||||
},
|
||||
|
||||
_sandbox: Class.Memoize(function () Cu.Sandbox(global, { wantXrays: false })),
|
||||
_sandbox: Class.Memoize(function () Cu.Sandbox(Cu.getGlobalForObject(global),
|
||||
{ wantXrays: false })),
|
||||
|
||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||
// any line breaks are displayed as \n
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
|
||||
try {
|
||||
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("util", {
|
||||
exports: ["DOM", "$", "FailedAssertion", "Math", "NS", "Point", "Util", "XBL", "XHTML", "XUL", "util"],
|
||||
require: ["dom", "services"]
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
lazyRequire("storage", ["File", "storage"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
var FailedAssertion = Class("FailedAssertion", ErrorBase, {
|
||||
init: function init(message, level, noTrace) {
|
||||
@@ -1615,7 +1616,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
* @singleton
|
||||
*/
|
||||
var GlobalMath = Math;
|
||||
var Math = update(Object.create(GlobalMath), {
|
||||
this.Math = update(Object.create(GlobalMath), {
|
||||
/**
|
||||
* Returns the specified *value* constrained to the range *min* - *max*.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user