Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/build-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ description: 'Set up your GitHub Actions workflow with a specific version of Nod
inputs:
new-arch-enabled:
description: 'Enable new architecture (example: 1 or 0))'
required: true
required: false
default: '1'

rn-ver:
description: 'Version of React Native (example: 0.72.6))'
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
new_arch_enabled: [ 1, 0 ]
rn_ver: [ latest ] # also, can be any npm tag: 0.71-stable, next, nightly
steps:
- name: Checkout repository
Expand All @@ -69,7 +68,6 @@ jobs:
- uses: ./.github/actions/build-app
with:
arch: arm64-v8a
new-arch-enabled: ${{ matrix.new_arch_enabled }}
rn-ver: ${{ matrix.rn_ver }}
module-to-install: ${{ github.workspace }}
store-artifacts: true
Expand All @@ -82,7 +80,6 @@ jobs:
fail-fast: false
max-parallel: 3
matrix:
new_arch_enabled: [ 1, 0 ]
rn_ver: [ latest ] # also, can be any npm tag: 0.71-stable, next, nightly
steps:
- name: Checkout repository
Expand All @@ -91,7 +88,6 @@ jobs:
fetch-depth: 0
- uses: ./.github/actions/build-app
with:
new-arch-enabled: ${{ matrix.new_arch_enabled }}
rn-ver: ${{ matrix.rn_ver }}
module-to-install: ${{ github.workspace }}
store-artifacts: true
Expand Down
15 changes: 0 additions & 15 deletions .release-it.json

