Skip to content

Commit 2018af1

Browse files
mganandrajcortinicokelsetKunal-Airtel2022Olivier Payen
authored
Refreshing 0.68-stable with upstream (#1331)
* 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: ``` > react-native-codegen@0.70.1 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 📦 react-native-codegen@0.70.1 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 + react-native-codegen@0.70.1 ``` 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 <ncor@fb.com> Co-authored-by: Lorenzo Sciandra <notkelset@kelset.dev> Co-authored-by: Kunal Farmah <kunal.farmah@airtel.com> Co-authored-by: Olivier Payen <olivier.payen@klarna.com> Co-authored-by: Kunal Farmah <kunalfarmah98@gmail.com>
1 parent cea2953 commit 2018af1

File tree

9 files changed

+136
-121
lines changed

9 files changed

+136
-121
lines changed

React/CxxBridge/RCTJSIExecutorRuntimeInstaller.mm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
bindNativeLogger(runtime, iosLoggingBinder);
2323

2424
PerformanceNow iosPerformanceNowBinder = []() {
25-
auto time = std::chrono::system_clock::now().time_since_epoch();
26-
return std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
25+
auto time = std::chrono::steady_clock::now();
26+
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
27+
time.time_since_epoch())
28+
.count();
29+
30+
constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
31+
32+
return duration / NANOSECONDS_IN_MILLISECOND;
2733
};
2834
bindNativePerformanceNow(runtime, iosPerformanceNowBinder);
2935

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react;
9+
10+
/**
11+
* An enum that specifies the JS Engine to be used in the app Old Logic uses the legacy code
12+
* JSC/HERMES loads the respective engine using the revamped logic
13+
*/
14+
public enum JSInterpreter {
15+
OLD_LOGIC,
16+
JSC,
17+
HERMES
18+
}

ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class ReactInstanceManagerBuilder {
6666
private @Nullable Map<String, RequestHandler> mCustomPackagerCommandHandlers;
6767
private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder;
6868
private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory;
69+
private JSInterpreter jsInterpreter = JSInterpreter.OLD_LOGIC;
6970

7071
/* package protected */ ReactInstanceManagerBuilder() {}
7172

@@ -125,6 +126,31 @@ public ReactInstanceManagerBuilder setJSBundleLoader(JSBundleLoader jsBundleLoad
125126
return this;
126127
}
127128

129+
/**
130+
* Sets the jsEngine as JSC or HERMES as per the setJsEngineAsHermes call Uses the enum {@link
131+
* JSInterpreter}
132+
*
133+
* @param jsInterpreter
134+
*/
135+
private void setJSEngine(JSInterpreter jsInterpreter) {
136+
this.jsInterpreter = jsInterpreter;
137+
}
138+
139+
/**
140+
* Utility setter to set the required JSEngine as HERMES or JSC Defaults to OLD_LOGIC if not
141+
* called by the host app
142+
*
143+
* @param hermesEnabled hermesEnabled = true sets the JS Engine as HERMES and JSC otherwise
144+
*/
145+
public ReactInstanceManagerBuilder setJsEngineAsHermes(boolean hermesEnabled) {
146+
if (hermesEnabled) {
147+
setJSEngine(JSInterpreter.HERMES);
148+
} else {
149+
setJSEngine(JSInterpreter.JSC);
150+
}
151+
return this;
152+
}
153+
128154
/**
129155
* Path to your app's main module on Metro. This is used when reloading JS during development. All
130156
* paths are relative to the root folder the packager is serving files from. Examples: {@code
@@ -345,41 +371,35 @@ public ReactInstanceManager build() {
345371

346372
private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
347373
String appName, String deviceName, Context applicationContext) {
348-
try {
349-
// If JSC is included, use it as normal
350-
initializeSoLoaderIfNecessary(applicationContext);
351-
JSCExecutor.loadLibrary();
352-
return new JSCExecutorFactory(appName, deviceName);
353-
} catch (UnsatisfiedLinkError jscE) {
354-
// https://github.com/facebook/hermes/issues/78 shows that
355-
// people who aren't trying to use Hermes are having issues.
356-
// https://github.com/facebook/react-native/issues/25923#issuecomment-554295179
357-
// includes the actual JSC error in at least one case.
358-
//
359-
// So, if "__cxa_bad_typeid" shows up in the jscE exception
360-
// message, then we will assume that's the failure and just
361-
// throw now.
362-
363-
if (jscE.getMessage().contains("__cxa_bad_typeid")) {
364-
throw jscE;
365-
}
366374

367-
// Otherwise use Hermes
375+
// Relying solely on try catch block and loading jsc even when
376+
// project is using hermes can lead to launch-time crashes especially in
377+
// monorepo architectures and hybrid apps using both native android
378+
// and react native.
379+
// So we can use the value of enableHermes received by the constructor
380+
// to decide which library to load at launch
381+
382+
// if nothing is specified, use old loading method
383+
// else load the required engine
384+
if (jsInterpreter == JSInterpreter.OLD_LOGIC) {
368385
try {
386+
// If JSC is included, use it as normal
387+
initializeSoLoaderIfNecessary(applicationContext);
388+
JSCExecutor.loadLibrary();
389+
return new JSCExecutorFactory(appName, deviceName);
390+
} catch (UnsatisfiedLinkError jscE) {
391+
if (jscE.getMessage().contains("__cxa_bad_typeid")) {
392+
throw jscE;
393+
}
369394
HermesExecutor.loadLibrary();
370395
return new HermesExecutorFactory();
371-
} catch (UnsatisfiedLinkError hermesE) {
372-
// If we get here, either this is a JSC build, and of course
373-
// Hermes failed (since it's not in the APK), or it's a Hermes
374-
// build, and Hermes had a problem.
375-
376-
// We suspect this is a JSC issue (it's the default), so we
377-
// will throw that exception, but we will print hermesE first,
378-
// since it could be a Hermes issue and we don't want to
379-
// swallow that.
380-
hermesE.printStackTrace();
381-
throw jscE;
382396
}
397+
} else if (jsInterpreter == JSInterpreter.HERMES) {
398+
HermesExecutor.loadLibrary();
399+
return new HermesExecutorFactory();
400+
} else {
401+
JSCExecutor.loadLibrary();
402+
return new JSCExecutorFactory(appName, deviceName);
383403
}
384404
}
385405
}

ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,12 +719,22 @@ private void attachToReactInstanceManager() {
719719

720720
// React Native requires that the RootView id be managed entirely by React Native, and will
721721
// crash in addRootView/startSurface if the native View id isn't set to NO_ID.
722+
723+
// This behavior can not be guaranteed in hybrid apps that have a native android layer over
724+
// which reactRootViews are added and the native views need to have ids on them in order to
725+
// work.
726+
// Hence this can cause unnecessary crashes at runtime for hybrid apps.
727+
// So converting this to a soft exception such that pure react-native devs can still see the
728+
// warning while hybrid apps continue to run without crashes
729+
722730
if (getId() != View.NO_ID) {
723-
throw new IllegalViewOperationException(
724-
"Trying to attach a ReactRootView with an explicit id already set to ["
725-
+ getId()
726-
+ "]. React Native uses the id field to track react tags and will overwrite this"
727-
+ " field. If that is fine, explicitly overwrite the id field to View.NO_ID.");
731+
ReactSoftExceptionLogger.logSoftException(
732+
TAG,
733+
new IllegalViewOperationException(
734+
"Trying to attach a ReactRootView with an explicit id already set to ["
735+
+ getId()
736+
+ "]. React Native uses the id field to track react tags and will overwrite this"
737+
+ " field. If that is fine, explicitly overwrite the id field to View.NO_ID."));
728738
}
729739

730740
try {

ReactAndroid/src/main/jni/react/jni/NativeTime.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ namespace facebook {
1212
namespace react {
1313

1414
double reactAndroidNativePerformanceNowHook() {
15-
auto time = std::chrono::system_clock::now().time_since_epoch();
16-
return std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
15+
auto time = std::chrono::steady_clock::now();
16+
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
17+
time.time_since_epoch())
18+
.count();
19+
20+
constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
21+
22+
return duration / NANOSECONDS_IN_MILLISECOND;
1723
}
1824

1925
} // namespace react
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- "C:\\github\\react-native\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\JSInterpreter.java" 2022-08-03 18:39:00.555240200 +0530
2+
+++ "C:\\github\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\JSInterpreter.java" 2022-08-05 12:35:15.030031000 +0530
3+
@@ -14,5 +14,6 @@
4+
public enum JSInterpreter {
5+
OLD_LOGIC,
6+
JSC,
7+
- HERMES
8+
+ HERMES,
9+
+ V8
10+
}
Lines changed: 18 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,21 @@
1-
--- ./ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java 2022-01-11 17:41:29.000000000 -0800
2-
+++ /var/folders/vs/8_b205053dddbcv7btj0w0v80000gn/T/update-1h8V3n/merge/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java 2022-01-12 15:04:31.000000000 -0800
3-
@@ -31,6 +31,7 @@
4-
import com.facebook.react.devsupport.interfaces.DevSupportManager;
5-
import com.facebook.react.jscexecutor.JSCExecutor;
6-
import com.facebook.react.jscexecutor.JSCExecutorFactory;
7-
+import com.facebook.react.v8executor.V8ExecutorFactory;
1+
--- "C:\\github\\react-native\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2022-08-05 12:59:58.286964700 +0530
2+
+++ "C:\\github\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2022-08-05 15:08:37.009898300 +0530
3+
@@ -34,6 +34,8 @@
84
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
95
import com.facebook.react.packagerconnection.RequestHandler;
106
import com.facebook.react.uimanager.UIImplementationProvider;
11-
@@ -67,8 +68,21 @@
12-
private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder;
13-
private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory;
14-
15-
+ public enum JSEngine {
16-
+ Hermes,
17-
+ V8
18-
+ }
19-
+
20-
+ private JSEngine mJSEngine = JSEngine.V8;
21-
+
22-
/* package protected */ ReactInstanceManagerBuilder() {}
23-
24-
+ public ReactInstanceManagerBuilder setJSEngine(
25-
+ JSEngine jsEngine) {
26-
+ mJSEngine = jsEngine;
27-
+ return this;
28-
+ }
29-
+
30-
/** Sets a provider of {@link UIImplementation}. Uses default provider if null is passed. */
31-
public ReactInstanceManagerBuilder setUIImplementationProvider(
32-
@Nullable UIImplementationProvider uiImplementationProvider) {
33-
@@ -345,41 +359,11 @@
34-
35-
private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
36-
String appName, String deviceName, Context applicationContext) {
37-
- try {
38-
- // If JSC is included, use it as normal
39-
- initializeSoLoaderIfNecessary(applicationContext);
40-
- JSCExecutor.loadLibrary();
41-
- return new JSCExecutorFactory(appName, deviceName);
42-
- } catch (UnsatisfiedLinkError jscE) {
43-
- // https://github.com/facebook/hermes/issues/78 shows that
44-
- // people who aren't trying to use Hermes are having issues.
45-
- // https://github.com/facebook/react-native/issues/25923#issuecomment-554295179
46-
- // includes the actual JSC error in at least one case.
47-
- //
48-
- // So, if "__cxa_bad_typeid" shows up in the jscE exception
49-
- // message, then we will assume that's the failure and just
50-
- // throw now.
51-
-
52-
- if (jscE.getMessage().contains("__cxa_bad_typeid")) {
53-
- throw jscE;
54-
- }
55-
-
56-
- // Otherwise use Hermes
57-
- try {
58-
+ if(mJSEngine == JSEngine.V8) {
59-
+ return new V8ExecutorFactory(appName, deviceName);
60-
+ } else {
61-
HermesExecutor.loadLibrary();
62-
return new HermesExecutorFactory();
63-
- } catch (UnsatisfiedLinkError hermesE) {
64-
- // If we get here, either this is a JSC build, and of course
65-
- // Hermes failed (since it's not in the APK), or it's a Hermes
66-
- // build, and Hermes had a problem.
67-
-
68-
- // We suspect this is a JSC issue (it's the default), so we
69-
- // will throw that exception, but we will print hermesE first,
70-
- // since it could be a Hermes issue and we don't want to
71-
- // swallow that.
72-
- hermesE.printStackTrace();
73-
- throw jscE;
74-
}
75-
- }
76-
}
77-
}
7+
+import com.facebook.react.v8executor.V8ExecutorFactory;
8+
+import com.facebook.react.v8executor.V8Executor;
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
import java.util.Map;
12+
@@ -397,6 +399,9 @@
13+
} else if (jsInterpreter == JSInterpreter.HERMES) {
14+
HermesExecutor.loadLibrary();
15+
return new HermesExecutorFactory();
16+
+ } else if(jsInterpreter == JSInterpreter.V8) {
17+
+ V8Executor.loadLibrary();
18+
+ return new V8ExecutorFactory(appName, deviceName);
19+
} else {
20+
JSCExecutor.loadLibrary();
21+
return new JSCExecutorFactory(appName, deviceName);

android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/v8executor/V8Executor.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
diff --git a/ReactAndroid/src/main/java/com/facebook/react/v8executor/V8Executor.java b/ReactAndroid/src/main/java/com/facebook/react/v8executor/V8Executor.java
2-
new file mode 100644
3-
index 0000000000..c28186d613
4-
--- /dev/null
5-
+++ b/ReactAndroid/src/main/java/com/facebook/react/v8executor/V8Executor.java
6-
@@ -0,0 +1,32 @@
1+
--- "C:\\github\\react-native\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\v8executor\\V8Executor.java" 1970-01-01 05:30:00.000000000 +0530
2+
+++ "C:\\github\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\v8executor\\V8Executor.java" 2022-08-05 12:38:10.946736100 +0530
3+
@@ -0,0 +1,36 @@
74
+/**
85
+ * Copyright (c) 2015-present, Facebook, Inc.
96
+ *
@@ -20,8 +17,12 @@
2017
+import com.facebook.soloader.SoLoader;
2118
+
2219
+@DoNotStrip
23-
+/* package */ class V8Executor extends JavaScriptExecutor {
20+
+public class V8Executor extends JavaScriptExecutor {
2421
+ static {
22+
+ loadLibrary();
23+
+ }
24+
+
25+
+ public static void loadLibrary() throws UnsatisfiedLinkError {
2526
+ SoLoader.loadLibrary("v8executor");
2627
+ }
2728
+

packages/react-native-codegen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "yarn clean && node scripts/build.js --verbose",
1313
"clean": "rm -rf lib",
14-
"prepublish": "yarn run build"
14+
"prepare": "yarn run build"
1515
},
1616
"license": "MIT",
1717
"files": [

0 commit comments

Comments
 (0)