-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added additional builder method receiving arguments for using jsc or hermes to correctly decide which DSO to load at app startup. #33952
Conversation
…structor which engine to load at app startup.
Base commit: 97291bf |
Base commit: 97291bf |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor nit, but it's good to go otherwise
ReactInstanceManagerBuilder() {} | ||
|
||
/** | ||
* Constructor that takes a Boolean specifying weather to load hermes or jsc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Constructor that takes a Boolean specifying weather to load hermes or jsc | |
* Constructor that takes a Boolean specifying whether to load hermes or jsc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. Fixed it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @KunalFarmah98, thanks a lot for this PR.
I left a comment to improve the readability and maintainability of the code. Let me know if it makes sense and what do you think about it!
@@ -212,6 +212,12 @@ public static ReactInstanceManagerBuilder builder() { | |||
return new ReactInstanceManagerBuilder(); | |||
} | |||
|
|||
/** Creates a builder that is capable of creating an instance of {@link ReactInstanceManager}. | |||
* and specifies weather to load with hermes or jsc */ | |||
public static ReactInstanceManagerBuilder builder(Boolean hermesEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't better if we use an enum instead of a boolean flag?
We can have an:
enum JSInterpreter {
OLD_LOGIC,
JSC,
HERMES
}
And switch over it. It will improve readability, it avoids possible bugs due to the use of a null value which has unclear semantic and it is ready if we would ever add a new interpreter later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cipolleschi , the Boolean is passed via the host app's BuildConfig. Hence keeping it null makes much more sense as no argument would automatically imply to use the old logic.
You can refer to the recommended changes I have mentioned in the host app to make use of this feature until it is made mandatory to be passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KunalFarmah98 I understand your point, though using an enum here is a bit more future proof.
Can I ask you to update the ReactInstanceManagerBuilder
to:
- Remove the constructor which accepts a boolean in input
- Add a
setJsEngine(JSEngine)
method that accepts the enum - Add a
setJsEngineAsHermes(boolean)
parameter which will if truesetJsEngine(HERMES)
elsesetJsEngine(JSC)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cortinico.
I have made the requested changes. I will update the PR description in some time. Meanwhile you can review the new changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description is updated. @cortinico @cipolleschi you can review it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing it @KunalFarmah98 👍 Left a minor comment, and we should be good to import/merge it
@@ -66,18 +68,11 @@ public class ReactInstanceManagerBuilder { | |||
private @Nullable Map<String, RequestHandler> mCustomPackagerCommandHandlers; | |||
private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder; | |||
private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory; | |||
private Boolean hermesEnabled = null; | |||
private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; | |
private JSInterpreter jsInterpreter = JSInterpreter.OLD_LOGIC; |
Let's use jsInterpreter
everywhere to keep it aligned with the enum class name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/** | ||
* An enum that specifies the JS Engine to be used in the app | ||
* Old Logic uses the legacy code | ||
* JSC/HERMES loads the respective engine using the revamped logic | ||
*/ | ||
public enum JSInterpreter { | ||
OLD_LOGIC, | ||
JSC, | ||
HERMES | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this in a separate file as it was before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android CI tests are failing in that case, I tried 3 times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests were failing as you used a import com.facebook.react.util.JSInterpreter;
. You should be good placing JSInterpreter
inside the com.facebook.react
package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @cortinico please review
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Thanks for sendign this over @KunalFarmah98. Sorry it took longer than expect to merge, but I'm glad we have it in 👍 |
This pull request was successfully merged by @KunalFarmah98 in 87cfd38. When will my fix make it into a release? | Upcoming Releases |
Thanks @cortinico. I regularly fix react native source code crashes in our app. Will keep contributing to maintain its stability. 👍 |
…hermes to correctly decide which DSO to load at app startup. (facebook#33952) Summary: The current implementation of **getDefaultJSExecutorFactory** relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration. Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native. So we can make use of an additional **ReactInstanceManager :: setJsEngineAsHermes** method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in **ReactInstanceManagerBuilder** which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files. The code snippet in **ReactInstanceManager** for adding a new setter method: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` The code snippet for the new logic in **ReactInstanceManagerBuilder**: 1) Setting up the new logic: Adding a new enum class : ``` public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable. ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` 2) Modifying the getDefaultJSExecutorFactory method to incorporate the new logic with the old one: ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` ``` builder = ReactInstanceManager.builder() .setApplication(this) .setJsEngineAsHermes(BuildConfig.HERMES_ENABLED) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") ``` where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle: `def enableHermes = project.ext.react.get("enableHermes", true) ` and then ``` defaultConfig{ if(enableHermes) { buildConfigField("boolean", "HERMES_ENABLED", "true") } else{ buildConfigField("boolean", "HERMES_ENABLED", "false") } } ``` Our app was facing a similar issue as listed in this list: **https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO**. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button. This change can possibly solve many of the issues listed in the list as it solved ours. [GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package: ``` /** * An enum that specifies the JS Engine to be used in the app * Old Logic uses the legacy code * JSC/HERMES loads the respective engine using the revamped logic */ public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` [GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder: ``` private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; ``` [GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` [GENERAL] [ADDED] - Modified **getDefaultJSExecutorFactory** method ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` Pull Request resolved: facebook#33952 Test Plan: The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in **packagingOptions** in build.gradle and using hermes in the project. It can be like: ``` packagingOptions { if (enableHermes) { exclude "**/libjsc*.so" } } ``` Reviewed By: lunaleaps Differential Revision: D37191981 Pulled By: cortinico fbshipit-source-id: c528ead126939f1d788af7523f3798ed2a14f36e
…hermes to correctly decide which DSO to load at app startup. (#33952) Summary: The current implementation of **getDefaultJSExecutorFactory** relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration. Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native. So we can make use of an additional **ReactInstanceManager :: setJsEngineAsHermes** method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in **ReactInstanceManagerBuilder** which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files. The code snippet in **ReactInstanceManager** for adding a new setter method: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` The code snippet for the new logic in **ReactInstanceManagerBuilder**: 1) Setting up the new logic: Adding a new enum class : ``` public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable. ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` 2) Modifying the getDefaultJSExecutorFactory method to incorporate the new logic with the old one: ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` ### **Suggested changes in any Android App's MainApplication that extends ReactApplication to take advantage of this fix** ``` builder = ReactInstanceManager.builder() .setApplication(this) .setJsEngineAsHermes(BuildConfig.HERMES_ENABLED) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") ``` where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle: `def enableHermes = project.ext.react.get("enableHermes", true) ` and then ``` defaultConfig{ if(enableHermes) { buildConfigField("boolean", "HERMES_ENABLED", "true") } else{ buildConfigField("boolean", "HERMES_ENABLED", "false") } } ``` Our app was facing a similar issue as listed in this list: **https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO**. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button. This change can possibly solve many of the issues listed in the list as it solved ours. ## Changelog [GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package: ``` /** * An enum that specifies the JS Engine to be used in the app * Old Logic uses the legacy code * JSC/HERMES loads the respective engine using the revamped logic */ public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` [GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder: ``` private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; ``` [GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` [GENERAL] [ADDED] - Modified **getDefaultJSExecutorFactory** method ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` Pull Request resolved: #33952 Test Plan: The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in **packagingOptions** in build.gradle and using hermes in the project. It can be like: ``` packagingOptions { if (enableHermes) { exclude "**/libjsc*.so" } } ``` Reviewed By: lunaleaps Differential Revision: D37191981 Pulled By: cortinico fbshipit-source-id: c528ead126939f1d788af7523f3798ed2a14f36e
…hermes to correctly decide which DSO to load at app startup. (#33952) Summary: The current implementation of **getDefaultJSExecutorFactory** relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration. Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native. So we can make use of an additional **ReactInstanceManager :: setJsEngineAsHermes** method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in **ReactInstanceManagerBuilder** which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files. The code snippet in **ReactInstanceManager** for adding a new setter method: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` The code snippet for the new logic in **ReactInstanceManagerBuilder**: 1) Setting up the new logic: Adding a new enum class : ``` public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable. ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` 2) Modifying the getDefaultJSExecutorFactory method to incorporate the new logic with the old one: ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` ### **Suggested changes in any Android App's MainApplication that extends ReactApplication to take advantage of this fix** ``` builder = ReactInstanceManager.builder() .setApplication(this) .setJsEngineAsHermes(BuildConfig.HERMES_ENABLED) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") ``` where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle: `def enableHermes = project.ext.react.get("enableHermes", true) ` and then ``` defaultConfig{ if(enableHermes) { buildConfigField("boolean", "HERMES_ENABLED", "true") } else{ buildConfigField("boolean", "HERMES_ENABLED", "false") } } ``` Our app was facing a similar issue as listed in this list: **https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO**. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button. This change can possibly solve many of the issues listed in the list as it solved ours. ## Changelog [GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package: ``` /** * An enum that specifies the JS Engine to be used in the app * Old Logic uses the legacy code * JSC/HERMES loads the respective engine using the revamped logic */ public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` [GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder: ``` private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; ``` [GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` [GENERAL] [ADDED] - Modified **getDefaultJSExecutorFactory** method ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` Pull Request resolved: #33952 Test Plan: The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in **packagingOptions** in build.gradle and using hermes in the project. It can be like: ``` packagingOptions { if (enableHermes) { exclude "**/libjsc*.so" } } ``` Reviewed By: lunaleaps Differential Revision: D37191981 Pulled By: cortinico fbshipit-source-id: c528ead126939f1d788af7523f3798ed2a14f36e
* Update script from prepublish (deprecated) to prepack (facebook#34198) Summary: Currently `react-native-codegen` uses `prepublish` to pre-build before publishing. Moving to `prepare` as `prepublish` is deprecated and not invoked anymore: https://docs.npmjs.com/cli/v8/using-npm/scripts#life-cycle-scripts ## Changelog [Internal][Fixed] - [codegen] Update script from prepublish (deprecated) to prepack Pull Request resolved: facebook#34198 Test Plan: Tested locally with: ``` cd packages/react-native-codegen/ && rm -rf lib && npm publish --dry-run --foreground-scripts ``` output is: ``` > [email protected] prepare > yarn run build yarn run v1.22.18 $ yarn clean && node scripts/build.js --verbose $ rm -rf lib react-native-codegen........................................................... • src/__tests__/__snapshots__/SchemaValidator-test.js.snap (ignore) • src/__tests__/SchemaValidator-test.js (ignore) • src/cli/combine/combine-js-to-schema-cli.js ⇒ lib/cli/combine/combine-js-to-schema-cli.js • src/cli/combine/combine-js-to-schema.js ⇒ lib/cli/combine/combine-js-to-schema.js • src/cli/generators/generate-all.js ⇒ lib/cli/generators/generate-all.js • src/cli/parser/parser-cli.js ⇒ lib/cli/parser/parser-cli.js • src/cli/parser/parser.js ⇒ lib/cli/parser/parser.js • src/cli/parser/parser.sh ⇒ lib/cli/parser/parser.sh (copy) • src/CodegenSchema.js ⇒ lib/CodegenSchema.js • src/generators/__test_fixtures__/fixtures.js ⇒ lib/generators/__test_fixtures__/fixtures.js • src/generators/__tests__/RNCodegen-test.js (ignore) • src/generators/components/__test_fixtures__/fixtures.js ⇒ lib/generators/components/__test_fixtures__/fixtures.js • src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap (ignore) • src/generators/components/__tests__/GenerateComponentDescriptorH-test.js (ignore) • src/generators/components/__tests__/GenerateComponentHObjCpp-test.js (ignore) • src/generators/components/__tests__/GenerateEventEmitterCpp-test.js (ignore) • src/generators/components/__tests__/GenerateEventEmitterH-test.js (ignore) • src/generators/components/__tests__/GeneratePropsCpp-test.js (ignore) • src/generators/components/__tests__/GeneratePropsH-test.js (ignore) • src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js (ignore) • src/generators/components/__tests__/GeneratePropsJavaInterface-test.js (ignore) • src/generators/components/__tests__/GeneratePropsJavaPojo-test.js (ignore) • src/generators/components/__tests__/GenerateShadowNodeCpp-test.js (ignore) • src/generators/components/__tests__/GenerateShadowNodeH-test.js (ignore) • src/generators/components/__tests__/GenerateTests-test.js (ignore) • src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderH-test.js (ignore) • src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js (ignore) • src/generators/components/__tests__/GenerateViewConfigJs-test.js (ignore) • src/generators/components/CppHelpers.js ⇒ lib/generators/components/CppHelpers.js • src/generators/components/GenerateComponentDescriptorH.js ⇒ lib/generators/components/GenerateComponentDescriptorH.js • src/generators/components/GenerateComponentHObjCpp.js ⇒ lib/generators/components/GenerateComponentHObjCpp.js • src/generators/components/GenerateEventEmitterCpp.js ⇒ lib/generators/components/GenerateEventEmitterCpp.js • src/generators/components/GenerateEventEmitterH.js ⇒ lib/generators/components/GenerateEventEmitterH.js • src/generators/components/GeneratePropsCpp.js ⇒ lib/generators/components/GeneratePropsCpp.js • src/generators/components/GeneratePropsH.js ⇒ lib/generators/components/GeneratePropsH.js • src/generators/components/GeneratePropsJavaDelegate.js ⇒ lib/generators/components/GeneratePropsJavaDelegate.js • src/generators/components/GeneratePropsJavaInterface.js ⇒ lib/generators/components/GeneratePropsJavaInterface.js • src/generators/components/GeneratePropsJavaPojo/index.js ⇒ lib/generators/components/GeneratePropsJavaPojo/index.js • src/generators/components/GeneratePropsJavaPojo/PojoCollector.js ⇒ lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js • src/generators/components/GeneratePropsJavaPojo/serializePojo.js ⇒ lib/generators/components/GeneratePropsJavaPojo/serializePojo.js • src/generators/components/GenerateShadowNodeCpp.js ⇒ lib/generators/components/GenerateShadowNodeCpp.js • src/generators/components/GenerateShadowNodeH.js ⇒ lib/generators/components/GenerateShadowNodeH.js • src/generators/components/GenerateTests.js ⇒ lib/generators/components/GenerateTests.js • src/generators/components/GenerateThirdPartyFabricComponentsProviderH.js ⇒ lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js • src/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js ⇒ lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js • src/generators/components/GenerateViewConfigJs.js ⇒ lib/generators/components/GenerateViewConfigJs.js • src/generators/components/JavaHelpers.js ⇒ lib/generators/components/JavaHelpers.js • src/generators/modules/__test_fixtures__/fixtures.js ⇒ lib/generators/modules/__test_fixtures__/fixtures.js • src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap (ignore) • src/generators/modules/__tests__/GenerateModuleCpp-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleH-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleJniCpp-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleJniH-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleMm-test.js (ignore) • src/generators/modules/GenerateModuleCpp.js ⇒ lib/generators/modules/GenerateModuleCpp.js • src/generators/modules/GenerateModuleH.js ⇒ lib/generators/modules/GenerateModuleH.js • src/generators/modules/GenerateModuleJavaSpec.js ⇒ lib/generators/modules/GenerateModuleJavaSpec.js • src/generators/modules/GenerateModuleJniCpp.js ⇒ lib/generators/modules/GenerateModuleJniCpp.js • src/generators/modules/GenerateModuleJniH.js ⇒ lib/generators/modules/GenerateModuleJniH.js • src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js ⇒ lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js • src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js ⇒ lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js • src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js ⇒ lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js • src/generators/modules/GenerateModuleObjCpp/index.js ⇒ lib/generators/modules/GenerateModuleObjCpp/index.js • src/generators/modules/GenerateModuleObjCpp/serializeMethod.js ⇒ lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js • src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js ⇒ lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js • src/generators/modules/GenerateModuleObjCpp/StructCollector.js ⇒ lib/generators/modules/GenerateModuleObjCpp/StructCollector.js • src/generators/modules/GenerateModuleObjCpp/Utils.js ⇒ lib/generators/modules/GenerateModuleObjCpp/Utils.js • src/generators/modules/Utils.js ⇒ lib/generators/modules/Utils.js • src/generators/RNCodegen.js ⇒ lib/generators/RNCodegen.js • src/generators/Utils.js ⇒ lib/generators/Utils.js • src/parsers/flow/components/__test_fixtures__/failures.js ⇒ lib/parsers/flow/components/__test_fixtures__/failures.js • src/parsers/flow/components/__test_fixtures__/fixtures.js ⇒ lib/parsers/flow/components/__test_fixtures__/fixtures.js • src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap (ignore) • src/parsers/flow/components/__tests__/component-parser-test.js (ignore) • src/parsers/flow/components/commands.js ⇒ lib/parsers/flow/components/commands.js • src/parsers/flow/components/events.js ⇒ lib/parsers/flow/components/events.js • src/parsers/flow/components/extends.js ⇒ lib/parsers/flow/components/extends.js • src/parsers/flow/components/index.js ⇒ lib/parsers/flow/components/index.js • src/parsers/flow/components/options.js ⇒ lib/parsers/flow/components/options.js • src/parsers/flow/components/props.js ⇒ lib/parsers/flow/components/props.js • src/parsers/flow/components/schema.js ⇒ lib/parsers/flow/components/schema.js • src/parsers/flow/errors.js ⇒ lib/parsers/flow/errors.js • src/parsers/flow/index.js ⇒ lib/parsers/flow/index.js • src/parsers/flow/modules/__test_fixtures__/failures.js ⇒ lib/parsers/flow/modules/__test_fixtures__/failures.js • src/parsers/flow/modules/__test_fixtures__/fixtures.js ⇒ lib/parsers/flow/modules/__test_fixtures__/fixtures.js • src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap (ignore) • src/parsers/flow/modules/__tests__/module-parser-e2e-test.js (ignore) • src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js (ignore) • src/parsers/flow/modules/errors.js ⇒ lib/parsers/flow/modules/errors.js • src/parsers/flow/modules/index.js ⇒ lib/parsers/flow/modules/index.js • src/parsers/flow/modules/schema.js ⇒ lib/parsers/flow/modules/schema.js • src/parsers/flow/modules/utils.js ⇒ lib/parsers/flow/modules/utils.js • src/parsers/flow/utils.js ⇒ lib/parsers/flow/utils.js • src/parsers/schema/index.js ⇒ lib/parsers/schema/index.js • src/parsers/typescript/components/__test_fixtures__/failures.js ⇒ lib/parsers/typescript/components/__test_fixtures__/failures.js • src/parsers/typescript/components/__test_fixtures__/fixtures.js ⇒ lib/parsers/typescript/components/__test_fixtures__/fixtures.js • src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap (ignore) • src/parsers/typescript/components/__tests__/typescript-component-parser-test.js (ignore) • src/parsers/typescript/components/commands.js ⇒ lib/parsers/typescript/components/commands.js • src/parsers/typescript/components/events.js ⇒ lib/parsers/typescript/components/events.js • src/parsers/typescript/components/extends.js ⇒ lib/parsers/typescript/components/extends.js • src/parsers/typescript/components/index.js ⇒ lib/parsers/typescript/components/index.js • src/parsers/typescript/components/options.js ⇒ lib/parsers/typescript/components/options.js • src/parsers/typescript/components/props.js ⇒ lib/parsers/typescript/components/props.js • src/parsers/typescript/components/schema.js ⇒ lib/parsers/typescript/components/schema.js • src/parsers/typescript/errors.js ⇒ lib/parsers/typescript/errors.js • src/parsers/typescript/index.js ⇒ lib/parsers/typescript/index.js • src/parsers/typescript/modules/__test_fixtures__/failures.js ⇒ lib/parsers/typescript/modules/__test_fixtures__/failures.js • src/parsers/typescript/modules/__test_fixtures__/fixtures.js ⇒ lib/parsers/typescript/modules/__test_fixtures__/fixtures.js • src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap (ignore) • src/parsers/typescript/modules/__tests__/typescript-module-parser-e2e-test.js (ignore) • src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js (ignore) • src/parsers/typescript/modules/errors.js ⇒ lib/parsers/typescript/modules/errors.js • src/parsers/typescript/modules/index.js ⇒ lib/parsers/typescript/modules/index.js • src/parsers/typescript/modules/schema.js ⇒ lib/parsers/typescript/modules/schema.js • src/parsers/typescript/modules/utils.js ⇒ lib/parsers/typescript/modules/utils.js • src/parsers/typescript/utils.js ⇒ lib/parsers/typescript/utils.js • src/SchemaValidator.js ⇒ lib/SchemaValidator.js [ OK ] ✨ Done in 2.27s. npm notice npm notice 📦 [email protected] npm notice === Tarball Contents === npm notice 383B README.md npm notice 3.2kB lib/cli/combine/combine-js-to-schema-cli.js npm notice 1.8kB lib/cli/combine/combine-js-to-schema-cli.js.flow npm notice 2.5kB lib/cli/combine/combine-js-to-schema.js npm notice 1.3kB lib/cli/combine/combine-js-to-schema.js.flow npm notice 1.5kB lib/cli/generators/generate-all.js npm notice 1.4kB lib/cli/generators/generate-all.js.flow npm notice 1.7kB lib/cli/parser/parser-cli.js npm notice 386B lib/cli/parser/parser-cli.js.flow npm notice 777B lib/cli/parser/parser.js npm notice 811B lib/cli/parser/parser.js.flow npm notice 483B lib/cli/parser/parser.sh npm notice 222B lib/CodegenSchema.js npm notice 8.8kB lib/CodegenSchema.js.flow npm notice 1.8kB lib/generators/__test_fixtures__/fixtures.js npm notice 1.9kB lib/generators/__test_fixtures__/fixtures.js.flow npm notice 43.6kB lib/generators/components/__test_fixtures__/fixtures.js npm notice 44.0kB lib/generators/components/__test_fixtures__/fixtures.js.flow npm notice 5.7kB lib/generators/components/CppHelpers.js npm notice 6.4kB lib/generators/components/CppHelpers.js.flow npm notice 2.0kB lib/generators/components/GenerateComponentDescriptorH.js npm notice 2.3kB lib/generators/components/GenerateComponentDescriptorH.js.flow npm notice 9.3kB lib/generators/components/GenerateComponentHObjCpp.js npm notice 10.3kB lib/generators/components/GenerateComponentHObjCpp.js.flow npm notice 6.3kB lib/generators/components/GenerateEventEmitterCpp.js npm notice 7.2kB lib/generators/components/GenerateEventEmitterCpp.js.flow npm notice 6.5kB lib/generators/components/GenerateEventEmitterH.js npm notice 7.4kB lib/generators/components/GenerateEventEmitterH.js.flow npm notice 4.0kB lib/generators/components/GeneratePropsCpp.js npm notice 4.3kB lib/generators/components/GeneratePropsCpp.js.flow npm notice 23.4kB lib/generators/components/GeneratePropsH.js npm notice 26.1kB lib/generators/components/GeneratePropsH.js.flow npm notice 9.4kB lib/generators/components/GeneratePropsJavaDelegate.js npm notice 10.0kB lib/generators/components/GeneratePropsJavaDelegate.js.flow npm notice 7.1kB lib/generators/components/GeneratePropsJavaInterface.js npm notice 7.8kB lib/generators/components/GeneratePropsJavaInterface.js.flow npm notice 2.0kB lib/generators/components/GeneratePropsJavaPojo/index.js npm notice 2.1kB lib/generators/components/GeneratePropsJavaPojo/index.js.flow npm notice 4.0kB lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js npm notice 4.7kB lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow npm notice 7.2kB lib/generators/components/GeneratePropsJavaPojo/serializePojo.js npm notice 7.5kB lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow npm notice 2.0kB lib/generators/components/GenerateShadowNodeCpp.js npm notice 2.2kB lib/generators/components/GenerateShadowNodeCpp.js.flow npm notice 2.8kB lib/generators/components/GenerateShadowNodeH.js npm notice 3.1kB lib/generators/components/GenerateShadowNodeH.js.flow npm notice 5.3kB lib/generators/components/GenerateTests.js npm notice 5.9kB lib/generators/components/GenerateTests.js.flow npm notice 2.5kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js npm notice 2.7kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js.flow npm notice 2.6kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js npm notice 2.8kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js.flow npm notice 13.4kB lib/generators/components/GenerateViewConfigJs.js npm notice 14.0kB lib/generators/components/GenerateViewConfigJs.js.flow npm notice 2.7kB lib/generators/components/JavaHelpers.js npm notice 3.2kB lib/generators/components/JavaHelpers.js.flow npm notice 47.0kB lib/generators/modules/__test_fixtures__/fixtures.js npm notice 47.2kB lib/generators/modules/__test_fixtures__/fixtures.js.flow npm notice 8.4kB lib/generators/modules/GenerateModuleCpp.js npm notice 7.3kB lib/generators/modules/GenerateModuleCpp.js.flow npm notice 8.5kB lib/generators/modules/GenerateModuleH.js npm notice 7.0kB lib/generators/modules/GenerateModuleH.js.flow npm notice 16.8kB lib/generators/modules/GenerateModuleJavaSpec.js npm notice 15.6kB lib/generators/modules/GenerateModuleJavaSpec.js.flow npm notice 14.9kB lib/generators/modules/GenerateModuleJniCpp.js npm notice 13.9kB lib/generators/modules/GenerateModuleJniCpp.js.flow npm notice 4.7kB lib/generators/modules/GenerateModuleJniH.js npm notice 4.9kB lib/generators/modules/GenerateModuleJniH.js.flow npm notice 9.5kB lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js npm notice 7.9kB lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow npm notice 9.1kB lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js npm notice 7.6kB lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow npm notice 720B lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js npm notice 836B lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js.flow npm notice 6.4kB lib/generators/modules/GenerateModuleObjCpp/index.js npm notice 6.6kB lib/generators/modules/GenerateModuleObjCpp/index.js.flow npm notice 14.6kB lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js npm notice 13.1kB lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow npm notice 2.9kB lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js npm notice 3.6kB lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js.flow npm notice 6.8kB lib/generators/modules/GenerateModuleObjCpp/StructCollector.js npm notice 5.4kB lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow npm notice 549B lib/generators/modules/GenerateModuleObjCpp/Utils.js npm notice 673B lib/generators/modules/GenerateModuleObjCpp/Utils.js.flow npm notice 848B lib/generators/modules/Utils.js npm notice 1.3kB lib/generators/modules/Utils.js.flow npm notice 7.1kB lib/generators/RNCodegen.js npm notice 8.4kB lib/generators/RNCodegen.js.flow npm notice 647B lib/generators/Utils.js npm notice 700B lib/generators/Utils.js.flow npm notice 14.1kB lib/parsers/flow/components/__test_fixtures__/failures.js npm notice 14.1kB lib/parsers/flow/components/__test_fixtures__/failures.js.flow npm notice 27.8kB lib/parsers/flow/components/__test_fixtures__/fixtures.js npm notice 27.9kB lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow npm notice 2.6kB lib/parsers/flow/components/commands.js npm notice 2.9kB lib/parsers/flow/components/commands.js.flow npm notice 6.2kB lib/parsers/flow/components/events.js npm notice 6.6kB lib/parsers/flow/components/events.js.flow npm notice 1.2kB lib/parsers/flow/components/extends.js npm notice 1.6kB lib/parsers/flow/components/extends.js.flow npm notice 8.1kB lib/parsers/flow/components/index.js npm notice 6.5kB lib/parsers/flow/components/index.js.flow npm notice 1.8kB lib/parsers/flow/components/options.js npm notice 2.1kB lib/parsers/flow/components/options.js.flow npm notice 13.1kB lib/parsers/flow/components/props.js npm notice 13.8kB lib/parsers/flow/components/props.js.flow npm notice 2.1kB lib/parsers/flow/components/schema.js npm notice 1.3kB lib/parsers/flow/components/schema.js.flow npm notice 738B lib/parsers/flow/errors.js npm notice 849B lib/parsers/flow/errors.js.flow npm notice 5.7kB lib/parsers/flow/index.js npm notice 3.7kB lib/parsers/flow/index.js.flow npm notice 5.3kB lib/parsers/flow/modules/__test_fixtures__/failures.js npm notice 5.4kB lib/parsers/flow/modules/__test_fixtures__/failures.js.flow npm notice 15.4kB lib/parsers/flow/modules/__test_fixtures__/fixtures.js npm notice 15.4kB lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow npm notice 8.6kB lib/parsers/flow/modules/errors.js npm notice 9.5kB lib/parsers/flow/modules/errors.js.flow npm notice 25.7kB lib/parsers/flow/modules/index.js npm notice 21.8kB lib/parsers/flow/modules/index.js.flow npm notice 416B lib/parsers/flow/modules/schema.js npm notice 557B lib/parsers/flow/modules/schema.js.flow npm notice 595B lib/parsers/flow/modules/utils.js npm notice 830B lib/parsers/flow/modules/utils.js.flow npm notice 4.4kB lib/parsers/flow/utils.js npm notice 5.1kB lib/parsers/flow/utils.js.flow npm notice 428B lib/parsers/schema/index.js npm notice 526B lib/parsers/schema/index.js.flow npm notice 12.9kB lib/parsers/typescript/components/__test_fixtures__/failures.js npm notice 13.0kB lib/parsers/typescript/components/__test_fixtures__/failures.js.flow npm notice 28.1kB lib/parsers/typescript/components/__test_fixtures__/fixtures.js npm notice 28.1kB lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow npm notice 3.1kB lib/parsers/typescript/components/commands.js npm notice 3.0kB lib/parsers/typescript/components/commands.js.flow npm notice 7.0kB lib/parsers/typescript/components/events.js npm notice 7.4kB lib/parsers/typescript/components/events.js.flow npm notice 1.3kB lib/parsers/typescript/components/extends.js npm notice 1.6kB lib/parsers/typescript/components/extends.js.flow npm notice 8.2kB lib/parsers/typescript/components/index.js npm notice 6.6kB lib/parsers/typescript/components/index.js.flow npm notice 1.8kB lib/parsers/typescript/components/options.js npm notice 2.1kB lib/parsers/typescript/components/options.js.flow npm notice 19.4kB lib/parsers/typescript/components/props.js npm notice 18.0kB lib/parsers/typescript/components/props.js.flow npm notice 2.1kB lib/parsers/typescript/components/schema.js npm notice 1.3kB lib/parsers/typescript/components/schema.js.flow npm notice 738B lib/parsers/typescript/errors.js npm notice 849B lib/parsers/typescript/errors.js.flow npm notice 5.8kB lib/parsers/typescript/index.js npm notice 3.9kB lib/parsers/typescript/index.js.flow npm notice 4.7kB lib/parsers/typescript/modules/__test_fixtures__/failures.js npm notice 4.7kB lib/parsers/typescript/modules/__test_fixtures__/failures.js.flow npm notice 18.8kB lib/parsers/typescript/modules/__test_fixtures__/fixtures.js npm notice 18.8kB lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow npm notice 8.6kB lib/parsers/typescript/modules/errors.js npm notice 9.5kB lib/parsers/typescript/modules/errors.js.flow npm notice 26.8kB lib/parsers/typescript/modules/index.js npm notice 22.9kB lib/parsers/typescript/modules/index.js.flow npm notice 416B lib/parsers/typescript/modules/schema.js npm notice 557B lib/parsers/typescript/modules/schema.js.flow npm notice 595B lib/parsers/typescript/modules/utils.js npm notice 830B lib/parsers/typescript/modules/utils.js.flow npm notice 4.6kB lib/parsers/typescript/utils.js npm notice 5.3kB lib/parsers/typescript/utils.js.flow npm notice 1.4kB lib/SchemaValidator.js npm notice 1.6kB lib/SchemaValidator.js.flow npm notice 1.4kB package.json npm notice === Tarball Details === npm notice name: react-native-codegen npm notice version: 0.70.1 npm notice filename: react-native-codegen-0.70.1.tgz npm notice package size: 168.4 kB npm notice unpacked size: 1.3 MB npm notice shasum: 10bf591db802342bd5ac38352821ad6452ba4b52 npm notice integrity: sha512-KXRXARscSO4mt[...]WCnuO5sLFEYQg== npm notice total files: 167 npm notice + [email protected] ``` Reviewed By: dmitryrykun Differential Revision: D37851965 Pulled By: cortinico fbshipit-source-id: 4d8c80831691e5f671c234bc3a1678ccb7435ff4 * [LOCAL] change ruby version for source * Logging a soft error when ReactRootView has an id other than -1 instead of crashing the app in hybrid apps. (facebook#33133) Summary: As per commit: facebook@4f3b174 which states that "React Native requires that the RootView id be managed entirely by React Native, and will crash in addRootView/startSurface if the native View id isn't set to NO_ID." This behaviour can not be guaranteed in **hybrid** apps that have a native android layer over which ReactRootViews are added and the native views need to have ids on them in order to work. **The control of views can jump back and forth between native android and react-native (fabric). As the ReactRootView is added to ViewGroups (or layouts) in Android Fragments and Activities, they contain ids on their views which might get passed down to the reactRootView by features like DataBinding** Hence this can cause unnecessary crashes at runtime for hybrid apps even when they are not changing the id of the reactRootView object they are adding to their ViewGroups. Our app is a hybrid app that uses both native android and react-native on different screens and on one such screen that has a Fragment adding a ReactRootView to its FrameLayout to render native android views to render in ReactNative, this crash occurs on pressing the back button as well as on unlocking the screen while staying on the same screen. The app was running fine on more than a 100 million devices on React Native 0.63.4 but after updating to 0.67.2, that features this commit, it crashes on the very first device it was tested on. Refer to the issue: facebook#33121 for more information on the crash The fragment in which this issues arises is like this: ```binding.frameLayout.addView(getReactRootView())``` where getReactRootView() is like this: ``` private var mReactRootView: ReactRootView? = null private var mReactInstanceManager: ReactInstanceManager? = null mReactRootView = ReactRootView(context) if (activity != null) { val application = activity?.application if (application is MainApplication) { mReactInstanceManager = application.reactInstanceManager } } fun getReactRootView():View?{ return mReactRootView } ``` So converting this to a soft exception such that pure react-native devs can still see the error while hybrid apps continue to run without crashes. ### Snippet of the change: ``` if (getId() != View.NO_ID) { ReactSoftExceptionLogger.logSoftException( TAG, new IllegalViewOperationException( "Trying to attach a ReactRootView with an explicit id already set to [" + getId() + "]. React Native uses the id field to track react tags and will overwrite this" + " field. If that is fine, explicitly overwrite the id field to View.NO_ID.")); } ``` ## Changelog [GENERAL] [ADDED] - A ReactSoftException log instead of a direct exception being thrown: ``` if (getId() != View.NO_ID) { ReactSoftExceptionLogger.logSoftException( TAG, new IllegalViewOperationException( "Trying to attach a ReactRootView with an explicit id already set to [" + getId() + "]. React Native uses the id field to track react tags and will overwrite this" + " field. If that is fine, explicitly overwrite the id field to View.NO_ID.")); } ``` [GENERAL] [REMOVED]- Directly throwing an exception even when the code is not responsible for this issue: ``` if (getId() != View.NO_ID) { throw new IllegalViewOperationException( "Trying to attach a ReactRootView with an explicit id already set to [" + getId() + "]. React Native uses the id field to track react tags and will overwrite this" + " field. If that is fine, explicitly overwrite the id field to View.NO_ID."); } ``` Pull Request resolved: facebook#33133 Test Plan: This crash is hard to reproduce but when it occurs, this is the only way to fix it. If any app used to crash with this exact error, it will no longer crash but show an error log in Logcat for developers to be informed about the issue. Reviewed By: ShikaSD Differential Revision: D34304212 Pulled By: cortinico fbshipit-source-id: f0eaeef2e905a6e0587df088b43cc49cabda397a * Use monotonic clock for performance.now() (facebook#33983) Summary: In facebook#32695, the `Performance.now()` implementation changed to use unix epoch timestamps instead of a monotonic clock. This is problematic, because it means that performance measurements get skewed if the device clock changes between two measurements. With this change, the clock is now monotonic (and the implementation stays consistent between platforms). More details and repro steps can be found in [this issue](facebook#33977) Closes facebook#33977 ## Changelog [General] [Fixed] - Use monotonic clock for performance.now() Pull Request resolved: facebook#33983 Test Plan: Run on iOS and Android: ``` const now = global.performance.now() console.log(`${Platform.OS}: ${now}`) ``` Reviewed By: JoshuaGross, cipolleschi Differential Revision: D37066999 Pulled By: dmitryrykun fbshipit-source-id: 298547bf39faea1b025c17ff2d2e1a03f929865b * Added additional builder method receiving arguments for using jsc or hermes to correctly decide which DSO to load at app startup. (facebook#33952) Summary: The current implementation of **getDefaultJSExecutorFactory** relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration. Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native. So we can make use of an additional **ReactInstanceManager :: setJsEngineAsHermes** method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in **ReactInstanceManagerBuilder** which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files. The code snippet in **ReactInstanceManager** for adding a new setter method: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` The code snippet for the new logic in **ReactInstanceManagerBuilder**: 1) Setting up the new logic: Adding a new enum class : ``` public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable. ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` 2) Modifying the getDefaultJSExecutorFactory method to incorporate the new logic with the old one: ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` ### **Suggested changes in any Android App's MainApplication that extends ReactApplication to take advantage of this fix** ``` builder = ReactInstanceManager.builder() .setApplication(this) .setJsEngineAsHermes(BuildConfig.HERMES_ENABLED) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") ``` where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle: `def enableHermes = project.ext.react.get("enableHermes", true) ` and then ``` defaultConfig{ if(enableHermes) { buildConfigField("boolean", "HERMES_ENABLED", "true") } else{ buildConfigField("boolean", "HERMES_ENABLED", "false") } } ``` Our app was facing a similar issue as listed in this list: **https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO**. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button. This change can possibly solve many of the issues listed in the list as it solved ours. ## Changelog [GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package: ``` /** * An enum that specifies the JS Engine to be used in the app * Old Logic uses the legacy code * JSC/HERMES loads the respective engine using the revamped logic */ public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` [GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder: ``` private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; ``` [GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` [GENERAL] [ADDED] - Modified **getDefaultJSExecutorFactory** method ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` Pull Request resolved: facebook#33952 Test Plan: The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in **packagingOptions** in build.gradle and using hermes in the project. It can be like: ``` packagingOptions { if (enableHermes) { exclude "**/libjsc*.so" } } ``` Reviewed By: lunaleaps Differential Revision: D37191981 Pulled By: cortinico fbshipit-source-id: c528ead126939f1d788af7523f3798ed2a14f36e * Rebasing V8 patches against the latest upstream changes * Some more fixes in the patches * Some more patches Co-authored-by: Nicola Corti <[email protected]> Co-authored-by: Lorenzo Sciandra <[email protected]> Co-authored-by: Kunal Farmah <[email protected]> Co-authored-by: Olivier Payen <[email protected]> Co-authored-by: Kunal Farmah <[email protected]>
* Update script from prepublish (deprecated) to prepack (facebook#34198) Summary: Currently `react-native-codegen` uses `prepublish` to pre-build before publishing. Moving to `prepare` as `prepublish` is deprecated and not invoked anymore: https://docs.npmjs.com/cli/v8/using-npm/scripts#life-cycle-scripts ## Changelog [Internal][Fixed] - [codegen] Update script from prepublish (deprecated) to prepack Pull Request resolved: facebook#34198 Test Plan: Tested locally with: ``` cd packages/react-native-codegen/ && rm -rf lib && npm publish --dry-run --foreground-scripts ``` output is: ``` > [email protected] prepare > yarn run build yarn run v1.22.18 $ yarn clean && node scripts/build.js --verbose $ rm -rf lib react-native-codegen........................................................... • src/__tests__/__snapshots__/SchemaValidator-test.js.snap (ignore) • src/__tests__/SchemaValidator-test.js (ignore) • src/cli/combine/combine-js-to-schema-cli.js ⇒ lib/cli/combine/combine-js-to-schema-cli.js • src/cli/combine/combine-js-to-schema.js ⇒ lib/cli/combine/combine-js-to-schema.js • src/cli/generators/generate-all.js ⇒ lib/cli/generators/generate-all.js • src/cli/parser/parser-cli.js ⇒ lib/cli/parser/parser-cli.js • src/cli/parser/parser.js ⇒ lib/cli/parser/parser.js • src/cli/parser/parser.sh ⇒ lib/cli/parser/parser.sh (copy) • src/CodegenSchema.js ⇒ lib/CodegenSchema.js • src/generators/__test_fixtures__/fixtures.js ⇒ lib/generators/__test_fixtures__/fixtures.js • src/generators/__tests__/RNCodegen-test.js (ignore) • src/generators/components/__test_fixtures__/fixtures.js ⇒ lib/generators/components/__test_fixtures__/fixtures.js • src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap (ignore) • src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap (ignore) • src/generators/components/__tests__/GenerateComponentDescriptorH-test.js (ignore) • src/generators/components/__tests__/GenerateComponentHObjCpp-test.js (ignore) • src/generators/components/__tests__/GenerateEventEmitterCpp-test.js (ignore) • src/generators/components/__tests__/GenerateEventEmitterH-test.js (ignore) • src/generators/components/__tests__/GeneratePropsCpp-test.js (ignore) • src/generators/components/__tests__/GeneratePropsH-test.js (ignore) • src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js (ignore) • src/generators/components/__tests__/GeneratePropsJavaInterface-test.js (ignore) • src/generators/components/__tests__/GeneratePropsJavaPojo-test.js (ignore) • src/generators/components/__tests__/GenerateShadowNodeCpp-test.js (ignore) • src/generators/components/__tests__/GenerateShadowNodeH-test.js (ignore) • src/generators/components/__tests__/GenerateTests-test.js (ignore) • src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderH-test.js (ignore) • src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js (ignore) • src/generators/components/__tests__/GenerateViewConfigJs-test.js (ignore) • src/generators/components/CppHelpers.js ⇒ lib/generators/components/CppHelpers.js • src/generators/components/GenerateComponentDescriptorH.js ⇒ lib/generators/components/GenerateComponentDescriptorH.js • src/generators/components/GenerateComponentHObjCpp.js ⇒ lib/generators/components/GenerateComponentHObjCpp.js • src/generators/components/GenerateEventEmitterCpp.js ⇒ lib/generators/components/GenerateEventEmitterCpp.js • src/generators/components/GenerateEventEmitterH.js ⇒ lib/generators/components/GenerateEventEmitterH.js • src/generators/components/GeneratePropsCpp.js ⇒ lib/generators/components/GeneratePropsCpp.js • src/generators/components/GeneratePropsH.js ⇒ lib/generators/components/GeneratePropsH.js • src/generators/components/GeneratePropsJavaDelegate.js ⇒ lib/generators/components/GeneratePropsJavaDelegate.js • src/generators/components/GeneratePropsJavaInterface.js ⇒ lib/generators/components/GeneratePropsJavaInterface.js • src/generators/components/GeneratePropsJavaPojo/index.js ⇒ lib/generators/components/GeneratePropsJavaPojo/index.js • src/generators/components/GeneratePropsJavaPojo/PojoCollector.js ⇒ lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js • src/generators/components/GeneratePropsJavaPojo/serializePojo.js ⇒ lib/generators/components/GeneratePropsJavaPojo/serializePojo.js • src/generators/components/GenerateShadowNodeCpp.js ⇒ lib/generators/components/GenerateShadowNodeCpp.js • src/generators/components/GenerateShadowNodeH.js ⇒ lib/generators/components/GenerateShadowNodeH.js • src/generators/components/GenerateTests.js ⇒ lib/generators/components/GenerateTests.js • src/generators/components/GenerateThirdPartyFabricComponentsProviderH.js ⇒ lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js • src/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js ⇒ lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js • src/generators/components/GenerateViewConfigJs.js ⇒ lib/generators/components/GenerateViewConfigJs.js • src/generators/components/JavaHelpers.js ⇒ lib/generators/components/JavaHelpers.js • src/generators/modules/__test_fixtures__/fixtures.js ⇒ lib/generators/modules/__test_fixtures__/fixtures.js • src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap (ignore) • src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap (ignore) • src/generators/modules/__tests__/GenerateModuleCpp-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleH-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleJniCpp-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleJniH-test.js (ignore) • src/generators/modules/__tests__/GenerateModuleMm-test.js (ignore) • src/generators/modules/GenerateModuleCpp.js ⇒ lib/generators/modules/GenerateModuleCpp.js • src/generators/modules/GenerateModuleH.js ⇒ lib/generators/modules/GenerateModuleH.js • src/generators/modules/GenerateModuleJavaSpec.js ⇒ lib/generators/modules/GenerateModuleJavaSpec.js • src/generators/modules/GenerateModuleJniCpp.js ⇒ lib/generators/modules/GenerateModuleJniCpp.js • src/generators/modules/GenerateModuleJniH.js ⇒ lib/generators/modules/GenerateModuleJniH.js • src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js ⇒ lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js • src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js ⇒ lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js • src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js ⇒ lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js • src/generators/modules/GenerateModuleObjCpp/index.js ⇒ lib/generators/modules/GenerateModuleObjCpp/index.js • src/generators/modules/GenerateModuleObjCpp/serializeMethod.js ⇒ lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js • src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js ⇒ lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js • src/generators/modules/GenerateModuleObjCpp/StructCollector.js ⇒ lib/generators/modules/GenerateModuleObjCpp/StructCollector.js • src/generators/modules/GenerateModuleObjCpp/Utils.js ⇒ lib/generators/modules/GenerateModuleObjCpp/Utils.js • src/generators/modules/Utils.js ⇒ lib/generators/modules/Utils.js • src/generators/RNCodegen.js ⇒ lib/generators/RNCodegen.js • src/generators/Utils.js ⇒ lib/generators/Utils.js • src/parsers/flow/components/__test_fixtures__/failures.js ⇒ lib/parsers/flow/components/__test_fixtures__/failures.js • src/parsers/flow/components/__test_fixtures__/fixtures.js ⇒ lib/parsers/flow/components/__test_fixtures__/fixtures.js • src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap (ignore) • src/parsers/flow/components/__tests__/component-parser-test.js (ignore) • src/parsers/flow/components/commands.js ⇒ lib/parsers/flow/components/commands.js • src/parsers/flow/components/events.js ⇒ lib/parsers/flow/components/events.js • src/parsers/flow/components/extends.js ⇒ lib/parsers/flow/components/extends.js • src/parsers/flow/components/index.js ⇒ lib/parsers/flow/components/index.js • src/parsers/flow/components/options.js ⇒ lib/parsers/flow/components/options.js • src/parsers/flow/components/props.js ⇒ lib/parsers/flow/components/props.js • src/parsers/flow/components/schema.js ⇒ lib/parsers/flow/components/schema.js • src/parsers/flow/errors.js ⇒ lib/parsers/flow/errors.js • src/parsers/flow/index.js ⇒ lib/parsers/flow/index.js • src/parsers/flow/modules/__test_fixtures__/failures.js ⇒ lib/parsers/flow/modules/__test_fixtures__/failures.js • src/parsers/flow/modules/__test_fixtures__/fixtures.js ⇒ lib/parsers/flow/modules/__test_fixtures__/fixtures.js • src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap (ignore) • src/parsers/flow/modules/__tests__/module-parser-e2e-test.js (ignore) • src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js (ignore) • src/parsers/flow/modules/errors.js ⇒ lib/parsers/flow/modules/errors.js • src/parsers/flow/modules/index.js ⇒ lib/parsers/flow/modules/index.js • src/parsers/flow/modules/schema.js ⇒ lib/parsers/flow/modules/schema.js • src/parsers/flow/modules/utils.js ⇒ lib/parsers/flow/modules/utils.js • src/parsers/flow/utils.js ⇒ lib/parsers/flow/utils.js • src/parsers/schema/index.js ⇒ lib/parsers/schema/index.js • src/parsers/typescript/components/__test_fixtures__/failures.js ⇒ lib/parsers/typescript/components/__test_fixtures__/failures.js • src/parsers/typescript/components/__test_fixtures__/fixtures.js ⇒ lib/parsers/typescript/components/__test_fixtures__/fixtures.js • src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap (ignore) • src/parsers/typescript/components/__tests__/typescript-component-parser-test.js (ignore) • src/parsers/typescript/components/commands.js ⇒ lib/parsers/typescript/components/commands.js • src/parsers/typescript/components/events.js ⇒ lib/parsers/typescript/components/events.js • src/parsers/typescript/components/extends.js ⇒ lib/parsers/typescript/components/extends.js • src/parsers/typescript/components/index.js ⇒ lib/parsers/typescript/components/index.js • src/parsers/typescript/components/options.js ⇒ lib/parsers/typescript/components/options.js • src/parsers/typescript/components/props.js ⇒ lib/parsers/typescript/components/props.js • src/parsers/typescript/components/schema.js ⇒ lib/parsers/typescript/components/schema.js • src/parsers/typescript/errors.js ⇒ lib/parsers/typescript/errors.js • src/parsers/typescript/index.js ⇒ lib/parsers/typescript/index.js • src/parsers/typescript/modules/__test_fixtures__/failures.js ⇒ lib/parsers/typescript/modules/__test_fixtures__/failures.js • src/parsers/typescript/modules/__test_fixtures__/fixtures.js ⇒ lib/parsers/typescript/modules/__test_fixtures__/fixtures.js • src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap (ignore) • src/parsers/typescript/modules/__tests__/typescript-module-parser-e2e-test.js (ignore) • src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js (ignore) • src/parsers/typescript/modules/errors.js ⇒ lib/parsers/typescript/modules/errors.js • src/parsers/typescript/modules/index.js ⇒ lib/parsers/typescript/modules/index.js • src/parsers/typescript/modules/schema.js ⇒ lib/parsers/typescript/modules/schema.js • src/parsers/typescript/modules/utils.js ⇒ lib/parsers/typescript/modules/utils.js • src/parsers/typescript/utils.js ⇒ lib/parsers/typescript/utils.js • src/SchemaValidator.js ⇒ lib/SchemaValidator.js [ OK ] ✨ Done in 2.27s. npm notice npm notice 📦 [email protected] npm notice === Tarball Contents === npm notice 383B README.md npm notice 3.2kB lib/cli/combine/combine-js-to-schema-cli.js npm notice 1.8kB lib/cli/combine/combine-js-to-schema-cli.js.flow npm notice 2.5kB lib/cli/combine/combine-js-to-schema.js npm notice 1.3kB lib/cli/combine/combine-js-to-schema.js.flow npm notice 1.5kB lib/cli/generators/generate-all.js npm notice 1.4kB lib/cli/generators/generate-all.js.flow npm notice 1.7kB lib/cli/parser/parser-cli.js npm notice 386B lib/cli/parser/parser-cli.js.flow npm notice 777B lib/cli/parser/parser.js npm notice 811B lib/cli/parser/parser.js.flow npm notice 483B lib/cli/parser/parser.sh npm notice 222B lib/CodegenSchema.js npm notice 8.8kB lib/CodegenSchema.js.flow npm notice 1.8kB lib/generators/__test_fixtures__/fixtures.js npm notice 1.9kB lib/generators/__test_fixtures__/fixtures.js.flow npm notice 43.6kB lib/generators/components/__test_fixtures__/fixtures.js npm notice 44.0kB lib/generators/components/__test_fixtures__/fixtures.js.flow npm notice 5.7kB lib/generators/components/CppHelpers.js npm notice 6.4kB lib/generators/components/CppHelpers.js.flow npm notice 2.0kB lib/generators/components/GenerateComponentDescriptorH.js npm notice 2.3kB lib/generators/components/GenerateComponentDescriptorH.js.flow npm notice 9.3kB lib/generators/components/GenerateComponentHObjCpp.js npm notice 10.3kB lib/generators/components/GenerateComponentHObjCpp.js.flow npm notice 6.3kB lib/generators/components/GenerateEventEmitterCpp.js npm notice 7.2kB lib/generators/components/GenerateEventEmitterCpp.js.flow npm notice 6.5kB lib/generators/components/GenerateEventEmitterH.js npm notice 7.4kB lib/generators/components/GenerateEventEmitterH.js.flow npm notice 4.0kB lib/generators/components/GeneratePropsCpp.js npm notice 4.3kB lib/generators/components/GeneratePropsCpp.js.flow npm notice 23.4kB lib/generators/components/GeneratePropsH.js npm notice 26.1kB lib/generators/components/GeneratePropsH.js.flow npm notice 9.4kB lib/generators/components/GeneratePropsJavaDelegate.js npm notice 10.0kB lib/generators/components/GeneratePropsJavaDelegate.js.flow npm notice 7.1kB lib/generators/components/GeneratePropsJavaInterface.js npm notice 7.8kB lib/generators/components/GeneratePropsJavaInterface.js.flow npm notice 2.0kB lib/generators/components/GeneratePropsJavaPojo/index.js npm notice 2.1kB lib/generators/components/GeneratePropsJavaPojo/index.js.flow npm notice 4.0kB lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js npm notice 4.7kB lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow npm notice 7.2kB lib/generators/components/GeneratePropsJavaPojo/serializePojo.js npm notice 7.5kB lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow npm notice 2.0kB lib/generators/components/GenerateShadowNodeCpp.js npm notice 2.2kB lib/generators/components/GenerateShadowNodeCpp.js.flow npm notice 2.8kB lib/generators/components/GenerateShadowNodeH.js npm notice 3.1kB lib/generators/components/GenerateShadowNodeH.js.flow npm notice 5.3kB lib/generators/components/GenerateTests.js npm notice 5.9kB lib/generators/components/GenerateTests.js.flow npm notice 2.5kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js npm notice 2.7kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js.flow npm notice 2.6kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js npm notice 2.8kB lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js.flow npm notice 13.4kB lib/generators/components/GenerateViewConfigJs.js npm notice 14.0kB lib/generators/components/GenerateViewConfigJs.js.flow npm notice 2.7kB lib/generators/components/JavaHelpers.js npm notice 3.2kB lib/generators/components/JavaHelpers.js.flow npm notice 47.0kB lib/generators/modules/__test_fixtures__/fixtures.js npm notice 47.2kB lib/generators/modules/__test_fixtures__/fixtures.js.flow npm notice 8.4kB lib/generators/modules/GenerateModuleCpp.js npm notice 7.3kB lib/generators/modules/GenerateModuleCpp.js.flow npm notice 8.5kB lib/generators/modules/GenerateModuleH.js npm notice 7.0kB lib/generators/modules/GenerateModuleH.js.flow npm notice 16.8kB lib/generators/modules/GenerateModuleJavaSpec.js npm notice 15.6kB lib/generators/modules/GenerateModuleJavaSpec.js.flow npm notice 14.9kB lib/generators/modules/GenerateModuleJniCpp.js npm notice 13.9kB lib/generators/modules/GenerateModuleJniCpp.js.flow npm notice 4.7kB lib/generators/modules/GenerateModuleJniH.js npm notice 4.9kB lib/generators/modules/GenerateModuleJniH.js.flow npm notice 9.5kB lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js npm notice 7.9kB lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow npm notice 9.1kB lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js npm notice 7.6kB lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow npm notice 720B lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js npm notice 836B lib/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js.flow npm notice 6.4kB lib/generators/modules/GenerateModuleObjCpp/index.js npm notice 6.6kB lib/generators/modules/GenerateModuleObjCpp/index.js.flow npm notice 14.6kB lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js npm notice 13.1kB lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow npm notice 2.9kB lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js npm notice 3.6kB lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js.flow npm notice 6.8kB lib/generators/modules/GenerateModuleObjCpp/StructCollector.js npm notice 5.4kB lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow npm notice 549B lib/generators/modules/GenerateModuleObjCpp/Utils.js npm notice 673B lib/generators/modules/GenerateModuleObjCpp/Utils.js.flow npm notice 848B lib/generators/modules/Utils.js npm notice 1.3kB lib/generators/modules/Utils.js.flow npm notice 7.1kB lib/generators/RNCodegen.js npm notice 8.4kB lib/generators/RNCodegen.js.flow npm notice 647B lib/generators/Utils.js npm notice 700B lib/generators/Utils.js.flow npm notice 14.1kB lib/parsers/flow/components/__test_fixtures__/failures.js npm notice 14.1kB lib/parsers/flow/components/__test_fixtures__/failures.js.flow npm notice 27.8kB lib/parsers/flow/components/__test_fixtures__/fixtures.js npm notice 27.9kB lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow npm notice 2.6kB lib/parsers/flow/components/commands.js npm notice 2.9kB lib/parsers/flow/components/commands.js.flow npm notice 6.2kB lib/parsers/flow/components/events.js npm notice 6.6kB lib/parsers/flow/components/events.js.flow npm notice 1.2kB lib/parsers/flow/components/extends.js npm notice 1.6kB lib/parsers/flow/components/extends.js.flow npm notice 8.1kB lib/parsers/flow/components/index.js npm notice 6.5kB lib/parsers/flow/components/index.js.flow npm notice 1.8kB lib/parsers/flow/components/options.js npm notice 2.1kB lib/parsers/flow/components/options.js.flow npm notice 13.1kB lib/parsers/flow/components/props.js npm notice 13.8kB lib/parsers/flow/components/props.js.flow npm notice 2.1kB lib/parsers/flow/components/schema.js npm notice 1.3kB lib/parsers/flow/components/schema.js.flow npm notice 738B lib/parsers/flow/errors.js npm notice 849B lib/parsers/flow/errors.js.flow npm notice 5.7kB lib/parsers/flow/index.js npm notice 3.7kB lib/parsers/flow/index.js.flow npm notice 5.3kB lib/parsers/flow/modules/__test_fixtures__/failures.js npm notice 5.4kB lib/parsers/flow/modules/__test_fixtures__/failures.js.flow npm notice 15.4kB lib/parsers/flow/modules/__test_fixtures__/fixtures.js npm notice 15.4kB lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow npm notice 8.6kB lib/parsers/flow/modules/errors.js npm notice 9.5kB lib/parsers/flow/modules/errors.js.flow npm notice 25.7kB lib/parsers/flow/modules/index.js npm notice 21.8kB lib/parsers/flow/modules/index.js.flow npm notice 416B lib/parsers/flow/modules/schema.js npm notice 557B lib/parsers/flow/modules/schema.js.flow npm notice 595B lib/parsers/flow/modules/utils.js npm notice 830B lib/parsers/flow/modules/utils.js.flow npm notice 4.4kB lib/parsers/flow/utils.js npm notice 5.1kB lib/parsers/flow/utils.js.flow npm notice 428B lib/parsers/schema/index.js npm notice 526B lib/parsers/schema/index.js.flow npm notice 12.9kB lib/parsers/typescript/components/__test_fixtures__/failures.js npm notice 13.0kB lib/parsers/typescript/components/__test_fixtures__/failures.js.flow npm notice 28.1kB lib/parsers/typescript/components/__test_fixtures__/fixtures.js npm notice 28.1kB lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow npm notice 3.1kB lib/parsers/typescript/components/commands.js npm notice 3.0kB lib/parsers/typescript/components/commands.js.flow npm notice 7.0kB lib/parsers/typescript/components/events.js npm notice 7.4kB lib/parsers/typescript/components/events.js.flow npm notice 1.3kB lib/parsers/typescript/components/extends.js npm notice 1.6kB lib/parsers/typescript/components/extends.js.flow npm notice 8.2kB lib/parsers/typescript/components/index.js npm notice 6.6kB lib/parsers/typescript/components/index.js.flow npm notice 1.8kB lib/parsers/typescript/components/options.js npm notice 2.1kB lib/parsers/typescript/components/options.js.flow npm notice 19.4kB lib/parsers/typescript/components/props.js npm notice 18.0kB lib/parsers/typescript/components/props.js.flow npm notice 2.1kB lib/parsers/typescript/components/schema.js npm notice 1.3kB lib/parsers/typescript/components/schema.js.flow npm notice 738B lib/parsers/typescript/errors.js npm notice 849B lib/parsers/typescript/errors.js.flow npm notice 5.8kB lib/parsers/typescript/index.js npm notice 3.9kB lib/parsers/typescript/index.js.flow npm notice 4.7kB lib/parsers/typescript/modules/__test_fixtures__/failures.js npm notice 4.7kB lib/parsers/typescript/modules/__test_fixtures__/failures.js.flow npm notice 18.8kB lib/parsers/typescript/modules/__test_fixtures__/fixtures.js npm notice 18.8kB lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow npm notice 8.6kB lib/parsers/typescript/modules/errors.js npm notice 9.5kB lib/parsers/typescript/modules/errors.js.flow npm notice 26.8kB lib/parsers/typescript/modules/index.js npm notice 22.9kB lib/parsers/typescript/modules/index.js.flow npm notice 416B lib/parsers/typescript/modules/schema.js npm notice 557B lib/parsers/typescript/modules/schema.js.flow npm notice 595B lib/parsers/typescript/modules/utils.js npm notice 830B lib/parsers/typescript/modules/utils.js.flow npm notice 4.6kB lib/parsers/typescript/utils.js npm notice 5.3kB lib/parsers/typescript/utils.js.flow npm notice 1.4kB lib/SchemaValidator.js npm notice 1.6kB lib/SchemaValidator.js.flow npm notice 1.4kB package.json npm notice === Tarball Details === npm notice name: react-native-codegen npm notice version: 0.70.1 npm notice filename: react-native-codegen-0.70.1.tgz npm notice package size: 168.4 kB npm notice unpacked size: 1.3 MB npm notice shasum: 10bf591db802342bd5ac38352821ad6452ba4b52 npm notice integrity: sha512-KXRXARscSO4mt[...]WCnuO5sLFEYQg== npm notice total files: 167 npm notice + [email protected] ``` Reviewed By: dmitryrykun Differential Revision: D37851965 Pulled By: cortinico fbshipit-source-id: 4d8c80831691e5f671c234bc3a1678ccb7435ff4 * [LOCAL] change ruby version for source * Logging a soft error when ReactRootView has an id other than -1 instead of crashing the app in hybrid apps. (facebook#33133) Summary: As per commit: facebook@4f3b174 which states that "React Native requires that the RootView id be managed entirely by React Native, and will crash in addRootView/startSurface if the native View id isn't set to NO_ID." This behaviour can not be guaranteed in **hybrid** apps that have a native android layer over which ReactRootViews are added and the native views need to have ids on them in order to work. **The control of views can jump back and forth between native android and react-native (fabric). As the ReactRootView is added to ViewGroups (or layouts) in Android Fragments and Activities, they contain ids on their views which might get passed down to the reactRootView by features like DataBinding** Hence this can cause unnecessary crashes at runtime for hybrid apps even when they are not changing the id of the reactRootView object they are adding to their ViewGroups. Our app is a hybrid app that uses both native android and react-native on different screens and on one such screen that has a Fragment adding a ReactRootView to its FrameLayout to render native android views to render in ReactNative, this crash occurs on pressing the back button as well as on unlocking the screen while staying on the same screen. The app was running fine on more than a 100 million devices on React Native 0.63.4 but after updating to 0.67.2, that features this commit, it crashes on the very first device it was tested on. Refer to the issue: facebook#33121 for more information on the crash The fragment in which this issues arises is like this: ```binding.frameLayout.addView(getReactRootView())``` where getReactRootView() is like this: ``` private var mReactRootView: ReactRootView? = null private var mReactInstanceManager: ReactInstanceManager? = null mReactRootView = ReactRootView(context) if (activity != null) { val application = activity?.application if (application is MainApplication) { mReactInstanceManager = application.reactInstanceManager } } fun getReactRootView():View?{ return mReactRootView } ``` So converting this to a soft exception such that pure react-native devs can still see the error while hybrid apps continue to run without crashes. ### Snippet of the change: ``` if (getId() != View.NO_ID) { ReactSoftExceptionLogger.logSoftException( TAG, new IllegalViewOperationException( "Trying to attach a ReactRootView with an explicit id already set to [" + getId() + "]. React Native uses the id field to track react tags and will overwrite this" + " field. If that is fine, explicitly overwrite the id field to View.NO_ID.")); } ``` ## Changelog [GENERAL] [ADDED] - A ReactSoftException log instead of a direct exception being thrown: ``` if (getId() != View.NO_ID) { ReactSoftExceptionLogger.logSoftException( TAG, new IllegalViewOperationException( "Trying to attach a ReactRootView with an explicit id already set to [" + getId() + "]. React Native uses the id field to track react tags and will overwrite this" + " field. If that is fine, explicitly overwrite the id field to View.NO_ID.")); } ``` [GENERAL] [REMOVED]- Directly throwing an exception even when the code is not responsible for this issue: ``` if (getId() != View.NO_ID) { throw new IllegalViewOperationException( "Trying to attach a ReactRootView with an explicit id already set to [" + getId() + "]. React Native uses the id field to track react tags and will overwrite this" + " field. If that is fine, explicitly overwrite the id field to View.NO_ID."); } ``` Pull Request resolved: facebook#33133 Test Plan: This crash is hard to reproduce but when it occurs, this is the only way to fix it. If any app used to crash with this exact error, it will no longer crash but show an error log in Logcat for developers to be informed about the issue. Reviewed By: ShikaSD Differential Revision: D34304212 Pulled By: cortinico fbshipit-source-id: f0eaeef2e905a6e0587df088b43cc49cabda397a * Use monotonic clock for performance.now() (facebook#33983) Summary: In facebook#32695, the `Performance.now()` implementation changed to use unix epoch timestamps instead of a monotonic clock. This is problematic, because it means that performance measurements get skewed if the device clock changes between two measurements. With this change, the clock is now monotonic (and the implementation stays consistent between platforms). More details and repro steps can be found in [this issue](facebook#33977) Closes facebook#33977 ## Changelog [General] [Fixed] - Use monotonic clock for performance.now() Pull Request resolved: facebook#33983 Test Plan: Run on iOS and Android: ``` const now = global.performance.now() console.log(`${Platform.OS}: ${now}`) ``` Reviewed By: JoshuaGross, cipolleschi Differential Revision: D37066999 Pulled By: dmitryrykun fbshipit-source-id: 298547bf39faea1b025c17ff2d2e1a03f929865b * Added additional builder method receiving arguments for using jsc or hermes to correctly decide which DSO to load at app startup. (facebook#33952) Summary: The current implementation of **getDefaultJSExecutorFactory** relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration. Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native. So we can make use of an additional **ReactInstanceManager :: setJsEngineAsHermes** method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in **ReactInstanceManagerBuilder** which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files. The code snippet in **ReactInstanceManager** for adding a new setter method: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` The code snippet for the new logic in **ReactInstanceManagerBuilder**: 1) Setting up the new logic: Adding a new enum class : ``` public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable. ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` 2) Modifying the getDefaultJSExecutorFactory method to incorporate the new logic with the old one: ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` ### **Suggested changes in any Android App's MainApplication that extends ReactApplication to take advantage of this fix** ``` builder = ReactInstanceManager.builder() .setApplication(this) .setJsEngineAsHermes(BuildConfig.HERMES_ENABLED) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") ``` where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle: `def enableHermes = project.ext.react.get("enableHermes", true) ` and then ``` defaultConfig{ if(enableHermes) { buildConfigField("boolean", "HERMES_ENABLED", "true") } else{ buildConfigField("boolean", "HERMES_ENABLED", "false") } } ``` Our app was facing a similar issue as listed in this list: **https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO**. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button. This change can possibly solve many of the issues listed in the list as it solved ours. ## Changelog [GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package: ``` /** * An enum that specifies the JS Engine to be used in the app * Old Logic uses the legacy code * JSC/HERMES loads the respective engine using the revamped logic */ public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` [GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder: ``` private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; ``` [GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` [GENERAL] [ADDED] - Modified **getDefaultJSExecutorFactory** method ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` Pull Request resolved: facebook#33952 Test Plan: The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in **packagingOptions** in build.gradle and using hermes in the project. It can be like: ``` packagingOptions { if (enableHermes) { exclude "**/libjsc*.so" } } ``` Reviewed By: lunaleaps Differential Revision: D37191981 Pulled By: cortinico fbshipit-source-id: c528ead126939f1d788af7523f3798ed2a14f36e * Let's not build reactnativeutilsjni shared library (facebook#34345) Co-authored-by: Sparsha Saha * [LOCAL] align pods version config with the rest of the repo * [0.68.3] Bump version numbers * Remove libreactutilsjni.so from nuget spec Co-authored-by: Nicola Corti <[email protected]> Co-authored-by: Lorenzo Sciandra <[email protected]> Co-authored-by: Kunal Farmah <[email protected]> Co-authored-by: Olivier Payen <[email protected]> Co-authored-by: Kunal Farmah <[email protected]> Co-authored-by: Sparsha Saha <[email protected]> Co-authored-by: Lorenzo Sciandra <[email protected]> Co-authored-by: Distiller <[email protected]>
…hermes to correctly decide which DSO to load at app startup. (facebook#33952) Summary: The current implementation of **getDefaultJSExecutorFactory** relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration. Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native. So we can make use of an additional **ReactInstanceManager :: setJsEngineAsHermes** method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in **ReactInstanceManagerBuilder** which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files. The code snippet in **ReactInstanceManager** for adding a new setter method: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` The code snippet for the new logic in **ReactInstanceManagerBuilder**: 1) Setting up the new logic: Adding a new enum class : ``` public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable. ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` 2) Modifying the getDefaultJSExecutorFactory method to incorporate the new logic with the old one: ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` ### **Suggested changes in any Android App's MainApplication that extends ReactApplication to take advantage of this fix** ``` builder = ReactInstanceManager.builder() .setApplication(this) .setJsEngineAsHermes(BuildConfig.HERMES_ENABLED) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") ``` where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle: `def enableHermes = project.ext.react.get("enableHermes", true) ` and then ``` defaultConfig{ if(enableHermes) { buildConfigField("boolean", "HERMES_ENABLED", "true") } else{ buildConfigField("boolean", "HERMES_ENABLED", "false") } } ``` Our app was facing a similar issue as listed in this list: **https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO**. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button. This change can possibly solve many of the issues listed in the list as it solved ours. ## Changelog [GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package: ``` /** * An enum that specifies the JS Engine to be used in the app * Old Logic uses the legacy code * JSC/HERMES loads the respective engine using the revamped logic */ public enum JSInterpreter { OLD_LOGIC, JSC, HERMES } ``` [GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder: ``` private JSInterpreter jsEngine = JSInterpreter.OLD_LOGIC; ``` [GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder: ``` /** * Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call * Uses the enum {link JSInterpreter} * param jsEngine */ private void setJSEngine(JSInterpreter jsEngine){ this.jsEngine = jsEngine; } /** * Utility setter to set the required JSEngine as HERMES or JSC * Defaults to OLD_LOGIC if not called by the host app * param hermesEnabled * hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise */ public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled){ if(hermesEnabled){ setJSEngine(JSInterpreter.HERMES); } else{ setJSEngine(JSInterpreter.JSC); } return this; } ``` [GENERAL] [ADDED] - Modified **getDefaultJSExecutorFactory** method ``` private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { // Relying solely on try catch block and loading jsc even when // project is using hermes can lead to launch-time crashes especially in // monorepo architectures and hybrid apps using both native android // and react native. // So we can use the value of enableHermes received by the constructor // to decide which library to load at launch // if nothing is specified, use old loading method // else load the required engine if (jsEngine == JSInterpreter.OLD_LOGIC) { try { // If JSC is included, use it as normal initializeSoLoaderIfNecessary(applicationContext); JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } catch (UnsatisfiedLinkError jscE) { if (jscE.getMessage().contains("__cxa_bad_typeid")) { throw jscE; } HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } } else if (jsEngine == JSInterpreter.HERMES) { HermesExecutor.loadLibrary(); return new HermesExecutorFactory(); } else { JSCExecutor.loadLibrary(); return new JSCExecutorFactory(appName, deviceName); } } ``` Pull Request resolved: facebook#33952 Test Plan: The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in **packagingOptions** in build.gradle and using hermes in the project. It can be like: ``` packagingOptions { if (enableHermes) { exclude "**/libjsc*.so" } } ``` Reviewed By: lunaleaps Differential Revision: D37191981 Pulled By: cortinico fbshipit-source-id: c528ead126939f1d788af7523f3798ed2a14f36e
Summary
The current implementation of getDefaultJSExecutorFactory relies solely on try catch to load the correct .so file for jsc or hermes based on the project configuration.
Relying solely on try catch block and loading jsc even when project is using hermes can lead to launch time crashes especially in monorepo architectures and hybrid apps using both native android and react native.
So we can make use of an additional ReactInstanceManager :: setJsEngineAsHermes method that accepts a Boolean argument from the host app while building ReactInstanceManager which can tell which library to load at startup in ReactInstanceManagerBuilder which will now have an enhanced getDefaultJSExecutorFactory method that will combine the old logic with the new one to load the dso files.
The code snippet in ReactInstanceManager for adding a new setter method:
The code snippet for the new logic in ReactInstanceManagerBuilder:
Adding a new enum class :
A setter getting boolean value telling whether to use hermes or not and calling a private setter to update the enum variable.
Suggested changes in any Android App's MainApplication that extends ReactApplication to take advantage of this fix
where HERMES_ENABLED is a buildConfigField based on the enableHermes flag in build.gradle:
def enableHermes = project.ext.react.get("enableHermes", true)
and then
Our app was facing a similar issue as listed in this list: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO. Which was react-native trying to load jsc even when our project used hermes when a debug build was deployed on a device using android studio play button.
This change can possibly solve many of the issues listed in the list as it solved ours.
Changelog
[GENERAL] [ADDED] - An enum JSInterpreter in com.facebook.react package:
[GENERAL] [ADDED] - An enum variable storing the default value of Js Engine loading mechanism in ReactInstanceManagerBuilder:
[GENERAL] [ADDED] - A new setter method and a helper method to set the js engine in ReactInstanceManagerBuilder:
[GENERAL] [ADDED] - Modified getDefaultJSExecutorFactory method
Test Plan
The testing for this change might be tricky but can be done by following the reproduction steps in the issues related to DSO loading here: https://github.com/facebook/react-native/issues?q=is%3Aissue+is%3Aopen+DSO
Generally, the app will not crash anymore on deploying debug using android studio if we are removing libjsc and its related libraries in packagingOptions in build.gradle and using hermes in the project.
It can be like: