diff --git a/template/App.tsx b/template/App.tsx old mode 100644 new mode 100755 index 9c39fa0..762b8b0 --- a/template/App.tsx +++ b/template/App.tsx @@ -1,7 +1,7 @@ /** * Sample React Native App * https://github.com/facebook/react-native - * + * * Generated with the TypeScript template * https://github.com/emin93/react-native-template-typescript * @@ -35,6 +35,11 @@ const App = () => { contentInsetAdjustmentBehavior="automatic" style={styles.scrollView}>
+ {global.HermesInternal == null ? null : ( + + Engine: Hermes + + )} Step One @@ -73,6 +78,10 @@ const styles = StyleSheet.create({ scrollView: { backgroundColor: Colors.lighter, }, + engine: { + position: 'absolute', + right: 0, + }, body: { backgroundColor: Colors.white, }, @@ -94,6 +103,14 @@ const styles = StyleSheet.create({ highlight: { fontWeight: '700', }, + footer: { + color: Colors.dark, + fontSize: 12, + fontWeight: '600', + padding: 4, + paddingRight: 12, + textAlign: 'right', + }, }); export default App; diff --git a/template/__tests__/App-test.tsx b/template/__tests__/App-test.tsx old mode 100644 new mode 100755 diff --git a/template/_gitignore b/template/_gitignore index d498e52..828cc88 100755 --- a/template/_gitignore +++ b/template/_gitignore @@ -20,7 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate -xcshareddata +project.xcworkspace # Android/IntelliJ # diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index 33fc177..7898e7b 100755 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -76,7 +76,8 @@ import com.android.build.OutputFile */ project.ext.react = [ - entryFile: "index.js" + entryFile: "index.js", + enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" @@ -97,13 +98,26 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false /** - * Use international variant JavaScriptCore - * International variant includes ICU i18n library and necessary data allowing to use - * e.g. Date.toLocaleString and String.localeCompare that give correct results - * when using with locales other than en-US. - * Note that this variant is about 6MiB larger per architecture than default. + * The preferred build flavor of JavaScriptCore. + * + * For example, to use the international variant, you can use: + * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` + * + * The international variant includes ICU i18n library and necessary data + * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that + * give correct results when using with locales other than en-US. Note that + * this variant is about 6MiB larger per architecture than default. */ -def useIntlJsc = false +def jscFlavor = 'org.webkit:android-jsc:+' + +/** + * Whether to enable the Hermes VM. + * + * This should be set on project.ext.react and mirrored here. If it is not set + * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode + * and the benefits of using Hermes will therefore be sharply reduced. + */ +def enableHermes = project.ext.react.get("enableHermes", false); android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -159,19 +173,30 @@ android { output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } + } } + + packagingOptions { + pickFirst '**/armeabi-v7a/libc++_shared.so' + pickFirst '**/x86/libc++_shared.so' + pickFirst '**/arm64-v8a/libc++_shared.so' + pickFirst '**/x86_64/libc++_shared.so' + pickFirst '**/x86/libjsc.so' + pickFirst '**/armeabi-v7a/libjsc.so' + } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules - // JSC from node_modules - if (useIntlJsc) { - implementation 'org.webkit:android-jsc-intl:+' + if (enableHermes) { + def hermesPath = "../../node_modules/hermesvm/android/"; + debugImplementation files(hermesPath + "hermes-debug.aar") + releaseImplementation files(hermesPath + "hermes-release.aar") } else { - implementation 'org.webkit:android-jsc:+' + implementation jscFlavor } } diff --git a/template/android/app/src/main/java/com/helloworld/MainActivity.java b/template/android/app/src/main/java/com/helloworld/MainActivity.java index c7106d5..1e9c189 100755 --- a/template/android/app/src/main/java/com/helloworld/MainActivity.java +++ b/template/android/app/src/main/java/com/helloworld/MainActivity.java @@ -4,12 +4,12 @@ import com.facebook.react.ReactActivity; public class MainActivity extends ReactActivity { - /** - * Returns the name of the main component registered from JavaScript. This is used to schedule - * rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "HelloWorld"; - } + /** + * Returns the name of the main component registered from JavaScript. + * This is used to schedule rendering of the component. + */ + @Override + protected String getMainComponentName() { + return "HelloWorld"; + } } diff --git a/template/android/app/src/main/java/com/helloworld/MainApplication.java b/template/android/app/src/main/java/com/helloworld/MainApplication.java index 68c6007..896a630 100755 --- a/template/android/app/src/main/java/com/helloworld/MainApplication.java +++ b/template/android/app/src/main/java/com/helloworld/MainApplication.java @@ -1,36 +1,40 @@ package com.helloworld; import android.app.Application; +import android.util.Log; + import com.facebook.react.PackageList; +import com.facebook.hermes.reactexecutor.HermesExecutorFactory; +import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; + import java.util.List; public class MainApplication extends Application implements ReactApplication { - private final ReactNativeHost mReactNativeHost = - new ReactNativeHost(this) { - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } + private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { + @Override + public boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } - @Override - protected List getPackages() { - @SuppressWarnings("UnnecessaryLocalVariable") - List packages = new PackageList(this).getPackages(); - // Packages that cannot be autolinked yet can be added manually here, for example: - // packages.add(new MyReactNativePackage()); - return packages; - } + @Override + protected List getPackages() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + // Packages that cannot be autolinked yet can be added manually here, for example: + // packages.add(new MyReactNativePackage()); + return packages; + } - @Override - protected String getJSMainModuleName() { - return "index"; - } - }; + @Override + protected String getJSMainModuleName() { + return "index"; + } + }; @Override public ReactNativeHost getReactNativeHost() { diff --git a/template/android/gradle/wrapper/gradle-wrapper.properties b/template/android/gradle/wrapper/gradle-wrapper.properties index e0c4de3..ee69dd6 100755 --- a/template/android/gradle/wrapper/gradle-wrapper.properties +++ b/template/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/template/ios/HelloWorldTests/HelloWorldTests.m b/template/ios/HelloWorldTests/HelloWorldTests.m index 3b45a1a..e9db2f1 100755 --- a/template/ios/HelloWorldTests/HelloWorldTests.m +++ b/template/ios/HelloWorldTests/HelloWorldTests.m @@ -12,7 +12,7 @@ #import #define TIMEOUT_SECONDS 600 -#define TEXT_TO_LOOK_FOR @"Welcome to React" +#define TEXT_TO_LOOK_FOR @"Welcome to React Native!" @interface HelloWorldTests : XCTestCase diff --git a/template/package.json b/template/package.json index abaf978..026a354 100755 --- a/template/package.json +++ b/template/package.json @@ -7,22 +7,22 @@ "test": "jest" }, "dependencies": { - "react": "16.8.1", - "react-native": "0.60.0" + "react": "16.8.6", + "react-native": "0.60.3" }, "devDependencies": { - "@babel/core": "^7.3.3", - "@babel/runtime": "^7.3.1", + "@babel/core": "^7.5.0", + "@babel/runtime": "^7.5.0", "@react-native-community/eslint-config": "^0.0.3", "@types/jest": "^24.0.15", "@types/react": "^16.8.23", - "@types/react-native": "^0.57.65", + "@types/react-native": "^0.60.1", "@types/react-test-renderer": "^16.8.2", "babel-jest": "^24.1.0", "jest": "^24.1.0", - "metro-react-native-babel-preset": "^0.51.1", - "react-test-renderer": "16.8.1", - "typescript": "^3.5.2" + "metro-react-native-babel-preset": "^0.54.1", + "react-test-renderer": "16.8.6", + "typescript": "^3.5.3" }, "jest": { "preset": "react-native", diff --git a/template/tsconfig.json b/template/tsconfig.json deleted file mode 100644 index 447c53d..0000000 --- a/template/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "isolatedModules": true, - "jsx": "react", - "lib": ["es6"], - "moduleResolution": "node", - "noEmit": true, - "strict": true, - "target": "esnext" - }, - "exclude": ["node_modules"] -}