Skip to content

Commit 6b0577a

Browse files
author
Juan Tejada
committed
Address comments
1 parent ddcbc01 commit 6b0577a

File tree

5 files changed

+25
-33
lines changed

5 files changed

+25
-33
lines changed

packages/react-devtools-extensions/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"private": true,
55
"scripts": {
66
"build": "cross-env NODE_ENV=production yarn run build:chrome && yarn run build:firefox && yarn run build:edge",
7-
"build:dev": "cross-env NODE_ENV=development yarn run build:chrome:dev && yarn run build:firefox:dev && yarn run build:edge:dev",
7+
"build:local": "cross-env NODE_ENV=development yarn run build:chrome:local && yarn run build:firefox:local && yarn run build:edge:local",
88
"build:chrome": "cross-env NODE_ENV=production node ./chrome/build",
99
"build:chrome:fb": "cross-env NODE_ENV=production FEATURE_FLAG_TARGET=extension-fb node ./chrome/build --crx",
10-
"build:chrome:dev": "cross-env NODE_ENV=development node ./chrome/build",
10+
"build:chrome:local": "cross-env NODE_ENV=development node ./chrome/build",
1111
"build:firefox": "cross-env NODE_ENV=production node ./firefox/build",
12-
"build:firefox:dev": "cross-env NODE_ENV=development node ./firefox/build",
12+
"build:firefox:local": "cross-env NODE_ENV=development node ./firefox/build",
1313
"build:edge": "cross-env NODE_ENV=production node ./edge/build",
1414
"build:edge:fb": "cross-env NODE_ENV=production FEATURE_FLAG_TARGET=extension-fb node ./edge/build --crx",
15-
"build:edge:dev": "cross-env NODE_ENV=development node ./edge/build",
15+
"build:edge:local": "cross-env NODE_ENV=development node ./edge/build",
1616
"test:chrome": "node ./chrome/test",
1717
"test:firefox": "node ./firefox/test",
1818
"test:edge": "node ./edge/test",

packages/react-devtools-extensions/src/background.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ const ports = {};
66

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

9-
import {
10-
EXTENSION_INSTALL_CHECK_MESSAGE,
11-
EXTENSION_INSTALLATION_TYPE,
12-
} from './constants';
9+
import {EXTENSION_INSTALL_CHECK_MESSAGE} from './constants';
1310

1411
chrome.runtime.onConnect.addListener(function(port) {
1512
let tab = null;
@@ -121,15 +118,13 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
121118
}
122119
});
123120

124-
if (EXTENSION_INSTALLATION_TYPE === 'internal') {
125-
chrome.runtime.onMessageExternal.addListener(
126-
(request, sender, sendResponse) => {
127-
if (request === EXTENSION_INSTALL_CHECK_MESSAGE) {
128-
sendResponse(true);
129-
}
130-
},
131-
);
132-
}
121+
chrome.runtime.onMessageExternal.addListener(
122+
(request, sender, sendResponse) => {
123+
if (request === EXTENSION_INSTALL_CHECK_MESSAGE) {
124+
sendResponse(true);
125+
}
126+
},
127+
);
133128

