Skip to content
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

Use JSROOT FileProxy to access files from WebView #20

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

linev
Copy link
Contributor

@linev linev commented Jul 5, 2022

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.

@linev linev changed the title [do not merge!!!] How FileProxy can be used in WebWiew [do not merge!!!] How FileProxy can be used in WebView Jul 5, 2022
@linev linev changed the title [do not merge!!!] How FileProxy can be used in WebView Use JSROOT FileProxy to access files from WebView Jul 7, 2022
@linev
Copy link
Contributor Author

linev commented Jul 7, 2022

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

This was referenced Jul 7, 2022
@AlbertoPdRF
Copy link
Owner

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?

AlbertoPdRF added a commit that referenced this pull request Aug 4, 2022
This is extracted from #20

Co-authored-by: Sergey Linev <[email protected]>
@AlbertoPdRF
Copy link
Owner

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 microsoft/vscode#84515 (comment).) 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 48e321b.

Thanks for all your help @linev!

@linev
Copy link
Contributor Author

linev commented Aug 9, 2022

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.

@AlbertoPdRF
Copy link
Owner

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.

@linev
Copy link
Contributor Author

linev commented Aug 9, 2022

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.

@AlbertoPdRF
Copy link
Owner

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.)

@linev
Copy link
Contributor Author

linev commented Aug 9, 2022

Then one have to use vscode.workspace.fs - but only when it is ready for such use.

@AlbertoPdRF
Copy link
Owner

Yep! Let's see if the people from VS Code reply, and then we can see how to move forward 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants