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

Ideas for automatically fetching files on the web #416

Closed
kitao opened this issue Sep 17, 2022 · 6 comments
Closed

Ideas for automatically fetching files on the web #416

kitao opened this issue Sep 17, 2022 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kitao
Copy link
Owner

kitao commented Sep 17, 2022

Thanks to Pyxel's new utility script, an html file for Pyxel is very simplified like this.

Another thing I would like to achieve is automatic fetching of files.
It seems that Emscripten can't mount real file system directly, but it may be realized virtually if I can insert some hook script for each load function in Pyxel.

With the feature, I would like shorten this script from

<body>
    <div id="loading">Loading...</div>
    <pyxel-asset name="assets/pyxel_logo_38x16.png"></pyxel-asset>
    <pyxel-run root="../../python/pyxel/examples" name="01_hello_pyxel.py"
        onstart="document.getElementById('loading').remove()"></pyxel-run>
</body>

to

<body>
    <div id="loading">Loading...</div>
    <pyxel-run root="../../python/pyxel/examples" name="01_hello_pyxel.py"
        onstart="document.getElementById('loading').remove()"></pyxel-run>
</body>

If anyone has the knowledge to implement this feature, I would appreciate any advice.

@kitao kitao added enhancement New feature or request help wanted Extra attention is needed labels Sep 17, 2022
@messense
Copy link

It seems that Emscripten can't mount real file system directly,

Related pyodide/pyodide#2987

@kitao
Copy link
Owner Author

kitao commented Oct 3, 2022

@messense Thank you for the information.
So the Pyodide main branch has native-fs feature now?

@kitao
Copy link
Owner Author

kitao commented Oct 3, 2022

Ah it doesn't support Safari for now...

https://github.com/pyodide/pyodide/blob/main/docs/usage/file-system.md

@kitao
Copy link
Owner Author

kitao commented Oct 5, 2022

In 1.8.12. I added a hook function for Emscripten file system so that Pyxel can get necessary files automatically.

@kitao kitao closed this as completed Oct 5, 2022
@km19809
Copy link
Contributor

km19809 commented Oct 6, 2022

It is astonishing!
When I tried synchronous XMLRequest for hooks, the browser blocked it since it is deprecated.
But your approach works!
I know this is a closed issue AND this is not much relevant to the pyxel, but can you tell me how did you make it work?

@kitao
Copy link
Owner Author

kitao commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants