in shells/dev/src/devtools.js [50:89]
connect(cb) {
const bridge = new Bridge({
listen(fn) {
const listener = ({ data }) => {
fn(data);
};
// Preserve the reference to the window we subscribe to, so we can unsubscribe from it when required.
const contentWindowParent = contentWindow.parent;
contentWindowParent.addEventListener('message', listener);
return () => {
contentWindowParent.removeEventListener('message', listener);
};
},
sendAll(events) {
contentWindow.postMessage(events, '*');
},
});
cb(bridge);
const store = new Store(bridge);
const root = createRoot(container);
const batch = root.createBatch();
batch.render(
createElement(DevTools, {
bridge,
browserTheme: 'light',
showTabBar: true,
store,
})
);
batch.then(() => {
batch.commit();
// Initialize the backend only once the DevTools frontend Store has been initialized.
// Otherwise the Store may miss important initial tree op codes.
inject('dist/backend.js');
});
},