2012-11-30 12:07:59 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2015-04-23 12:24:49 +03:00
|
|
|
const { Cu } = require("chrome");
|
2013-04-12 00:59:08 +04:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2015-04-23 12:24:49 +03:00
|
|
|
const { gDevTools } = require("resource:///modules/devtools/gDevTools.jsm");
|
|
|
|
|
|
|
|
const { defaultTools, defaultThemes } = require("definitions");
|
|
|
|
|
|
|
|
defaultTools.forEach(definition => gDevTools.registerTool(definition));
|
|
|
|
defaultThemes.forEach(definition => gDevTools.registerTheme(definition));
|
|
|
|
|
|
|
|
// Re-export for backwards compatibility, but we should probably the
|
|
|
|
// definitions from require("definitions") in the future
|
|
|
|
exports.defaultTools = require("definitions").defaultTools;
|
|
|
|
exports.defaultThemes = require("definitions").defaultThemes;
|
|
|
|
exports.Tools = require("definitions").Tools;
|
2012-11-30 12:07:59 +04:00
|
|
|
|
2013-04-12 00:59:08 +04:00
|
|
|
Object.defineProperty(exports, "Toolbox", {
|
|
|
|
get: () => require("devtools/framework/toolbox").Toolbox
|
|
|
|
});
|
|
|
|
Object.defineProperty(exports, "TargetFactory", {
|
|
|
|
get: () => require("devtools/framework/target").TargetFactory
|
|
|
|
});
|
2012-12-14 02:17:00 +04:00
|
|
|
|
2015-04-23 12:24:49 +03:00
|
|
|
const unloadObserver = {
|
2013-04-12 00:59:08 +04:00
|
|
|
observe: function(subject, topic, data) {
|
|
|
|
if (subject.wrappedJSObject === require("@loader/unload")) {
|
|
|
|
Services.obs.removeObserver(unloadObserver, "sdk:loader:destroy");
|
2013-05-04 10:31:07 +04:00
|
|
|
for (let definition of gDevTools.getToolDefinitionArray()) {
|
2013-04-12 00:59:08 +04:00
|
|
|
gDevTools.unregisterTool(definition.id);
|
|
|
|
}
|
2014-08-18 16:25:14 +04:00
|
|
|
for (let definition of gDevTools.getThemeDefinitionArray()) {
|
|
|
|
gDevTools.unregisterTheme(definition.id);
|
|
|
|
}
|
2013-04-12 00:59:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Services.obs.addObserver(unloadObserver, "sdk:loader:destroy", false);
|
|
|
|
|
2015-04-23 12:24:49 +03:00
|
|
|
const events = require("sdk/system/events");
|
2013-08-03 14:29:48 +04:00
|
|
|
events.emit("devtools-loaded", {});
|