-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[react-devtools/extension]: use chrome.storage to persist setting…
…s across sessions
- Loading branch information
Showing
12 changed files
with
97 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
}, | ||
"permissions": [ | ||
"scripting", | ||
"storage", | ||
"tabs" | ||
], | ||
"host_permissions": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
}, | ||
"permissions": [ | ||
"scripting", | ||
"storage", | ||
"tabs" | ||
], | ||
"host_permissions": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ | |
}, | ||
"permissions": [ | ||
"scripting", | ||
"storage", | ||
"tabs" | ||
], | ||
"host_permissions": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/react-devtools-extensions/src/contentScripts/hookSettingsInjector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* global chrome */ | ||
|
||
// We can't use chrome.storage domain from scripts which are injected in ExecutionWorld.MAIN | ||
// This is the only purpose of this script - to send persisted settings to installHook.js content script | ||
|
||
async function messageListener(event: MessageEvent) { | ||
if (event.source !== window) { | ||
return; | ||
} | ||
|
||
if (event.data.source === 'react-devtools-hook-installer') { | ||
if (event.data.payload.handshake) { | ||
const settings = await chrome.storage.local.get(); | ||
// If storage was empty (first installation), define default settings | ||
if (typeof settings.appendComponentStack !== 'boolean') { | ||
settings.appendComponentStack = true; | ||
} | ||
if (typeof settings.breakOnConsoleErrors !== 'boolean') { | ||
settings.breakOnConsoleErrors = false; | ||
} | ||
if (typeof settings.showInlineWarningsAndErrors !== 'boolean') { | ||
settings.showInlineWarningsAndErrors = true; | ||
} | ||
if (typeof settings.hideConsoleLogsInStrictMode !== 'boolean') { | ||
settings.hideConsoleLogsInStrictMode = false; | ||
} | ||
|
||
window.postMessage({ | ||
source: 'react-devtools-hook-settings-injector', | ||
payload: {settings}, | ||
}); | ||
|
||
window.removeEventListener('message', messageListener); | ||
} | ||
} | ||
} | ||
|
||
window.addEventListener('message', messageListener); | ||
window.postMessage({ | ||
source: 'react-devtools-hook-settings-injector', | ||
payload: {handshake: true}, | ||
}); |
39 changes: 36 additions & 3 deletions
39
packages/react-devtools-extensions/src/contentScripts/installHook.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
packages/react-devtools-extensions/src/main/syncSavedPreferences.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters