Skip to content
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

React Native 0.77.x compatibility #167

Merged
merged 6 commits into from
Jan 22, 2025
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
13 changes: 0 additions & 13 deletions .eslintrc.js

This file was deleted.

18 changes: 12 additions & 6 deletions .github/actions/build-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,23 @@ runs:
run: |
set -x # print all executed commands

export YARN_ENABLE_IMMUTABLE_INSTALLS=false

# Create new tmp React Native project
npx react-native@${{ inputs.rn-ver }} init ${{ env.APP_NAME }} --version ${{ inputs.rn-ver }} --skip-git-init --install-pods false
npx @react-native-community/cli init ${{ env.APP_NAME }} --version ${{ inputs.rn-ver }} --skip-git-init --install-pods false --pm yarn
cd ${{ env.APP_NAME }}

# Install my module
# Yarn1 syntax: yarn add ${{ inputs.module-to-install }}
# Yarn Berry (2+) syntax:
yarn add @react-native-community/image-editor@portal:${{ inputs.module-to-install }}
# Link my module
if [ -d ".yarn" ]; then
# Yarn Berry (2+) syntax:
yarn add @react-native-community/image-editor@portal:${{ inputs.module-to-install }}
else
# Yarn1 syntax:
yarn add ${{ inputs.module-to-install }}
fi

# Debug info
npx react-native@${{ inputs.rn-ver }} info
npx @react-native-community/cli info

if [[ '${{ inputs.platform }}' == 'ios' ]]; then
brew install xcbeautify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
}
}

/**
* React Native
* - 0.77.x: toHashMap(): HashMap<String, Any?>?
* - 0.76.x: toHashMap(): HashMap<String, Any>?
*/
fun <V> safeConvert(map: HashMap<String, V>?): HashMap<String, Any>? {
return map?.filterValues { it != null } as? HashMap<String, Any>
}

/**
* Crop an image. If all goes well, the promise will be resolved with the file:// URI of the new
* image as the only argument. This is a temporary file - consider using
Expand All @@ -102,7 +111,7 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
fun cropImage(uri: String?, options: ReadableMap, promise: Promise) {
val headers =
if (options.hasKey("headers") && options.getType("headers") == ReadableType.Map)
options.getMap("headers")?.toHashMap()
safeConvert(options.getMap("headers")?.toHashMap())
else null
val format = if (options.hasKey("format")) options.getString("format") else null
val offset = if (options.hasKey("offset")) options.getMap("offset") else null
Expand Down
16 changes: 16 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const callstackConfigReact = require('@callstack/eslint-config/react.flat.js');

module.exports = [
{
ignores: ['node_modules/', 'lib/'],
},
...callstackConfigReact,
{
files: ['eslint.config.js', 'example/**/*.{js,ts,tsx}'],
rules: {
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'require-await': 'off',
},
},
];
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Jetifier randomly fails on these libraries
android.jetifier.ignorelist=hermes-android
android.jetifier.ignorelist=hermes-android,react-android

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
Expand Down
Binary file modified example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
4 changes: 4 additions & 0 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"dist/assets",
"dist/main.macos.jsbundle"
],
"visionos": [
"dist/assets",
"dist/main.visionos.jsbundle"
],
"windows": [
"dist/assets",
"dist/main.windows.bundle"
Expand Down
4 changes: 4 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @format
*/

import { AppRegistry } from 'react-native';
import App from './src/App';
import { name as appName } from './app.json';
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ require "#{ws_dir}/node_modules/react-native-test-app/test_app.rb"

workspace 'ImageEditorExample.xcworkspace'

use_test_app!
use_test_app! :hermes_enabled => true
Loading
Loading