Skip to content

Commit

Permalink
Merge pull request #97 from friederbluemle/update-rn
Browse files Browse the repository at this point in the history
  • Loading branch information
friederbluemle authored Mar 1, 2023
2 parents 7faa70c + e7a5749 commit 8e02e80
Show file tree
Hide file tree
Showing 19 changed files with 4,172 additions and 4,344 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android/
ios/
74 changes: 35 additions & 39 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,66 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*
node_modules/react-native/Libraries/polyfills/.*

; Ignore metro
.*/node_modules/metro/.*
; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

; Ignore malformed json
.*/node_modules/resolve/test/.*\.json

.*/example/.*

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/interface.js
node_modules/react-native/flow/

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*

munge_underscores=true
exact_by_default=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
format.bracket_spacing=false

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
unnecessary-invariant=warn
signature-verification-failure=warn

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.92.0
^0.158.0
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
- run: yarn --frozen-lockfile
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 6.5
gradle-version: 6.9
- name: Create Gradle Wrapper scripts
working-directory: ./android
run: gradle wrapper --gradle-version 5.4.1
run: gradle wrapper --gradle-version 6.9
- name: Run Android tests
uses: reactivecircus/android-emulator-runner@v2
with:
Expand All @@ -52,13 +52,21 @@ jobs:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ios/Pods/
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '12.0'
xcode-version: '12.1'
- run: yarn --frozen-lockfile
- working-directory: ./ios
run: pod install
- name: Run iOS tests
working-directory: ./ios
run: xcodebuild -scheme "ElectrodeReactNativeBridgeTests" -destination "platform=iOS Simulator,name=iPhone 8" test
run: xcodebuild -workspace "ElectrodeReactNativeBridge.xcworkspace" -scheme "ElectrodeReactNativeBridgeTests" -destination "platform=iOS Simulator,name=iPhone 8" test
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ node_modules/
npm-debug.log
yarn-error.log

# VSCode
.vscode
# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
};
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,9 @@ Mandatory:
Example:

```javascript
electrodeBridge.registerRequestHandler(
'myapp.awesomerequest',
(requestData) => {
return Promise.resolve({hello: 'World'});
},
);
electrodeBridge.registerRequestHandler('myapp.awesomerequest', requestData => {
return Promise.resolve({hello: 'World'});
});
```

#### electrodeBridge.registerEventListener
Expand All @@ -157,7 +154,7 @@ Mandatory:
Example:

```javascript
electrodeBridge.registerEventListener('myapp.coolevent', (eventData) => {
electrodeBridge.registerEventListener('myapp.coolevent', eventData => {
// Do whatever you need to do
});
```
Expand Down
38 changes: 17 additions & 21 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ buildscript {
if (project == rootProject) {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
ndk {
Expand All @@ -46,30 +46,26 @@ android {
}
}

def REACT_NATIVE_VERSION = new groovy.json.JsonSlurper().parse(new File("$rootDir/../node_modules/react-native/package.json")).version
configurations.all {
resolutionStrategy {
// Remove this override in 0.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}

repositories {
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
jcenter()
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral()
google()
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//noinspection GradleDynamicVersion
androidTestImplementation 'org.webkit:android-jsc:+' // From node_modules
androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.walmartlabs.electrode.reactnative.bridge.helpers.Logger;

import org.junit.Before;
Expand All @@ -54,6 +55,7 @@ public class BaseBridgeTestCase {
@Before
public void setUp() throws Exception {
Logger.overrideLogLevel(Logger.LogLevel.DEBUG);
SoLoader.init(InstrumentationRegistry.getInstrumentation().getContext(), /* native exopackage */ false);
initBridge();
ElectrodeBridgeTransceiver.instance().debug_ClearRequestHandlerRegistrar();
((EventRegistrarImpl) mockEventRegistrar).reset();
Expand Down Expand Up @@ -104,8 +106,9 @@ public void onReactContextInitialized(ReactContext context) {

private class MockElectrodePackage extends ElectrodeBridgePackage {

@NonNull
@Override
public List<NativeModule> createNativeModules(final ReactApplicationContext reactContext) {
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
this.electrodeBridgeTransceiver = ElectrodeBridgeTransceiver.create(getReactContextWrapper(reactContext));
modules.add(electrodeBridgeTransceiver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package com.walmartlabs.electrode.reactnative.bridge;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.uimanager.ViewManager;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -32,25 +33,18 @@ public class ElectrodeBridgePackage implements ReactPackage {
@VisibleForTesting
ElectrodeBridgeTransceiver electrodeBridgeTransceiver;

@NonNull
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
this.electrodeBridgeTransceiver = ElectrodeBridgeTransceiver.create(reactContext);
modules.add(electrodeBridgeTransceiver);
return modules;
}

// Do not annotate the method with @Override
// We want to provide backward compatibility starting react-native version 0.42
// Breaking change in react-native version 0.47 : Android Remove unused createJSModules calls
// Find more information here : https://github.com/facebook/react-native/releases/tag/v0.47.2
// https://github.com/facebook/react-native/commit/ce6fb337a146e6f261f2afb564aa19363774a7a8
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}

@NonNull
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}

Expand Down
Loading

0 comments on commit 8e02e80

Please sign in to comment.