Lots of cleanup still left to do. Draft PR for adding support for OPFS for WASM build (add support for limbo in browser). Overall explanation of the architecture: this follows the sqlite wasm architecture for OPFS. main <> (limbo-worker.js) limbo (VFS - opfs.js) <> opfs-sync-proxy The main thread loads limbo-worker.js which bootstraps the opfs.js and opfs-sync-proxy.js and then launches the limbo-wasm.js. At that point it can be used with worker.postmessage and worker.onmessage interactions from the main thread. The VFS provided by opfs.js provides a sync API by offloading async operations to opfs-sync-proxy.js. This is done through SharedArrayBuffer and Atomic.wait() to make the actual async operations appear synchronous for limbo. resolves #531 Closes #594
Limbo Wasm bindings
This source tree contains Limbo Wasm bindings.
Building
For nodejs
./scripts/build
For web
./scripts/build web
Browser Support
Adding experimental support for limbo in the browser. This is done by adding support for OPFS as a VFS.
To see a basic example of this npm run dev and navigate to http://localhost:5173/limbo-opfs-test.html and open the console.
Design
This design mirrors sqlite's approach for OPFS support. It has a sync api in opfs.js which communicates with opfs-sync-proxy.js via SharedArrayBuffer and Atomics.wait. This allows us to live the VFS api in lib.rs unchanged.
You can see limbo-opfs-test.html for basic usage.
UTs
There are OPFS specific unit tests and then some basic limbo unit tests. These are run via npm test or npx vitest.
For more info and log output you can run npx vitest:ui but you can get some parallel execution of test cases which cause issues.
TODO
-[] Add a wrapper js that provides a clean interface to the limbo-worker.js
-[] Add more tests for opfs.js operations
-[] Add error return handling
-[] Make sure posix flags for open are handled instead of just being ignored (this requires creating a mapping of behaviors from posix to opfs as far as makes sense)