feat(p2-shim): add opfs filesystem adapter - #2095
Conversation
e0456d6 to
64c1588
Compare
There was a problem hiding this comment.
This is awesome! Thanks for working on this -- most of my nits are more about testing and reserving some future optionality.
One more thing I'd really love to have is an E2E test in the browser! We have machinery and browser automation already set up, but for some reason we don't actually use it from any of the tests... I think you should be able to copy the setup in other projects (jco, primarily), but also happy to leave that as a follow up (we can make a new issue to track that separately, it would be very easy for anyone else to pick up), if you'd rather get this in as-is!
64c1588 to
b398726
Compare
b398726 to
2e47e5e
Compare
|
Added e2e coverage using the harness in test/common.ts (startTestServer/runBasicHarnessPageTest), in opfs-filesystem-e2e.ts:
|
vados-cosmonic
left a comment
There was a problem hiding this comment.
LGTM 🚀
I think some of the new tests could do without the beforeAll (since they are testing results from a single run), but that can definitely get fixed in a follow up!)
e2f0547
Adds a first-party OPFS-backed filesystem adapter for
preview2-shim's browserwasi:filesystemimplementation, plus two non-JSPI improvement candidates (advisory locking, in-memory symlink support).OpfsFilesystemAdapter(src/browser/opfs-filesystem.ts) - loads a preopened OPFS directory into an in-memory tree once (loadOpfsCapability()), so everyDescriptorop stays fully synchronous - no JSPI required. Mutations flush back to OPFS automatically (debounced to a microtask);flush()/dispose()force it explicitly..__wasi_symlinks__.json) per root, since OPFS has no native symlink concept.lockShared/lockExclusive/tryLock*/unlock) onBrowserFilesystemDescriptor, backed by a same-process reader/writer lock inInMemoryFilesystemAdapter.new OpfsFilesystemAdapter({ lockManager: navigator.locks })opts into best-effort cross-tab coordination via the Web Locks API - off by default.lockManagertakes a narrowBrowserLockManagerinterface rather than the globalnavigatordirectly, so it's easy to fake in tests._addPreopenWithAdapter(src/browser/filesystem.ts) lets a host wire a custom adapter into the top-levelwasi:filesystem/preopenssingleton that transpiled components import statically.Related to: #144