Skip to content

Commit

Permalink
Merge branch 'dev-v2.31'
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Jan 28, 2025
2 parents 4e80566 + 8556bd4 commit f142cb3
Show file tree
Hide file tree
Showing 49 changed files with 1,069 additions and 2,280 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.13.0
v22.13.1
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<!-- Collection of hyperlinks. -->
[Date]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
[New Architecture]: https://reactnative.dev/docs/the-new-architecture/landing-page
[Old Architecture]: https://reactnative.dev/docs/native-modules-intro
[React Native]: https://reactnative.dev/
[react-native-fs]: https://github.com/itinance/react-native-fs
<!-- End of hyperlinks collection. -->
Expand All @@ -17,8 +15,7 @@
<!-- End of status badges section. -->

File system access for [React Native] applications for Android, iOS,
Mac (Catalyst), and Windows platforms. Supports both [new][New Architecture]
and [old][Old Architecture] [RN][React Native] architectures.
Mac (Catalyst), and Windows platforms.

[![Sponsor](https://raw.githubusercontent.com/birdofpreyru/react-native-fs/master/.README/sponsor.svg)](https://github.com/sponsors/birdofpreyru)

Expand Down Expand Up @@ -174,9 +171,8 @@ npx react-native autolink-windows --sln "windows\ReactNativeFsExample.sln" --pro

This project is a fork of the upstream [react-native-fs] library, which has been
abandoned by its owners and maintainers. This forks aims to keep the library on
par with the latest React Native standards, with support of the [New Architecture],
backward compatibility with the [Old Architecture]; and to further develop
the library according to the best industry practices.
par with the latest React Native standards, and to further develop the library
according to the best industry practices.

To migrate from the legacy [react-native-fs] install this fork_
```bash
Expand Down
34 changes: 10 additions & 24 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ReactNativeFs_kotlinVersion"]
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeFs_' + name]
}

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.android.tools.build:gradle:8.7.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
}
}

def reactNativeArchitectures() {
def value = rootProject.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
Expand All @@ -30,10 +27,6 @@ if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNativeFs_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeFs_" + name]).toInteger()
}
Expand Down Expand Up @@ -89,14 +82,10 @@ android {
sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"src/newarch",
// Codegen specs
"generated/java",
"generated/jni"
]
} else {
java.srcDirs += ["src/oldarch"]
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}
Expand All @@ -110,10 +99,7 @@ repositories {
def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

Expand Down
10 changes: 5 additions & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ReactNativeFs_kotlinVersion=1.7.0
ReactNativeFs_minSdkVersion=21
ReactNativeFs_targetSdkVersion=31
ReactNativeFs_compileSdkVersion=31
ReactNativeFs_ndkversion=21.4.7075529
ReactNativeFs_kotlinVersion=2.0.21
ReactNativeFs_minSdkVersion=24
ReactNativeFs_targetSdkVersion=34
ReactNativeFs_compileSdkVersion=35
ReactNativeFs_ndkversion=27.1.12297006
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.facebook.react.ReactActivity
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.annotations.ReactModule

import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.WritableMap
Expand All @@ -41,8 +43,9 @@ import java.util.ArrayDeque
// Note: Some input files use or override a deprecated API.
// Note: Recompile with -Xlint:deprecation for details.
// It should be taken care of later.
class ReactNativeFsModule internal constructor(context: ReactApplicationContext) :
ReactNativeFsSpec(context) {
@ReactModule(name = ReactNativeFsModule.NAME)
class ReactNativeFsModule(reactContext: ReactApplicationContext) :
NativeReactNativeFsSpec(reactContext) {
private val downloaders = SparseArray<Downloader>()
private val uploaders = SparseArray<Uploader>()
private val pendingPickFilePromises = ArrayDeque<Promise>()
Expand Down Expand Up @@ -480,7 +483,8 @@ class ReactNativeFsModule internal constructor(context: ReactApplicationContext)
var mimeTypes = emptyArray<String>()
if (mimeTypesArray != null) {
for (i in 0 until mimeTypesArray.size()) {
mimeTypes += mimeTypesArray.getString(i)
val type = mimeTypesArray.getString(i)
if (type != null) mimeTypes += type
}
}

Expand Down Expand Up @@ -741,7 +745,8 @@ class ReactNativeFsModule internal constructor(context: ReactApplicationContext)
val fileList = ArrayList<ReadableMap>()
val params = UploadParams()
for (i in 0 until files!!.size()) {
fileList.add(files.getMap(i))
val map = files.getMap(i)
if (map != null) fileList.add(map)
}
params.src = url
params.files = fileList
Expand Down Expand Up @@ -1005,6 +1010,10 @@ class ReactNativeFsModule internal constructor(context: ReactApplicationContext)
emitter.emit(eventName, params)
}

override fun getName(): String {
return NAME
}

companion object {
const val NAME = "ReactNativeFs"

Expand All @@ -1023,8 +1032,4 @@ class ReactNativeFsModule internal constructor(context: ReactApplicationContext)
return bytesResult
}
}

override fun getName(): String {
return NAME
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.drpogodin.reactnativefs

import com.facebook.react.TurboReactPackage
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import java.util.HashMap

class ReactNativeFsPackage : TurboReactPackage() {
class ReactNativeFsPackage : BaseReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return if (name == ReactNativeFsModule.NAME) {
ReactNativeFsModule(reactContext)
Expand All @@ -19,15 +19,13 @@ class ReactNativeFsPackage : TurboReactPackage() {
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
return ReactModuleInfoProvider {
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
moduleInfos[ReactNativeFsModule.NAME] = ReactModuleInfo(
ReactNativeFsModule.NAME,
ReactNativeFsModule.NAME,
canOverrideExistingModule = false, // canOverrideExistingModule
needsEagerInit = false, // needsEagerInit
hasConstants = true, // hasConstants
isCxxModule = false, // isCxxModule
isTurboModule = isTurboModule // isTurboModule
isTurboModule = true // isTurboModule
)
moduleInfos
}
Expand Down
7 changes: 0 additions & 7 deletions android/src/newarch/ReactNativeFsSpec.kt

This file was deleted.

118 changes: 0 additions & 118 deletions android/src/oldarch/ReactNativeFsSpec.kt

This file was deleted.

4 changes: 1 addition & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module.exports = {
presets: [
['module:react-native-builder-bob/babel-preset', { modules: 'commonjs' }],
],
presets: ['module:react-native-builder-bob/babel-preset'],
};
5 changes: 3 additions & 2 deletions dr-pogodin-react-native-fs.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported, osx: "10.15" }
s.platforms = { :ios => min_ios_version_supported, :osx => "10.13" }
s.source = { :git => "https://github.com/birdofpreyru/react-native-fs.git", :tag => "#{s.version}" }

s.resource_bundles = { 'RNFS_PrivacyInfo' => 'ios/PrivacyInfo.xcprivacy' }
s.frameworks = "Photos"
s.frameworks = "AVFoundation", "Photos"
s.source_files = "ios/**/*.{h,m,mm,cpp}"
s.private_header_files = "ios/generated/**/*.h"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
Expand Down
1 change: 1 addition & 0 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ruby ">= 2.6.10"
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
gem 'concurrent-ruby', '< 1.3.4'
10 changes: 8 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ def isNewArchitectureEnabled() {
if (isNewArchitectureEnabled()) {
// Since our library doesn't invoke codegen automatically we need to do it here.
tasks.register('invokeLibraryCodegen', Exec) {
workingDir "$rootDir/../../"
commandLine "npx", "bob", "build", "--target", "codegen"
workingDir "$rootDir/../../"
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')

if (isWindows) {
commandLine 'cmd', '/c', 'npx bob build --target codegen'
} else {
commandLine 'sh', '-c', 'npx bob build --target codegen'
}
}
preBuild.dependsOn invokeLibraryCodegen
}
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buildscript {
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.24"
ndkVersion = "27.1.12297006"
kotlinVersion = "2.0.21"
}
repositories {
google()
Expand Down
Loading

0 comments on commit f142cb3

Please sign in to comment.