Skip to content

Commit 488eff1

Browse files
authored
chore: update example to RN0.61.5 (#51)
* chore: update example to RN0.61.5 * chore: use DeviceEventEmitter * chore: update example * chore: update flow and modify tsconfig
1 parent fbcb2e7 commit 488eff1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3259
-3516
lines changed

.flowconfig

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,75 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
1514

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
; Ignore example folder
19+
.*/example/.*
1820

19-
; Ignore metro
20-
.*/node_modules/metro/.*
21+
22+
[untyped]
23+
.*/node_modules/@react-native-community/cli/.*/.*
2124

2225
[include]
2326

2427
[libs]
2528
node_modules/react-native/Libraries/react-native/react-native-interface.js
2629
node_modules/react-native/flow/
27-
node_modules/react-native/flow-github/
2830

2931
[options]
3032
emoji=true
3133

3234
esproposal.optional_chaining=enable
3335
esproposal.nullish_coalescing=enable
3436

35-
module.system=haste
36-
module.system.haste.use_name_reducers=true
37-
# get basename
38-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
39-
# strip .js or .js.flow suffix
40-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
41-
# strip .ios suffix
42-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
44-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
45-
module.system.haste.paths.blacklist=.*/__tests__/.*
46-
module.system.haste.paths.blacklist=.*/__mocks__/.*
47-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
48-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
37+
module.file_ext=.js
38+
module.file_ext=.json
39+
module.file_ext=.ios.js
4940

5041
munge_underscores=true
5142

52-
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'
53-
# Support the library import in examples
54-
module.name_mapper='^\@react-native-community/push-notification-ios$' -> '<PROJECT_ROOT>/js/index.js'
55-
56-
module.file_ext=.js
57-
module.file_ext=.jsx
58-
module.file_ext=.json
59-
module.file_ext=.native.js
43+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
44+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
45+
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'
6046

6147
suppress_type=$FlowIssue
6248
suppress_type=$FlowFixMe
6349
suppress_type=$FlowFixMeProps
6450
suppress_type=$FlowFixMeState
6551

66-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
67-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
68-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6954
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
7055

56+
[lints]
57+
sketchy-null-number=warn
58+
sketchy-null-mixed=warn
59+
sketchy-number=warn
60+
untyped-type-import=warn
61+
nonstrict-import=warn
62+
deprecated-type=warn
63+
unsafe-getters-setters=warn
64+
inexact-spread=warn
65+
unnecessary-invariant=warn
66+
signature-verification-failure=warn
67+
deprecated-utility=error
68+
69+
[strict]
70+
deprecated-type
71+
nonstrict-import
72+
sketchy-null
73+
unclear-type
74+
unsafe-getters-setters
75+
untyped-import
76+
untyped-type-import
77+
7178
[version]
72-
^0.86.0
79+
^0.105.0

.yarnclean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ docs
99
doc
1010
website
1111
images
12-
assets
1312

1413
# examples
1514
example

example/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

example/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ yarn-error.log
4040
buck-out/
4141
\.buckd/
4242
*.keystore
43+
!debug.keystore
4344

4445
# fastlane
4546
#
@@ -54,3 +55,6 @@ buck-out/
5455

5556
# Bundle artifact
5657
*.jsbundle
58+
59+
# CocoaPods
60+
/ios/Pods/

example/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/App.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
* Sample React Native App
33
* https://github.com/facebook/react-native
44
*
5-
* @format
65
* @flow
7-
* @lint-ignore-every XPLATJSCOPYRIGHT1
86
*/
97

108
import React, {Component} from 'react';
119
import {
12-
AlertIOS,
10+
Alert,
1311
StyleSheet,
1412
Text,
1513
TouchableHighlight,
1614
View,
15+
DeviceEventEmitter,
1716
} from 'react-native';
18-
import PushNotificationIOS from '@react-native-community/push-notification-ios';
17+
import PushNotificationIOS from '../js';
1918

2019
class Button extends React.Component<$FlowFixMeProps> {
2120
render() {
@@ -34,7 +33,7 @@ type Props = {};
3433
type State = {
3534
permissions: Object,
3635
};
37-
export default class App extends Component<Props, State> {
36+
export class App extends Component<Props, State> {
3837
state = {
3938
permissions: {},
4039
};
@@ -74,6 +73,7 @@ export default class App extends Component<Props, State> {
7473
}
7574

7675
render() {
76+
console.log(PushNotificationIOS);
7777
return (
7878
<View style={styles.container}>
7979
<Button
@@ -105,7 +105,7 @@ export default class App extends Component<Props, State> {
105105
}
106106

107107
_sendNotification() {
108-
require('RCTDeviceEventEmitter').emit('remoteNotificationReceived', {
108+
DeviceEventEmitter.emit('remoteNotificationReceived', {
109109
remote: true,
110110
aps: {
111111
alert: 'Sample notification',
@@ -125,20 +125,16 @@ export default class App extends Component<Props, State> {
125125
}
126126

127127
_onRegistered(deviceToken) {
128-
AlertIOS.alert(
129-
'Registered For Remote Push',
130-
`Device Token: ${deviceToken}`,
131-
[
132-
{
133-
text: 'Dismiss',
134-
onPress: null,
135-
},
136-
],
137-
);
128+
Alert.alert('Registered For Remote Push', `Device Token: ${deviceToken}`, [
129+
{
130+
text: 'Dismiss',
131+
onPress: null,
132+
},
133+
]);
138134
}
139135

140136
_onRegistrationError(error) {
141-
AlertIOS.alert(
137+
Alert.alert(
142138
'Failed To Register For Remote Push',
143139
`Error (${error.code}): ${error.message}`,
144140
[
@@ -157,7 +153,7 @@ export default class App extends Component<Props, State> {
157153
category: ${notification.getCategory()};\n
158154
content-available: ${notification.getContentAvailable()}.`;
159155

160-
AlertIOS.alert('Push Notification Received', result, [
156+
Alert.alert('Push Notification Received', result, [
161157
{
162158
text: 'Dismiss',
163159
onPress: null,
@@ -166,7 +162,7 @@ export default class App extends Component<Props, State> {
166162
}
167163

168164
_onLocalNotification(notification) {
169-
AlertIOS.alert(
165+
Alert.alert(
170166
'Local Notification Received',
171167
'Alert message: ' + notification.getMessage(),
172168
[

example/android/app/build.gradle

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import com.android.build.OutputFile
1818
* // the entry file for bundle generation
1919
* entryFile: "index.android.js",
2020
*
21+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22+
* bundleCommand: "ram-bundle",
23+
*
2124
* // whether to bundle JS and assets in debug mode
2225
* bundleInDebug: false,
2326
*
@@ -73,7 +76,8 @@ import com.android.build.OutputFile
7376
*/
7477

7578
project.ext.react = [
76-
entryFile: "index.js"
79+
entryFile: "index.js",
80+
enableHermes: false, // clean and rebuild if changing
7781
]
7882

7983
apply from: "../../node_modules/react-native/react.gradle"
@@ -93,9 +97,35 @@ def enableSeparateBuildPerCPUArchitecture = false
9397
*/
9498
def enableProguardInReleaseBuilds = false
9599

100+
/**
101+
* The preferred build flavor of JavaScriptCore.
102+
*
103+
* For example, to use the international variant, you can use:
104+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+
*
106+
* The international variant includes ICU i18n library and necessary data
107+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+
* give correct results when using with locales other than en-US. Note that
109+
* this variant is about 6MiB larger per architecture than default.
110+
*/
111+
def jscFlavor = 'org.webkit:android-jsc:+'
112+
113+
/**
114+
* Whether to enable the Hermes VM.
115+
*
116+
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+
* and the benefits of using Hermes will therefore be sharply reduced.
119+
*/
120+
def enableHermes = project.ext.react.get("enableHermes", false);
121+
96122
android {
97123
compileSdkVersion rootProject.ext.compileSdkVersion
98-
buildToolsVersion rootProject.ext.buildToolsVersion
124+
125+
compileOptions {
126+
sourceCompatibility JavaVersion.VERSION_1_8
127+
targetCompatibility JavaVersion.VERSION_1_8
128+
}
99129

100130
defaultConfig {
101131
applicationId "com.example"
@@ -109,11 +139,25 @@ android {
109139
reset()
110140
enable enableSeparateBuildPerCPUArchitecture
111141
universalApk false // If true, also generate a universal APK
112-
include "armeabi-v7a", "x86", "arm64-v8a"
142+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
143+
}
144+
}
145+
signingConfigs {
146+
debug {
147+
storeFile file('debug.keystore')
148+
storePassword 'android'
149+
keyAlias 'androiddebugkey'
150+
keyPassword 'android'
113151
}
114152
}
115153
buildTypes {
154+
debug {
155+
signingConfig signingConfigs.debug
156+
}
116157
release {
158+
// Caution! In production, you need to generate your own keystore file.
159+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
160+
signingConfig signingConfigs.debug
117161
minifyEnabled enableProguardInReleaseBuilds
118162
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
119163
}
@@ -122,21 +166,29 @@ android {
122166
applicationVariants.all { variant ->
123167
variant.outputs.each { output ->
124168
// For each separate APK per architecture, set a unique version code as described here:
125-
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
126-
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
169+
// https://developer.android.com/studio/build/configure-apk-splits.html
170+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
127171
def abi = output.getFilter(OutputFile.ABI)
128172
if (abi != null) { // null for the universal-debug, universal-release variants
129173
output.versionCodeOverride =
130174
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
131175
}
176+
132177
}
133178
}
134179
}
135180

136181
dependencies {
137182
implementation fileTree(dir: "libs", include: ["*.jar"])
138-
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
139183
implementation "com.facebook.react:react-native:+" // From node_modules
184+
185+
if (enableHermes) {
186+
def hermesPath = "../../node_modules/hermes-engine/android/";
187+
debugImplementation files(hermesPath + "hermes-debug.aar")
188+
releaseImplementation files(hermesPath + "hermes-release.aar")
189+
} else {
190+
implementation jscFlavor
191+
}
140192
}
141193

142194
// Run this once to be able to run the application with BUCK
@@ -145,3 +197,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
145197
from configurations.compile
146198
into 'libs'
147199
}
200+
201+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/debug.keystore

2.2 KB
Binary file not shown.

example/android/app/proguard-rules.pro

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,3 @@
88
# http://developer.android.com/guide/developing/tools/proguard.html
99

1010
# Add any project specific keep options here:
11-
12-
# If your project uses WebView with JS, uncomment the following
13-
# and specify the fully qualified class name to the JavaScript interface
14-
# class:
15-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16-
# public *;
17-
#}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6+
7+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
8+
</manifest>

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example">
2+
package="com.example">
33

44
<uses-permission android:name="android.permission.INTERNET" />
5-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
65

76
<application
87
android:name=".MainApplication"

0 commit comments

Comments
 (0)