-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(devtools): rename DevTools tab to "Angular & Wiz" for Googlers #69877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eduhmc
wants to merge
1
commit into
angular:main
Choose a base branch
from
eduhmc:plan-issue-505086695
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+78
−58
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -16,69 +16,77 @@ | |
| const DEEP_LINK_SCHEME = 'angular-devtools'; | ||
|
|
||
| const theme = chrome.devtools.panels.themeName; | ||
| chrome.devtools.panels.create( | ||
| 'Angular', | ||
| // Firefox specifically displays the icon in the tab. | ||
| // the bw icon wasn't visible in dark mode | ||
| theme === 'dark' ? 'assets/icon16.png' : 'assets/icon-bw16.png', | ||
| 'index.html', | ||
| (panel) => { | ||
| // Keep a reference to the panel's window so we can post messages | ||
| // even if the panel is already visible (onShown won't re-fire). | ||
| let currentPanelWindow: Window | null = null; | ||
| panel.onShown.addListener((panelWindow: Window) => { | ||
| currentPanelWindow = panelWindow; | ||
| }); | ||
| panel.onHidden.addListener(() => { | ||
| currentPanelWindow = null; | ||
| }); | ||
|
|
||
| // Register a handler for deep links from the Chrome Performance panel. | ||
| // When the user clicks on an Angular performance entry (e.g. a component lifecycle hook), | ||
| // Chrome calls this handler with the deep link URL, activating the Angular DevTools panel | ||
| // and navigating to the relevant component. | ||
| // | ||
| // The optional `urlScheme` second parameter on `setOpenResourceHandler` is a Chrome 140+ | ||
| // extension that registers this handler exclusively for URLs with the given scheme. | ||
| // It is not yet reflected in the official chrome.devtools.panels in @types/chrome | ||
| // see: https://issues.chromium.org/issues/427430112 | ||
| // | ||
| // NOTE: This feature requires the following Chrome flag to be enabled: | ||
| // chrome://flags/#enable-devtools-deep-link-via-extensibility-api | ||
| type OpenResourceHandler = ( | ||
| callback: (resource: {url: string}) => void, | ||
| urlScheme?: string, | ||
| ) => void; | ||
| chrome.storage.local.get('isGoogler', (res) => { | ||
| const isGoogler = res['isGoogler'] !== false; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this set |
||
| createDevToolsPanel(isGoogler ? 'Angular & Wiz' : 'Angular'); | ||
| }); | ||
|
|
||
| const setHandler = chrome.devtools.panels.setOpenResourceHandler as OpenResourceHandler; | ||
| function createDevToolsPanel(title: string) { | ||
| chrome.devtools.panels.create( | ||
| title, | ||
| // Firefox specifically displays the icon in the tab. | ||
| // the bw icon wasn't visible in dark mode | ||
| theme === 'dark' ? 'assets/icon16.png' : 'assets/icon-bw16.png', | ||
| 'index.html', | ||
| (panel) => { | ||
| // Keep a reference to the panel's window so we can post messages | ||
| // even if the panel is already visible (onShown won't re-fire). | ||
| let currentPanelWindow: Window | null = null; | ||
| panel.onShown.addListener((panelWindow: Window) => { | ||
| currentPanelWindow = panelWindow; | ||
| }); | ||
| panel.onHidden.addListener(() => { | ||
| currentPanelWindow = null; | ||
| }); | ||
|
|
||
| setHandler((resource: {url: string}) => { | ||
| // Extract the instance ID from "angular-devtools://component/{instanceId}". | ||
| const match = resource.url.match(/^angular-devtools:\/\/component\/(\d+)$/); | ||
| if (!match) return; | ||
| // Register a handler for deep links from the Chrome Performance panel. | ||
| // When the user clicks on an Angular performance entry (e.g. a component lifecycle hook), | ||
| // Chrome calls this handler with the deep link URL, activating the Angular DevTools panel | ||
| // and navigating to the relevant component. | ||
| // | ||
| // The optional `urlScheme` second parameter on `setOpenResourceHandler` is a Chrome 140+ | ||
| // extension that registers this handler exclusively for URLs with the given scheme. | ||
| // It is not yet reflected in the official chrome.devtools.panels in @types/chrome | ||
| // see: https://issues.chromium.org/issues/427430112 | ||
| // | ||
| // NOTE: This feature requires the following Chrome flag to be enabled: | ||
| // chrome://flags/#enable-devtools-deep-link-via-extensibility-api | ||
| type OpenResourceHandler = ( | ||
| callback: (resource: {url: string}) => void, | ||
| urlScheme?: string, | ||
| ) => void; | ||
|
|
||
| const instanceId = parseInt(match[1], 10); | ||
| const setHandler = chrome.devtools.panels.setOpenResourceHandler as OpenResourceHandler; | ||
|
|
||
| panel.show(); | ||
| setHandler((resource: {url: string}) => { | ||
| // Extract the instance ID from "angular-devtools://component/{instanceId}". | ||
| const match = resource.url.match(/^angular-devtools:\/\/component\/(\d+)$/); | ||
| if (!match) return; | ||
|
|
||
| // Post immediately if the panel is already visible; otherwise wait for onShown. | ||
| if (currentPanelWindow) { | ||
| currentPanelWindow.postMessage({type: 'angular-devtools-deep-link', instanceId}, '*'); | ||
| } else { | ||
| const onShown = (panelWindow: Window) => { | ||
| panel.onShown.removeListener(onShown); | ||
| const instanceId = parseInt(match[1], 10); | ||
|
|
||
| panelWindow.postMessage( | ||
| { | ||
| type: 'angular-devtools-deep-link', | ||
| instanceId, | ||
| }, | ||
| '*', | ||
| ); | ||
| }; | ||
| panel.show(); | ||
|
|
||
| panel.onShown.addListener(onShown); | ||
| } | ||
| }, DEEP_LINK_SCHEME); | ||
| }, | ||
| ); | ||
| // Post immediately if the panel is already visible; otherwise wait for onShown. | ||
| if (currentPanelWindow) { | ||
| currentPanelWindow.postMessage({type: 'angular-devtools-deep-link', instanceId}, '*'); | ||
| } else { | ||
| const onShown = (panelWindow: Window) => { | ||
| panel.onShown.removeListener(onShown); | ||
|
|
||
| panelWindow.postMessage( | ||
| { | ||
| type: 'angular-devtools-deep-link', | ||
| instanceId, | ||
| }, | ||
| '*', | ||
| ); | ||
| }; | ||
|
|
||
| panel.onShown.addListener(onShown); | ||
| } | ||
| }, DEEP_LINK_SCHEME); | ||
| }, | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.