root-file-viewer
root-file-viewer copied to clipboard
Use JSROOT FileProxy to access files from WebView
I introduce FileProxy class in JSROOT and will try to use it here.
Idea that binary data from the file can be read though such proxy.
That I am missing - how node modules can be used on Code side?
You see commented lines:
// let btoa = require('btoa'); // this should be "btoa" module
// let fs = require('fs'); // this is native "fs" module
// let fd = fs.openSync(filename, 'r');
// if (fd) {
// let stats = fs.statSync(filename.uri);
// filesize = stats.size;
// }
I need standard "fs" module and "btoa" module from node. Also would be nice if you could help to produce filename which can be used to read file content.
Now it is working, using JSROOT from master branch.
I found a way to correctly use fs - was relatively easy.
It can be merged if you like
Hey @linev!
All your work here is incredible!! Thank you so much!
I don't have much time now to go through everything, but I'll try to get to it as soon as possible. Would you mind if I split all the different changes in different PRs when I have the time?
I've finally been able to take a look at the PR! For these changes to also work when the extension runs in remote environments, vscode.workspace.fs should be used instead of regular fs. However, I believe this wouldn't allow us to read ROOT files in chunks as of now (see https://github.com/microsoft/vscode/issues/84515#issuecomment-1205111291.) Let's wait and see what the VS Code people reply.
Meanwhile, I've extracted the part that allows the PNG screenshots to be saved in 48e321b91d363b6a94551c5d4bb5354775654a6e.
Thanks for all your help @linev!
For these changes to also work when the extension runs in remote environments, vscode.workspace.fs should be used instead of regular fs.
What kind of remote environments? Reading of local files works ok.
However, I believe this wouldn't allow us to read ROOT files in chunks as of now
As I understand, it is limitation of vscode.workspace.fs. Probably, one can use it when it provides right functionality.
For these changes to also work when the extension runs in remote environments, vscode.workspace.fs should be used instead of regular fs.
What kind of remote environments? Reading of local files works ok.
When VS Code runs on the browser, through SSH, or things like that.
However, I believe this wouldn't allow us to read ROOT files in chunks as of now
As I understand, it is limitation of
vscode.workspace.fs. Probably, one can use it when it provides right functionality.
Yes, exactly! And it seems like the right functionality is already implemented, it's just that it's not exposed yet for extensions to use.
Probably, one can detect such remote environment? And if it runs on web server - may be file URL will be also with http? In such case one could use standard JSROOT file I/O which involves http requests.
Yes, I believe one should be able to detect the remote environment. However, I don't think one could use http requests like you can do when JSROOT runs in the browser standalone, as VS Code mounts a virtual file system and everything runs in more or less the same way (WebView restrictions, etc.)
Then one have to use vscode.workspace.fs - but only when it is ready for such use.
Yep! Let's see if the people from VS Code reply, and then we can see how to move forward :slightly_smiling_face: