Skip to content

Commit db42b63

Browse files
committed
dev preference
1 parent e9fa6c0 commit db42b63

2 files changed

Lines changed: 43 additions & 34 deletions

File tree

client/lib/main.js

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,45 @@ function main(options, callbacks) {
1919
// Initialize extension object (singleton).
2020
EXTENSION.initialize(options);
2121

22-
// Wait for Console panel initialization
22+
2323
GDEVTOOLS.on("webconsole-init", onConsoleInit);
2424

2525

26-
var uri = DATA.url("bundles/components/main.js");
27-
// TODO: Get URI from mappings.
28-
uri = "http://localhost:8080/bundles/main.js";
26+
var API = {
27+
CC: CC,
28+
CU: CU,
29+
CI: CI,
30+
GDEVTOOLS: GDEVTOOLS,
31+
SELF: require("sdk/self"),
32+
TIMERS: require("sdk/timers"),
33+
CLASS: require("sdk/core/heritage").Class,
34+
DEV_PANEL: require("dev/panel.js").Panel,
35+
DEV_TOOL: require("dev/toolbox").Tool,
36+
PANEL: require("sdk/panel"),
37+
PAGE_WORKER: require("sdk/page-worker"),
38+
ADDON_INSTALLER: require("sdk/addon/installer"),
39+
TABS: require("sdk/tabs"),
40+
SYSTEM: require("sdk/system"),
41+
SIMPLE_PREFS: require("sdk/simple-prefs"),
42+
PREFERENCES_SERVICE: require("sdk/preferences/service")
43+
};
44+
45+
API.getBootOptions = function () {
46+
return options;
47+
}
2948

30-
SANDBOX(uri, function(sandbox) {
49+
API.inDevMode = function () {
50+
return !!API.SIMPLE_PREFS.prefs.dev;
51+
}
3152

32-
sandbox.main({
33-
CC: CC,
34-
CU: CU,
35-
CI: CI,
36-
GDEVTOOLS: GDEVTOOLS,
37-
SELF: require("sdk/self"),
38-
TIMERS: require("sdk/timers"),
39-
CLASS: require("sdk/core/heritage").Class,
40-
DEV_PANEL: require("dev/panel.js").Panel,
41-
DEV_TOOL: require("dev/toolbox").Tool,
42-
PANEL: require("sdk/panel"),
43-
PAGE_WORKER: require("sdk/page-worker"),
44-
ADDON_INSTALLER: require("sdk/addon/installer"),
45-
TABS: require("sdk/tabs"),
46-
getBootOptions: function () {
47-
return options;
48-
}
49-
});
53+
54+
var uri = DATA.url("bundles/components/main.js");
55+
if (API.inDevMode()) {
56+
// TODO: Get URI from mappings.
57+
uri = "http://localhost:8080/bundles/main.js";
58+
}
59+
SANDBOX(uri, function(sandbox) {
60+
sandbox.main(API);
5061
});
5162

5263
}

components/main.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ exports.main = function (API) {
2828

2929

3030

31-
const MONITORS_BUNDLE_SERVER_API = makeAPI(API, {
32-
name: "monitors/bundle-server"
33-
});
34-
const MONITORS_BUNDLE_SERVER_EXPORTS = require("./monitors/bundle-server").for(MONITORS_BUNDLE_SERVER_API);
31+
if (API.inDevMode()) {
3532

36-
MONITORS_BUNDLE_SERVER_API.once("restarted", function () {
33+
const MONITORS_BUNDLE_SERVER_API = makeAPI(API, {
34+
name: "monitors/bundle-server"
35+
});
36+
const MONITORS_BUNDLE_SERVER_EXPORTS = require("./monitors/bundle-server").for(MONITORS_BUNDLE_SERVER_API);
3737

38-
ADDON_EXPORTS.reload();
38+
MONITORS_BUNDLE_SERVER_API.once("restarted", function () {
39+
ADDON_EXPORTS.reload();
40+
});
3941

40-
});
42+
}
4143

4244

4345

@@ -61,10 +63,6 @@ exports.main = function (API) {
6163

6264

6365

64-
API.console.log("Open tab!");
65-
API.TABS.open("http://localhost:49084/");
66-
67-
6866

6967
} catch (err) {
7068
console.error(err.stack);

0 commit comments

Comments
 (0)