You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, I LOVE the new v2.11.0 update, and the changes to the web IDE to use monaco to support 'references', 'go to declaration', etc.
This issue is about an idea I've had and wanted to work on myself for a while, but haven't got around to it yet. Often when exploring web apps, I make pretty heavy use of Chrome DevTools' 'Search' / 'Sources' / 'Network' / etc tabs, the debugger, and the console / utilities APIs. While there have been some nice improvements to the 'Sources' tab over the years (pretty printing, syntax highlighting, code folding, etc); one area I have really wished it was able to support for a long time now is 'references' / 'go to definition' / similar.
A thought I had in this space is that, while I obviously can't outright replace the 'Sources' tab (which I believe is based on CodeMirror), it should be possible to create a Chrome DevTools Extension that adds a new tab/panel that does similar to the current 'Sources' tab, but using monaco as it's base, and enabling features like 'references' / 'go to definition' / etc within that.
Extending DevTools
DevTools extensions add functionality to Chrome DevTools by accessing DevTools-specific extension APIs through a DevTools page added to the extension.
Some of the Chrome Extension API's that would be useful/enable this:
Use the chrome.devtools.inspectedWindow API to interact with the inspected window: obtain the tab ID for the inspected page, evaluate the code in the context of the inspected window, reload the page, or obtain the list of resources within the page.
Use the getResources call and the onResourceContent event to obtain the list of resources (documents, stylesheets, scripts, images etc) within the inspected page. The getContent and setContent methods of the Resource class along with the onResourceContentCommitted event may be used to support modification of the resource content, for example, by an external editor.
The most interesting part of this API is probably reloadOptions -> injectedScript (though userAgent might be useful sometimes too):
injectedScript: If specified, the script will be injected into every frame of the inspected page immediately upon load, before any of the frame's scripts.
userAgent: If specified, the string will override the value of the User-Agent HTTP header that's sent while loading the resources of the inspected page. The string will also override the value of the navigator.userAgent property that's returned to any scripts that are running within the inspected page.
Use the chrome.devtools.panels API to integrate your extension into Developer Tools window UI: create your own panels, access existing panels, and add sidebars.
I hadn't stumbled upon this before, but it sounds like it's possible to access the existing 'Sources' panel; can react to 'when an object is selected in the panel' (not sure what 'object' refers to in this case), can create a sidebar pane, etc
Specifies the function to be called when the user clicks a resource link in the Developer Tools window. To unset the handler, either call the method with no parameters or pass null as the parameter.
Use the chrome.devtools.network API to retrieve the information about network requests displayed by the Developer Tools in the Network panel.
Probably less specifically relevant to the functionality I was thinking of, but could be some value/crossover there, so figured I'd mention it. onNavigated / onRequestFinished might be useful in some cases.
Use the chrome.devtools.recorder API to customize the Recorder panel in DevTools. devtools.recorder API is a preview feature that allows you to extend the Recorder panel in Chrome DevTools.
Again, probably not as useful, but linking here in case.
The chrome.debugger API serves as an alternate transport for Chrome's remote debugging protocol. Use chrome.debugger to attach to one or more tabs to instrument network interaction, debug JavaScript, mutate the DOM and CSS, etc.
This can do all sorts of powerful stuff, though some of the original reasons I was thinking of needing to use it (eg. getting access to the page's script contents/etc) are apparently already covered in other more specific APIs (eg. chrome.devtools.inspectedWindow). Still worth being aware of it and the features it has though, as there is some pretty cool stuff here!
Use the chrome.runtime API to retrieve the service worker, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.
Some more esotetic, but interesting aspects of this, are the ability to communicate with other externsions and/or locally installed programs using connect / onConnectExternal / onMessageExternal / connectNative / sendMessageNative:
Attempts to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via tabs.connect.
Use the chrome.permissions API to request declared optional permissions at run time rather than install time, so users understand why the permissions are needed and grant only those that are necessary.
Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
Use the chrome.storage API to store, retrieve, and track changes to user data.
The Storage API provides an extension-specific way to persist user data and state. It's similar to the web platform's storage APIs (IndexedDB, and Storage), but was designed to meet the storage needs of extensions.
Use the offscreen API to create and manage offscreen documents.
Edit: This is also captured on the following gist for posterity, and that will likely be where I capture any future notes about my own explorations of this:
First off, I LOVE the new v2.11.0 update, and the changes to the web IDE to use
monaco
to support 'references', 'go to declaration', etc.This issue is about an idea I've had and wanted to work on myself for a while, but haven't got around to it yet. Often when exploring web apps, I make pretty heavy use of Chrome DevTools' 'Search' / 'Sources' / 'Network' / etc tabs, the debugger, and the console / utilities APIs. While there have been some nice improvements to the 'Sources' tab over the years (pretty printing, syntax highlighting, code folding, etc); one area I have really wished it was able to support for a long time now is 'references' / 'go to definition' / similar.
A thought I had in this space is that, while I obviously can't outright replace the 'Sources' tab (which I believe is based on CodeMirror), it should be possible to create a Chrome DevTools Extension that adds a new tab/panel that does similar to the current 'Sources' tab, but using
monaco
as it's base, and enabling features like 'references' / 'go to definition' / etc within that.Useful Chrome Extension APIs
Overview of extending DevTools:
Some of the Chrome Extension API's that would be useful/enable this:
frameURL
s, differentscriptExecutionContext
s, etcreloadOptions
->injectedScript
(thoughuserAgent
might be useful sometimes too):chrome.devtools.network
API to retrieve the information about network requests displayed by the Developer Tools in the Network panel.onNavigated
/onRequestFinished
might be useful in some cases.chrome.devtools.inspectedWindow
). Still worth being aware of it and the features it has though, as there is some pretty cool stuff here!Then there are also all of the 'standard' Chrome Extension APIs as well, which can do a lot of cool stuff:
A few of which could be useful for this feature:
connect
/onConnectExternal
/onMessageExternal
/connectNative
/sendMessageNative
:chrome.notifications
API to create rich notifications using templates and show these notifications to users in the system tray.And some that are a little more esoteric, but might still be interesting/useful:
Edit: This is also captured on the following gist for posterity, and that will likely be where I capture any future notes about my own explorations of this:
The text was updated successfully, but these errors were encountered: