MCPcopy
hub / github.com/facebook/react / createBridgeAndStore

Function createBridgeAndStore

packages/react-devtools-extensions/src/main/index.js:146–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144}
145
146function createBridgeAndStore() {
147 createBridge();
148
149 const {isProfiling} = getProfilingFlags();
150
151 store = new Store(bridge, {
152 isProfiling,
153 supportsReloadAndProfile: __IS_CHROME__ || __IS_EDGE__,
154 // At this time, the timeline can only parse Chrome performance profiles.
155 supportsTimeline: __IS_CHROME__,
156 supportsTraceUpdates: true,
157 supportsInspectMatchingDOMElement: true,
158 supportsClickToInspect: true,
159 });
160
161 store.addListener('enableSuspenseTab', () => {
162 createSuspensePanel();
163 });
164
165 store.addListener('settingsUpdated', settings => {
166 chrome.storage.local.set(settings);
167 });
168
169 if (!isProfiling) {
170 // We previously stored this in performCleanup function
171 store.profilerStore.profilingData = profilingData;
172 }
173
174 // Initialize the backend only once the Store has been initialized.
175 // Otherwise, the Store may miss important initial tree op codes.
176 injectBackendManager(chrome.devtools.inspectedWindow.tabId);
177
178 const viewAttributeSourceFunction = (id, path) => {
179 const rendererID = store.getRendererIDForElement(id);
180 if (rendererID != null) {
181 viewAttributeSource(rendererID, id, path);
182 }
183 };
184
185 const viewElementSourceFunction = (source, symbolicatedSource) => {
186 const [, sourceURL, line, column] = symbolicatedSource
187 ? symbolicatedSource
188 : source;
189
190 // We use 1-based line and column, Chrome expects them 0-based.
191 chrome.devtools.panels.openResource(
192 normalizeUrlIfValid(sourceURL),
193 line - 1,
194 column - 1,
195 );
196 };
197
198 root = createRoot(document.createElement('div'));
199
200 render = (overrideTab = mostRecentOverrideTab) => {
201 mostRecentOverrideTab = overrideTab;
202
203 root.render(

Callers 1

mountReactDevToolsFunction · 0.85

Calls 10

createRootFunction · 0.90
createElementFunction · 0.90
getBrowserThemeFunction · 0.90
getProfilingFlagsFunction · 0.85
createSuspensePanelFunction · 0.85
injectBackendManagerFunction · 0.85
setMethod · 0.80
createBridgeFunction · 0.70
addListenerMethod · 0.65
renderMethod · 0.65

Tested by

no test coverage detected