This file was deleted.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ Originally extracted from React Native [`issue#23313`](https://github.com/facebo

## Getting started

### Requirements

Starting from v5, this library supports only the [New Architecture](https://reactnative.dev/architecture/landing-page) (TurboModules). The Old Architecture is no longer supported.

| Library version | React Native version | Architecture |
| --------------- | -------------------- | -------------- |
| 5.x | >= 0.74 | New only |
| 4.x | >= 0.57 | Old and New |

> [!NOTE]
> React Native 0.76+ enables the New Architecture by default. On React Native 0.74 and 0.75 you must enable it manually: set `newArchEnabled=true` in `android/gradle.properties`, and install pods with `RCT_NEW_ARCH_ENABLED=1 npx pod-install`.
>
> If your app still uses the Old Architecture, stay on v4.

### Install

```shell
Expand Down
42 changes: 6 additions & 36 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ buildscript {
}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

if (project == rootProject) {
apply from: 'spotless.gradle'
}
Expand All @@ -31,7 +27,9 @@ if (project.extensions.findByName('kotlin') == null) {
apply plugin: "kotlin-android"
}

if (isNewArchitectureEnabled()) {
// Skip when `android/` is evaluated standalone (e.g. `yarn lint:android`),
// where the React Native Gradle plugin is not on the classpath.
if (project != rootProject) {
apply plugin: "com.facebook.react"
}

Expand All @@ -43,33 +41,12 @@ def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNImageEditor_" + name]).toInteger()
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
return (major == 7 && minor >= 3) || major >= 8
}

android {
if (supportsNamespace()) {
namespace "com.reactnativecommunity.imageeditor"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}
namespace "com.reactnativecommunity.imageeditor"
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildFeatures {
buildConfig true
}

buildTypes {
Expand All @@ -92,11 +69,7 @@ android {

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ["src/newarch", "${project.buildDir}/generated/source/codegen/java"]
} else {
java.srcDirs += ["src/oldarch"]
}
java.srcDirs += ["${project.buildDir}/generated/source/codegen/java"]
}
}
}
Expand All @@ -110,10 +83,7 @@ def kotlinx_coroutines_version = getExtOrDefault('kotlinxCoroutinesVersion')
def androidx_exifinterface_version = getExtOrDefault('androidxExifinterfaceVersion')

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.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"
implementation "androidx.exifinterface:exifinterface:$androidx_exifinterface_version"
}
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativecommunity.imageeditor">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
2 changes: 0 additions & 2 deletions android/src/main/AndroidManifestNew.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
*/
package com.reactnativecommunity.imageeditor

import com.facebook.react.TurboReactPackage
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.turbomodule.core.interfaces.TurboModule

class ImageEditorPackage : TurboReactPackage() {
class ImageEditorPackage : BaseReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return if (name == ImageEditorModule.NAME) {
ImageEditorModule(reactContext)
Expand All @@ -24,21 +22,18 @@ class ImageEditorPackage : TurboReactPackage() {
}

override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
val moduleList: Array<Class<out NativeModule?>> = arrayOf(ImageEditorModule::class.java)
val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap()
for (moduleClass in moduleList) {
val reactModule = moduleClass.getAnnotation(ReactModule::class.java) ?: continue
reactModuleInfoMap[reactModule.name] =
ReactModuleInfo(
reactModule.name,
moduleClass.name,
true,
reactModule.needsEagerInit,
reactModule.hasConstants,
reactModule.isCxxModule,
TurboModule::class.java.isAssignableFrom(moduleClass)
)
return ReactModuleInfoProvider {
mapOf(
ImageEditorModule.NAME to
ReactModuleInfo(
ImageEditorModule.NAME, // name
ImageEditorModule::class.java.name, // className
true, // canOverrideExistingModule
false, // needsEagerInit
false, // isCxxModule
true, // isTurboModule
)
)
}
return ReactModuleInfoProvider { reactModuleInfoMap }
}
}

This file was deleted.

6 changes: 0 additions & 6 deletions ios/RNCImageEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#ifdef RCT_NEW_ARCH_ENABLED
#import "RNCImageEditorSpec.h"

@interface RNCImageEditor : NSObject <NativeRNCImageEditorSpec>
#else
#import <React/RCTBridgeModule.h>

@interface RNCImageEditor : NSObject <RCTBridgeModule>
#endif

@end
22 changes: 0 additions & 22 deletions ios/RNCImageEditor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ - (Params)adaptParamsWithFormat:(id)format
* be scaled down to `displaySize` rather than `size`.
* All units are in px (not points).
*/
#ifdef RCT_NEW_ARCH_ENABLED
- (void) cropImage:(NSString *)uri
cropData:(JS::NativeRNCImageEditor::SpecCropImageCropData &)data
resolve:(RCTPromiseResolveBlock)resolve
Expand All @@ -97,25 +96,6 @@ - (void) cropImage:(NSString *)uri
quality:@(data.quality().has_value() ? *data.quality() : DEFAULT_COMPRESSION_QUALITY)
includeBase64:@(data.includeBase64().has_value() ? *data.includeBase64() : NO)
headers: data.headers()];
#else
RCT_EXPORT_METHOD(cropImage:(NSString *)uri
cropData:(NSDictionary *)cropData
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
auto params = [self adaptParamsWithFormat:cropData[@"format"]
width:cropData[@"size"][@"width"]
height:cropData[@"size"][@"height"]
offsetX:cropData[@"offset"][@"x"]
offsetY:cropData[@"offset"][@"y"]
resizeMode:cropData[@"resizeMode"]
displayWidth:cropData[@"displaySize"] ? cropData[@"displaySize"][@"width"] : @(DEFAULT_DISPLAY_SIZE)
displayHeight:cropData[@"displaySize"] ? cropData[@"displaySize"][@"height"] : @(DEFAULT_DISPLAY_SIZE)
quality:cropData[@"quality"] ? cropData[@"quality"] : @(DEFAULT_COMPRESSION_QUALITY)
includeBase64:cropData[@"includeBase64"]
headers:cropData[@"headers"]];

#endif
NSMutableURLRequest *imageRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: uri]];
[params.headers enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
if (value) {
Expand Down Expand Up @@ -198,12 +178,10 @@ - (void) cropImage:(NSString *)uri
}];
}

#ifdef RCT_NEW_ARCH_ENABLED
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return std::make_shared<facebook::react::NativeRNCImageEditorSpecJSI>(params);
}
#endif

@end
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-community/image-editor",
"version": "4.3.0",
"version": "5.0.0",
"description": "React Native Image Editing native modules for iOS & Android",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down Expand Up @@ -52,12 +52,11 @@
"lint": "eslint '**/*.{js,ts,tsx}'",
"lint:android": "./android/gradlew -p android spotlessCheck --quiet",
"format:android": "./android/gradlew -p android spotlessapply",
"release": "release-it",
"build": "bob build",
"prepack": "yarn run build"
},
"peerDependencies": {
"react-native": ">=0.57.0"
"react-native": ">=0.74.0"
},
"peerDependenciesMeta": {
"react-native": {
Expand All @@ -70,13 +69,12 @@
"@react-native/babel-preset": "^0.86.1",
"@react-native/typescript-config": "^0.86.1",
"@types/react": "^19.2.17",
"eslint": "^9.18.0",
"eslint": "^9.39.5",
"prettier": "^3.9.6",
"react": "^19.2.8",
"react-native": "^0.86.0",
"react-native-builder-bob": "^0.35.2",
"react-native-test-app": "^5.4.5",
"release-it": "^10.3.1",
"typescript": "^6.0.3"
},
"publishConfig": {
Expand Down
Loading
Loading