forked from firefox-devtools/profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (60 loc) · 2.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* 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/. */
// @flow
// Import all global css. Ensure that this is these CSS imports happen before any
// JS imports happen, as this determines the rule order. Global CSS should be easy
// to overwrite with a simple class name.
import '../res/css/focus.css';
import 'photon-colors/photon-colors.css';
import '../res/css/photon/index.css';
import '../res/css/protocol/index.css';
import '../res/css/style.css';
import '../res/css/global.css';
import '../res/css/categories.css';
import '../res/css/network.css';
import 'react-splitter-layout/lib/index.css';
import React from 'react';
import { render } from 'react-dom';
import { Root } from './components/app/Root';
import createStore from './app-logic/create-store';
import {
addDataToWindowObject,
logFriendlyPreamble,
logDevelopmentTips,
} from './utils/window-console';
import { ensureExists } from './utils/flow';
// Mock out Google Analytics for anything that's not production so that we have run-time
// code coverage in development and testing.
// Note that ga isn't included nowadays. We still keep this code because we
// intend to replace ga with Glean in the future, and this will still be useful.
if (process.env.NODE_ENV === 'development') {
window.ga = (event: string, ...payload: mixed[]) => {
const style = 'color: #FF6D00; font-weight: bold';
console.log(`[analytics] %c"${event}"`, style, ...payload);
};
} else if (process.env.NODE_ENV !== 'production') {
window.ga = () => {};
}
window.geckoProfilerPromise = new Promise(function (resolve) {
window.connectToGeckoProfiler = resolve;
});
const store = createStore();
// This uses the React 17 API despite that we use React 18. When moving to the
// newer API, don't forget to update the tests in
// src/test/fixtures/testing-library.js.
render(
<Root store={store} />,
ensureExists(
document.getElementById('root'),
'Unable to find the DOM element to attach the React element to.'
)
);
addDataToWindowObject(store.getState, store.dispatch);
if (process.env.NODE_ENV === 'production') {
// Don't clutter the console in development mode.
logFriendlyPreamble();
}
if (process.env.NODE_ENV === 'development') {
logDevelopmentTips();
}