gecko-dev/devtools/client/main.js
J. Ryan Stinnett efe328f1b2 Bug 912121 - Rewrite require / import to match source tree. rs=devtools
In a following patch, all DevTools moz.build files will use DevToolsModules to
install JS modules at a path that corresponds directly to their source tree
location.  Here we rewrite all require and import calls to match the new
location that these files are installed to.

--HG--
extra : commitid : F2ItGm8ptRz
extra : rebase_source : b082fe4bf77e22e297e303fc601165ceff1c4cbc
2015-09-21 12:04:18 -05:00

46 lines
1.8 KiB
JavaScript

/* 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";
const { Cu } = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
const { gDevTools } = require("resource:///modules/devtools/client/framework/gDevTools.jsm");
const { defaultTools, defaultThemes } = require("devtools/client/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("devtools/client/definitions") in the future
exports.defaultTools = require("devtools/client/definitions").defaultTools;
exports.defaultThemes = require("devtools/client/definitions").defaultThemes;
exports.Tools = require("devtools/client/definitions").Tools;
Object.defineProperty(exports, "Toolbox", {
get: () => require("devtools/client/framework/toolbox").Toolbox
});
Object.defineProperty(exports, "TargetFactory", {
get: () => require("devtools/client/framework/target").TargetFactory
});
const unloadObserver = {
observe: function(subject, topic, data) {
if (subject.wrappedJSObject === require("@loader/unload")) {
Services.obs.removeObserver(unloadObserver, "sdk:loader:destroy");
for (let definition of gDevTools.getToolDefinitionArray()) {
gDevTools.unregisterTool(definition.id);
}
for (let definition of gDevTools.getThemeDefinitionArray()) {
gDevTools.unregisterTheme(definition.id);
}
}
}
};
Services.obs.addObserver(unloadObserver, "sdk:loader:destroy", false);
const events = require("sdk/system/events");
events.emit("devtools-loaded", {});