Skip to content

Commit

Permalink
Revert "Prevent errors/crashing when multiple installs of DevTools ar…
Browse files Browse the repository at this point in the history
…e present (facebook#22517)"

This reverts commit 545d4c2.
  • Loading branch information
Juan Tejada committed Oct 18, 2021
1 parent 2fed713 commit 56e2bbc
Show file tree
Hide file tree
Showing 8 changed files with 350 additions and 576 deletions.
11 changes: 0 additions & 11 deletions packages/react-devtools-extensions/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,6 @@ const build = async (tempPath, manifestPath) => {
}
manifest.description += `\n\nCreated from revision ${commit} on ${dateString}.`;

if (process.env.NODE_ENV === 'development') {
// When building the local development version of the
// extension we want to be able to have a stable extension ID
// for the local build (in order to be able to reliably detect
// duplicate installations of DevTools).
// By specifying a key in the built manifest.json file,
// we can make it so the generated extension ID is stable.
// For more details see the docs here: https://developer.chrome.com/docs/extensions/mv2/manifest/key/
manifest.key = 'reactdevtoolslocalbuilduniquekey';
}

writeFileSync(copiedManifestPath, JSON.stringify(manifest, null, 2));

// Pack the extension
Expand Down
8 changes: 4 additions & 4 deletions packages/react-devtools-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"private": true,
"scripts": {
"build": "cross-env NODE_ENV=production yarn run build:chrome && yarn run build:firefox && yarn run build:edge",
"build:local": "cross-env NODE_ENV=development yarn run build:chrome:local && yarn run build:firefox:local && yarn run build:edge:local",
"build:dev": "cross-env NODE_ENV=development yarn run build:chrome:dev && yarn run build:firefox:dev && yarn run build:edge:dev",
"build:chrome": "cross-env NODE_ENV=production node ./chrome/build",
"build:chrome:fb": "cross-env NODE_ENV=production FEATURE_FLAG_TARGET=extension-fb node ./chrome/build --crx",
"build:chrome:local": "cross-env NODE_ENV=development node ./chrome/build",
"build:chrome:dev": "cross-env NODE_ENV=development node ./chrome/build",
"build:firefox": "cross-env NODE_ENV=production node ./firefox/build",
"build:firefox:local": "cross-env NODE_ENV=development node ./firefox/build",
"build:firefox:dev": "cross-env NODE_ENV=development node ./firefox/build",
"build:edge": "cross-env NODE_ENV=production node ./edge/build",
"build:edge:fb": "cross-env NODE_ENV=production FEATURE_FLAG_TARGET=extension-fb node ./edge/build --crx",
"build:edge:local": "cross-env NODE_ENV=development node ./edge/build",
"build:edge:dev": "cross-env NODE_ENV=development node ./edge/build",
"test:chrome": "node ./chrome/test",
"test:firefox": "node ./firefox/test",
"test:edge": "node ./edge/test",
Expand Down
10 changes: 0 additions & 10 deletions packages/react-devtools-extensions/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const ports = {};

const IS_FIREFOX = navigator.userAgent.indexOf('Firefox') >= 0;

import {EXTENSION_INSTALL_CHECK_MESSAGE} from './constants';

chrome.runtime.onConnect.addListener(function(port) {
let tab = null;
let name = null;
Expand Down Expand Up @@ -118,14 +116,6 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
}
});

chrome.runtime.onMessageExternal.addListener(
(request, sender, sendResponse) => {
if (request === EXTENSION_INSTALL_CHECK_MESSAGE) {
sendResponse(true);
}
},
);

chrome.runtime.onMessage.addListener((request, sender) => {
const tab = sender.tab;
if (tab) {
Expand Down

This file was deleted.

31 changes: 0 additions & 31 deletions packages/react-devtools-extensions/src/constants.js

This file was deleted.

19 changes: 2 additions & 17 deletions packages/react-devtools-extensions/src/injectGlobalHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import nullthrows from 'nullthrows';
import {installHook} from 'react-devtools-shared/src/hook';
import {
__DEBUG__,
SESSION_STORAGE_RELOAD_AND_PROFILE_KEY,
} from 'react-devtools-shared/src/constants';
import {CURRENT_EXTENSION_ID, EXTENSION_INSTALLATION_TYPE} from './constants';
import {SESSION_STORAGE_RELOAD_AND_PROFILE_KEY} from 'react-devtools-shared/src/constants';
import {sessionStorageGetItem} from 'react-devtools-shared/src/storage';

function injectCode(code) {
Expand All @@ -31,17 +27,7 @@ window.addEventListener('message', function onMessage({data, source}) {
if (source !== window || !data) {
return;
}
if (data.extensionId !== CURRENT_EXTENSION_ID) {
if (__DEBUG__) {
console.log(
`[injectGlobalHook] Received message '${data.source}' from different extension instance. Skipping message.`,
{
currentExtension: EXTENSION_INSTALLATION_TYPE,
},
);
}
return;
}

switch (data.source) {
case 'react-devtools-detector':
lastDetectionResult = {
Expand Down Expand Up @@ -116,7 +102,6 @@ window.__REACT_DEVTOOLS_GLOBAL_HOOK__.on('renderer', function({reactBuildType})
window.postMessage({
source: 'react-devtools-detector',
reactBuildType,
extensionId: "${CURRENT_EXTENSION_ID}",
}, '*');
});
`;
Expand Down
Loading

0 comments on commit 56e2bbc

Please sign in to comment.