mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
933f6a07ca
* Added rudimentary context menu hook and menu UI * Added backend support for copying a value at a specific path for the inspected element * Added backend support for storing a value (at a specified path) as a global variable * Added special casing to enable copying undefined/unserializable values to the clipboard * Added copy and store-as-global context menu options to selected element props panel * Store global variables separately, with auto-incremented name (like browsers do) * Added tests for new copy and store-as-global backend functions * Fixed some ownerDocument/contentWindow edge cases * Refactored context menu to support dynamic options Used this mechanism to add a conditional menu option for inspecting the current value (if it's a function) * Renamed "safeSerialize" to "serializeToString" and added inline comment
31 lines
906 B
JavaScript
31 lines
906 B
JavaScript
/* global chrome */
|
|
|
|
const IS_CHROME = navigator.userAgent.indexOf('Firefox') < 0;
|
|
|
|
export type BrowserName = 'Chrome' | 'Firefox';
|
|
|
|
export function getBrowserName(): BrowserName {
|
|
return IS_CHROME ? 'Chrome' : 'Firefox';
|
|
}
|
|
|
|
export type BrowserTheme = 'dark' | 'light';
|
|
|
|
export function getBrowserTheme(): BrowserTheme {
|
|
if (IS_CHROME) {
|
|
// chrome.devtools.panels added in Chrome 18.
|
|
// chrome.devtools.panels.themeName added in Chrome 54.
|
|
return chrome.devtools.panels.themeName === 'dark' ? 'dark' : 'light';
|
|
} else {
|
|
// chrome.devtools.panels.themeName added in Firefox 55.
|
|
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/devtools.panels/themeName
|
|
if (chrome.devtools && chrome.devtools.panels) {
|
|
switch (chrome.devtools.panels.themeName) {
|
|
case 'dark':
|
|
return 'dark';
|
|
default:
|
|
return 'light';
|
|
}
|
|
}
|
|
}
|
|
}
|