forked from itinance/react-native-fs
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 4
[WIP] Nitro Modules Migration #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Draft
      
      
            ian-wd
  wants to merge
  19
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
nitro-migration
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
                
     Draft
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    6eb2777    to
    5ca45fa      
    Compare
  
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  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.
  
    
  
    
🚀 Nitro Modules Migration + Streaming API (Beta)
Overview
This is a major release that completely reimagines
react-native-fs2by migrating from the legacy React Native architecture to Nitro Modules, bringing significant performance improvements and introducing a powerful new File Streaming API.🎯 Key Changes
✨ Migration to Nitro Modules
The entire native bridge has been rewritten using Nitro Modules, providing:
🌊 Streaming API (Beta)
Introducing a new File Streaming API for efficient handling of large files:
Read Streams
Write Streams
Key Features
See FILE_STREAM.md for complete documentation.
📋 Changes & Compatibility
✅ Mostly Backward Compatible!
The core API remains backward compatible - most existing code will work without changes!
Required Dependencies
You'll need to add Nitro Modules as a peer dependency:
{ "react-native-nitro-modules": "^0.29.7" }API Improvements (Non-Breaking)
Backward Compatible File Operations
The core file API remains backward compatible! You can still use the same API:
Under the hood: The native bridge now uses
ArrayBufferfor better performance and smaller memory footprint, but encoding/decoding is handled transparently in JavaScript. No code changes required!Download API - Fully Backward Compatible
The download API remains 100% backward compatible:
Internal improvement: Under the hood, the download system now uses Nitro's event listeners for better performance, but the public API is unchanged.
Breaking Type Changes
These changes may require code updates:
Timestamps as numbers:
ReadDirItemandstat()now return timestamps as numbers (milliseconds since epoch) instead of Date objectsMediaStore
queryMediaStoreresult structure changed (Breaking - requires code changes):MediaStoreQueryResult→MediaStoreFilecontentUri→uriname,mimeType,size,dateAdded,dateModified,relativePathMigration: Replace all
result.contentUriwithresult.uriMediaStore type renames (Breaking for TypeScript users):
FileDescriptor→FileDescriptionStricter types: Hash algorithms and file protection types are now union types for better type safety
🎁 New Features
Stream API
Enhanced MediaStore Support (Android)
MediaStore functionality remains available with improved type safety and performance.
Improved Error Handling
Better error messages with platform-specific error codes and context.
🚀 Performance Improvements
📚 Documentation
New documentation added:
🔧 Migration Guide
1. Install Dependencies
2. Update Imports
3. Verify File Operations
Most file operations are backward compatible - no changes needed! The same API works:
4. (Optional) Explore New Features
Check out the new capabilities:
5. Test Key Areas
Since most APIs are backward compatible, focus testing on:
mtime/ctimefromstat()orreadDir()(now numbers instead of Date)🐛 Known Issues
🙏 Acknowledgments
This major release builds upon the foundation of
react-native-fsand leverages the incredible work of:📦 Package Info
Testing Checklist
Note: This is a major version bump due to the architectural change and new peer dependency requirement. The API is mostly backward compatible with only minor type changes for timestamps. Most apps can upgrade with minimal changes!