Add WASMFS/OPFS filesystem backend support #109
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds OPFS (Origin Private File System) via Emscripten's WASMFS as a new persistent storage backend for browser environments. OPFS provides improved performance and quota management compared to IDBFS.
Build System
Release-opfsandDebug-opfstargets tobuild.sh-sWASMFS -sWASM_BIGINTwith asyncify enabledImplementation
emscriptenbuild/post-opfs.js: Glue code based onpost-async.jswith WASMFS configurationtest-browser-opfs/: Test suite covering clone, commit, push, and file operationsopfsjob in GitHub Actions workflowUsage
Browser Support
Chrome 86+, Edge 86+, Firefox 111+, Safari 15.2+
Original prompt
Goal
Enable and test Emscripten's WASMFS (with OPFS) as a filesystem backend for wasm-git, providing the same (or better) test coverage as currently exists for MEMFS/IDBFS/NODEFS.
Closes #108
Background
Current Implementation Details
Build System (
emscriptenbuild/build.sh)The current build exports these filesystems:
Build targets exist for:
Debug/Release- synchronous versionsDebug-async/Release-async- async versions with AsyncifyTest Structure
test/- Node.js teststest-browser/- Browser tests (sync version with web worker)test-browser-async/- Browser tests (async version)Required Changes
1. Build Configuration Changes (
emscriptenbuild/build.sh)Add new build targets for WASMFS/OPFS:
Key Emscripten flags needed:
-sWASMFS- Enable the new WASMFS implementation-sOPFS- Enable OPFS backend for WASMFS-pthreadif synchronous file access handles are required2. JavaScript Glue Code (
emscriptenbuild/post-opfs.js)Create a new file for OPFS-specific initialization, similar to
post-async.js:3. Test Directory (
test-browser-opfs/)Create a new test directory mirroring
test-browser-async/structure:test-browser-opfs/test.spec.js- Test file using OPFStest-browser-opfs/lg2_opfs.js- Symlink to build outputtest-browser-opfs/lg2_opfs.wasm- Symlink to build outputThe test should cover the same operations as existing tests:
4. Karma/Test Runner Configuration
Add new config file
karma.conf-opfs.jsor extend existing configuration to support OPFS tests.Add npm script in
package.json:5. GitHub Actions CI (
.github/workflows/main.yml)Add OPFS build and test steps to the CI pipeline.
6. Documentation Updates
Update
README.mdto document:Technical Considerations
Threading/CORS Requirements
OPFS's synchronous access handles may require SharedArrayBuffer:
Cross-Origin-Opener-Policy: same-originheaderThis pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.