2017-03-29 06:30:34 +00: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";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This script is the entry point of devtools-launchpad. Make netmonitor possible
|
|
|
|
* to run on standalone browser tab without chrome privilege.
|
|
|
|
* See README.md for more information.
|
|
|
|
*/
|
|
|
|
const React = require("react");
|
|
|
|
const ReactDOM = require("react-dom");
|
2017-04-09 08:51:41 +00:00
|
|
|
const { bindActionCreators } = require("redux");
|
2017-04-01 15:01:06 +00:00
|
|
|
const { bootstrap, renderRoot } = require("devtools-launchpad");
|
2017-04-01 08:39:41 +00:00
|
|
|
const { Services: { appinfo, pref }} = require("devtools-modules");
|
2017-03-29 06:30:34 +00:00
|
|
|
|
2017-07-25 13:23:45 +00:00
|
|
|
// Initialize preferences as early as possible
|
2017-09-14 07:50:54 +00:00
|
|
|
pref("devtools.theme", "light");
|
2017-07-25 13:23:45 +00:00
|
|
|
pref("devtools.cache.disabled", false);
|
2017-04-01 04:32:27 +00:00
|
|
|
pref("devtools.netmonitor.enabled", true);
|
|
|
|
pref("devtools.netmonitor.filters", "[\"all\"]");
|
2017-06-29 09:11:00 +00:00
|
|
|
pref("devtools.netmonitor.visibleColumns",
|
|
|
|
"[\"status\",\"method\",\"file\",\"domain\",\"cause\"," +
|
|
|
|
"\"type\",\"transferred\",\"contentSize\",\"waterfall\"]"
|
2017-05-01 20:02:10 +00:00
|
|
|
);
|
2017-04-01 04:32:27 +00:00
|
|
|
pref("devtools.netmonitor.panes-network-details-width", 550);
|
|
|
|
pref("devtools.netmonitor.panes-network-details-height", 450);
|
|
|
|
pref("devtools.netmonitor.har.defaultLogDir", "");
|
|
|
|
pref("devtools.netmonitor.har.defaultFileName", "Archive %date");
|
|
|
|
pref("devtools.netmonitor.har.jsonp", false);
|
|
|
|
pref("devtools.netmonitor.har.jsonpCallback", "");
|
|
|
|
pref("devtools.netmonitor.har.includeResponseBodies", true);
|
|
|
|
pref("devtools.netmonitor.har.compress", false);
|
|
|
|
pref("devtools.netmonitor.har.forceExport", false);
|
|
|
|
pref("devtools.netmonitor.har.pageLoadedTimeout", 1500);
|
|
|
|
pref("devtools.netmonitor.har.enableAutoExportToFile", false);
|
2017-09-01 04:42:15 +00:00
|
|
|
pref("devtools.netmonitor.persistlog", false);
|
2017-07-12 15:46:17 +00:00
|
|
|
pref("devtools.styleeditor.enabled", true);
|
2017-04-01 04:32:27 +00:00
|
|
|
|
2017-07-25 13:23:45 +00:00
|
|
|
require("./src/assets/styles/netmonitor.css");
|
|
|
|
|
2017-10-16 12:42:25 +00:00
|
|
|
const EventEmitter = require("devtools-modules/src/utils/event-emitter");
|
2017-07-25 13:23:45 +00:00
|
|
|
EventEmitter.decorate(window);
|
2017-10-16 12:42:25 +00:00
|
|
|
|
2018-03-01 09:48:26 +00:00
|
|
|
const { configureStore } = require("./src/create-store");
|
2017-10-24 06:56:00 +00:00
|
|
|
const App = require("./src/components/App");
|
2017-10-16 12:42:25 +00:00
|
|
|
const { Connector } = require("./src/connector/index");
|
|
|
|
const connector = new Connector();
|
|
|
|
const store = configureStore(connector);
|
2017-04-09 08:51:41 +00:00
|
|
|
const actions = bindActionCreators(require("./src/actions"), store.dispatch);
|
2017-04-29 15:20:24 +00:00
|
|
|
|
|
|
|
// Inject to global window for testing
|
|
|
|
window.store = store;
|
2017-03-29 06:30:34 +00:00
|
|
|
|
2017-04-01 15:01:06 +00:00
|
|
|
/**
|
|
|
|
* Stylesheet links in devtools xhtml files are using chrome or resource URLs.
|
|
|
|
* Rewrite the href attribute to remove the protocol. web-server.js contains redirects
|
|
|
|
* to map CSS urls to the proper file. Supports urls using:
|
|
|
|
* - devtools/client/
|
|
|
|
* - devtools/content/
|
|
|
|
* - skin/
|
|
|
|
* Will also add mandatory classnames and attributes to be compatible with devtools theme
|
|
|
|
* stylesheet.
|
|
|
|
*/
|
2017-04-01 08:39:41 +00:00
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
2018-06-01 10:36:09 +00:00
|
|
|
for (const link of document.head.querySelectorAll("link")) {
|
2017-04-01 15:01:06 +00:00
|
|
|
link.href = link.href.replace(/(resource|chrome)\:\/\//, "/");
|
|
|
|
}
|
|
|
|
|
2017-04-01 08:39:41 +00:00
|
|
|
if (appinfo.OS === "Darwin") {
|
|
|
|
document.documentElement.setAttribute("platform", "mac");
|
|
|
|
} else if (appinfo.OS === "Linux") {
|
|
|
|
document.documentElement.setAttribute("platform", "linux");
|
|
|
|
} else {
|
|
|
|
document.documentElement.setAttribute("platform", "win");
|
|
|
|
}
|
|
|
|
});
|
2017-04-01 04:32:27 +00:00
|
|
|
|
2017-04-29 15:20:24 +00:00
|
|
|
bootstrap(React, ReactDOM).then((connection) => {
|
2017-04-01 15:01:06 +00:00
|
|
|
if (!connection) {
|
2017-03-29 06:30:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-10-16 12:42:25 +00:00
|
|
|
|
2018-02-07 14:05:43 +00:00
|
|
|
renderRoot(React, ReactDOM, App, store, {actions, connector});
|
2017-10-16 12:42:25 +00:00
|
|
|
connector.connect(connection, actions, store.getState);
|
2017-03-29 06:30:34 +00:00
|
|
|
});
|