Skip to content

Commit 89ffbfe

Browse files
committed
WIP: modify all changes RN 0.59 to RN 0.62 by hands
1 parent 32e3702 commit 89ffbfe

File tree

28 files changed

+721
-1286
lines changed

28 files changed

+721
-1286
lines changed

StaticServerExample/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

StaticServerExample/.flowconfig

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
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
1817

19-
; Ignore metro
20-
.*/node_modules/metro/.*
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
2120

2221
[include]
2322

2423
[libs]
25-
node_modules/react-native/Libraries/react-native/react-native-interface.js
24+
node_modules/react-native/interface.js
2625
node_modules/react-native/flow/
2726

2827
[options]
@@ -31,39 +30,44 @@ emoji=true
3130
esproposal.optional_chaining=enable
3231
esproposal.nullish_coalescing=enable
3332

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

4937
munge_underscores=true
5038

51-
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'
52-
53-
module.file_ext=.js
54-
module.file_ext=.jsx
55-
module.file_ext=.json
56-
module.file_ext=.native.js
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
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'
5741

5842
suppress_type=$FlowIssue
5943
suppress_type=$FlowFixMe
6044
suppress_type=$FlowFixMeProps
6145
suppress_type=$FlowFixMeState
6246

63-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6649
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
6750

51+
[lints]
52+
sketchy-null-number=warn
53+
sketchy-null-mixed=warn
54+
sketchy-number=warn
55+
untyped-type-import=warn
56+
nonstrict-import=warn
57+
deprecated-type=warn
58+
unsafe-getters-setters=warn
59+
inexact-spread=warn
60+
unnecessary-invariant=warn
61+
signature-verification-failure=warn
62+
deprecated-utility=error
63+
[strict]
64+
deprecated-type
65+
nonstrict-import
66+
sketchy-null
67+
unclear-type
68+
unsafe-getters-setters
69+
untyped-import
70+
untyped-type-import
71+
6872
[version]
69-
^0.92.0
73+
^0.113.0

StaticServerExample/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
*.pbxproj -text
2+
# specific for windows script files
3+
*.bat text eol=crlf

StaticServerExample/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#
@@ -54,3 +54,6 @@ buck-out/
5454

5555
# Bundle artifact
5656
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/

StaticServerExample/.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

StaticServerExample/android/app/build.gradle

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ import com.android.build.OutputFile
1515
* // the name of the generated asset file containing your JS bundle
1616
* bundleAssetName: "index.android.bundle",
1717
*
18-
* // the entry file for bundle generation
18+
* // the entry file for bundle generation. If none specified and
19+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20+
* // default. Can be overridden with ENTRY_FILE environment variable.
1921
* entryFile: "index.android.js",
2022
*
23+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
24+
* bundleCommand: "ram-bundle",
25+
*
2126
* // whether to bundle JS and assets in debug mode
2227
* bundleInDebug: false,
2328
*
@@ -73,7 +78,7 @@ import com.android.build.OutputFile
7378
*/
7479

7580
project.ext.react = [
76-
entryFile: "index.js"
81+
enableHermes: false, // clean and rebuild if changing
7782
]
7883

7984
apply from: "../../node_modules/react-native/react.gradle"
@@ -93,6 +98,28 @@ def enableSeparateBuildPerCPUArchitecture = false
9398
*/
9499
def enableProguardInReleaseBuilds = false
95100

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

@@ -116,34 +143,76 @@ android {
116143
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
117144
}
118145
}
146+
signingConfigs {
147+
debug {
148+
storeFile file('debug.keystore')
149+
storePassword 'android'
150+
keyAlias 'androiddebugkey'
151+
keyPassword 'android'
152+
}
153+
}
119154
buildTypes {
155+
debug {
156+
signingConfig signingConfigs.debug
157+
}
120158
release {
159+
// Caution! In production, you need to generate your own keystore file.
160+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
161+
signingConfig signingConfigs.debug
121162
minifyEnabled enableProguardInReleaseBuilds
122163
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
123164
}
124165
}
166+
167+
packagingOptions {
168+
pickFirst "lib/armeabi-v7a/libc++_shared.so"
169+
pickFirst "lib/arm64-v8a/libc++_shared.so"
170+
pickFirst "lib/x86/libc++_shared.so"
171+
pickFirst "lib/x86_64/libc++_shared.so"
172+
}
173+
125174
// applicationVariants are e.g. debug, release
126175
applicationVariants.all { variant ->
127176
variant.outputs.each { output ->
128177
// For each separate APK per architecture, set a unique version code as described here:
129-
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
130-
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
178+
// https://developer.android.com/studio/build/configure-apk-splits.html
179+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
131180
def abi = output.getFilter(OutputFile.ABI)
132181
if (abi != null) { // null for the universal-debug, universal-release variants
133182
output.versionCodeOverride =
134183
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
135184
}
185+
136186
}
137187
}
138188
}
139189

