Question: Transfering data from window to extension
See original GitHub issueHey, i have a question. I would like to use this implementation of vscode in browser as frontend for lowcode platform. I want to use this in iframe and i want to send data through window.postMessage.
However vscode extension has no access to window object. I tried creating custom command similarly to github1s.vscode.get-browser-url
and i am able to register eventListener on window in this way, but i have no clue how to pass information from callback to extension
Is this even possible?
Thanks for info
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Chrome extension: sending data to window created with ...
windows.create in my extension. I've got the wiring between content script and background script right. I can right click an element and send...
Read more >Migrate data of a Chrome extension from one computer to ...
Fortunately, it is possible to individually migrate the extension's specific data in Brave browser, as per this question.
Read more >Chrome Extensions Message passing
How to pass messages between extensions and content scripts.
Read more >How to install and manage Azure CLI extensions
To see the Azure CLI extensions provided and maintained by Microsoft, use the az extension list-available command. Azure CLI Copy.
Read more >Visual Studio Code Frequently Asked Questions
If you don't want to send usage data to Microsoft, you can set the telemetry.telemetryLevel user setting to off . From File >...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think we can do that:
@mecirmartin
Yes, the extension runs inside a webworker, so we can’t visit the
window
object directly. And the extension host service also runs inside an isolated iframe:https://github.com/conwnet/github1s/blob/master/resources/index.html#L180-L181
We can also use the
postMessage
API inside a webworker (just contact with the extension host service directly), but I think the vscode command maybe better in this case.You can register a command like
github1s.vscode.get-browser-url
in vscode main service, and then the extension can get the data from vscode main service by using the extension API (vscode.commands.executeCommand('github1s.vscode.get-browser-url', ...arguments)
). Noted theReturns
of theexecuteCommand
API is the returned value of the given command(thewindow
object works here) and thearguments
is the data we can get inside an extension context (webworker).https://code.visualstudio.com/api/references/vscode-api#commands
You can also register a command in your extension context using the API (vscode.commands.registerCommand). So that we can call the function which comes from the extension context once the vscode is ready when we are in vscode main service.
Hope the information above can help you.