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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DerivedData
*.ipa
*.xcuserstate
project.xcworkspace
example/ios/.xcode.env.local
**/.xcode.env.local

# Android/IJ
#
Expand Down Expand Up @@ -77,3 +77,10 @@ android/keystores/debug.keystore

# generated by bob
lib/

# React Native Codegen
ios/generated
android/generated

# React Native Nitro Modules
nitrogen/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
23 changes: 0 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,6 @@ To run the example app on iOS:
yarn example ios
```

By default, the example is configured to build with the old architecture. To run the example with the new architecture, you can do the following:

1. For Android, run:

```sh
ORG_GRADLE_PROJECT_newArchEnabled=true yarn example android
```

2. For iOS, run:

```sh
cd example/ios
RCT_NEW_ARCH_ENABLED=1 pod install
cd -
yarn example ios
```

If you are building for a different architecture than your previous build, make sure to remove the build folders first. You can run the following command to cleanup all build folders:

```sh
yarn clean
```

To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:

```sh
Expand Down
19 changes: 7 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
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["OrientationDirector_kotlinVersion"]
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['OrientationDirector_' + 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 isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}
Expand All @@ -25,10 +27,6 @@ if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

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

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["OrientationDirector_" + name]).toInteger()
}
Expand Down Expand Up @@ -111,10 +109,7 @@ def robolectric_version = getDefault("robolectricVersion")
def mockito_core_version = getDefault("mockitoCoreVersion")

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"

testImplementation "junit:junit:$junit_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.orientationdirector

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

class OrientationDirectorPackage : TurboReactPackage() {
class OrientationDirectorPackage : BaseReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return if (name == OrientationDirectorModuleImpl.NAME) {
OrientationDirectorModule(reactContext)
Expand All @@ -26,7 +26,6 @@ class OrientationDirectorPackage : TurboReactPackage() {
OrientationDirectorModuleImpl.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
isTurboModule // isTurboModule
)
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,7 @@ SPEC CHECKSUMS:
React-logger: 9a0c4e1e41cd640ac49d69aacadab783f7e0096b
React-Mapbuffer: 6993c785c22a170c02489bc78ed207814cbd700f
React-microtasksnativemodule: 19230cd0933df6f6dc1336c9a9edc382d62638ae
react-native-orientation-director: c0dab0122a86a4b9fb062cd71b6d1c1fc10a42ae
react-native-orientation-director: 93fcddefcbbc2bb2e26fea97ae81991c44060346
react-native-safe-area-context: 6b85173d2cee963d5232ac2fd260e8ebd63273dc
React-nativeconfig: cd0fbb40987a9658c24dab5812c14e5522a64929
React-NativeModulesApple: 45187d13c68d47250a7416b18ff082c7cc07bff7
Expand Down
1 change: 0 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import AppNavigationContainer from './AppNavigationContainer';

export default function App() {
Expand Down
1 change: 0 additions & 1 deletion example/src/AppNavigationContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Home from './screens/Home';
Expand Down
1 change: 0 additions & 1 deletion example/src/screens/Explore.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Button, Text, View } from 'react-native';
import { exploreStyle } from './styles';
import RNOrientationDirector, {
Expand Down
1 change: 0 additions & 1 deletion example/src/screens/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useNavigation } from '@react-navigation/native';
import React from 'react';
import { Button, ScrollView, Text, View } from 'react-native';
import { homepageStyle } from './styles';
import RNOrientationDirector, {
Expand Down
1 change: 0 additions & 1 deletion example/src/screens/InnerExplore.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Text, View } from 'react-native';
import { innerExploreStyle } from './styles';
import RNOrientationDirector, {
Expand Down
2 changes: 1 addition & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pre-commit:
run: npx eslint {staged_files}
types:
glob: "*.{js,ts, jsx, tsx}"
run: npx tsc --noEmit
run: npx tsc
commit-msg:
parallel: true
commands:
Expand Down
56 changes: 43 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
"name": "react-native-orientation-director",
"version": "2.2.0",
"description": "A Modern React Native library that allows you to access orientation",
"main": "lib/commonjs/index",
"module": "lib/module/index",
"types": "lib/typescript/src/index.d.ts",
"react-native": "src/index",
"source": "src/index",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",
"module": "./lib/module/index.js",
"exports": {
".": {
"import": {
"types": "./lib/typescript/module/src/index.d.ts",
"default": "./lib/module/index.js"
},
"require": {
"types": "./lib/typescript/commonjs/src/index.d.ts",
"default": "./lib/commonjs/index.js"
}
}
},
"files": [
"src",
"lib",
Expand All @@ -28,7 +38,7 @@
"scripts": {
"example": "yarn workspace react-native-orientation-director-example",
"test": "jest",
"typecheck": "tsc --noEmit",
"typecheck": "tsc",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bob build",
Expand Down Expand Up @@ -56,7 +66,7 @@
"@commitlint/config-conventional": "^17.0.2",
"@evilmartians/lefthook": "^1.5.0",
"@react-native/eslint-config": "^0.73.1",
"@release-it/conventional-changelog": "^5.0.0",
"@release-it/conventional-changelog": "^9.0.2",
"@types/jest": "^29.5.5",
"@types/react": "^18.2.44",
"commitlint": "^17.0.2",
Expand All @@ -68,8 +78,8 @@
"prettier": "^3.0.3",
"react": "18.3.1",
"react-native": "0.77.0",
"react-native-builder-bob": "^0.23.2",
"release-it": "^15.0.0",
"react-native-builder-bob": "^0.36.0",
"release-it": "^17.10.0",
"turbo": "^1.10.7",
"typescript": "^5.2.2"
},
Expand Down Expand Up @@ -133,6 +143,7 @@
"prettier"
],
"rules": {
"react/react-in-jsx-scope": "off",
"prettier/prettier": [
"error",
{
Expand Down Expand Up @@ -160,19 +171,38 @@
"source": "src",
"output": "lib",
"targets": [
"commonjs",
"module",
[
"commonjs",
{
"esm": true
}
],
[
"module",
{
"esm": true
}
],
[
"typescript",
{
"project": "tsconfig.build.json"
"project": "tsconfig.build.json",
"esm": true
}
]
]
},
"codegenConfig": {
"name": "RNOrientationDirectorSpec",
"type": "modules",
"jsSrcsDir": "src"
"jsSrcsDir": "src",
"android": {
"javaPackageName": "com.orientationdirector"
}
},
"create-react-native-library": {
"type": "turbo-module",
"languages": "kotlin-objc",
"version": "0.48.0"
}
}
3 changes: 2 additions & 1 deletion react-native-orientation-director.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Pod::Spec.new do |s|
s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/gladiuscode/react-native-orientation-director.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
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
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig",
"exclude": ["example"]
"exclude": ["example", "lib"]
}
12 changes: 7 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": ["esnext"],
"module": "esnext",
"moduleResolution": "node",
"jsx": "react-jsx",
"lib": ["ESNext"],
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
Expand All @@ -20,9 +21,10 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"resolvePackageJsonImports": false,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"target": "ESNext",
"verbatimModuleSyntax": true
}
}
2 changes: 2 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build:android": {
"env": ["ORG_GRADLE_PROJECT_newArchEnabled"],
"inputs": [
"package.json",
"android",
Expand All @@ -17,6 +18,7 @@
"outputs": []
},
"build:ios": {
"env": ["RCT_NEW_ARCH_ENABLED"],
"inputs": [
"package.json",
"*.podspec",
Expand Down
Loading
Loading