140190
dependencies {
141-
implementation project(':rn-fetch-blob')
142-
implementation project(':react-native-webview')
143-
implementation project(':react-native-static-server')
144191
implementation fileTree(dir: "libs", include: ["*.jar"])
145-
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
192+
//noinspection GradleDynamicVersion
146193
implementation "com.facebook.react:react-native:+" // From node_modules
194+
195+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
196+
197+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
198+
exclude group:'com.facebook.fbjni'
199+
}
200+
201+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202+
exclude group:'com.facebook.flipper'
203+
}
204+
205+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
206+
exclude group:'com.facebook.flipper'
207+
}
208+
209+
if (enableHermes) {
210+
def hermesPath = "../../node_modules/hermes-engine/android/";
211+
debugImplementation files(hermesPath + "hermes-debug.aar")
212+
releaseImplementation files(hermesPath + "hermes-release.aar")
213+
} else {
214+
implementation jscFlavor
215+
}
147216
}
148217

149218
// Run this once to be able to run the application with BUCK
@@ -152,3 +221,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
152221
from configurations.compile
153222
into 'libs'
154223
}
224+
225+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

StaticServerExample/android/app/proguard-rules.pro

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,3 @@
99

1010
# Add any project specific keep options here:
1111

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: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+
* directory of this source tree.
6+
*/
7+
package com.staticserverexample;
8+
import android.content.Context;
9+
import com.facebook.flipper.android.AndroidFlipperClient;
10+
import com.facebook.flipper.android.utils.FlipperUtils;
11+
import com.facebook.flipper.core.FlipperClient;
12+
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
13+
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
14+
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
15+
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
16+
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
17+
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
18+
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
19+
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
20+
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
21+
import com.facebook.react.ReactInstanceManager;
22+
import com.facebook.react.bridge.ReactContext;
23+
import com.facebook.react.modules.network.NetworkingModule;
24+
import okhttp3.OkHttpClient;
25+
public class ReactNativeFlipper {
26+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
27+
if (FlipperUtils.shouldEnableFlipper(context)) {
28+
final FlipperClient client = AndroidFlipperClient.getInstance(context);
29+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
30+
client.addPlugin(new ReactFlipperPlugin());
31+
client.addPlugin(new DatabasesFlipperPlugin(context));
32+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
33+
client.addPlugin(CrashReporterPlugin.getInstance());
34+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
35+
NetworkingModule.setCustomClientBuilder(
36+
new NetworkingModule.CustomClientBuilder() {
37+
@Override
38+
public void apply(OkHttpClient.Builder builder) {
39+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
40+
}
41+
});
42+
client.addPlugin(networkFlipperPlugin);
43+
client.start();
44+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
45+
// Hence we run if after all native modules have been initialized
46+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
47+
if (reactContext == null) {
48+
reactInstanceManager.addReactInstanceEventListener(
49+
new ReactInstanceManager.ReactInstanceEventListener() {
50+
@Override
51+
public void onReactContextInitialized(ReactContext reactContext) {
52+
reactInstanceManager.removeReactInstanceEventListener(this);
53+
reactContext.runOnNativeModulesQueueThread(
54+
new Runnable() {
55+
@Override
56+
public void run() {
57+
client.addPlugin(new FrescoFlipperPlugin());
58+
}
59+
});
60+
}
61+
});
62+
} else {
63+
client.addPlugin(new FrescoFlipperPlugin());
64+
}
65+
}
66+
}
67+
}

StaticServerExample/android/app/src/main/java/com/staticserverexample/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
public class MainActivity extends ReactActivity {
66

77
/**
8-
* Returns the name of the main component registered from JavaScript.
9-
* This is used to schedule rendering of the component.
8+
* Returns the name of the main component registered from JavaScript. This is used to schedule
9+
* rendering of the component.
1010
*/
1111
@Override
1212
protected String getMainComponentName() {

0 commit comments

Comments
 (0)