emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.67k stars 3.29k forks source link

discussion - feasibility to integrate `https://wicg.github.io/file-system-access/` #12428

Open kaizhu256 opened 3 years ago

kaizhu256 commented 3 years ago

a serious limitation of downstream libraries like sql.js is inability to persist largish databases (e.g. 1gb) to local filesystem.

that might finally be overcome with newly proposed https://wicg.github.io/file-system-access (note spec's motivation appears mainly saving data in web-editors and ides). they have an experimental demo here

feasibility question - what additional spec read/write features are needed to integrate emscripten with file-system-access?

spec's current read/write capabilities are (from what i gather):

read

write

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

sbc100 commented 2 years ago

@tlively is this the same thing you are working on with wasmfs+opfs?

tlively commented 2 years ago

Very related, but the API in the OP accesses and stores data to the user's file system rather than a private file system as in OPFS.

ProgrammerIn-wonderland commented 2 months ago

Very related, but the API in the OP accesses and stores data to the user's file system rather than a private file system as in OPFS.

tested, you can replace the let root = await navigator.storage.getDirectory(); in the compiled output with

        let root;
        await new Promise((res, rej) => {
          const button = document.createElement("button")
          button.onclick = async () => {
            root = await window.showDirectoryPicker({mode:"readwrite"});
            res();
          }
          button.textContent = "Click me to proceed";
          document.body.appendChild(button);
        })

and it works fine, the emscripten code can access the local files. The button is created because showDirectoryPicker can only be run as a result of user interaction