forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
84 lines (69 loc) · 2.31 KB
/
Copy pathmain.js
File metadata and controls
84 lines (69 loc) · 2.31 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// @flow
const React = require("react");
const { bindActionCreators, combineReducers } = require("redux");
const ReactDOM = require("react-dom");
const {
client: { getClient, firefox },
renderRoot, bootstrap, L10N
} = require("devtools-local-toolbox");
const { getValue, isFirefoxPanel } = require("devtools-config");
const configureStore = require("./utils/create-store");
const { onConnect, onFirefoxConnect } = require("./utils/client");
const reducers = require("./reducers");
const selectors = require("./selectors");
const App = require("./components/App");
const createStore = configureStore({
log: getValue("logging.actions"),
makeThunkArgs: (args, state) => {
return Object.assign({}, args, { client: getClient(state) });
}
});
const store = createStore(combineReducers(reducers));
const actions = bindActionCreators(require("./actions"), store.dispatch);
if (!isFirefoxPanel()) {
window.L10N = L10N;
window.L10N.setBundle(require("./strings.json"));
}
window.appStore = store;
// Expose the bound actions so external things can do things like
// selecting a source.
window.actions = {
selectSource: actions.selectSource,
selectSourceURL: actions.selectSourceURL
};
function unmountRoot() {
const mount = document.querySelector("#mount");
ReactDOM.unmountComponentAtNode(mount);
}
if (isFirefoxPanel()) {
const sourceMap = require("./utils/source-map");
const prettyPrint = require("./utils/pretty-print");
module.exports = {
bootstrap: ({ threadClient, tabTarget, toolbox, L10N }: any) => {
// TODO (jlast) remove when the panel has L10N
if (L10N) {
window.L10N = L10N;
} else {
window.L10N = require("../packages/devtools-local-toolbox/src/utils/L10N");
window.L10N.setBundle(require("./strings.json"));
}
firefox.setThreadClient(threadClient);
firefox.setTabTarget(tabTarget);
renderRoot(React, ReactDOM, App, store);
firefox.initPage(actions);
onFirefoxConnect(actions, firefox);
},
destroy: () => {
unmountRoot();
sourceMap.destroyWorker();
prettyPrint.destroyWorker();
},
store: store,
actions: actions,
selectors: selectors,
client: firefox.clientCommands
};
} else {
bootstrap(React, ReactDOM, App, actions, store)
.then(() => onFirefoxConnect(actions, firefox));
}