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

[wasm/js] find or implement fs.open mapping to local storage and working #124

Open
ldemailly opened this issue Aug 11, 2024 · 1 comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ldemailly
Copy link
Member

so load/save can work on the web client version

@ldemailly
Copy link
Member Author

ldemailly commented Aug 11, 2024

Possible pointers from slack #webassembly : (thanks Bailey Hayes)

The emscripten toolchain has a couple different impls for filesystems. IDB FS uses IndexedDB: https://emscripten.org/docs/api_reference/Filesystem-API.html?highlight=fs#filesystem-api-idbfs
Note there are some gotchas to using localStorage: https://emscripten.org/docs/compiling/Deploying-Pages.html?highlight=localstorage#providing-a-quick-second-time-load
If you build targeting wasip2 and then use jco to build for the web, you'd be able to use the shims as part of the jco ecosytem (wasip2): https://github.com/bytecodealliance/jco/blob/main/packages/preview2-shim/lib/nodejs/filesystem.js
In practice, I usually see most folks use an in-memory fs for portability (like emscripten's). A third option is to build a wasip2 component and then compose with wasi-virt to virtualize the fs (aka it's an in-memory fs): https://github.com/bytecodealliance/wasi-virt. This approach is more bleeding edge and will likely have a few rough edges.

You could also take a look at jsfs, which implements all of the os stdlib io functions with a persistent IndexedDB backend. (You need to use this
wasm_exec.js along with it).

https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API is (maybe) available everywhere local storage is (to be verified)

@ldemailly ldemailly added help wanted Extra attention is needed good first issue Good for newcomers labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant