-
Notifications
You must be signed in to change notification settings - Fork 282
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
Expose (some) CDP commands #893
Comments
I'd be open to that. Feel free to toss in a PR, or I can get to it eventually. Code pointers:
|
Thanks - I'll try to submit a PR this week! |
I would like to piggyback on What do you think about this and how is your PR coming? Maybe we can collaborate on this? |
I would prefer a design where you don't actually proxy 'everything'. For example, you may not care about |
I've started working with the Edge Devtools team who would like to integrate with js-debug using this mechanism too. I'm not sure how far you've gone, my initial thought for a design would be something like this:
If you've got something working, I'd like to help bring that in, let me know 🙂 |
I like that! Also, it would be very nice if this design allows multiple extensions to use this API, not just exclusive access. I guess this is unproblematic as I got something working, but it was just a technical proof of concept, nothing that could help yet. Due to university exams and my masters thesis, I had to put my idea on hold, but I will resume in a couple of months. |
There's a small difficulty is that the typescript api is only accessible by extensions running in the same extension host. js-debug will always run in the workspace, and this would mean ui extensions don't have access. However I'm not sure if m/any extensions will run into this, there are not many ui extensions.
Yep
Ok, thanks for letting me know. Hope your thesis goes well! |
I see. Anyways, I think it might make sense to make this a hidden implementation detail of some
Thanks! I was lucky and found a nice employer who will let me work on VS Code, I hope I can focus more on VS Code/extensions then ;) |
I am digging my way through a similar solution right now, with three differences:
Good to hear that my approach was not that much off so far 😅 @connor4312 I will adapt my solution to your considerations and keep you posted.
For my project personally, I feel like this is enough. |
EDIT: I opted for a different approach for now... Please ignore this message :) |
Thanks for your work, that looks like a great start!
There is, but you may not like it 😄 type DomainMethods<D extends keyof Cdp.Api> = {
[M in keyof Cdp.Api[D]]: Cdp.Api[D][M] extends (params: infer P) => Promise<infer R>
? [P, R]
: never;
};
private async sendToCDP<
Domain extends keyof Cdp.Api,
Method extends keyof DomainMethods<Domain>,
Signature extends DomainMethods<Domain>[Method]
>(domain: Domain, method: Method, params: Signature[0]): Promise<Signature[1]> {
const agent = this.cdp[domain];
if (agent) {
const fn = agent[method];
if (typeof fn === 'function') {
return await fn(params);
} else {
throw new Error(`Unknown method for domain "${method}"`);
}
} else {
throw new Error(`Unknown domain "${domain}"`);
}
} As far as I know there isn't a way to do that for the second case, however, since the overloaded Feel free to put in a PR, that will give me write access and I can help put in tweaks to get this ready to ship 🚢 |
Thank you for your input! I tried to do something similar, but obviously missed the
Let's keep it simple then. Even with the suggested
Nice! I just opened #964. Please let me know how you want to proceed and where I can jump in. |
Thanks for your work and input, I've documented this here |
fyi @swissmanu @hediet please be aware of this breaking change in the upcoming nightly #987 |
thx! will keep that in mind 👍 |
@hediet please verify this one! |
for what it's worth, i have this successfully running with the current release of |
My toy extension works nicely with this new API, but I cannot get the current stack trace if the extensions connects to the proxy while the debugger is already in a paused state. |
@hediet We can add replay behavior for the Debugger.paused event here: vscode-js-debug/src/adapter/cdpProxy.ts Lines 152 to 162 in 9a4ed83
|
I'd love to play around with the
Page.captureScreenshot
request for an experimental VS Code extension.It would be awesome if the VS Code Debug Adapter would expose some request that would allow to call these CDB requests through
debugSession.customRequest
.Advantages
Risks
I guess to mitigate 1), the exposed CDP requests could be allow-listed (e.g. only when using the non-insiders build to enable exploring ideas).
Page.captureScreenshot
should be pretty risk free.What do you think?
The text was updated successfully, but these errors were encountered: