refactor(utoo-wasm): replace sabcom with rust sync fs apis - #2460
Conversation
Summary of ChangesHello @xusd320, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the file system operations within the WASM and web worker environment by replacing the Shared Array Buffer (SAB) based synchronization mechanism with native Rust synchronous file system APIs. The core change involves introducing a new set of synchronous file system methods to the WASM Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a great refactoring that replaces the sabcom implementation with new synchronous Rust APIs for file system operations, which simplifies the codebase significantly. I've found a critical bug in the rmSync polyfill and a high-severity functional regression in statSync where timestamps are no longer correctly reported. I've also included a medium-severity suggestion to reduce code duplication in the new Rust sync functions.
a9f27de to
6cb69b1
Compare
8553771 to
811eee2
Compare
跨分支保存了。reset 掉了 |
This pull request introduces several significant changes focused on improving the file system operations in the WASM and web worker environment. The main updates include adding synchronous file system APIs to the WASM layer, updating memory configuration for WASM, and cleaning up unused shared array buffer (SAB) communication code in the web worker loader and polyfills.
WASM file system enhancements:
Projectclass incrates/utoo-wasm/src/project.rs, includingreadSync,readDirSync,writeSync,createDirSync,createDirAllSync,copyFileSync,removeFileSync,removeDirSync, andmetadataSync. These methods use a oneshot channel to bridge async Rust code into synchronous JS calls, enabling blocking file system operations from JavaScript.readmethod ofProjectto return ajs_sys::Uint8Arrayinstead of aVec<u8>, improving compatibility with JavaScript consumers.oneshotcrate as a dependency to support the new synchronous APIs.WASM build configuration:
.cargo/config.tomlby explicitly setting--initial-memory=67108864(64MB) and reordering--max-memoryto ensure proper memory configuration for the WASM runtime.Web worker and polyfill cleanup:
sabcom.tsshared array buffer communication code, indicating a shift away from SAB-based sync file system emulation in the web worker environment.loaderWorkerPool.tsandfsPolyfill.ts, simplifying worker setup and file system polyfills. [1] [2] [3] [4] [5]CommonJS loader improvements:
path.joininstead ofpath.resolvefor relative paths, ensuring correct path joining semantics.statSyncandexistsSynccache logic from the CJS loader, further cleaning up the codebase.These changes collectively modernize and streamline the WASM file system interface, improve memory handling, and remove legacy SAB-based code from the web worker environment.