134129
chrome.runtime.onMessage.addListener((request, sender) => {
135130
const tab = sender.tab;

packages/react-devtools-extensions/src/checkForDuplicateInstallations.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919

2020
export function checkForDuplicateInstallations(callback: boolean => void) {
2121
switch (EXTENSION_INSTALLATION_TYPE) {
22-
case 'chrome-web-store': {
23-
// If this is the Chrome Web Store extension, check if an internal build of the
24-
// extension is also installed, and if so, disable this extension.
22+
case 'public': {
23+
// If this is the public extension (e.g. from Chrome Web Store), check if an internal
24+
// build of the extension is also installed, and if so, disable this extension.
2525
chrome.runtime.sendMessage(
2626
INTERNAL_EXTENSION_ID,
2727
EXTENSION_INSTALL_CHECK_MESSAGE,
@@ -39,7 +39,7 @@ export function checkForDuplicateInstallations(callback: boolean => void) {
3939
if (chrome.runtime.lastError != null) {
4040
callback(false);
4141
} else {
42-
callback(response === true);
42+
callback(true);
4343
}
4444
},
4545
);
@@ -66,8 +66,8 @@ export function checkForDuplicateInstallations(callback: boolean => void) {
6666
chrome.management.getAll(extensions => {
6767
if (chrome.runtime.lastError != null) {
6868
const errorMessage =
69-
'React Developer Tools: Unable to access `chrome.management` to check for duplicate extensions. This extension will be disabled.' +
70-
'If you are developing this extension locally, make sure to build the extension using the `yarn build:<browser>:dev` command.';
69+
'React Developer Tools: Unable to access `chrome.management` to check for duplicate extensions. This extension will be disabled. ' +
70+
'If you are developing this extension locally, make sure to build the extension using the `yarn build:<browser>:local` command.';
7171
console.error(errorMessage);
7272
chrome.devtools.inspectedWindow.eval(
7373
`console.error("${errorMessage}")`,
@@ -81,7 +81,7 @@ export function checkForDuplicateInstallations(callback: boolean => void) {
8181
if (devToolsExtensions.length > 1) {
8282
// TODO: Show warning in UI of extension that remains enabled
8383
const errorMessage =
84-
'React Developer Tools: You are running multiple installations of the React Developer Tools extension, which will conflict with this development build of the extension.' +
84+
'React Developer Tools: You are running multiple installations of the React Developer Tools extension, which will conflict with this development build of the extension. ' +
8585
'In order to prevent conflicts, this development build of the extension will be disabled. In order to continue local development, please disable or uninstall ' +
8686
'any other installations of the extension in your browser.';
8787
chrome.devtools.inspectedWindow.eval(
@@ -101,9 +101,9 @@ export function checkForDuplicateInstallations(callback: boolean => void) {
101101
// In this case, assume there are no duplicate exensions and show a warning about
102102
// potential conflicts.
103103
const warnMessage =
104-
'React Developer Tools: You are running an unrecognized installation of the React Developer Tools extension, which might conflict with other versions of the extension installed in your browser.' +
105-
'Please make sure you only have a single version of the extension installed or enabled.' +
106-
'If you are developing this extension locally, make sure to build the extension using the `yarn build:<browser>:dev` command.';
104+
'React Developer Tools: You are running an unrecognized installation of the React Developer Tools extension, which might conflict with other versions of the extension installed in your browser. ' +
105+
'Please make sure you only have a single version of the extension installed or enabled. ' +
106+
'If you are developing this extension locally, make sure to build the extension using the `yarn build:<browser>:local` command.';
107107
console.warn(warnMessage);
108108
chrome.devtools.inspectedWindow.eval(`console.warn("${warnMessage}")`);
109109
callback(false);

packages/react-devtools-extensions/src/constants.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ export const EXTENSION_INSTALL_CHECK_MESSAGE = 'extension-install-check';
1717
export const CHROME_WEBSTORE_EXTENSION_ID = 'fmkadmapgofadopljbjfkapdkoienihi';
1818
export const INTERNAL_EXTENSION_ID = 'dnjnjgbfilfphmojnmhliehogmojhclc';
1919

20-
export const EXTENSION_INSTALLATION_TYPE:
21-
| 'chrome-web-store'
22-
| 'internal'
23-
| 'unknown' =
20+
export const EXTENSION_INSTALLATION_TYPE: 'public' | 'internal' | 'unknown' =
2421
CURRENT_EXTENSION_ID === CHROME_WEBSTORE_EXTENSION_ID
25-
? 'chrome-web-store'
22+
? 'public'
2623
: CURRENT_EXTENSION_ID === INTERNAL_EXTENSION_ID
2724
? 'internal'
2825
: 'unknown';

packages/react-devtools/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Some changes requiring testing in the browser extension (e.g. like "named hooks"
5757
```sh
5858
cd <react-repo>
5959
cd packages/react-devtools-extensions
60-
yarn build:chrome:dev && yarn test:chrome
60+
yarn build:chrome:local && yarn test:chrome
6161
```
6262
This will launch a standalone version of Chrome with the locally built React DevTools pre-installed. If you are testing a specific URL, you can make your testing even faster by passing the `--url` argument to the test script:
6363
```sh

0 commit comments

Comments
 (0)