mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 16:17:57 +01:00
Fix live update issues.
This commit is contained in:
17
common/bootstrap.js
vendored
17
common/bootstrap.js
vendored
@@ -29,15 +29,19 @@ const resourceProto = Services.io.getProtocolHandler("resource")
|
|||||||
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||||
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
|
|
||||||
try { // Temporary migration code.
|
|
||||||
const storage = Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication).storage;
|
|
||||||
var JSMLoader = storage.get("dactyl.JSMLoader", undefined);
|
|
||||||
}
|
|
||||||
catch (e) {}
|
|
||||||
|
|
||||||
const BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
|
const BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
|
||||||
JSMLoader = JSMLoader || BOOTSTRAP_CONTRACT in Cc && Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
JSMLoader = JSMLoader || BOOTSTRAP_CONTRACT in Cc && Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
||||||
|
|
||||||
|
var JSMLoader = BOOTSTRAP_CONTRACT in Components.classes &&
|
||||||
|
Components.classes[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
||||||
|
|
||||||
|
// Temporary migration code.
|
||||||
|
if (!JSMLoader && "@mozilla.org/fuel/application;1" in Components.classes)
|
||||||
|
JSMLoader = Components.classes["@mozilla.org/fuel/application;1"]
|
||||||
|
.getService(Components.interfaces.extIApplication)
|
||||||
|
.storage.get("dactyl.JSMLoader", null);
|
||||||
|
|
||||||
|
|
||||||
function reportError(e) {
|
function reportError(e) {
|
||||||
dump("\ndactyl: bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
|
dump("\ndactyl: bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
|
||||||
Cu.reportError(e);
|
Cu.reportError(e);
|
||||||
@@ -152,6 +156,7 @@ function init() {
|
|||||||
let chars = "0123456789abcdefghijklmnopqrstuv";
|
let chars = "0123456789abcdefghijklmnopqrstuv";
|
||||||
for (let n = Date.now(); n; n = Math.round(n / chars.length))
|
for (let n = Date.now(); n; n = Math.round(n / chars.length))
|
||||||
suffix += chars[n % chars.length];
|
suffix += chars[n % chars.length];
|
||||||
|
suffix = "";
|
||||||
|
|
||||||
for each (let line in manifest.split("\n")) {
|
for each (let line in manifest.split("\n")) {
|
||||||
let fields = line.split(/\s+/);
|
let fields = line.split(/\s+/);
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ var CommandLine = Module("commandline", {
|
|||||||
highlightGroup = highlightGroup || this.HL_NORMAL;
|
highlightGroup = highlightGroup || this.HL_NORMAL;
|
||||||
|
|
||||||
if (flags & this.APPEND_TO_MESSAGES) {
|
if (flags & this.APPEND_TO_MESSAGES) {
|
||||||
let message = isObject(data) && !isinstance(data, _) ? data : { message: String(data) };
|
let message = isObject(data) ? data : { message: String(data) };
|
||||||
this._messageHistory.add(update({ highlight: highlightGroup }, message));
|
this._messageHistory.add(update({ highlight: highlightGroup }, message));
|
||||||
data = message.message;
|
data = message.message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,11 +337,14 @@ var Mappings = Module("mappings", {
|
|||||||
* @param {Object} extra An optional extra configuration hash.
|
* @param {Object} extra An optional extra configuration hash.
|
||||||
* @optional
|
* @optional
|
||||||
*/
|
*/
|
||||||
add: function () {
|
add: function add() {
|
||||||
util.assert(util.isDactyl(Components.stack.caller),
|
let group = this.builtin;
|
||||||
"User scripts may not add builtin mappings. Please use group.mappings.add instead.");
|
if (!util.isDactyl(Components.stack.caller)) {
|
||||||
|
deprecated.warn(add, "mappings.add", "group.mappings.add");
|
||||||
|
group = this.user;
|
||||||
|
}
|
||||||
|
|
||||||
let map = this.builtin.add.apply(this.builtin, arguments);
|
let map = group.add.apply(group, arguments);
|
||||||
map.definedAt = contexts.getCaller(Components.stack.caller);
|
map.definedAt = contexts.getCaller(Components.stack.caller);
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -287,27 +287,33 @@ function deprecated(alternative, fn) {
|
|||||||
let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments);
|
let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments);
|
||||||
|
|
||||||
function deprecatedMethod() {
|
function deprecatedMethod() {
|
||||||
let frame = Components.stack.caller;
|
|
||||||
let obj = this.className ? this.className + "#" :
|
let obj = this.className ? this.className + "#" :
|
||||||
this.constructor.className ? this.constructor.className + "#" :
|
this.constructor.className ? this.constructor.className + "#" :
|
||||||
"";
|
"";
|
||||||
let filename = util.fixURI(frame.filename || "unknown");
|
|
||||||
if (!set.add(deprecatedMethod.seen, filename))
|
deprecated.warn(func, obj + (fn.name || name), alternative);
|
||||||
util.dactyl(fn).warn(
|
|
||||||
util.urlPath(filename) + ":" + frame.lineNumber + ": " +
|
|
||||||
obj + (fn.name || name) + " is deprecated: Please use " + alternative + " instead");
|
|
||||||
return func.apply(this, arguments);
|
return func.apply(this, arguments);
|
||||||
}
|
}
|
||||||
memoize(deprecatedMethod, "seen", function () set([
|
|
||||||
"resource://dactyl" + JSMLoader.suffix + "/javascript.jsm",
|
|
||||||
"resource://dactyl" + JSMLoader.suffix + "/util.jsm"
|
|
||||||
]));
|
|
||||||
|
|
||||||
return callable(fn) ? deprecatedMethod : Class.Property({
|
return callable(fn) ? deprecatedMethod : Class.Property({
|
||||||
get: function () deprecatedMethod,
|
get: function () deprecatedMethod,
|
||||||
init: function (prop) { name = prop; }
|
init: function (prop) { name = prop; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
deprecated.warn = function warn(func, name, alternative, frame) {
|
||||||
|
if (!func.seenCaller)
|
||||||
|
func.seenCaller = set([
|
||||||
|
"resource://dactyl" + JSMLoader.suffix + "/javascript.jsm",
|
||||||
|
"resource://dactyl" + JSMLoader.suffix + "/util.jsm"
|
||||||
|
]);
|
||||||
|
|
||||||
|
frame = frame || Components.stack.caller.caller;
|
||||||
|
let filename = util.fixURI(frame.filename || "unknown");
|
||||||
|
if (!set.add(func.seenCaller, filename))
|
||||||
|
util.dactyl(func).warn(
|
||||||
|
util.urlPath(filename) + ":" + frame.lineNumber + ": " +
|
||||||
|
name + " is deprecated: Please use " + alternative + " instead");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over all of the top-level, iterable property names of an
|
* Iterates over all of the top-level, iterable property names of an
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ var BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
|
|||||||
var JSMLoader = BOOTSTRAP_CONTRACT in Components.classes &&
|
var JSMLoader = BOOTSTRAP_CONTRACT in Components.classes &&
|
||||||
Components.classes[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
Components.classes[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
|
||||||
|
|
||||||
|
if (!JSMLoader && "@mozilla.org/fuel/application;1" in Components.classes)
|
||||||
|
JSMLoader = Components.classes["@mozilla.org/fuel/application;1"]
|
||||||
|
.getService(Components.interfaces.extIApplication)
|
||||||
|
.storage.get("dactyl.JSMLoader", null);
|
||||||
|
|
||||||
if (JSMLoader && JSMLoader.bump === 4)
|
if (JSMLoader && JSMLoader.bump === 4)
|
||||||
JSMLoader.global = this;
|
JSMLoader.global = this;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -692,9 +692,13 @@ var Commands = Module("commands", {
|
|||||||
repeat: null,
|
repeat: null,
|
||||||
|
|
||||||
add: function add() {
|
add: function add() {
|
||||||
util.assert(util.isDactyl(Components.stack.caller),
|
let group = this.builtin;
|
||||||
"User scripts may not add builtin commands. Please use group.commands.add instead.");
|
if (!util.isDactyl(Components.stack.caller)) {
|
||||||
return this.builtin._add.apply(this.builtin, arguments);
|
deprecated.warn(add, "commands.add", "group.commands.add");
|
||||||
|
group = this.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
return group._add.apply(group, arguments);
|
||||||
},
|
},
|
||||||
addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.closure._add }),
|
addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.closure._add }),
|
||||||
getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()),
|
getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ var Messages = Module("messages", {
|
|||||||
init: function _(message) {
|
init: function _(message) {
|
||||||
this.args = arguments;
|
this.args = arguments;
|
||||||
},
|
},
|
||||||
value: Class.memoize(function () {
|
message: Class.memoize(function () {
|
||||||
let message = this.args[0];
|
let message = this.args[0];
|
||||||
|
|
||||||
if (this.args.length > 1) {
|
if (this.args.length > 1) {
|
||||||
@@ -33,8 +33,8 @@ var Messages = Module("messages", {
|
|||||||
}
|
}
|
||||||
return self.get(message);
|
return self.get(message);
|
||||||
}),
|
}),
|
||||||
valueOf: function valueOf() this.value,
|
valueOf: function valueOf() this.message,
|
||||||
toString: function toString() this.value
|
toString: function toString() this.message
|
||||||
});
|
});
|
||||||
|
|
||||||
let seen = {};
|
let seen = {};
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ var Overlay = Module("Overlay", {
|
|||||||
defineModule.modules.forEach(function defModule({ lazyInit, constructor: { className } }) {
|
defineModule.modules.forEach(function defModule({ lazyInit, constructor: { className } }) {
|
||||||
if (!lazyInit) {
|
if (!lazyInit) {
|
||||||
frob(className);
|
frob(className);
|
||||||
modules[className] = modules[className];
|
Class.replaceProperty(modules, className, modules[className]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
modules.__defineGetter__(className, function () {
|
modules.__defineGetter__(className, function () {
|
||||||
|
|||||||
@@ -864,7 +864,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
*/
|
*/
|
||||||
isDactyl: Class.memoize(function () {
|
isDactyl: Class.memoize(function () {
|
||||||
let base = util.regexp.escape(Components.stack.filename.replace(/[^\/]+$/, ""));
|
let base = util.regexp.escape(Components.stack.filename.replace(/[^\/]+$/, ""));
|
||||||
let re = RegExp("^(resource://dactyl|" + base + ")\\S+( -> resource://dactyl(?!-content/eval.js)\\S+)?$");
|
let re = RegExp("^(?:.* -> )?(?:resource://dactyl(?!-content/eval.js)|" + base + ")\\S+$");
|
||||||
return function isDactyl(frame) re.test(frame.filename);
|
return function isDactyl(frame) re.test(frame.filename);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user