-
Notifications
You must be signed in to change notification settings - Fork 69
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
Thoughts on shimming browseURL() #295
Comments
Yes, we will definitely want to handle One issue I can think of is that if the local HTML file depends on other files on the VFS (e.g. scripts or images), those too would need to be transferred to the main thread for display. It would probably be possible to parse the HTML file in question to look for dependencies, but that might not be the best solution. Making use of a JS Service Worker might be possible and prefereable. This is how Shinylive exposes a web server in the R process to the main thread. However, only one service worker can be active at a time for a particular origin, so such a method will need to be mindful of the existing webR Service Worker communication channel that may or may not already be running in the page.
The easiest way is probably through a custom webR channel message. Running the following in R: webr::eval_js("chan.write({ type: 'myEvent', data: { mydata: 123 } })") will cause a custom message to appear in Lines 14 to 27 in 1c36fda
|
+1 this would be super useful! |
With the infrastructure added by #449 the steps to implement this are now much more approachable:
|
The browseURL() function defines :
As far as I can tell, this can be shimmed via running JS code in the main thread.
Two case:
Possibly, we might start with supporting only remote URL (the helps says "Some platforms also accept file paths.", so I feel like this is ok to not support local file in a first time).
I'm not exactly sure how to send JS code from webr to be executed in the main thread, though, any help on how to do this would be awesome :)
Thanks
The text was updated successfully, but these errors were encountered: