From bfb2c4be99cf2a94d8e7e157a7cce6d705d2633b Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Wed, 4 Nov 2020 05:45:00 -0800 Subject: [PATCH 0001/1810] Rename `//xplat/js:experimental-packager` to `//xplat/js:metro-transform-worker` Summary: Changelog: [Internal] Reviewed By: MichaReiser Differential Revision: D24678671 fbshipit-source-id: 7fc82f73b9f78411dd652f16260af61c18b539b2 --- packages/assets/BUCK | 2 +- packages/normalize-color/BUCK | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/assets/BUCK b/packages/assets/BUCK index fa6f04f440ac24..742b02552c13c8 100644 --- a/packages/assets/BUCK +++ b/packages/assets/BUCK @@ -11,7 +11,7 @@ rn_library( labels = ["supermodule:xplat/default/public.react_native.core"], skip_processors = True, visibility = ["PUBLIC"], - worker = "//xplat/js:experimental-packager", + worker = "//xplat/js:metro-transform-worker", ) yarn_workspace( diff --git a/packages/normalize-color/BUCK b/packages/normalize-color/BUCK index 50fab1d885b8ab..ff21b6e917dec6 100644 --- a/packages/normalize-color/BUCK +++ b/packages/normalize-color/BUCK @@ -11,7 +11,7 @@ rn_library( labels = ["supermodule:xplat/default/public.react_native.core"], skip_processors = True, visibility = ["PUBLIC"], - worker = "//xplat/js:experimental-packager", + worker = "//xplat/js:metro-transform-worker", ) yarn_workspace( From 04de0e75a00630e0d3c715fe5aec519e4d9cb0ab Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 4 Nov 2020 08:08:26 -0800 Subject: [PATCH 0002/1810] Back out "Use ConcreteStateTeller in RCTSafeAreaViewComponentView" Summary: We don't need StateTeller anymore because we already shipped state-autorepeat mechanism on Android. Original commit changeset: 67596194b599 Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D24719346 fbshipit-source-id: 798b6897c49c45ffbf481e6d1be17bc5e7810f27 --- .../SafeAreaView/RCTSafeAreaViewComponentView.mm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm index 7623c1099f93b0..78a1514350f267 100644 --- a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm @@ -17,7 +17,7 @@ using namespace facebook::react; @implementation RCTSafeAreaViewComponentView { - SafeAreaViewShadowNode::ConcreteStateTeller _stateTeller; + SafeAreaViewShadowNode::ConcreteState::Shared _state; EdgeInsets _lastPaddingStateWasUpdatedWith; } @@ -50,6 +50,10 @@ - (void)safeAreaInsetsDidChange - (void)_updateStateIfNecessary { + if (!_state) { + return; + } + UIEdgeInsets insets = [self _safeAreaInsets]; insets.left = RCTRoundPixelValue(insets.left); insets.top = RCTRoundPixelValue(insets.top); @@ -66,21 +70,22 @@ - (void)_updateStateIfNecessary } _lastPaddingStateWasUpdatedWith = newPadding; - _stateTeller.updateState(SafeAreaViewState{newPadding}); + _state->updateState(SafeAreaViewState{newPadding}); } #pragma mark - RCTComponentViewProtocol -- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState +- (void)updateState:(facebook::react::State::Shared const &)state + oldState:(facebook::react::State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); [self _updateStateIfNecessary]; } - (void)prepareForRecycle { [super prepareForRecycle]; - _stateTeller.invalidate(); + _state.reset(); _lastPaddingStateWasUpdatedWith = {}; } From bd7ab6c90b6eae84f50ff4f3bb62f4edf4df0831 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 4 Nov 2020 08:08:26 -0800 Subject: [PATCH 0003/1810] Fabric: Introducing `YogaLayoutableKindMutatesStylesAfterCloning` trait Summary: This implements a new ShadowNode trait that helps to propagate Yoga node `isDirty` flag down the root of the tree and clone siblings appropriately. Several Fabric components mutate its Yoga styles after the node was cloned. In such cases, we need to mark the node as dirty after doing so. The problem with this is that the parent node and its siblings were already updated (cloned or not) based on the previous value of the `isDirty` flag. This happens because this logic is implemented in YogaLayoutableShadowNode which is a base constructor that must be called before any other logic from a subclass can run. For now, this change enables that for SafeAreaView only (which seems to help with some junkiness issues), later we can extend the usage of this for other components if needed. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D24719347 fbshipit-source-id: b0d050afea5de9c470e05e1b4c9e7052e00ae949 --- .../components/safeareaview/SafeAreaViewShadowNode.h | 8 ++++++++ .../renderer/components/view/YogaLayoutableShadowNode.cpp | 5 +++++ ReactCommon/react/renderer/core/ShadowNodeTraits.h | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h index 1bd4e47e62ea68..2c1e0c7fa5d82a 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h @@ -26,6 +26,14 @@ class SafeAreaViewShadowNode final : public ConcreteViewShadowNode< ViewEventEmitter, SafeAreaViewState> { using ConcreteViewShadowNode::ConcreteViewShadowNode; + + public: + static ShadowNodeTraits BaseTraits() { + auto traits = ConcreteViewShadowNode::BaseTraits(); + traits.set( + ShadowNodeTraits::Trait::YogaLayoutableKindMutatesStylesAfterCloning); + return traits; + } }; } // namespace react diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 60f867e1ee00f0..4b4fee2b47ef87 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -82,6 +82,11 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( static_cast(sourceShadowNode) .yogaNode_.isDirty() == yogaNode_.isDirty()); + if (getTraits().check(ShadowNodeTraits::Trait:: + YogaLayoutableKindMutatesStylesAfterCloning)) { + yogaNode_.setDirty(true); + } + if (fragment.props) { updateYogaProps(); } diff --git a/ReactCommon/react/renderer/core/ShadowNodeTraits.h b/ReactCommon/react/renderer/core/ShadowNodeTraits.h index 16b7129bd00c71..d4b663406ca8a4 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeTraits.h +++ b/ReactCommon/react/renderer/core/ShadowNodeTraits.h @@ -54,6 +54,12 @@ class ShadowNodeTraits { // Nodes with this trait (and all their descendants) will not produce views. Hidden = 1 << 6, + // Indicates that the `YogaLayoutableShadowNode` must set `isDirty` flag for + // Yoga node when a `ShadowNode` is being cloned. `ShadowNode`s that modify + // Yoga styles in the constructor (or later) *after* the `ShadowNode` + // is cloned must set this trait. + YogaLayoutableKindMutatesStylesAfterCloning = 1 << 7, + // Inherits `YogaLayoutableShadowNode` and enforces that the `YGNode` is a // leaf. LeafYogaNode = 1 << 10, From 5c4979b2a5b233e4d28e9da277a3e865fc35a86e Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 4 Nov 2020 08:08:26 -0800 Subject: [PATCH 0004/1810] Fabric: Using state auto-repeating in RCTSafeAreaViewComponentView Summary: This change introducing using `updateStateWithAutorepeat` for state updates in RCTSafeAreaViewComponentView. This way we can reduce the number of active commits and reduce jumps & relayout passes. The approach with a callback is better than using `_lastPaddingStateWasUpdatedWith` because: * When we compare the values, we can compare them with actual previous padding numbers stored in Shadow Tree. * The value stored in a UIView instance can go away because of a view being remounted because of flattening. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D24719345 fbshipit-source-id: 9bf1ae284875b4c99cf23be2fcc9a829eb8a895e --- .../RCTSafeAreaViewComponentView.mm | 40 ++++++++++++------- .../safeareaview/SafeAreaViewState.h | 4 +- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm index 78a1514350f267..ddc2cc5bccf251 100644 --- a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm @@ -18,7 +18,6 @@ @implementation RCTSafeAreaViewComponentView { SafeAreaViewShadowNode::ConcreteState::Shared _state; - EdgeInsets _lastPaddingStateWasUpdatedWith; } - (instancetype)initWithFrame:(CGRect)frame @@ -62,23 +61,40 @@ - (void)_updateStateIfNecessary auto newPadding = RCTEdgeInsetsFromUIEdgeInsets(insets); auto threshold = 1.0 / RCTScreenScale() + 0.01; // Size of a pixel plus some small threshold. - auto deltaPadding = newPadding - _lastPaddingStateWasUpdatedWith; - if (std::abs(deltaPadding.left) < threshold && std::abs(deltaPadding.top) < threshold && - std::abs(deltaPadding.right) < threshold && std::abs(deltaPadding.bottom) < threshold) { - return; - } - - _lastPaddingStateWasUpdatedWith = newPadding; - _state->updateState(SafeAreaViewState{newPadding}); + _state->updateStateWithAutorepeat( + [=](SafeAreaViewShadowNode::ConcreteState::Data const &oldData) + -> SafeAreaViewShadowNode::ConcreteState::SharedData { + auto oldPadding = oldData.padding; + auto deltaPadding = newPadding - oldPadding; + + if (std::abs(deltaPadding.left) < threshold && std::abs(deltaPadding.top) < threshold && + std::abs(deltaPadding.right) < threshold && std::abs(deltaPadding.bottom) < threshold) { + return nullptr; + } + + auto newData = oldData; + newData.padding = newPadding; + return std::make_shared(newData); + }); } #pragma mark - RCTComponentViewProtocol ++ (ComponentDescriptorProvider)componentDescriptorProvider +{ + return concreteComponentDescriptorProvider(); +} + - (void)updateState:(facebook::react::State::Shared const &)state oldState:(facebook::react::State::Shared const &)oldState { _state = std::static_pointer_cast(state); +} + +- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask +{ + [super finalizeUpdates:updateMask]; [self _updateStateIfNecessary]; } @@ -86,12 +102,6 @@ - (void)prepareForRecycle { [super prepareForRecycle]; _state.reset(); - _lastPaddingStateWasUpdatedWith = {}; -} - -+ (ComponentDescriptorProvider)componentDescriptorProvider -{ - return concreteComponentDescriptorProvider(); } @end diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h index 6b4c0c008059cb..f64b1bb275b6bf 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h @@ -17,9 +17,7 @@ namespace react { */ class SafeAreaViewState final { public: - using Shared = std::shared_ptr; - - EdgeInsets const padding{}; + EdgeInsets padding{}; }; } // namespace react From a26db2292f153b825101f49577ce9b6f3a0a2cf6 Mon Sep 17 00:00:00 2001 From: "MD. Mizanur Rahman" Date: Wed, 4 Nov 2020 09:31:57 -0800 Subject: [PATCH 0005/1810] fix community link [404 not found] (#30313) Summary: The README file in this repo has a bad link - [404:NotFound] Status code [404:NotFound] - Link: https://reactnative.dev/en/help ## Changelog fixed link: https://reactnative.dev/help [Link] [fixed] - fixed broken link. Pull Request resolved: https://github.com/facebook/react-native/pull/30313 Test Plan: ![image](https://user-images.githubusercontent.com/46071874/98048666-5fe91c00-1e58-11eb-804e-b90f6d77b15f.png) Reviewed By: yungsters Differential Revision: D24716546 Pulled By: cpojer fbshipit-source-id: 684285e5cc0bb6fadc88c1f25d77b38d482084ce --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb54a2231a34b8..af9316f2e2acb0 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ · Contribute · - Community + Community · Support From 2ea7ae4b7c5d20f89ed259098964b9df947be445 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 4 Nov 2020 10:07:41 -0800 Subject: [PATCH 0006/1810] Remove worker param from rn_bundle() macro Summary: Changelog: [Internal] Reviewed By: MichaReiser Differential Revision: D24728338 fbshipit-source-id: a4ed2ac8fdd0115872333f46f48b488af98e681b --- packages/assets/BUCK | 1 - packages/normalize-color/BUCK | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/assets/BUCK b/packages/assets/BUCK index 742b02552c13c8..424f33a0003ce6 100644 --- a/packages/assets/BUCK +++ b/packages/assets/BUCK @@ -11,7 +11,6 @@ rn_library( labels = ["supermodule:xplat/default/public.react_native.core"], skip_processors = True, visibility = ["PUBLIC"], - worker = "//xplat/js:metro-transform-worker", ) yarn_workspace( diff --git a/packages/normalize-color/BUCK b/packages/normalize-color/BUCK index ff21b6e917dec6..e99164634de048 100644 --- a/packages/normalize-color/BUCK +++ b/packages/normalize-color/BUCK @@ -11,7 +11,6 @@ rn_library( labels = ["supermodule:xplat/default/public.react_native.core"], skip_processors = True, visibility = ["PUBLIC"], - worker = "//xplat/js:metro-transform-worker", ) yarn_workspace( From b141dd70080539e4df61cd3e248b8459cd959e0a Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Wed, 4 Nov 2020 11:20:21 -0800 Subject: [PATCH 0007/1810] Make getTurboModule required in RCTTurboModule protocol Summary: This change should make all type-safe NativeModules TurboModule-compatible. Changelog: [Internal] Differential Revision: D24729493 fbshipit-source-id: 7712708a24d675ca567225797016a7ff66a2920e --- .../react/nativemodule/core/platform/ios/RCTTurboModule.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h index bdd94494689284..0f6bd7cb30f1b1 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h @@ -108,8 +108,6 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule { */ @property (nonatomic, weak) id turboModuleRegistry; -@optional -// This should be required, after migration is done. - (std::shared_ptr)getTurboModule: (const facebook::react::ObjCTurboModule::InitParams &)params; From 7324b92dc45679d3b38526378b7d3e78ad082641 Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Wed, 4 Nov 2020 12:46:56 -0800 Subject: [PATCH 0008/1810] Change StatusBar default style handling strategy Summary: Changelog: [Android] - Change StatusBar style handling strategy Previously Android status bar can set to `dark-content` or `default`, I made the following changes: - Added `light-content` to get align with iOS - Changed the behavior of `default` from setting status bar with 'SYSTEM_UI_FLAG_LIGHT_STATUS_BAR' to not doing anything, I did this because 1, `setStyle('default')` is found called even without explicitly declared on that surface, which I think should fail silently 2, my idea is that user should set status bar style to `dark-content` or `light-content` explicitly instead of using `default`. - Fixed the bug found in Dating Settings's Second Look. Reviewed By: RSNara Differential Revision: D24714152 fbshipit-source-id: 76e7d0d45fd3b8c3733efaee81426f5f449cc7d8 --- Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js | 1 + Libraries/Components/StatusBar/StatusBar.js | 2 +- .../com/facebook/react/modules/statusbar/StatusBarModule.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js b/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js index 5b00b2a4c218a6..b451b90827ed30 100644 --- a/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +++ b/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js @@ -55,6 +55,7 @@ const NativeStatusBarManager = { /** * - statusBarStyles can be: * - 'default' + * - 'light-content' * - 'dark-content' */ setStyle(statusBarStyle?: ?string): void { diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 021e75494d12fa..75b51a082829ef 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -25,7 +25,7 @@ import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS'; */ export type StatusBarStyle = $Keys<{ /** - * Default status bar style (dark for iOS, light for Android) + * Default status bar style (dark for iOS, no change for Android) */ default: string, /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java index b4a4e80e68485e..44391965e63b31 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java @@ -194,7 +194,7 @@ public void run() { int systemUiVisibilityFlags = decorView.getSystemUiVisibility(); if ("dark-content".equals(style)) { systemUiVisibilityFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } else { + } else if ("light-content".equals(style)) { systemUiVisibilityFlags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } decorView.setSystemUiVisibility(systemUiVisibilityFlags); From 8663ec4f428efdd54bffe965460b1be26d780108 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Wed, 4 Nov 2020 21:37:26 -0800 Subject: [PATCH 0009/1810] Unbreak iOS build due to header import failure Summary: Changelog: [Internal] Reviewed By: p-sun, yungsters Differential Revision: D24749871 fbshipit-source-id: 70692b8a32f9b7a214d7192ba444c695568e2ccf --- React/CxxBridge/RCTCxxBridge.mm | 5 +++++ packages/rn-tester/RNTester/AppDelegate.mm | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index bf1647fc7acc02..23222509610882 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -37,9 +37,14 @@ #import #import +#ifndef RCT_USE_HERMES #if __has_include() #define RCT_USE_HERMES 1 +#else +#define RCT_USE_HERMES 0 +#endif #endif + #if RCT_USE_HERMES #import "HermesExecutorFactory.h" #else diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index 0b9b534cd68f37..074e520c0c3427 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -7,9 +7,14 @@ #import "AppDelegate.h" +#ifndef RCT_USE_HERMES #if __has_include() #define RCT_USE_HERMES 1 +#else +#define RCT_USE_HERMES 0 +#endif #endif + #if RCT_USE_HERMES #import #else @@ -45,7 +50,6 @@ #import #endif - #if DEBUG #ifdef FB_SONARKIT_ENABLED #import From 729e535137f625c7bb34af2e25b12cfc96698e1f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 5 Nov 2020 03:00:03 -0800 Subject: [PATCH 0010/1810] Fix TextLayoutManager cxx stubs Summary: Changelog: [Internal] Reviewed By: shergin Differential Revision: D24702815 fbshipit-source-id: 5928e66ed881a9a3e80d0a2c604d5ce578253fd6 --- .../platform/cxx/TextLayoutManager.cpp | 18 ++++++++++++++++-- .../platform/cxx/TextLayoutManager.h | 17 ++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp index ffdfeae66d547e..6d7f07ea6d1edb 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp @@ -13,15 +13,29 @@ namespace react { TextLayoutManager::~TextLayoutManager() {} void *TextLayoutManager::getNativeTextLayoutManager() const { - return self_; + return (void *)this; } TextMeasurement TextLayoutManager::measure( AttributedStringBox attributedStringBox, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { - return TextMeasurement{{0, 0}, {}}; + TextMeasurement::Attachments attachments; + for (auto const &fragment : attributedStringBox.getValue().getFragments()) { + if (fragment.isAttachment()) { + attachments.push_back( + TextMeasurement::Attachment{{{0, 0}, {0, 0}}, false}); + } + } + return TextMeasurement{{0, 0}, attachments}; } +LinesMeasurements TextLayoutManager::measureLines( + AttributedString attributedString, + ParagraphAttributes paragraphAttributes, + Size size) const { + return {}; +}; + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h index 7033cdeafe3b41..87c6fdf4bfeca7 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h @@ -28,8 +28,7 @@ using SharedTextLayoutManager = std::shared_ptr; */ class TextLayoutManager { public: - TextLayoutManager(const ContextContainer::Shared &contextContainer) - : contextContainer_(contextContainer){}; + TextLayoutManager(const ContextContainer::Shared &contextContainer) {} ~TextLayoutManager(); /* @@ -40,16 +39,20 @@ class TextLayoutManager { ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const; + /* + * Measures lines of `attributedString` using native text rendering + * infrastructure. + */ + LinesMeasurements measureLines( + AttributedString attributedString, + ParagraphAttributes paragraphAttributes, + Size size) const; + /* * Returns an opaque pointer to platform-specific TextLayoutManager. * Is used on a native views layer to delegate text rendering to the manager. */ void *getNativeTextLayoutManager() const; - - private: - void *self_; - - ContextContainer::Shared contextContainer_; }; } // namespace react From 3e77e15526def73e54af50e9991c18751bf9aed3 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Thu, 5 Nov 2020 06:06:35 -0800 Subject: [PATCH 0011/1810] Continuous Integration cleanup Reviewed By: yungsters Differential Revision: D24700192 fbshipit-source-id: 239a8ad4848a41ad721a635d4ec37d990989f041 --- packages/rn-tester/RCTTest/RCTTestRunner.m | 107 ++++++++++-------- packages/rn-tester/RNTester-tvOS/Info.plist | 2 - packages/rn-tester/RNTester/AppDelegate.mm | 97 ++++++++-------- packages/rn-tester/RNTester/Info.plist | 2 - .../RCTLoggingTests.m | 38 ++++--- .../RNTesterIntegrationTests.xcscheme | 5 - 6 files changed, 131 insertions(+), 120 deletions(-) diff --git a/packages/rn-tester/RCTTest/RCTTestRunner.m b/packages/rn-tester/RCTTest/RCTTestRunner.m index 161b80b874ea2a..daa047dfcd2aeb 100644 --- a/packages/rn-tester/RCTTest/RCTTestRunner.m +++ b/packages/rn-tester/RCTTest/RCTTestRunner.m @@ -20,8 +20,7 @@ static const NSTimeInterval kTestTimeoutSeconds = 120; -@implementation RCTTestRunner -{ +@implementation RCTTestRunner { FBSnapshotTestController *_testController; RCTBridgeModuleListProvider _moduleProvider; NSString *_appPath; @@ -62,7 +61,8 @@ - (instancetype)initWithApp:(NSString *)app if ((self = [super init])) { if (!referenceDirectory.length) { - referenceDirectory = [[NSBundle bundleForClass:self.class].resourcePath stringByAppendingPathComponent:@"ReferenceImages"]; + referenceDirectory = + [[NSBundle bundleForClass:self.class].resourcePath stringByAppendingPathComponent:@"ReferenceImages"]; } NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"]; @@ -82,13 +82,13 @@ - (instancetype)initWithApp:(NSString *)app return self; } -RCT_NOT_IMPLEMENTED(- (instancetype)init) +RCT_NOT_IMPLEMENTED(-(instancetype)init) - (NSURL *)defaultScriptURL { if (getenv("CI_USE_PACKAGER") || _useBundler) { - NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"]; - return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, _appPath]]; + return [NSURL + URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", _appPath]]; } else { return [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; } @@ -121,53 +121,63 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName [self runTest:test module:moduleName initialProps:nil configurationBlock:nil expectErrorBlock:nil]; } -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock +- (void)runTest:(SEL)test + module:(NSString *)moduleName + initialProps:(NSDictionary *)initialProps + configurationBlock:(void (^)(RCTRootView *rootView))configurationBlock { - [self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:nil]; + [self runTest:test + module:moduleName + initialProps:initialProps + configurationBlock:configurationBlock + expectErrorBlock:nil]; } -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -expectErrorRegex:(NSString *)errorRegex +- (void)runTest:(SEL)test + module:(NSString *)moduleName + initialProps:(NSDictionary *)initialProps + configurationBlock:(void (^)(RCTRootView *rootView))configurationBlock + expectErrorRegex:(NSString *)errorRegex { - BOOL(^expectErrorBlock)(NSString *error) = ^BOOL(NSString *error){ + BOOL (^expectErrorBlock)(NSString *error) = ^BOOL(NSString *error) { return [error rangeOfString:errorRegex options:NSRegularExpressionSearch].location != NSNotFound; }; - [self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:expectErrorBlock]; + [self runTest:test + module:moduleName + initialProps:initialProps + configurationBlock:configurationBlock + expectErrorBlock:expectErrorBlock]; } -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock +- (void)runTest:(SEL)test + module:(NSString *)moduleName + initialProps:(NSDictionary *)initialProps + configurationBlock:(void (^)(RCTRootView *rootView))configurationBlock + expectErrorBlock:(BOOL (^)(NSString *error))expectErrorBlock { __weak RCTBridge *batchedBridge; NSNumber *rootTag; RCTLogFunction defaultLogFunction = RCTGetLogFunction(); // Catch all error logs, that are equivalent to redboxes in dev mode. __block NSMutableArray *errors = nil; - RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { - defaultLogFunction(level, source, fileName, lineNumber, message); - if (level >= RCTLogLevelError) { - if (errors == nil) { - errors = [NSMutableArray new]; - } - [errors addObject:message]; - } - }); + RCTSetLogFunction( + ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { + defaultLogFunction(level, source, fileName, lineNumber, message); + if (level >= RCTLogLevelError) { + if (errors == nil) { + errors = [NSMutableArray new]; + } + [errors addObject:message]; + } + }); @autoreleasepool { RCTBridge *bridge; if (_bridgeDelegate) { bridge = [[RCTBridge alloc] initWithDelegate:_bridgeDelegate launchOptions:nil]; } else { - bridge= [[RCTBridge alloc] initWithBundleURL:_scriptURL - moduleProvider:_moduleProvider - launchOptions:nil]; + bridge = [[RCTBridge alloc] initWithBundleURL:_scriptURL moduleProvider:_moduleProvider launchOptions:nil]; } [bridge.devSettings setIsDebuggingRemotely:_useJSDebugger]; batchedBridge = [bridge batchedBridge]; @@ -183,7 +193,9 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName @autoreleasepool { // The rootView needs to be deallocated after this @autoreleasepool block exits. - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProps]; + RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge + moduleName:moduleName + initialProperties:initialProps]; #if TARGET_OS_TV rootView.frame = CGRectMake(0, 0, 1920, 1080); // Standard screen size for tvOS #else @@ -210,20 +222,22 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName } // From this point on catch only fatal errors. - RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { - defaultLogFunction(level, source, fileName, lineNumber, message); - if (level >= RCTLogLevelFatal) { - if (errors == nil) { - errors = [NSMutableArray new]; - } - [errors addObject:message]; - } - }); + RCTSetLogFunction( + ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { + defaultLogFunction(level, source, fileName, lineNumber, message); + if (level >= RCTLogLevelFatal) { + if (errors == nil) { + errors = [NSMutableArray new]; + } + [errors addObject:message]; + } + }); #if RCT_DEV - NSArray *nonLayoutSubviews = [vc.view.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) { - return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"]; - }]]; + NSArray *nonLayoutSubviews = [vc.view.subviews + filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) { + return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"]; + }]]; RCTAssert(nonLayoutSubviews.count == 0, @"There shouldn't be any other views: %@", nonLayoutSubviews); #endif @@ -232,7 +246,8 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName RCTAssert(expectErrorBlock(errors[0]), @"Expected an error but the first one was missing or did not match."); } else { RCTAssert(errors == nil, @"RedBox errors: %@", errors); - RCTAssert(testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds); + RCTAssert( + testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds); RCTAssert(testModule.status == RCTTestStatusPassed, @"Test failed"); } diff --git a/packages/rn-tester/RNTester-tvOS/Info.plist b/packages/rn-tester/RNTester-tvOS/Info.plist index 1f05733996acbd..0afedbb816c675 100644 --- a/packages/rn-tester/RNTester-tvOS/Info.plist +++ b/packages/rn-tester/RNTester-tvOS/Info.plist @@ -31,7 +31,5 @@ UIUserInterfaceStyle Automatic - RN_BUNDLE_PREFIX - $(RN_BUNDLE_PREFIX) diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index 074e520c0c3427..4ce922259a5444 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -21,19 +21,19 @@ #import #endif -#import #import #import #import +#import +#import +#import +#import +#import +#import #import #import -#import #import -#import #import -#import -#import -#import #import #import @@ -43,9 +43,9 @@ #endif #ifdef RN_FABRIC_ENABLED +#import #import #import -#import #import #endif @@ -66,8 +66,7 @@ #import "RNTesterTurboModuleProvider.h" -@interface AppDelegate() { - +@interface AppDelegate () { #ifdef RN_FABRIC_ENABLED RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; std::shared_ptr _reactNativeConfig; @@ -84,14 +83,14 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith { RCTEnableTurboModule(YES); - _bridge = [[RCTBridge alloc] initWithDelegate:self - launchOptions:launchOptions]; + _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; // Appetizer.io params check NSDictionary *initProps = @{}; NSString *_routeUri = [[NSUserDefaults standardUserDefaults] stringForKey:@"route"]; if (_routeUri) { - initProps = @{@"exampleFromAppetizeParams": [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]}; + initProps = + @{@"exampleFromAppetizeParams" : [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]}; } #ifdef RN_FABRIC_ENABLED @@ -100,12 +99,13 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); - _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:_bridge - contextContainer:_contextContainer]; + _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:_bridge contextContainer:_contextContainer]; _bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; - UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; + UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge + moduleName:@"RNTesterApp" + initialProperties:initProps]; #else UIView *rootView = [[RCTRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; #endif @@ -121,9 +121,7 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { - NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"]; - NSString *bundleRoot = [NSString stringWithFormat:@"%@packages/rn-tester/js/RNTesterApp.ios", bundlePrefix]; - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundleRoot + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/rn-tester/js/RNTesterApp.ios" fallbackResource:nil]; } @@ -145,7 +143,7 @@ - (void)initializeFlipper:(UIApplication *)application - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url - options:(NSDictionary *)options + options:(NSDictionary *)options { return [RCTLinkingManager application:app openURL:url options:options]; } @@ -154,12 +152,10 @@ - (void)loadSourceForBridge:(RCTBridge *)bridge onProgress:(RCTSourceLoadProgressBlock)onProgress onComplete:(RCTSourceLoadBlock)loadCallback { - [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] - onProgress:onProgress - onComplete:loadCallback]; + [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback]; } -# pragma mark - RCTCxxBridgeDelegate +#pragma mark - RCTCxxBridgeDelegate - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge { @@ -182,19 +178,17 @@ - (void)loadSourceForBridge:(RCTBridge *)bridge #else return std::make_unique( #endif - facebook::react::RCTJSIExecutorRuntimeInstaller([weakSelf, bridge](facebook::jsi::Runtime &runtime) { - if (!bridge) { - return; - } - __typeof(self) strongSelf = weakSelf; - if (strongSelf) { - facebook::react::RuntimeExecutor syncRuntimeExecutor = [&](std::function &&callback) { - callback(runtime); - }; - [strongSelf->_turboModuleManager installJSBindingWithRuntimeExecutor:syncRuntimeExecutor]; - } - }) - ); + facebook::react::RCTJSIExecutorRuntimeInstaller([weakSelf, bridge](facebook::jsi::Runtime &runtime) { + if (!bridge) { + return; + } + __typeof(self) strongSelf = weakSelf; + if (strongSelf) { + facebook::react::RuntimeExecutor syncRuntimeExecutor = + [&](std::function &&callback) { callback(runtime); }; + [strongSelf->_turboModuleManager installJSBindingWithRuntimeExecutor:syncRuntimeExecutor]; + } + })); } #pragma mark RCTTurboModuleManagerDelegate @@ -211,7 +205,8 @@ - (Class)getModuleClassFromName:(const char *)name } - (std::shared_ptr)getTurboModule:(const std::string &)name - initParams:(const facebook::react::ObjCTurboModule::InitParams &)params + initParams: + (const facebook::react::ObjCTurboModule::InitParams &)params { return facebook::react::RNTesterTurboModuleProvider(name, params); } @@ -219,13 +214,15 @@ - (Class)getModuleClassFromName:(const char *)name - (id)getModuleInstanceFromClass:(Class)moduleClass { if (moduleClass == RCTImageLoader.class) { - return [[moduleClass alloc] initWithRedirectDelegate:nil loadersProvider:^NSArray> *{ - return @[[RCTLocalAssetImageLoader new]]; - } decodersProvider:^NSArray> *{ - return @[[RCTGIFImageDecoder new]]; - }]; + return [[moduleClass alloc] initWithRedirectDelegate:nil + loadersProvider:^NSArray> * { + return @ [[RCTLocalAssetImageLoader new]]; + } + decodersProvider:^NSArray> * { + return @ [[RCTGIFImageDecoder new]]; + }]; } else if (moduleClass == RCTNetworking.class) { - return [[moduleClass alloc] initWithHandlersProvider:^NSArray> *{ + return [[moduleClass alloc] initWithHandlersProvider:^NSArray> * { return @[ [RCTHTTPRequestHandler new], [RCTDataRequestHandler new], @@ -237,24 +234,27 @@ - (Class)getModuleClassFromName:(const char *)name return [moduleClass new]; } -# pragma mark - Push Notifications +#pragma mark - Push Notifications #if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC // Required to register for notifications -- (void)application:(__unused UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings +- (void)application:(__unused UIApplication *)application + didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings]; } // Required for the remoteNotificationsRegistered event. -- (void)application:(__unused UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken +- (void)application:(__unused UIApplication *)application + didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } // Required for the remoteNotificationRegistrationError event. -- (void)application:(__unused UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error +- (void)application:(__unused UIApplication *)application + didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error]; } @@ -266,7 +266,8 @@ - (void)application:(__unused UIApplication *)application didReceiveRemoteNotifi } // Required for the localNotificationReceived event. -- (void)application:(__unused UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification +- (void)application:(__unused UIApplication *)application + didReceiveLocalNotification:(UILocalNotification *)notification { [RCTPushNotificationManager didReceiveLocalNotification:notification]; } diff --git a/packages/rn-tester/RNTester/Info.plist b/packages/rn-tester/RNTester/Info.plist index 3b0806d0b90814..13573d49b86602 100644 --- a/packages/rn-tester/RNTester/Info.plist +++ b/packages/rn-tester/RNTester/Info.plist @@ -60,7 +60,5 @@ NSPhotoLibraryUsageDescription You need to add NSPhotoLibraryUsageDescription key in Info.plist to enable photo library usage, otherwise it is going to *fail silently*! - RN_BUNDLE_PREFIX - $(RN_BUNDLE_PREFIX) diff --git a/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m b/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m index 36b47a79b7e846..0346208ceb811b 100644 --- a/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m +++ b/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m @@ -15,8 +15,7 @@ @interface RCTLoggingTests : XCTestCase @end -@implementation RCTLoggingTests -{ +@implementation RCTLoggingTests { RCTBridge *_bridge; dispatch_semaphore_t _logSem; @@ -29,9 +28,9 @@ - (void)setUp { NSURL *scriptURL; if (getenv("CI_USE_PACKAGER")) { - NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"]; NSString *app = @"IntegrationTests/IntegrationTestsApp"; - scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, app]]; + scriptURL = + [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]]; } else { scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; } @@ -59,18 +58,23 @@ - (void)testLogging { // First console log call will fire after 2.0 sec, to allow for any initial log messages // that might come in (seeing this in tvOS) - [_bridge enqueueJSCall:@"LoggingTestModule.logToConsoleAfterWait" args:@[@"Invoking console.log",@2000]]; + [_bridge enqueueJSCall:@"LoggingTestModule.logToConsoleAfterWait" args:@[ @"Invoking console.log", @2000 ]]; // Spin native layer for 1.9 sec [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.9]]; // Now set the log function to signal the semaphore - RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, __unused NSString *fileName, __unused NSNumber *lineNumber, NSString *message) { - if (source == RCTLogSourceJavaScript) { - self->_lastLogLevel = level; - self->_lastLogSource = source; - self->_lastLogMessage = message; - dispatch_semaphore_signal(self->_logSem); - } - }); + RCTSetLogFunction( + ^(RCTLogLevel level, + RCTLogSource source, + __unused NSString *fileName, + __unused NSNumber *lineNumber, + NSString *message) { + if (source == RCTLogSourceJavaScript) { + self->_lastLogLevel = level; + self->_lastLogSource = source; + self->_lastLogMessage = message; + dispatch_semaphore_signal(self->_logSem); + } + }); // Wait for console log to signal the semaphore dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER); @@ -78,21 +82,21 @@ - (void)testLogging XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript); XCTAssertEqualObjects(_lastLogMessage, @"Invoking console.log"); - [_bridge enqueueJSCall:@"LoggingTestModule.warning" args:@[@"Generating warning"]]; + [_bridge enqueueJSCall:@"LoggingTestModule.warning" args:@[ @"Generating warning" ]]; dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER); XCTAssertEqual(_lastLogLevel, RCTLogLevelWarning); XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript); XCTAssertEqualObjects(_lastLogMessage, @"Generating warning"); - [_bridge enqueueJSCall:@"LoggingTestModule.invariant" args:@[@"Invariant failed"]]; + [_bridge enqueueJSCall:@"LoggingTestModule.invariant" args:@[ @"Invariant failed" ]]; dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER); XCTAssertEqual(_lastLogLevel, RCTLogLevelError); XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript); XCTAssertTrue([_lastLogMessage containsString:@"Invariant Violation: Invariant failed"]); - [_bridge enqueueJSCall:@"LoggingTestModule.logErrorToConsole" args:@[@"Invoking console.error"]]; + [_bridge enqueueJSCall:@"LoggingTestModule.logErrorToConsole" args:@[ @"Invoking console.error" ]]; dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER); // For local bundles, we'll first get a warning about symbolication @@ -104,7 +108,7 @@ - (void)testLogging XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript); XCTAssertEqualObjects(_lastLogMessage, @"Invoking console.error"); - [_bridge enqueueJSCall:@"LoggingTestModule.throwError" args:@[@"Throwing an error"]]; + [_bridge enqueueJSCall:@"LoggingTestModule.throwError" args:@[ @"Throwing an error" ]]; dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER); // For local bundles, we'll first get a warning about symbolication diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/xcshareddata/xcschemes/RNTesterIntegrationTests.xcscheme b/packages/rn-tester/RNTesterPods.xcodeproj/xcshareddata/xcschemes/RNTesterIntegrationTests.xcscheme index 53412600d9bbf7..8d487f97cdb398 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/xcshareddata/xcschemes/RNTesterIntegrationTests.xcscheme +++ b/packages/rn-tester/RNTesterPods.xcodeproj/xcshareddata/xcschemes/RNTesterIntegrationTests.xcscheme @@ -42,11 +42,6 @@ value = "1" isEnabled = "YES"> - - Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0012/1810] Clean up EventObjectPropertyType Summary: All ObjectTypeAnnotation *properties* in the codegen have the following shape: ``` { name: string, optional: boolean, typeAnnotation: ... } ``` EventObjectTypeProperty is a property of some ObjectTypeAnnotation, yet it doesn't follow this pattern. This diff cleans up EventObjectPropertyType. This is a part of a larger effort to clean up the Component Schema and unify the notion of a "type annotation" across the Component and Module schemas. Reviewed By: yungsters Differential Revision: D24701027 fbshipit-source-id: edc7dc632a217fb5a82ffd8a62aef990baf398c2 --- .../react-native-codegen/src/CodegenSchema.js | 80 +- .../components/GenerateEventEmitterCpp.js | 27 +- .../components/GenerateEventEmitterH.js | 20 +- .../components/__test_fixtures__/fixtures.js | 110 +- .../component-parser-test.js.snap | 7970 ++++++++++------- .../src/parsers/flow/components/events.js | 38 +- 6 files changed, 4990 insertions(+), 3255 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 358033306d91f3..3fe73a0ca60b9b 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -55,46 +55,28 @@ export type StringTypeAnnotation = $ReadOnly<{| type: 'StringTypeAnnotation', |}>; -export type EventObjectPropertyType = - | $ReadOnly<{| - type: 'BooleanTypeAnnotation', - name: string, - optional: boolean, - |}> - | $ReadOnly<{| - type: 'StringTypeAnnotation', - name: string, - optional: boolean, - |}> - | $ReadOnly<{| - type: 'DoubleTypeAnnotation', - name: string, - optional: boolean, - |}> - | $ReadOnly<{| - type: 'FloatTypeAnnotation', - name: string, - optional: boolean, - |}> - | $ReadOnly<{| - type: 'Int32TypeAnnotation', - name: string, - optional: boolean, - |}> - | $ReadOnly<{| - type: 'StringEnumTypeAnnotation', - name: string, - optional: boolean, - options: $ReadOnlyArray<{| - name: string, +export type StringEnumTypeAnnotation = $ReadOnly<{| + type: 'StringEnumTypeAnnotation', + options: $ReadOnlyArray<{| + name: string, + |}>, +|}>; + +export type EventObjectPropertyType = $ReadOnly<{| + name: string, + optional: boolean, + typeAnnotation: + | BooleanTypeAnnotation + | StringTypeAnnotation + | DoubleTypeAnnotation + | FloatTypeAnnotation + | Int32TypeAnnotation + | StringEnumTypeAnnotation + | $ReadOnly<{| + type: 'ObjectTypeAnnotation', + properties: $ReadOnlyArray, |}>, - |}> - | $ReadOnly<{| - type: 'ObjectTypeAnnotation', - name: string, - optional: boolean, - properties: $ReadOnlyArray, - |}>; +|}>; type PropTypeTypeAnnotation = | $ReadOnly<{| @@ -146,21 +128,11 @@ type PropTypeTypeAnnotation = | $ReadOnly<{| type: 'ArrayTypeAnnotation', elementType: - | $ReadOnly<{| - type: 'BooleanTypeAnnotation', - |}> - | $ReadOnly<{| - type: 'StringTypeAnnotation', - |}> - | $ReadOnly<{| - type: 'DoubleTypeAnnotation', - |}> - | $ReadOnly<{| - type: 'FloatTypeAnnotation', - |}> - | $ReadOnly<{| - type: 'Int32TypeAnnotation', - |}> + | BooleanTypeAnnotation + | StringTypeAnnotation + | DoubleTypeAnnotation + | FloatTypeAnnotation + | Int32TypeAnnotation | $ReadOnly<{| type: 'StringEnumTypeAnnotation', default: string, diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index f1e20d59070e06..cde931ae98d9c8 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -86,11 +86,32 @@ function generateSetters( ): string { const propSetters = properties .map(eventProperty => { - switch (eventProperty.type) { + const {typeAnnotation} = eventProperty; + switch (typeAnnotation.type) { case 'BooleanTypeAnnotation': + return generateSetter( + parentPropertyName, + eventProperty.name, + propertyParts, + ); case 'StringTypeAnnotation': + return generateSetter( + parentPropertyName, + eventProperty.name, + propertyParts, + ); case 'Int32TypeAnnotation': + return generateSetter( + parentPropertyName, + eventProperty.name, + propertyParts, + ); case 'DoubleTypeAnnotation': + return generateSetter( + parentPropertyName, + eventProperty.name, + propertyParts, + ); case 'FloatTypeAnnotation': return generateSetter( parentPropertyName, @@ -110,7 +131,7 @@ function generateSetters( auto ${propertyName} = jsi::Object(runtime); ${generateSetters( propertyName, - eventProperty.properties, + typeAnnotation.properties, propertyParts.concat([propertyName]), )} @@ -118,7 +139,7 @@ function generateSetters( } `.trim(); default: - (eventProperty: empty); + (typeAnnotation.type: empty); throw new Error('Received invalid event property type'); } }) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js index b9d6c3204c0e10..0415b7af9b446d 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js @@ -102,7 +102,7 @@ function getNativeTypeFromAnnotation( eventProperty: EventObjectPropertyType, nameParts: $ReadOnlyArray, ): string { - const type = eventProperty.type; + const {type} = eventProperty.typeAnnotation; switch (type) { case 'BooleanTypeAnnotation': @@ -163,13 +163,17 @@ function generateStruct( }) .join('\n' + ' '); - properties.forEach((property: EventObjectPropertyType) => { - const name = property.name; - switch (property.type) { + properties.forEach(property => { + const {name, typeAnnotation} = property; + switch (typeAnnotation.type) { case 'BooleanTypeAnnotation': + return; case 'StringTypeAnnotation': + return; case 'Int32TypeAnnotation': + return; case 'DoubleTypeAnnotation': + return; case 'FloatTypeAnnotation': return; case 'ObjectTypeAnnotation': @@ -177,16 +181,16 @@ function generateStruct( structs, componentName, nameParts.concat([name]), - nullthrows(property.properties), + nullthrows(typeAnnotation.properties), ); return; case 'StringEnumTypeAnnotation': - generateEnum(structs, property.options, nameParts.concat([name])); + generateEnum(structs, typeAnnotation.options, nameParts.concat([name])); return; default: - (property: empty); + (typeAnnotation.type: empty); throw new Error( - `Received invalid event property type ${property.type}`, + `Received invalid event property type ${typeAnnotation.type}`, ); } }); diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index 233254e8011281..02cae025420f35 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -58,9 +58,11 @@ const INTERFACE_ONLY: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'BooleanTypeAnnotation', name: 'value', optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, }, ], }, @@ -110,9 +112,11 @@ const EVENTS_WITH_PAPER_NAME: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'BooleanTypeAnnotation', name: 'value', optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, }, ], }, @@ -129,9 +133,11 @@ const EVENTS_WITH_PAPER_NAME: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'BooleanTypeAnnotation', name: 'value', optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, }, ], }, @@ -1134,24 +1140,32 @@ const EVENT_PROPS: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'BooleanTypeAnnotation', name: 'value', optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, }, { - type: 'StringTypeAnnotation', name: 'source', optional: true, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, }, { - type: 'Int32TypeAnnotation', name: 'progress', optional: true, + typeAnnotation: { + type: 'Int32TypeAnnotation', + }, }, { - type: 'FloatTypeAnnotation', name: 'scale', optional: true, + typeAnnotation: { + type: 'FloatTypeAnnotation', + }, }, ], }, @@ -1167,9 +1181,11 @@ const EVENT_PROPS: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'BooleanTypeAnnotation', name: 'value', optional: false, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, }, ], }, @@ -1185,17 +1201,19 @@ const EVENT_PROPS: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'StringEnumTypeAnnotation', name: 'orientation', optional: false, - options: [ - { - name: 'landscape', - }, - { - name: 'portrait', - }, - ], + typeAnnotation: { + type: 'StringEnumTypeAnnotation', + options: [ + { + name: 'landscape', + }, + { + name: 'portrait', + }, + ], + }, }, ], }, @@ -1250,33 +1268,43 @@ const EVENT_NESTED_OBJECT_PROPS: SchemaType = { type: 'ObjectTypeAnnotation', properties: [ { - type: 'ObjectTypeAnnotation', name: 'location', optional: false, - properties: [ - { - type: 'ObjectTypeAnnotation', - name: 'source', - optional: false, - properties: [ - { - type: 'StringTypeAnnotation', - name: 'url', - optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'source', + optional: false, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'url', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + ], }, - ], - }, - { - type: 'Int32TypeAnnotation', - name: 'x', - optional: false, - }, - { - type: 'Int32TypeAnnotation', - name: 'y', - optional: false, - }, - ], + }, + { + name: 'x', + optional: false, + typeAnnotation: { + type: 'Int32TypeAnnotation', + }, + }, + { + name: 'y', + optional: false, + typeAnnotation: { + type: 'Int32TypeAnnotation', + }, + }, + ], + }, }, ], }, diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index b66ee965af504b..51bcdca03c4942 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -1300,291 +1300,385 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -1601,291 +1695,385 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -1901,291 +2089,385 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -2202,291 +2484,385 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -2833,291 +3209,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -3133,291 +3603,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -3433,291 +3997,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -3733,291 +4391,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -4034,291 +4786,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -4334,291 +5180,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -4634,291 +5574,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -4934,291 +5968,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -5234,291 +6362,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_readonly_optional_key', - 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -5535,291 +6757,385 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -6787,291 +8103,385 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_readonly_optional_value', - 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -7088,291 +8498,385 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -7388,291 +8892,385 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_readonly_optional_both', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } @@ -7689,291 +9287,385 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'type': 'ObjectTypeAnnotation', 'properties': [ { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'BooleanTypeAnnotation', 'name': 'boolean_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'StringTypeAnnotation', 'name': 'string_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'DoubleTypeAnnotation', 'name': 'double_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'FloatTypeAnnotation', 'name': 'float_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_required', - 'optional': false + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_key', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_value', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'Int32TypeAnnotation', 'name': 'int32_optional_both', - 'optional': true + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_required', 'optional': false, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_key', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_value', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'StringEnumTypeAnnotation', 'name': 'enum_optional_both', 'optional': true, - 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } - ] + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + { + 'name': 'small' + }, + { + 'name': 'large' + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_required_nested_2_layers', 'optional': false, - 'properties': [ - { - 'type': 'ObjectTypeAnnotation', - 'name': 'object_optional_nested_1_layer', - 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'boolean_required', - 'optional': false - }, - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - }, - { - 'type': 'DoubleTypeAnnotation', - 'name': 'double_optional_value', - 'optional': true - }, - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - }, - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] } - ] - } - ] + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_required', 'optional': false, - 'properties': [ - { - 'type': 'BooleanTypeAnnotation', - 'name': 'boolean_required', - 'optional': false - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_key', 'optional': true, - 'properties': [ - { - 'type': 'StringTypeAnnotation', - 'name': 'string_optional_key', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_value', 'optional': true, - 'properties': [ - { - 'type': 'FloatTypeAnnotation', - 'name': 'float_optional_value', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } }, { - 'type': 'ObjectTypeAnnotation', 'name': 'object_readonly_optional_both', 'optional': true, - 'properties': [ - { - 'type': 'Int32TypeAnnotation', - 'name': 'int32_optional_both', - 'optional': true - } - ] + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } } ] } diff --git a/packages/react-native-codegen/src/parsers/flow/components/events.js b/packages/react-native-codegen/src/parsers/flow/components/events.js index 81295411a08c06..6f6105bbfd006c 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/events.js +++ b/packages/react-native-codegen/src/parsers/flow/components/events.js @@ -15,7 +15,11 @@ import type { EventObjectPropertyType, } from '../../../CodegenSchema.js'; -function getPropertyType(name, optional, typeAnnotation) { +function getPropertyType( + name, + optional, + typeAnnotation, +): EventObjectPropertyType { const type = typeAnnotation.type === 'GenericTypeAnnotation' ? typeAnnotation.id.name @@ -24,33 +28,43 @@ function getPropertyType(name, optional, typeAnnotation) { switch (type) { case 'BooleanTypeAnnotation': return { - type: 'BooleanTypeAnnotation', name, optional, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, }; case 'StringTypeAnnotation': return { - type: 'StringTypeAnnotation', name, optional, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, }; case 'Int32': return { - type: 'Int32TypeAnnotation', name, optional, + typeAnnotation: { + type: 'Int32TypeAnnotation', + }, }; case 'Double': return { - type: 'DoubleTypeAnnotation', name, optional, + typeAnnotation: { + type: 'DoubleTypeAnnotation', + }, }; case 'Float': return { - type: 'FloatTypeAnnotation', name, optional, + typeAnnotation: { + type: 'FloatTypeAnnotation', + }, }; case '$ReadOnly': return getPropertyType( @@ -60,17 +74,21 @@ function getPropertyType(name, optional, typeAnnotation) { ); case 'ObjectTypeAnnotation': return { - type: 'ObjectTypeAnnotation', name, optional, - properties: typeAnnotation.properties.map(buildPropertiesForEvent), + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: typeAnnotation.properties.map(buildPropertiesForEvent), + }, }; case 'UnionTypeAnnotation': return { - type: 'StringEnumTypeAnnotation', name, optional, - options: typeAnnotation.types.map(option => ({name: option.value})), + typeAnnotation: { + type: 'StringEnumTypeAnnotation', + options: typeAnnotation.types.map(option => ({name: option.value})), + }, }; default: (type: empty); From 856bc2978cabba20374b5a57683d1e9e7bd52ce2 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0013/1810] Introduce NamedShape utility type Summary: Our CodegenSchema is littered with types that have the following shape ``` { name: string, optional: boolean, typeAnnotation: ... } ``` In all these types, the only difference is the typeAnnotation. This diff introduces a new utility type called `NamedShape`, that just creates this shape, given a type annotation. This should help reduce the amount of noise in the CodegenSchema, and make it a bit easier to read. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24701331 fbshipit-source-id: a30d3e22933116e3dabf7929615905febacecba3 --- .../react-native-codegen/src/CodegenSchema.js | 65 ++++++++----------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 3fe73a0ca60b9b..b141a28b12f451 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -62,21 +62,24 @@ export type StringEnumTypeAnnotation = $ReadOnly<{| |}>, |}>; -export type EventObjectPropertyType = $ReadOnly<{| +type NamedShape<+T> = $ReadOnly<{ name: string, optional: boolean, - typeAnnotation: - | BooleanTypeAnnotation - | StringTypeAnnotation - | DoubleTypeAnnotation - | FloatTypeAnnotation - | Int32TypeAnnotation - | StringEnumTypeAnnotation - | $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}>, -|}>; + typeAnnotation: T, +}>; + +export type EventObjectPropertyType = NamedShape< + | BooleanTypeAnnotation + | StringTypeAnnotation + | DoubleTypeAnnotation + | FloatTypeAnnotation + | Int32TypeAnnotation + | StringEnumTypeAnnotation + | $ReadOnly<{| + type: 'ObjectTypeAnnotation', + properties: $ReadOnlyArray, + |}>, +>; type PropTypeTypeAnnotation = | $ReadOnly<{| @@ -161,11 +164,7 @@ type PropTypeTypeAnnotation = |}>, |}>; -export type PropTypeShape = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: PropTypeTypeAnnotation, -|}>; +export type PropTypeShape = NamedShape; export type EventTypeShape = $ReadOnly<{| name: string, @@ -181,11 +180,7 @@ export type EventTypeShape = $ReadOnly<{| |}>, |}>; -export type CommandTypeShape = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: CommandsFunctionTypeAnnotation, -|}>; +export type CommandTypeShape = NamedShape; export type OptionsShape = $ReadOnly<{| interfaceOnly?: boolean, @@ -257,11 +252,9 @@ type NativeModuleSpec = $ReadOnly<{| properties: $ReadOnlyArray, |}>; -export type NativeModulePropertySchema = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: Nullable, -|}>; +export type NativeModulePropertySchema = NamedShape< + Nullable, +>; export type NativeModuleAliasMap = $ReadOnly<{| [aliasName: string]: NativeModuleObjectTypeAnnotation, @@ -273,22 +266,18 @@ export type NativeModuleFunctionTypeAnnotation = $ReadOnly<{| returnTypeAnnotation: Nullable, |}>; -export type NativeModuleMethodParamSchema = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: Nullable, -|}>; +export type NativeModuleMethodParamSchema = NamedShape< + Nullable, +>; export type NativeModuleObjectTypeAnnotation = $ReadOnly<{| type: 'ObjectTypeAnnotation', properties: $ReadOnlyArray, |}>; -export type NativeModuleObjectTypeAnnotationPropertySchema = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: Nullable, -|}>; +export type NativeModuleObjectTypeAnnotationPropertySchema = NamedShape< + Nullable, +>; export type NativeModuleArrayTypeAnnotation< +T: Nullable, From 1231db0d7fc4525bcf6f8f0ad8df2906f5a297be Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0014/1810] Rename ReservedFunctionValueTypeAnnotation to ReservedTypeAnnotation Summary: Reserved type annotations can appear in three different contexts: commands, props, and NativeModules. For now, commands and NativeModules share the same reserved type annotations. In the future, we may want to merge these reserved type annotations with the props reserved type annotations. **Motivation:** The meaning of FunctionValue in FunctionValueTypeAnnotation isn't clear - in fact, it's downright confusing. Therefore, this diff renames this Flow type to ReservedTypeAnnotation, which I believe sufficiently captures the intent of the type annotation. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24701322 fbshipit-source-id: bde0273b4a89c9e7175c60ed3468ed870b320044 --- .../react-native-codegen/src/CodegenSchema.js | 17 ++---- .../components/GenerateComponentHObjCpp.js | 8 +-- .../components/GeneratePropsJavaDelegate.js | 2 +- .../components/GeneratePropsJavaInterface.js | 2 +- .../components/__test_fixtures__/fixtures.js | 2 +- .../generators/modules/GenerateModuleCpp.js | 2 +- .../src/generators/modules/GenerateModuleH.js | 2 +- .../modules/GenerateModuleJavaSpec.js | 6 +- .../modules/GenerateModuleJniCpp.js | 6 +- .../GenerateModuleObjCpp/StructCollector.js | 4 +- .../header/serializeConstantsStruct.js | 4 +- .../header/serializeRegularStruct.js | 4 +- .../GenerateModuleObjCpp/serializeMethod.js | 6 +- .../modules/__test_fixtures__/fixtures.js | 4 +- .../component-parser-test.js.snap | 2 +- .../src/parsers/flow/components/commands.js | 2 +- .../module-parser-snapshot-test.js.snap | 4 +- .../__tests__/module-parser-e2e-test.js | 56 ++++++------------- .../src/parsers/flow/modules/index.js | 2 +- 19 files changed, 53 insertions(+), 82 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index b141a28b12f451..48047fe186f44f 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -23,16 +23,16 @@ export type CommandsFunctionTypeParamAnnotation = $ReadOnly<{| |}>; export type CommandsTypeAnnotation = - | ReservedFunctionValueTypeAnnotation + | ReservedTypeAnnotation | BooleanTypeAnnotation | Int32TypeAnnotation | DoubleTypeAnnotation | FloatTypeAnnotation | StringTypeAnnotation; -type ReservedFunctionValueTypeAnnotation = $ReadOnly<{| - type: 'ReservedFunctionValueTypeAnnotation', - name: ReservedFunctionValueTypeName, +export type ReservedTypeAnnotation = $ReadOnly<{| + type: 'ReservedTypeAnnotation', + name: 'RootTag', // Union with more custom types. |}>; export type DoubleTypeAnnotation = $ReadOnly<{| @@ -318,11 +318,6 @@ export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{| type: 'GenericObjectTypeAnnotation', |}>; -export type NativeModuleReservedFunctionValueTypeAnnotation = $ReadOnly<{| - type: 'ReservedFunctionValueTypeAnnotation', - name: ReservedFunctionValueTypeName, -|}>; - export type NativeModuleTypeAliasTypeAnnotation = $ReadOnly<{| type: 'TypeAliasTypeAnnotation', name: string, @@ -344,7 +339,7 @@ export type NativeModuleBaseTypeAnnotation = | NativeModuleFloatTypeAnnotation | NativeModuleBooleanTypeAnnotation | NativeModuleGenericObjectTypeAnnotation - | NativeModuleReservedFunctionValueTypeAnnotation + | ReservedTypeAnnotation | NativeModuleTypeAliasTypeAnnotation | NativeModuleArrayTypeAnnotation> | NativeModuleObjectTypeAnnotation; @@ -366,5 +361,3 @@ type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation; type NativeModuleReturnOnlyTypeAnnotation = | NativeModulePromiseTypeAnnotation | NativeModuleVoidTypeAnnotation; - -export type ReservedFunctionValueTypeName = 'RootTag'; // Union with more custom types. diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 978c46887ec78f..467d02bcdaeab0 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -107,7 +107,7 @@ function getObjCParamType(param: CommandsFunctionTypeParamAnnotation): string { const {typeAnnotation} = param; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return 'double'; @@ -137,7 +137,7 @@ function getObjCExpectedKindParamType( const {typeAnnotation} = param; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return '[NSNumber class]'; @@ -167,7 +167,7 @@ function getReadableExpectedKindParamType( const {typeAnnotation} = param; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return 'double'; @@ -198,7 +198,7 @@ function getObjCRightHandAssignmentParamType( const {typeAnnotation} = param; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return `[(NSNumber *)arg${index} doubleValue]`; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index e1bb022ba4efe1..c963d8b61e2de8 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -157,7 +157,7 @@ function getCommandArgJavaType(param, index) { const {typeAnnotation} = param; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return `args.getDouble(${index})`; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index a357470ce2987c..d5e26c745a8e87 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -128,7 +128,7 @@ function getCommandArgJavaType(param) { const {typeAnnotation} = param; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return 'double'; diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index 02cae025420f35..5e82ace63356fe 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -1537,7 +1537,7 @@ const COMMANDS_AND_PROPS: SchemaType = { { name: 'rootTag', typeAnnotation: { - type: 'ReservedFunctionValueTypeAnnotation', + type: 'ReservedTypeAnnotation', name: 'RootTag', }, }, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index 48f70b5b7af896..5050f213707287 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -118,7 +118,7 @@ function serializeArg( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return wrap('.getNumber()'); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index 1f37cc08365dee..7b53dea5bfb022 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -78,7 +78,7 @@ function translatePrimitiveJSTypeToCpp( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return 'double'; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index dcb39b11ebd32f..a18315346d1f8d 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -118,7 +118,7 @@ function translateFunctionParamToJavaType( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return !isRequired ? 'Double' : 'double'; @@ -188,7 +188,7 @@ function translateFunctionReturnTypeToJavaType( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return nullable ? 'Double' : 'double'; @@ -245,7 +245,7 @@ function getFalsyReturnStatementFromReturnType( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return 'return 0.0;'; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index f13c8ee54ca047..8b4a9317766b37 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -137,7 +137,7 @@ function translateReturnTypeToKind( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return 'NumberKind'; @@ -194,7 +194,7 @@ function translateParamTypeToJniType( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return !isRequired ? 'Ljava/lang/Double;' : 'D'; @@ -244,7 +244,7 @@ function translateReturnTypeToJniType( } switch (realTypeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': return nullable ? 'Ljava/lang/Double;' : 'D'; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js index 13c3c1031abff4..ae48982139a247 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js @@ -20,7 +20,7 @@ import type { NativeModuleFloatTypeAnnotation, NativeModuleBooleanTypeAnnotation, NativeModuleGenericObjectTypeAnnotation, - NativeModuleReservedFunctionValueTypeAnnotation, + ReservedTypeAnnotation, NativeModuleTypeAliasTypeAnnotation, NativeModuleArrayTypeAnnotation, NativeModuleBaseTypeAnnotation, @@ -64,7 +64,7 @@ export type StructTypeAnnotation = | NativeModuleFloatTypeAnnotation | NativeModuleBooleanTypeAnnotation | NativeModuleGenericObjectTypeAnnotation - | NativeModuleReservedFunctionValueTypeAnnotation + | ReservedTypeAnnotation | NativeModuleTypeAliasTypeAnnotation | NativeModuleArrayTypeAnnotation>; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js index 0e7f2ab9e2b156..0579c28f925ea0 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js @@ -87,7 +87,7 @@ function toObjCType( }; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return wrapFollyOptional('double'); @@ -152,7 +152,7 @@ function toObjCValue( } switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return wrapPrimitive('double'); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js index 60e5859a5ca647..3eb5155201d5df 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js @@ -76,7 +76,7 @@ function toObjCType( }; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return wrapFollyOptional('double'); @@ -140,7 +140,7 @@ function toObjCValue( }; switch (typeAnnotation.type) { - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return RCTBridgingTo('Double'); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index d5db63c7610120..bf12da4ecfa324 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -246,7 +246,7 @@ function getParamObjCType( ' &', ); } - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (structTypeAnnotation.name) { case 'RootTag': return notStruct(notRequired ? 'NSNumber *' : 'double'); @@ -308,7 +308,7 @@ function getReturnObjCType( typeAnnotation.elementType, )}> *`, ); - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': return wrapIntoNullableIfNeeded('NSNumber *'); @@ -358,7 +358,7 @@ function getReturnJSType( return 'ObjectKind'; case 'ArrayTypeAnnotation': return 'ArrayKind'; - case 'ReservedFunctionValueTypeAnnotation': + case 'ReservedTypeAnnotation': return 'NumberKind'; case 'StringTypeAnnotation': return 'StringKind'; diff --git a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js index 17d2f010804efc..eb1f8ddd6f1edf 100644 --- a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js @@ -185,7 +185,7 @@ const SIMPLE_NATIVE_MODULES: SchemaType = { typeAnnotation: { type: 'FunctionTypeAnnotation', returnTypeAnnotation: { - type: 'ReservedFunctionValueTypeAnnotation', + type: 'ReservedTypeAnnotation', name: 'RootTag', }, params: [ @@ -193,7 +193,7 @@ const SIMPLE_NATIVE_MODULES: SchemaType = { optional: false, name: 'arg', typeAnnotation: { - type: 'ReservedFunctionValueTypeAnnotation', + type: 'ReservedTypeAnnotation', name: 'RootTag', }, }, diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index 51bcdca03c4942..61cef441150ae9 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -2925,7 +2925,7 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_DEFINED_WITH_ALL_T { 'name': 'rootTag', 'typeAnnotation': { - 'type': 'ReservedFunctionValueTypeAnnotation', + 'type': 'ReservedTypeAnnotation', 'name': 'RootTag' } } diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index 92aef0a2ad0b18..b6b2ce39b952fd 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -49,7 +49,7 @@ function buildCommandSchema(property, types: TypeDeclarationMap) { switch (type) { case 'RootTag': returnType = { - type: 'ReservedFunctionValueTypeAnnotation', + type: 'ReservedTypeAnnotation', name: 'RootTag', }; break; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap index 5aca4040dbcbee..0592287aea105d 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap @@ -1236,7 +1236,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ROOT_TAG 'typeAnnotation': { 'type': 'FunctionTypeAnnotation', 'returnTypeAnnotation': { - 'type': 'ReservedFunctionValueTypeAnnotation', + 'type': 'ReservedTypeAnnotation', 'name': 'RootTag' }, 'params': [ @@ -1244,7 +1244,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ROOT_TAG 'name': 'rootTag', 'optional': false, 'typeAnnotation': { - 'type': 'ReservedFunctionValueTypeAnnotation', + 'type': 'ReservedTypeAnnotation', 'name': 'RootTag' } } diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js index bf2e29082f08eb..fc03e16e360ad8 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js @@ -9,7 +9,6 @@ */ import type { - ReservedFunctionValueTypeName, NativeModuleReturnTypeAnnotation, NativeModuleBaseTypeAnnotation, NativeModuleSchema, @@ -43,7 +42,7 @@ const PRIMITIVES: $ReadOnlyArray<[string, PrimitiveTypeAnnotationType]> = [ ['boolean', 'BooleanTypeAnnotation'], ]; -const RESERVED_FUNCTION_VALUE_TYPE_NAME: $ReadOnlyArray = [ +const RESERVED_FUNCTION_VALUE_TYPE_NAME: $ReadOnlyArray<'RootTag'> = [ 'RootTag', ]; @@ -201,12 +200,9 @@ describe('Flow Module Parser', () => { it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of reserved type '${FLOW_TYPE}'`, () => { const [paramTypeAnnotation] = parseParamType('arg', FLOW_TYPE); - expect(paramTypeAnnotation.type).toBe( - 'ReservedFunctionValueTypeAnnotation', - ); + expect(paramTypeAnnotation.type).toBe('ReservedTypeAnnotation'); invariant( - paramTypeAnnotation.type === - 'ReservedFunctionValueTypeAnnotation', + paramTypeAnnotation.type === 'ReservedTypeAnnotation', 'Param must be a Reserved type', ); @@ -267,13 +263,8 @@ describe('Flow Module Parser', () => { 'arg', FLOW_TYPE, ); - expect(elementType.type).toBe( - 'ReservedFunctionValueTypeAnnotation', - ); - invariant( - elementType.type === 'ReservedFunctionValueTypeAnnotation', - '', - ); + expect(elementType.type).toBe('ReservedTypeAnnotation'); + invariant(elementType.type === 'ReservedTypeAnnotation', ''); expect(elementType.name).toBe(FLOW_TYPE); }); @@ -511,11 +502,10 @@ describe('Flow Module Parser', () => { FLOW_TYPE, ); expect(prop.typeAnnotation.type).toBe( - 'ReservedFunctionValueTypeAnnotation', + 'ReservedTypeAnnotation', ); invariant( - prop.typeAnnotation.type === - 'ReservedFunctionValueTypeAnnotation', + prop.typeAnnotation.type === 'ReservedTypeAnnotation', '', ); @@ -583,12 +573,9 @@ describe('Flow Module Parser', () => { FLOW_TYPE, ); - expect(elementType.type).toBe( - 'ReservedFunctionValueTypeAnnotation', - ); + expect(elementType.type).toBe('ReservedTypeAnnotation'); invariant( - elementType.type === - 'ReservedFunctionValueTypeAnnotation', + elementType.type === 'ReservedTypeAnnotation', '', ); expect(elementType.name).toBe(FLOW_TYPE); @@ -800,11 +787,10 @@ describe('Flow Module Parser', () => { it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} reserved return of type '${FLOW_TYPE}'`, () => { const [returnTypeAnnotation] = parseReturnType(FLOW_TYPE); expect(returnTypeAnnotation.type).toBe( - 'ReservedFunctionValueTypeAnnotation', + 'ReservedTypeAnnotation', ); invariant( - returnTypeAnnotation.type === - 'ReservedFunctionValueTypeAnnotation', + returnTypeAnnotation.type === 'ReservedTypeAnnotation', '', ); expect(returnTypeAnnotation.name).toBe(FLOW_TYPE); @@ -863,13 +849,8 @@ describe('Flow Module Parser', () => { RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<${FLOW_TYPE}>'`, () => { const [elementType] = parseArrayElementReturnType(FLOW_TYPE); - expect(elementType.type).toBe( - 'ReservedFunctionValueTypeAnnotation', - ); - invariant( - elementType.type === 'ReservedFunctionValueTypeAnnotation', - '', - ); + expect(elementType.type).toBe('ReservedTypeAnnotation'); + invariant(elementType.type === 'ReservedTypeAnnotation', ''); expect(elementType.name).toBe(FLOW_TYPE); }); @@ -1079,11 +1060,11 @@ describe('Flow Module Parser', () => { ); expect(property.typeAnnotation.type).toBe( - 'ReservedFunctionValueTypeAnnotation', + 'ReservedTypeAnnotation', ); invariant( property.typeAnnotation.type === - 'ReservedFunctionValueTypeAnnotation', + 'ReservedTypeAnnotation', '', ); @@ -1152,12 +1133,9 @@ describe('Flow Module Parser', () => { 'prop', FLOW_TYPE, ); - expect(elementType.type).toBe( - 'ReservedFunctionValueTypeAnnotation', - ); + expect(elementType.type).toBe('ReservedTypeAnnotation'); invariant( - elementType.type === - 'ReservedFunctionValueTypeAnnotation', + elementType.type === 'ReservedTypeAnnotation', '', ); diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 9c71bd6704e1cd..76727185f01793 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -70,7 +70,7 @@ function translateTypeAnnotation( switch (typeAnnotation.id.name) { case 'RootTag': { return wrapNullable(nullable, { - type: 'ReservedFunctionValueTypeAnnotation', + type: 'ReservedTypeAnnotation', name: 'RootTag', }); } From b9f69372887b1577f0491376eb5aab86d385dd58 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0015/1810] Reorganize CodegenSchema types into "use before declaration" order Summary: This diff re-organizes CodegenSchema to declare the larger types first, which use smaller undeclared types. The smaller types are declared further down the file, and they themselves use even smaller undeclared types. **Motivation:** Increase the readability of CodegenSchema.js. Now, if people want to understand the shape of the Codegen Schema, they can just read the file from top to bottom. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24701424 fbshipit-source-id: 181e87bff5e32d998463221891f459b0df26ef52 --- .../react-native-codegen/src/CodegenSchema.js | 145 +++++++++--------- 1 file changed, 74 insertions(+), 71 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 48047fe186f44f..a496f777e15a4d 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -12,29 +12,15 @@ export type PlatformType = 'iOS' | 'android'; -export type CommandsFunctionTypeAnnotation = $ReadOnly<{| - type: 'FunctionTypeAnnotation', - params: $ReadOnlyArray, -|}>; - -export type CommandsFunctionTypeParamAnnotation = $ReadOnly<{| - name: string, - typeAnnotation: CommandsTypeAnnotation, -|}>; - -export type CommandsTypeAnnotation = - | ReservedTypeAnnotation - | BooleanTypeAnnotation - | Int32TypeAnnotation - | DoubleTypeAnnotation - | FloatTypeAnnotation - | StringTypeAnnotation; - -export type ReservedTypeAnnotation = $ReadOnly<{| - type: 'ReservedTypeAnnotation', - name: 'RootTag', // Union with more custom types. +export type SchemaType = $ReadOnly<{| + modules: $ReadOnly<{| + [hasteModuleName: string]: ComponentSchema | NativeModuleSchema, + |}>, |}>; +/** + * Component Type Annotations + */ export type DoubleTypeAnnotation = $ReadOnly<{| type: 'DoubleTypeAnnotation', |}>; @@ -68,6 +54,55 @@ type NamedShape<+T> = $ReadOnly<{ typeAnnotation: T, }>; +export type ComponentSchema = $ReadOnly<{| + type: 'Component', + components: $ReadOnly<{| + [componentName: string]: ComponentShape, + |}>, +|}>; + +export type ComponentShape = $ReadOnly<{| + ...OptionsShape, + extendsProps: $ReadOnlyArray, + events: $ReadOnlyArray, + props: $ReadOnlyArray, + commands: $ReadOnlyArray, +|}>; + +export type OptionsShape = $ReadOnly<{| + interfaceOnly?: boolean, + + // Use for components with no current paper rename in progress + // Does not check for new name + paperComponentName?: string, + + // Use for components that are not used on other platforms. + excludedPlatforms?: $ReadOnlyArray, + + // Use for components currently being renamed in paper + // Will use new name if it is available and fallback to this name + paperComponentNameDeprecated?: string, +|}>; + +export type ExtendsPropsShape = $ReadOnly<{| + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', +|}>; + +export type EventTypeShape = $ReadOnly<{| + name: string, + bubblingType: 'direct' | 'bubble', + optional: boolean, + paperTopLevelNameDeprecated?: string, + typeAnnotation: $ReadOnly<{| + type: 'EventTypeAnnotation', + argument?: $ReadOnly<{| + type: 'ObjectTypeAnnotation', + properties: $ReadOnlyArray, + |}>, + |}>, +|}>; + export type EventObjectPropertyType = NamedShape< | BooleanTypeAnnotation | StringTypeAnnotation @@ -81,6 +116,8 @@ export type EventObjectPropertyType = NamedShape< |}>, >; +export type PropTypeShape = NamedShape; + type PropTypeTypeAnnotation = | $ReadOnly<{| type: 'BooleanTypeAnnotation', @@ -164,63 +201,29 @@ type PropTypeTypeAnnotation = |}>, |}>; -export type PropTypeShape = NamedShape; - -export type EventTypeShape = $ReadOnly<{| - name: string, - bubblingType: 'direct' | 'bubble', - optional: boolean, - paperTopLevelNameDeprecated?: string, - typeAnnotation: $ReadOnly<{| - type: 'EventTypeAnnotation', - argument?: $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}>, - |}>, -|}>; - export type CommandTypeShape = NamedShape; -export type OptionsShape = $ReadOnly<{| - interfaceOnly?: boolean, - - // Use for components with no current paper rename in progress - // Does not check for new name - paperComponentName?: string, - - // Use for components that are not used on other platforms. - excludedPlatforms?: $ReadOnlyArray, - - // Use for components currently being renamed in paper - // Will use new name if it is available and fallback to this name - paperComponentNameDeprecated?: string, -|}>; - -export type ExtendsPropsShape = $ReadOnly<{| - type: 'ReactNativeBuiltInType', - knownTypeName: 'ReactNativeCoreViewProps', +export type CommandsFunctionTypeAnnotation = $ReadOnly<{| + type: 'FunctionTypeAnnotation', + params: $ReadOnlyArray, |}>; -export type ComponentShape = $ReadOnly<{| - ...OptionsShape, - extendsProps: $ReadOnlyArray, - events: $ReadOnlyArray, - props: $ReadOnlyArray, - commands: $ReadOnlyArray, +export type CommandsFunctionTypeParamAnnotation = $ReadOnly<{| + name: string, + typeAnnotation: CommandsTypeAnnotation, |}>; -export type SchemaType = $ReadOnly<{| - modules: $ReadOnly<{| - [hasteModuleName: string]: ComponentSchema | NativeModuleSchema, - |}>, -|}>; +export type CommandsTypeAnnotation = + | ReservedTypeAnnotation + | BooleanTypeAnnotation + | Int32TypeAnnotation + | DoubleTypeAnnotation + | FloatTypeAnnotation + | StringTypeAnnotation; -export type ComponentSchema = $ReadOnly<{| - type: 'Component', - components: $ReadOnly<{| - [componentName: string]: ComponentShape, - |}>, +export type ReservedTypeAnnotation = $ReadOnly<{| + type: 'ReservedTypeAnnotation', + name: 'RootTag', // Union with more custom types. |}>; /** From 688caa0bdc5cffe83e2e7b715eb28d45de82fd1b Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0016/1810] Introduce ObjectTypeAnnotation utility type Summary: All throughout the Codegen schema, we re-declare the following shape: ``` { type: 'ObjectTypeAnnotation', properties: $ReadOnlyArray<{ name: string, optional: boolean, typeAnnotation: ... }> } ``` This diff introduces an `ObjectTypeAnnotation` utility type and replaces those re-declarations with instantiations of this type. **Motivation:** To reduce noise in the CodegenSchema. This should be a pure refactor, and shouldn't actually change any behaviour. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24707963 fbshipit-source-id: 6b4eb711ddd041f3a041109ade5ad5644fb16924 --- .../react-native-codegen/src/CodegenSchema.js | 59 +++++++------------ .../src/generators/components/CppHelpers.js | 8 ++- .../components/GenerateComponentHObjCpp.js | 5 +- .../components/GenerateEventEmitterCpp.js | 5 +- .../components/GenerateEventEmitterH.js | 7 ++- .../generators/components/GeneratePropsH.js | 11 ++-- .../components/GeneratePropsJavaDelegate.js | 11 ++-- .../components/GeneratePropsJavaInterface.js | 12 ++-- .../src/parsers/flow/components/commands.js | 7 ++- .../src/parsers/flow/components/events.js | 7 ++- .../src/parsers/flow/components/props.js | 9 ++- .../src/parsers/flow/components/schema.js | 9 +-- 12 files changed, 78 insertions(+), 72 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index a496f777e15a4d..2d22324f82b4b9 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -48,7 +48,12 @@ export type StringEnumTypeAnnotation = $ReadOnly<{| |}>, |}>; -type NamedShape<+T> = $ReadOnly<{ +type ObjectTypeAnnotation<+T> = $ReadOnly<{| + type: 'ObjectTypeAnnotation', + properties: $ReadOnlyArray>, +|}>; + +export type NamedShape<+T> = $ReadOnly<{ name: string, optional: boolean, typeAnnotation: T, @@ -65,8 +70,8 @@ export type ComponentShape = $ReadOnly<{| ...OptionsShape, extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, - props: $ReadOnlyArray, - commands: $ReadOnlyArray, + props: $ReadOnlyArray>, + commands: $ReadOnlyArray>, |}>; export type OptionsShape = $ReadOnly<{| @@ -96,29 +101,20 @@ export type EventTypeShape = $ReadOnly<{| paperTopLevelNameDeprecated?: string, typeAnnotation: $ReadOnly<{| type: 'EventTypeAnnotation', - argument?: $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}>, + argument?: ObjectTypeAnnotation, |}>, |}>; -export type EventObjectPropertyType = NamedShape< +export type EventTypeAnnotation = | BooleanTypeAnnotation | StringTypeAnnotation | DoubleTypeAnnotation | FloatTypeAnnotation | Int32TypeAnnotation | StringEnumTypeAnnotation - | $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}>, ->; - -export type PropTypeShape = NamedShape; + | ObjectTypeAnnotation; -type PropTypeTypeAnnotation = +export type PropTypeAnnotation = | $ReadOnly<{| type: 'BooleanTypeAnnotation', default: boolean | null, @@ -161,10 +157,7 @@ type PropTypeTypeAnnotation = | 'PointPrimitive' | 'EdgeInsetsPrimitive', |}> - | $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}> + | ObjectTypeAnnotation | $ReadOnly<{| type: 'ArrayTypeAnnotation', elementType: @@ -180,10 +173,7 @@ type PropTypeTypeAnnotation = name: string, |}>, |}> - | $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}> + | ObjectTypeAnnotation | $ReadOnly<{| type: 'ReservedPropTypeAnnotation', name: @@ -194,26 +184,22 @@ type PropTypeTypeAnnotation = |}> | $ReadOnly<{| type: 'ArrayTypeAnnotation', - elementType: $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}>, + elementType: ObjectTypeAnnotation, |}>, |}>; -export type CommandTypeShape = NamedShape; - -export type CommandsFunctionTypeAnnotation = $ReadOnly<{| +// TODO: Unify this function type annotation with NativeModule schema +export type CommandsTypeAnnotation = $ReadOnly<{| type: 'FunctionTypeAnnotation', params: $ReadOnlyArray, |}>; export type CommandsFunctionTypeParamAnnotation = $ReadOnly<{| name: string, - typeAnnotation: CommandsTypeAnnotation, + typeAnnotation: CommandsParamTypeAnnotation, |}>; -export type CommandsTypeAnnotation = +type CommandsParamTypeAnnotation = | ReservedTypeAnnotation | BooleanTypeAnnotation | Int32TypeAnnotation @@ -273,10 +259,9 @@ export type NativeModuleMethodParamSchema = NamedShape< Nullable, >; -export type NativeModuleObjectTypeAnnotation = $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, -|}>; +export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation< + Nullable, +>; export type NativeModuleObjectTypeAnnotationPropertySchema = NamedShape< Nullable, diff --git a/packages/react-native-codegen/src/generators/components/CppHelpers.js b/packages/react-native-codegen/src/generators/components/CppHelpers.js index f6e7077a416942..1f816df8fd793b 100644 --- a/packages/react-native-codegen/src/generators/components/CppHelpers.js +++ b/packages/react-native-codegen/src/generators/components/CppHelpers.js @@ -9,7 +9,7 @@ */ 'use strict'; -import type {PropTypeShape} from '../../CodegenSchema'; +import type {NamedShape, PropTypeAnnotation} from '../../CodegenSchema'; function upperCaseFirst(inString: string): string { if (inString.length === 0) { @@ -55,7 +55,9 @@ function getCppTypeForAnnotation( } } -function getImports(properties: $ReadOnlyArray): Set { +function getImports( + properties: $ReadOnlyArray>, +): Set { const imports: Set = new Set(); function addImportsForNativeName(name) { @@ -122,7 +124,7 @@ function getEnumMaskName(enumName: string): string { function convertDefaultTypeToString( componentName: string, - prop: PropTypeShape, + prop: NamedShape, ): string { const typeAnnotation = prop.typeAnnotation; switch (typeAnnotation.type) { diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 467d02bcdaeab0..9ede5b15eb7ec7 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -11,7 +11,8 @@ 'use strict'; import type { - CommandTypeShape, + NamedShape, + CommandsTypeAnnotation, ComponentShape, SchemaType, CommandsFunctionTypeParamAnnotation, @@ -273,7 +274,7 @@ function generateConvertAndValidateParam( } function generateCommandIfCase( - command: CommandTypeShape, + command: NamedShape, componentName: string, ) { const params = command.typeAnnotation.params; diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index cde931ae98d9c8..62201df8f368c3 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -14,7 +14,8 @@ const {generateEventStructName} = require('./CppHelpers.js'); import type { ComponentShape, - EventObjectPropertyType, + NamedShape, + EventTypeAnnotation, SchemaType, } from '../../CodegenSchema'; @@ -81,7 +82,7 @@ function generateEnumSetter(variableName, propertyName, propertyParts) { function generateSetters( parentPropertyName: string, - properties: $ReadOnlyArray, + properties: $ReadOnlyArray>, propertyParts: $ReadOnlyArray, ): string { const propSetters = properties diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js index 0415b7af9b446d..acb4346173f05d 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js @@ -21,7 +21,8 @@ const { import type { ComponentShape, EventTypeShape, - EventObjectPropertyType, + NamedShape, + EventTypeAnnotation, SchemaType, } from '../../CodegenSchema'; @@ -99,7 +100,7 @@ function indent(nice: string, spaces: number) { function getNativeTypeFromAnnotation( componentName: string, - eventProperty: EventObjectPropertyType, + eventProperty: NamedShape, nameParts: $ReadOnlyArray, ): string { const {type} = eventProperty.typeAnnotation; @@ -148,7 +149,7 @@ function generateStruct( structs: StructsMap, componentName: string, nameParts: $ReadOnlyArray, - properties: $ReadOnlyArray, + properties: $ReadOnlyArray>, ): void { const structNameParts = nameParts; const structName = generateEventStructName(structNameParts); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index b84793ca440ca5..b498c04c0d9d20 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -23,7 +23,8 @@ const { import type { ExtendsPropsShape, - PropTypeShape, + NamedShape, + PropTypeAnnotation, SchemaType, } from '../../CodegenSchema'; @@ -447,7 +448,7 @@ function generateEnumString(componentName: string, component): string { function generatePropsString( componentName: string, - props: $ReadOnlyArray, + props: $ReadOnlyArray>, ) { return props .map(prop => { @@ -487,7 +488,7 @@ function getExtendsImports( } function getLocalImports( - properties: $ReadOnlyArray, + properties: $ReadOnlyArray>, ): Set { const imports: Set = new Set(); @@ -677,7 +678,7 @@ function generateStruct( structs: StructsMap, componentName: string, nameParts: $ReadOnlyArray, - properties: $ReadOnlyArray, + properties: $ReadOnlyArray>, ): void { const structNameParts = nameParts; const structName = generateStructName(componentName, structNameParts); @@ -692,7 +693,7 @@ function generateStruct( }) .join('\n' + ' '); - properties.forEach((property: PropTypeShape) => { + properties.forEach((property: NamedShape) => { const name = property.name; switch (property.typeAnnotation.type) { case 'BooleanTypeAnnotation': diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index c963d8b61e2de8..528d0fb628c45d 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -11,9 +11,10 @@ 'use strict'; import type { - CommandTypeShape, + NamedShape, + CommandsTypeAnnotation, ComponentShape, - PropTypeShape, + PropTypeAnnotation, SchemaType, } from '../../CodegenSchema'; const { @@ -64,7 +65,7 @@ const commandsTemplate = ` `; function getJavaValueForProp( - prop: PropTypeShape, + prop: NamedShape, componentName: string, ): string { const typeAnnotation = prop.typeAnnotation; @@ -181,7 +182,9 @@ function getCommandArgJavaType(param, index) { } } -function getCommandArguments(command: CommandTypeShape): string { +function getCommandArguments( + command: NamedShape, +): string { return [ 'view', ...command.typeAnnotation.params.map(getCommandArgJavaType), diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index d5e26c745a8e87..27c0f3de25ea7d 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -11,9 +11,10 @@ 'use strict'; import type { - CommandTypeShape, + NamedShape, + CommandsTypeAnnotation, ComponentShape, - PropTypeShape, + PropTypeAnnotation, SchemaType, } from '../../CodegenSchema'; const { @@ -47,7 +48,10 @@ function addNullable(imports) { imports.add('import androidx.annotation.Nullable;'); } -function getJavaValueForProp(prop: PropTypeShape, imports): string { +function getJavaValueForProp( + prop: NamedShape, + imports, +): string { const typeAnnotation = prop.typeAnnotation; switch (typeAnnotation.type) { @@ -153,7 +157,7 @@ function getCommandArgJavaType(param) { } function getCommandArguments( - command: CommandTypeShape, + command: NamedShape, componentName: string, ): string { return [ diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index b6b2ce39b952fd..c79c8e84090186 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -10,7 +10,10 @@ 'use strict'; -import type {CommandTypeShape} from '../../../CodegenSchema.js'; +import type { + NamedShape, + CommandsTypeAnnotation, +} from '../../../CodegenSchema.js'; import type {TypeDeclarationMap} from '../utils.js'; const {getValueFromTypes} = require('../utils.js'); @@ -99,7 +102,7 @@ function buildCommandSchema(property, types: TypeDeclarationMap) { function getCommands( commandTypeAST: $ReadOnlyArray, types: TypeDeclarationMap, -): $ReadOnlyArray { +): $ReadOnlyArray> { return commandTypeAST .filter(property => property.type === 'ObjectTypeProperty') .map(property => buildCommandSchema(property, types)) diff --git a/packages/react-native-codegen/src/parsers/flow/components/events.js b/packages/react-native-codegen/src/parsers/flow/components/events.js index 6f6105bbfd006c..868f6feefeee73 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/events.js +++ b/packages/react-native-codegen/src/parsers/flow/components/events.js @@ -12,14 +12,15 @@ import type { EventTypeShape, - EventObjectPropertyType, + NamedShape, + EventTypeAnnotation, } from '../../../CodegenSchema.js'; function getPropertyType( name, optional, typeAnnotation, -): EventObjectPropertyType { +): NamedShape { const type = typeAnnotation.type === 'GenericTypeAnnotation' ? typeAnnotation.id.name @@ -150,7 +151,7 @@ function findEventArgumentsAndType( } } -function buildPropertiesForEvent(property): EventObjectPropertyType { +function buildPropertiesForEvent(property): NamedShape { const name = property.key.name; const optional = property.value.type === 'NullableTypeAnnotation' || property.optional; diff --git a/packages/react-native-codegen/src/parsers/flow/components/props.js b/packages/react-native-codegen/src/parsers/flow/components/props.js index 50e887bcd93b9e..757e238d38f72d 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/props.js +++ b/packages/react-native-codegen/src/parsers/flow/components/props.js @@ -12,7 +12,7 @@ const {getValueFromTypes} = require('../utils.js'); -import type {PropTypeShape} from '../../../CodegenSchema.js'; +import type {NamedShape, PropTypeAnnotation} from '../../../CodegenSchema.js'; import type {TypeDeclarationMap} from '../utils.js'; function getPropProperties( @@ -324,7 +324,10 @@ function getTypeAnnotation( } } -function buildPropSchema(property, types: TypeDeclarationMap): ?PropTypeShape { +function buildPropSchema( + property, + types: TypeDeclarationMap, +): ?NamedShape { const name = property.key.name; const value = getValueFromTypes(property.value, types); @@ -460,7 +463,7 @@ function flattenProperties( function getProps( typeDefinition: $ReadOnlyArray, types: TypeDeclarationMap, -): $ReadOnlyArray { +): $ReadOnlyArray> { return flattenProperties(typeDefinition, types) .map(property => buildPropSchema(property, types)) .filter(Boolean); diff --git a/packages/react-native-codegen/src/parsers/flow/components/schema.js b/packages/react-native-codegen/src/parsers/flow/components/schema.js index 9ca89ebc12ef52..dda92acb990f71 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/schema.js +++ b/packages/react-native-codegen/src/parsers/flow/components/schema.js @@ -12,8 +12,9 @@ import type { EventTypeShape, - PropTypeShape, - CommandTypeShape, + NamedShape, + CommandsTypeAnnotation, + PropTypeAnnotation, ExtendsPropsShape, SchemaType, OptionsShape, @@ -24,8 +25,8 @@ export type ComponentSchemaBuilderConfig = $ReadOnly<{| componentName: string, extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, - props: $ReadOnlyArray, - commands: $ReadOnlyArray, + props: $ReadOnlyArray>, + commands: $ReadOnlyArray>, options?: ?OptionsShape, |}>; From 04f235e7fbffa78d8e674a4c0c9ad912acdad26f Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0017/1810] Rename Commands* -> Command* Summary: The names of events and props flow type annotations are singular. The names of the commands flow types are however plural. This diff renames all "Commands*" flow types to be singular. **Motivation:** Consistency Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24708276 fbshipit-source-id: 5d5d2123426ca1139953169d0ea764b82b2f3809 --- .../react-native-codegen/src/CodegenSchema.js | 14 +++++++------- .../components/GenerateComponentHObjCpp.js | 16 ++++++++-------- .../components/GeneratePropsJavaDelegate.js | 4 ++-- .../components/GeneratePropsJavaInterface.js | 4 ++-- .../src/parsers/flow/components/commands.js | 4 ++-- .../src/parsers/flow/components/schema.js | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 2d22324f82b4b9..1c6b90f9e84d05 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -71,7 +71,7 @@ export type ComponentShape = $ReadOnly<{| extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, props: $ReadOnlyArray>, - commands: $ReadOnlyArray>, + commands: $ReadOnlyArray>, |}>; export type OptionsShape = $ReadOnly<{| @@ -188,18 +188,18 @@ export type PropTypeAnnotation = |}>, |}>; -// TODO: Unify this function type annotation with NativeModule schema -export type CommandsTypeAnnotation = $ReadOnly<{| +export type CommandTypeAnnotation = $ReadOnly<{| type: 'FunctionTypeAnnotation', - params: $ReadOnlyArray, + params: $ReadOnlyArray, |}>; -export type CommandsFunctionTypeParamAnnotation = $ReadOnly<{| +// TODO: Unify this function type annotation with NativeModule schema +export type CommandFunctionTypeParamAnnotation = $ReadOnly<{| name: string, - typeAnnotation: CommandsParamTypeAnnotation, + typeAnnotation: CommandParamTypeAnnotation, |}>; -type CommandsParamTypeAnnotation = +type CommandParamTypeAnnotation = | ReservedTypeAnnotation | BooleanTypeAnnotation | Int32TypeAnnotation diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 9ede5b15eb7ec7..057cf1a5cb574e 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -12,10 +12,10 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, ComponentShape, SchemaType, - CommandsFunctionTypeParamAnnotation, + CommandFunctionTypeParamAnnotation, } from '../../CodegenSchema'; type FilesOutput = Map; @@ -104,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END `.trim(); -function getObjCParamType(param: CommandsFunctionTypeParamAnnotation): string { +function getObjCParamType(param: CommandFunctionTypeParamAnnotation): string { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -133,7 +133,7 @@ function getObjCParamType(param: CommandsFunctionTypeParamAnnotation): string { } function getObjCExpectedKindParamType( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, ): string { const {typeAnnotation} = param; @@ -163,7 +163,7 @@ function getObjCExpectedKindParamType( } function getReadableExpectedKindParamType( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, ): string { const {typeAnnotation} = param; @@ -193,7 +193,7 @@ function getReadableExpectedKindParamType( } function getObjCRightHandAssignmentParamType( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, index: number, ): string { const {typeAnnotation} = param; @@ -253,7 +253,7 @@ function generateProtocol( } function generateConvertAndValidateParam( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, index: number, componentName: string, ): string { @@ -274,7 +274,7 @@ function generateConvertAndValidateParam( } function generateCommandIfCase( - command: NamedShape, + command: NamedShape, componentName: string, ) { const params = command.typeAnnotation.params; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index 528d0fb628c45d..55cf822b18ee9b 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -12,7 +12,7 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, ComponentShape, PropTypeAnnotation, SchemaType, @@ -183,7 +183,7 @@ function getCommandArgJavaType(param, index) { } function getCommandArguments( - command: NamedShape, + command: NamedShape, ): string { return [ 'view', diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index 27c0f3de25ea7d..ec2c97de79bb5b 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -12,7 +12,7 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, ComponentShape, PropTypeAnnotation, SchemaType, @@ -157,7 +157,7 @@ function getCommandArgJavaType(param) { } function getCommandArguments( - command: NamedShape, + command: NamedShape, componentName: string, ): string { return [ diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index c79c8e84090186..1734cf75cfa5e0 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -12,7 +12,7 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, } from '../../../CodegenSchema.js'; import type {TypeDeclarationMap} from '../utils.js'; @@ -102,7 +102,7 @@ function buildCommandSchema(property, types: TypeDeclarationMap) { function getCommands( commandTypeAST: $ReadOnlyArray, types: TypeDeclarationMap, -): $ReadOnlyArray> { +): $ReadOnlyArray> { return commandTypeAST .filter(property => property.type === 'ObjectTypeProperty') .map(property => buildCommandSchema(property, types)) diff --git a/packages/react-native-codegen/src/parsers/flow/components/schema.js b/packages/react-native-codegen/src/parsers/flow/components/schema.js index dda92acb990f71..d48e186d7e089b 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/schema.js +++ b/packages/react-native-codegen/src/parsers/flow/components/schema.js @@ -13,7 +13,7 @@ import type { EventTypeShape, NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, PropTypeAnnotation, ExtendsPropsShape, SchemaType, @@ -26,7 +26,7 @@ export type ComponentSchemaBuilderConfig = $ReadOnly<{| extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, props: $ReadOnlyArray>, - commands: $ReadOnlyArray>, + commands: $ReadOnlyArray>, options?: ?OptionsShape, |}>; From c6b8c75b6be3efa0e3bfeff84daabaad8de01cd9 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0018/1810] Remove miscellaneous exports of NativeModule Flow types in Codegen Schema Summary: CodegenSchema exports `NativeModuleMethodParamSchema` and `NativeModuleObjectTypeAnnotationPropertySchema`, which are partials of NativeModule type annotations. This creates unnecessary coupling between the type annotations of CodegenSchema and the files that depend on it. **Actual Problem:** Suppose that we want to rename one of these partials. Then, all imports in all files would have to be updated, even when the actual shape of the composed type annotation wasn't changed. This diff removes these partials, which reduces the surface area of the exports of CodegenSchema.js Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24719396 fbshipit-source-id: c822aaa252f156c524f4ef4917ebb61b1a39ff9e --- .../react-native-codegen/src/CodegenSchema.js | 10 +- .../generators/modules/GenerateModuleCpp.js | 7 +- .../modules/GenerateModuleJavaSpec.js | 6 +- .../modules/GenerateModuleJniCpp.js | 6 +- .../GenerateModuleObjCpp/serializeMethod.js | 14 +- .../src/parsers/flow/modules/index.js | 129 +++++++++--------- 6 files changed, 87 insertions(+), 85 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 1c6b90f9e84d05..8fc315ae745770 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -251,22 +251,14 @@ export type NativeModuleAliasMap = $ReadOnly<{| export type NativeModuleFunctionTypeAnnotation = $ReadOnly<{| type: 'FunctionTypeAnnotation', - params: $ReadOnlyArray, + params: $ReadOnlyArray>>, returnTypeAnnotation: Nullable, |}>; -export type NativeModuleMethodParamSchema = NamedShape< - Nullable, ->; - export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation< Nullable, >; -export type NativeModuleObjectTypeAnnotationPropertySchema = NamedShape< - Nullable, ->; - export type NativeModuleArrayTypeAnnotation< +T: Nullable, > = $ReadOnly<{| diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index 5050f213707287..dd30806c0cf440 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -13,7 +13,8 @@ import type { SchemaType, NativeModulePropertySchema, - NativeModuleMethodParamSchema, + Nullable, + NamedShape, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, } from '../../CodegenSchema'; @@ -99,8 +100,10 @@ ${modules} `; }; +type Param = NamedShape>; + function serializeArg( - arg: NativeModuleMethodParamSchema, + arg: Param, index: number, resolveAlias: AliasResolver, ): string { diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index a18315346d1f8d..fdaf07657b28dd 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -12,9 +12,9 @@ import type { Nullable, + NamedShape, SchemaType, NativeModulePropertySchema, - NativeModuleMethodParamSchema, NativeModuleReturnTypeAnnotation, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, @@ -91,8 +91,10 @@ function MethodTemplate( )})${methodClosing}`; } +type Param = NamedShape>; + function translateFunctionParamToJavaType( - param: NativeModuleMethodParamSchema, + param: Param, createErrorMessage: (typeName: string) => string, resolveAlias: AliasResolver, imports: Set, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index 8b4a9317766b37..d02b0d6731b33a 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -12,9 +12,9 @@ import type { Nullable, + NamedShape, SchemaType, NativeModulePropertySchema, - NativeModuleMethodParamSchema, NativeModuleReturnTypeAnnotation, NativeModuleParamTypeAnnotation, NativeModuleFunctionTypeAnnotation, @@ -177,8 +177,10 @@ function translateReturnTypeToKind( } } +type Param = NamedShape>; + function translateParamTypeToJniType( - param: NativeModuleMethodParamSchema, + param: Param, resolveAlias: AliasResolver, ): string { const {optional, typeAnnotation: nullableTypeAnnotation} = param; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index bf12da4ecfa324..54ab9a2b72b9e8 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -11,10 +11,11 @@ 'use strict'; import type { - NativeModuleMethodParamSchema, - NativeModuleReturnTypeAnnotation, NativeModulePropertySchema, Nullable, + NamedShape, + NativeModuleParamTypeAnnotation, + NativeModuleReturnTypeAnnotation, } from '../../../CodegenSchema'; import type {AliasResolver} from '../Utils'; @@ -164,10 +165,9 @@ function serializeMethod( ]; } -function getParamStructName( - methodName: string, - param: NativeModuleMethodParamSchema, -): string { +type Param = NamedShape>; + +function getParamStructName(methodName: string, param: Param): string { const [typeAnnotation] = unwrapNullable(param.typeAnnotation); if (typeAnnotation.type === 'TypeAliasTypeAnnotation') { return typeAnnotation.name; @@ -179,7 +179,7 @@ function getParamStructName( function getParamObjCType( hasteModuleName: string, methodName: string, - param: NativeModuleMethodParamSchema, + param: Param, structName: string, structCollector: StructCollector, resolveAlias: AliasResolver, diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 76727185f01793..6e44e6572080fd 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -11,13 +11,13 @@ 'use strict'; import type { + NamedShape, NativeModuleAliasMap, NativeModuleArrayTypeAnnotation, NativeModuleBaseTypeAnnotation, NativeModuleFunctionTypeAnnotation, - NativeModuleMethodParamSchema, - NativeModuleObjectTypeAnnotationPropertySchema, NativeModulePropertySchema, + NativeModuleParamTypeAnnotation, NativeModuleSchema, Nullable, } from '../../../CodegenSchema.js'; @@ -207,68 +207,70 @@ function translateTypeAnnotation( const objectTypeAnnotation = { type: 'ObjectTypeAnnotation', properties: (typeAnnotation.properties: Array<$FlowFixMe>) - .map(property => { - return guard(() => { - if (property.type !== 'ObjectTypeProperty') { - throw new UnsupportedObjectPropertyTypeAnnotationParserError( - hasteModuleName, - property, - property.type, - ); - } - - const {optional, key} = property; - - const [ - propertyTypeAnnotation, - isPropertyNullable, - ] = unwrapNullable( - translateTypeAnnotation( - hasteModuleName, - property.value, - types, - aliasMap, - guard, - ), - ); - - if (propertyTypeAnnotation.type === 'FunctionTypeAnnotation') { - throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( - hasteModuleName, - property.value, - property.key, - propertyTypeAnnotation.type, - ); - } - - if (propertyTypeAnnotation.type === 'VoidTypeAnnotation') { - throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( - hasteModuleName, - property.value, - property.key, - 'void', - ); - } - - if (propertyTypeAnnotation.type === 'PromiseTypeAnnotation') { - throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( - hasteModuleName, - property.value, - property.key, - 'Promise', + .map>>( + property => { + return guard(() => { + if (property.type !== 'ObjectTypeProperty') { + throw new UnsupportedObjectPropertyTypeAnnotationParserError( + hasteModuleName, + property, + property.type, + ); + } + + const {optional, key} = property; + + const [ + propertyTypeAnnotation, + isPropertyNullable, + ] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + property.value, + types, + aliasMap, + guard, + ), ); - } - return { - name: key.name, - optional, - typeAnnotation: wrapNullable( - isPropertyNullable, - propertyTypeAnnotation, - ), - }; - }); - }) + if (propertyTypeAnnotation.type === 'FunctionTypeAnnotation') { + throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( + hasteModuleName, + property.value, + property.key, + propertyTypeAnnotation.type, + ); + } + + if (propertyTypeAnnotation.type === 'VoidTypeAnnotation') { + throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( + hasteModuleName, + property.value, + property.key, + 'void', + ); + } + + if (propertyTypeAnnotation.type === 'PromiseTypeAnnotation') { + throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( + hasteModuleName, + property.value, + property.key, + 'Promise', + ); + } + + return { + name: key.name, + optional, + typeAnnotation: wrapNullable( + isPropertyNullable, + propertyTypeAnnotation, + ), + }; + }); + }, + ) .filter(Boolean), }; @@ -391,7 +393,8 @@ function translateFunctionTypeAnnotation( aliasMap: {...NativeModuleAliasMap}, guard: ParserErrorCapturer, ): NativeModuleFunctionTypeAnnotation { - const params: Array = []; + type Param = NamedShape>; + const params: Array = []; for (const flowParam of (flowFunctionTypeAnnotation.params: $ReadOnlyArray<$FlowFixMe>)) { const parsedParam = guard(() => { From 0d748cf8bb033b63c9f0c36e196ddfb4c4ea61a3 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0019/1810] Rename NativeModulePropertySchema -> NativeModulePropertyShape Summary: Everywhere else in the CodegenSchema, type annotation partials are suffixed with "Shape". In the NativeModule schema, we were using the suffix "Schema". In this diff, we standardize on the "Shape" suffix. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24719395 fbshipit-source-id: 307935f5fe0681c31cd52e9cf4ae579f61c1ae68 --- packages/react-native-codegen/src/CodegenSchema.js | 4 ++-- .../src/generators/modules/GenerateModuleCpp.js | 4 ++-- .../src/generators/modules/GenerateModuleJavaSpec.js | 4 ++-- .../src/generators/modules/GenerateModuleJniCpp.js | 6 +++--- .../modules/GenerateModuleObjCpp/serializeMethod.js | 6 +++--- .../src/parsers/flow/modules/index.js | 12 ++++++------ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 8fc315ae745770..b5d931a119a217 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -238,10 +238,10 @@ export type NativeModuleSchema = $ReadOnly<{| |}>; type NativeModuleSpec = $ReadOnly<{| - properties: $ReadOnlyArray, + properties: $ReadOnlyArray, |}>; -export type NativeModulePropertySchema = NamedShape< +export type NativeModulePropertyShape = NamedShape< Nullable, >; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index dd30806c0cf440..e20396e768197d 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -12,9 +12,9 @@ import type { SchemaType, - NativeModulePropertySchema, Nullable, NamedShape, + NativeModulePropertyShape, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, } from '../../CodegenSchema'; @@ -161,7 +161,7 @@ function serializeArg( function serializePropertyIntoHostFunction( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { const [ diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index fdaf07657b28dd..539268b369202c 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -14,7 +14,7 @@ import type { Nullable, NamedShape, SchemaType, - NativeModulePropertySchema, + NativeModulePropertyShape, NativeModuleReturnTypeAnnotation, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, @@ -285,7 +285,7 @@ function getFalsyReturnStatementFromReturnType( // Build special-cased runtime check for getConstants(). function buildGetConstantsMethod( - method: NativeModulePropertySchema, + method: NativeModulePropertyShape, imports: Set, ): string { const [ diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index d02b0d6731b33a..9c8a599cc3245c 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -14,7 +14,7 @@ import type { Nullable, NamedShape, SchemaType, - NativeModulePropertySchema, + NativeModulePropertyShape, NativeModuleReturnTypeAnnotation, NativeModuleParamTypeAnnotation, NativeModuleFunctionTypeAnnotation, @@ -287,7 +287,7 @@ function translateReturnTypeToJniType( } function translateMethodTypeToJniSignature( - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { const {name, typeAnnotation} = property; @@ -327,7 +327,7 @@ function translateMethodTypeToJniSignature( function translateMethodForImplementation( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { const [ diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index 54ab9a2b72b9e8..e3b5d39bc9b165 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -11,11 +11,11 @@ 'use strict'; import type { - NativeModulePropertySchema, Nullable, NamedShape, NativeModuleParamTypeAnnotation, NativeModuleReturnTypeAnnotation, + NativeModulePropertyShape, } from '../../../CodegenSchema'; import type {AliasResolver} from '../Utils'; @@ -62,7 +62,7 @@ export type MethodSerializationOutput = $ReadOnly<{| function serializeMethod( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, structCollector: StructCollector, resolveAlias: AliasResolver, ): $ReadOnlyArray { @@ -384,7 +384,7 @@ function getReturnJSType( function serializeConstantsProtocolMethods( hasteModuleName: string, - property: NativeModulePropertySchema, + property: NativeModulePropertyShape, structCollector: StructCollector, resolveAlias: AliasResolver, ): $ReadOnlyArray { diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 6e44e6572080fd..7bcff0dd894db9 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -16,8 +16,8 @@ import type { NativeModuleArrayTypeAnnotation, NativeModuleBaseTypeAnnotation, NativeModuleFunctionTypeAnnotation, - NativeModulePropertySchema, NativeModuleParamTypeAnnotation, + NativeModulePropertyShape, NativeModuleSchema, Nullable, } from '../../../CodegenSchema.js'; @@ -487,7 +487,7 @@ function buildPropertySchema( types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, guard: ParserErrorCapturer, -): NativeModulePropertySchema { +): NativeModulePropertyShape { let nullable = false; let {key, value} = property; @@ -574,13 +574,13 @@ function buildModuleSchema( .filter(property => property.type === 'ObjectTypeProperty') .map(property => { const aliasMap: {...NativeModuleAliasMap} = {}; return guard(() => ({ aliasMap: aliasMap, - propertySchema: buildPropertySchema( + propertyShape: buildPropertySchema( hasteModuleName, property, types, @@ -591,12 +591,12 @@ function buildModuleSchema( }) .filter(Boolean) .reduce( - (moduleSchema: NativeModuleSchema, {aliasMap, propertySchema}) => { + (moduleSchema: NativeModuleSchema, {aliasMap, propertyShape}) => { return { type: 'NativeModule', aliases: {...moduleSchema.aliases, ...aliasMap}, spec: { - properties: [...moduleSchema.spec.properties, propertySchema], + properties: [...moduleSchema.spec.properties, propertyShape], }, moduleNames: moduleSchema.moduleNames, excludedPlatforms: moduleSchema.excludedPlatforms, From a31d7aa2d3acd1317dff4148cffe3e886d5b5404 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0020/1810] Standardize on one FunctionTypeAnnotation shape Summary: Commands are `FunctionTypeAnnotation`, but they don't have a return type. I this diff, I introduced a `FunctionTypeAnnotation<+P, +R>` utility type, and made the `CommandTypeAnnotation` be an instantiation of it, with the return type fixed to `VoidTypeAnnotation`. Now, the shape of a FunctionTypeAnnotation is unified across the NativeModule and Component schemas. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24719965 fbshipit-source-id: 0089c3b23f05b0c534ba28dbe336c7f2db5866b3 --- .../react-native-codegen/src/CodegenSchema.js | 41 +++++++++---------- .../components/GenerateComponentHObjCpp.js | 18 ++++---- .../components/__test_fixtures__/fixtures.js | 20 +++++++++ .../component-parser-test.js.snap | 25 ++++++++--- .../src/parsers/flow/components/commands.js | 3 ++ 5 files changed, 71 insertions(+), 36 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index b5d931a119a217..8efda90ff74df5 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -48,11 +48,21 @@ export type StringEnumTypeAnnotation = $ReadOnly<{| |}>, |}>; +export type VoidTypeAnnotation = $ReadOnly<{| + type: 'VoidTypeAnnotation', +|}>; + type ObjectTypeAnnotation<+T> = $ReadOnly<{| type: 'ObjectTypeAnnotation', properties: $ReadOnlyArray>, |}>; +type FunctionTypeAnnotation<+P, +R> = $ReadOnly<{| + type: 'FunctionTypeAnnotation', + params: $ReadOnlyArray>, + returnTypeAnnotation: R, +|}>; + export type NamedShape<+T> = $ReadOnly<{ name: string, optional: boolean, @@ -188,18 +198,12 @@ export type PropTypeAnnotation = |}>, |}>; -export type CommandTypeAnnotation = $ReadOnly<{| - type: 'FunctionTypeAnnotation', - params: $ReadOnlyArray, -|}>; - -// TODO: Unify this function type annotation with NativeModule schema -export type CommandFunctionTypeParamAnnotation = $ReadOnly<{| - name: string, - typeAnnotation: CommandParamTypeAnnotation, -|}>; +export type CommandTypeAnnotation = FunctionTypeAnnotation< + CommandParamTypeAnnotation, + VoidTypeAnnotation, +>; -type CommandParamTypeAnnotation = +export type CommandParamTypeAnnotation = | ReservedTypeAnnotation | BooleanTypeAnnotation | Int32TypeAnnotation @@ -249,11 +253,10 @@ export type NativeModuleAliasMap = $ReadOnly<{| [aliasName: string]: NativeModuleObjectTypeAnnotation, |}>; -export type NativeModuleFunctionTypeAnnotation = $ReadOnly<{| - type: 'FunctionTypeAnnotation', - params: $ReadOnlyArray>>, - returnTypeAnnotation: Nullable, -|}>; +export type NativeModuleFunctionTypeAnnotation = FunctionTypeAnnotation< + Nullable, + Nullable, +>; export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation< Nullable, @@ -307,10 +310,6 @@ export type NativeModulePromiseTypeAnnotation = $ReadOnly<{| type: 'PromiseTypeAnnotation', |}>; -export type NativeModuleVoidTypeAnnotation = $ReadOnly<{| - type: 'VoidTypeAnnotation', -|}>; - export type NativeModuleBaseTypeAnnotation = | NativeModuleStringTypeAnnotation | NativeModuleNumberTypeAnnotation @@ -340,4 +339,4 @@ export type NativeModuleTypeAnnotation = type NativeModuleParamOnlyTypeAnnotation = NativeModuleFunctionTypeAnnotation; type NativeModuleReturnOnlyTypeAnnotation = | NativeModulePromiseTypeAnnotation - | NativeModuleVoidTypeAnnotation; + | VoidTypeAnnotation; diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 057cf1a5cb574e..b8950352b58c33 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -15,7 +15,7 @@ import type { CommandTypeAnnotation, ComponentShape, SchemaType, - CommandFunctionTypeParamAnnotation, + CommandParamTypeAnnotation, } from '../../CodegenSchema'; type FilesOutput = Map; @@ -104,7 +104,9 @@ NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END `.trim(); -function getObjCParamType(param: CommandFunctionTypeParamAnnotation): string { +type Param = NamedShape; + +function getObjCParamType(param: Param): string { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -132,9 +134,7 @@ function getObjCParamType(param: CommandFunctionTypeParamAnnotation): string { } } -function getObjCExpectedKindParamType( - param: CommandFunctionTypeParamAnnotation, -): string { +function getObjCExpectedKindParamType(param: Param): string { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -162,9 +162,7 @@ function getObjCExpectedKindParamType( } } -function getReadableExpectedKindParamType( - param: CommandFunctionTypeParamAnnotation, -): string { +function getReadableExpectedKindParamType(param: Param): string { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -193,7 +191,7 @@ function getReadableExpectedKindParamType( } function getObjCRightHandAssignmentParamType( - param: CommandFunctionTypeParamAnnotation, + param: Param, index: number, ): string { const {typeAnnotation} = param; @@ -253,7 +251,7 @@ function generateProtocol( } function generateConvertAndValidateParam( - param: CommandFunctionTypeParamAnnotation, + param: Param, index: number, componentName: string, ): string { diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index 5e82ace63356fe..2737ac892d7f1a 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -1456,6 +1456,9 @@ const COMMANDS: SchemaType = { typeAnnotation: { type: 'FunctionTypeAnnotation', params: [], + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, }, }, { @@ -1466,35 +1469,43 @@ const COMMANDS: SchemaType = { params: [ { name: 'x', + optional: false, typeAnnotation: { type: 'Int32TypeAnnotation', }, }, { name: 'y', + optional: false, typeAnnotation: { type: 'FloatTypeAnnotation', }, }, { name: 'z', + optional: false, typeAnnotation: { type: 'DoubleTypeAnnotation', }, }, { name: 'message', + optional: false, typeAnnotation: { type: 'StringTypeAnnotation', }, }, { name: 'animated', + optional: false, typeAnnotation: { type: 'BooleanTypeAnnotation', }, }, ], + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, }, }, ], @@ -1536,12 +1547,16 @@ const COMMANDS_AND_PROPS: SchemaType = { params: [ { name: 'rootTag', + optional: false, typeAnnotation: { type: 'ReservedTypeAnnotation', name: 'RootTag', }, }, ], + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, }, }, { @@ -1552,17 +1567,22 @@ const COMMANDS_AND_PROPS: SchemaType = { params: [ { name: 'x', + optional: false, typeAnnotation: { type: 'Int32TypeAnnotation', }, }, { name: 'y', + optional: false, typeAnnotation: { type: 'Int32TypeAnnotation', }, }, ], + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, }, }, ], diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index 61cef441150ae9..161a60b909d404 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -2889,7 +2889,10 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'type': 'BooleanTypeAnnotation' } } - ] + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } } } ] @@ -2929,7 +2932,10 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_DEFINED_WITH_ALL_T 'name': 'RootTag' } } - ] + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } } }, { @@ -2950,7 +2956,10 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_DEFINED_WITH_ALL_T 'type': 'Int32TypeAnnotation' } } - ] + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } } }, { @@ -2983,7 +2992,10 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_DEFINED_WITH_ALL_T 'type': 'BooleanTypeAnnotation' } } - ] + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } } } ] @@ -3028,7 +3040,10 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_WITH_EXTERNAL_TYPE 'type': 'BooleanTypeAnnotation' } } - ] + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } } } ] diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index 1734cf75cfa5e0..48103dc595f680 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -95,6 +95,9 @@ function buildCommandSchema(property, types: TypeDeclarationMap) { typeAnnotation: { type: 'FunctionTypeAnnotation', params, + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, }, }; } From 0de4b514be567c5e3960bb1183391c5c52e3fd8a Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0021/1810] Simplify Int32EnumTypeAnnotation and StringEnumTypeAnnotation Summary: Int32EnumTypeAnnotation represents a union of numbers. In the corresponding type annotation, we represent options as `$ReadOnlyArray<{value: number}>`. Since each option is a number, we could instead represent options as `$ReadOnlyArray` - there's no need to use an object with a singular property (i.e: 'value'). The same is could be said of StringEnumTypeAnnotation. In this diff, we change `Int32EnumTypeAnnotation.options` to `$ReadOnlyArray`, and `StringEnumTypeAnnotation.options` to `$ReadOnlyArray`. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24723107 fbshipit-source-id: 4734cf72a4a29b6b321d8161bea70cf524ce0963 --- .../react-native-codegen/src/CodegenSchema.js | 16 +- .../components/GenerateEventEmitterH.js | 6 +- .../generators/components/GeneratePropsH.js | 11 +- .../generators/components/GenerateTests.js | 4 +- .../components/__test_fixtures__/fixtures.js | 54 +- .../component-parser-test.js.snap | 624 +++++------------- .../src/parsers/flow/components/events.js | 2 +- .../src/parsers/flow/components/props.js | 6 +- 8 files changed, 177 insertions(+), 546 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 8efda90ff74df5..a0c87b5e7db750 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -43,9 +43,7 @@ export type StringTypeAnnotation = $ReadOnly<{| export type StringEnumTypeAnnotation = $ReadOnly<{| type: 'StringEnumTypeAnnotation', - options: $ReadOnlyArray<{| - name: string, - |}>, + options: $ReadOnlyArray, |}>; export type VoidTypeAnnotation = $ReadOnly<{| @@ -148,16 +146,12 @@ export type PropTypeAnnotation = | $ReadOnly<{| type: 'StringEnumTypeAnnotation', default: string, - options: $ReadOnlyArray<{| - name: string, - |}>, + options: $ReadOnlyArray, |}> | $ReadOnly<{| type: 'Int32EnumTypeAnnotation', default: number, - options: $ReadOnlyArray<{| - value: number, - |}>, + options: $ReadOnlyArray, |}> | $ReadOnly<{| type: 'ReservedPropTypeAnnotation', @@ -179,9 +173,7 @@ export type PropTypeAnnotation = | $ReadOnly<{| type: 'StringEnumTypeAnnotation', default: string, - options: $ReadOnlyArray<{| - name: string, - |}>, + options: $ReadOnlyArray, |}> | ObjectTypeAnnotation | $ReadOnly<{| diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js index acb4346173f05d..6a6607ac8bb8be 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js @@ -124,15 +124,13 @@ function getNativeTypeFromAnnotation( function generateEnum(structs, options, nameParts) { const structName = generateEventStructName(nameParts); const fields = options - .map((option, index) => `${toSafeCppString(option.name)}`) + .map((option, index) => `${toSafeCppString(option)}`) .join(',\n '); const toCases = options .map( option => - `case ${structName}::${toSafeCppString(option.name)}: return "${ - option.name - }";`, + `case ${structName}::${toSafeCppString(option)}: return "${option}";`, ) .join('\n' + ' '); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index b498c04c0d9d20..d9dd5152248474 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -290,9 +290,8 @@ function convertValueToEnumOption(value: string): string { function generateArrayEnumString( componentName: string, name: string, - enumOptions, + options: $ReadOnlyArray, ): string { - const options = enumOptions.map(option => option.name); const enumName = getEnumName(componentName, name); const values = options @@ -329,9 +328,7 @@ function generateArrayEnumString( function generateStringEnum(componentName, prop) { const typeAnnotation = prop.typeAnnotation; if (typeAnnotation.type === 'StringEnumTypeAnnotation') { - const values: $ReadOnlyArray = typeAnnotation.options.map( - option => option.name, - ); + const values: $ReadOnlyArray = typeAnnotation.options; const enumName = getEnumName(componentName, prop.name); const fromCases = values @@ -365,9 +362,7 @@ function generateStringEnum(componentName, prop) { function generateIntEnum(componentName, prop) { const typeAnnotation = prop.typeAnnotation; if (typeAnnotation.type === 'Int32EnumTypeAnnotation') { - const values: $ReadOnlyArray = typeAnnotation.options.map( - option => option.value, - ); + const values: $ReadOnlyArray = typeAnnotation.options; const enumName = getEnumName(componentName, prop.name); const fromCases = values diff --git a/packages/react-native-codegen/src/generators/components/GenerateTests.js b/packages/react-native-codegen/src/generators/components/GenerateTests.js index ab8e00e4534590..155c41fe5119c7 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateTests.js +++ b/packages/react-native-codegen/src/generators/components/GenerateTests.js @@ -58,8 +58,8 @@ function getTestCasesForProp(propName, typeAnnotation) { typeAnnotation.options.forEach(option => cases.push({ propName, - testName: `${propName}_${toSafeCppString(option.name)}`, - propValue: option.name, + testName: `${propName}_${toSafeCppString(option)}`, + propValue: option, }), ); } else if (typeAnnotation.type === 'StringTypeAnnotation') { diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index 2737ac892d7f1a..69529644cc4298 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -621,14 +621,7 @@ const ARRAY_PROPS: SchemaType = { elementType: { type: 'StringEnumTypeAnnotation', default: 'small', - options: [ - { - name: 'small', - }, - { - name: 'large', - }, - ], + options: ['small', 'large'], }, }, }, @@ -843,11 +836,7 @@ const OBJECT_PROPS: SchemaType = { typeAnnotation: { type: 'StringEnumTypeAnnotation', default: 'option1', - options: [ - { - name: 'option1', - }, - ], + options: ['option1'], }, }, { @@ -856,11 +845,7 @@ const OBJECT_PROPS: SchemaType = { typeAnnotation: { type: 'Int32EnumTypeAnnotation', default: 0, - options: [ - { - value: 0, - }, - ], + options: [0], }, }, { @@ -1055,17 +1040,7 @@ const STRING_ENUM_PROP: SchemaType = { typeAnnotation: { type: 'StringEnumTypeAnnotation', default: 'center', - options: [ - { - name: 'top', - }, - { - name: 'center', - }, - { - name: 'bottom-right', - }, - ], + options: ['top', 'center', 'bottom-right'], }, }, ], @@ -1096,17 +1071,7 @@ const INT32_ENUM_PROP: SchemaType = { typeAnnotation: { type: 'Int32EnumTypeAnnotation', default: 0, - options: [ - { - value: 0, - }, - { - value: 1, - }, - { - value: 2, - }, - ], + options: [0, 1, 2], }, }, ], @@ -1205,14 +1170,7 @@ const EVENT_PROPS: SchemaType = { optional: false, typeAnnotation: { type: 'StringEnumTypeAnnotation', - options: [ - { - name: 'landscape', - }, - { - name: 'portrait', - }, - ], + options: ['landscape', 'portrait'], }, }, ], diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index 161a60b909d404..48836ae868944b 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -264,12 +264,8 @@ exports[`RN Codegen Flow Parser can generate fixture ALL_PROP_TYPES_NO_EVENTS 1` 'type': 'StringEnumTypeAnnotation', 'default': 'small', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -280,12 +276,8 @@ exports[`RN Codegen Flow Parser can generate fixture ALL_PROP_TYPES_NO_EVENTS 1` 'type': 'StringEnumTypeAnnotation', 'default': 'small', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -296,12 +288,8 @@ exports[`RN Codegen Flow Parser can generate fixture ALL_PROP_TYPES_NO_EVENTS 1` 'type': 'Int32EnumTypeAnnotation', 'default': 0, 'options': [ - { - 'value': 0 - }, - { - 'value': 1 - } + 0, + 1 ] } }, @@ -785,12 +773,8 @@ exports[`RN Codegen Flow Parser can generate fixture ARRAY_PROP_TYPES_NO_EVENTS 'type': 'StringEnumTypeAnnotation', 'default': 'small', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } } @@ -804,12 +788,8 @@ exports[`RN Codegen Flow Parser can generate fixture ARRAY_PROP_TYPES_NO_EVENTS 'type': 'StringEnumTypeAnnotation', 'default': 'small', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } } @@ -1445,12 +1425,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1460,12 +1436,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1475,12 +1447,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1490,12 +1458,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1840,12 +1804,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1855,12 +1815,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1870,12 +1826,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -1885,12 +1837,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2234,12 +2182,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2249,12 +2193,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2264,12 +2204,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2279,12 +2215,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2629,12 +2561,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2644,12 +2572,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2659,12 +2583,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -2674,12 +2594,8 @@ exports[`RN Codegen Flow Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_E 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3369,12 +3285,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3384,12 +3296,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3399,12 +3307,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3414,12 +3318,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3763,12 +3663,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3778,12 +3674,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3793,12 +3685,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -3808,12 +3696,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4157,12 +4041,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4172,12 +4052,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4187,12 +4063,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4202,12 +4074,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4551,12 +4419,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4566,12 +4430,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4581,12 +4441,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4596,12 +4452,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4946,12 +4798,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4961,12 +4809,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4976,12 +4820,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -4991,12 +4831,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5340,12 +5176,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5355,12 +5187,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5370,12 +5198,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5385,12 +5209,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5734,12 +5554,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5749,12 +5565,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5764,12 +5576,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -5779,12 +5587,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6128,12 +5932,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6143,12 +5943,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6158,12 +5954,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6173,12 +5965,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6522,12 +6310,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6537,12 +6321,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6552,12 +6332,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6567,12 +6343,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6917,12 +6689,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6932,12 +6700,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6947,12 +6711,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -6962,12 +6722,8 @@ exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -7390,12 +7146,8 @@ exports[`RN Codegen Flow Parser can generate fixture OBJECT_PROP_TYPES_NO_EVENTS 'type': 'StringEnumTypeAnnotation', 'default': 'small', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } } @@ -8263,12 +8015,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8278,12 +8026,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8293,12 +8037,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8308,12 +8048,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8658,12 +8394,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8673,12 +8405,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8688,12 +8416,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -8703,12 +8427,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9052,12 +8772,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9067,12 +8783,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9082,12 +8794,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9097,12 +8805,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9447,12 +9151,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9462,12 +9162,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9477,12 +9173,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, @@ -9492,12 +9184,8 @@ exports[`RN Codegen Flow Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPO 'typeAnnotation': { 'type': 'StringEnumTypeAnnotation', 'options': [ - { - 'name': 'small' - }, - { - 'name': 'large' - } + 'small', + 'large' ] } }, diff --git a/packages/react-native-codegen/src/parsers/flow/components/events.js b/packages/react-native-codegen/src/parsers/flow/components/events.js index 868f6feefeee73..61962cf790e98b 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/events.js +++ b/packages/react-native-codegen/src/parsers/flow/components/events.js @@ -88,7 +88,7 @@ function getPropertyType( optional, typeAnnotation: { type: 'StringEnumTypeAnnotation', - options: typeAnnotation.types.map(option => ({name: option.value})), + options: typeAnnotation.types.map(option => option.value), }, }; default: diff --git a/packages/react-native-codegen/src/parsers/flow/components/props.js b/packages/react-native-codegen/src/parsers/flow/components/props.js index 757e238d38f72d..208885505f76ef 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/props.js +++ b/packages/react-native-codegen/src/parsers/flow/components/props.js @@ -153,7 +153,7 @@ function getTypeAnnotationForArray(name, typeAnnotation, defaultValue, types) { return { type: 'StringEnumTypeAnnotation', default: (defaultValue: string), - options: typeAnnotation.types.map(option => ({name: option.value})), + options: typeAnnotation.types.map(option => option.value), }; } else if (unionType === 'NumberLiteralTypeAnnotation') { throw new Error( @@ -301,13 +301,13 @@ function getTypeAnnotation( return { type: 'StringEnumTypeAnnotation', default: (defaultValue: string), - options: typeAnnotation.types.map(option => ({name: option.value})), + options: typeAnnotation.types.map(option => option.value), }; } else if (unionType === 'NumberLiteralTypeAnnotation') { return { type: 'Int32EnumTypeAnnotation', default: (defaultValue: number), - options: typeAnnotation.types.map(option => ({value: option.value})), + options: typeAnnotation.types.map(option => option.value), }; } else { throw new Error( From 1ee406b9ccbecc52dff3e77d65c6d9b4837e6dab Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 5 Nov 2020 17:43:23 -0800 Subject: [PATCH 0022/1810] Pull out ReservedPropTypeAnnotation into type alias Summary: This type annotation was declared inline twice. Just pulling it out into a type alias in this diff. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24723191 fbshipit-source-id: 9f2061087172979ea838dfdf2533e17b9b559c71 --- .../react-native-codegen/src/CodegenSchema.js | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index a0c87b5e7db750..4aec6a45332099 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -153,14 +153,7 @@ export type PropTypeAnnotation = default: number, options: $ReadOnlyArray, |}> - | $ReadOnly<{| - type: 'ReservedPropTypeAnnotation', - name: - | 'ColorPrimitive' - | 'ImageSourcePrimitive' - | 'PointPrimitive' - | 'EdgeInsetsPrimitive', - |}> + | ReservedPropTypeAnnotation | ObjectTypeAnnotation | $ReadOnly<{| type: 'ArrayTypeAnnotation', @@ -176,20 +169,22 @@ export type PropTypeAnnotation = options: $ReadOnlyArray, |}> | ObjectTypeAnnotation - | $ReadOnly<{| - type: 'ReservedPropTypeAnnotation', - name: - | 'ColorPrimitive' - | 'ImageSourcePrimitive' - | 'PointPrimitive' - | 'EdgeInsetsPrimitive', - |}> + | ReservedPropTypeAnnotation | $ReadOnly<{| type: 'ArrayTypeAnnotation', elementType: ObjectTypeAnnotation, |}>, |}>; +type ReservedPropTypeAnnotation = $ReadOnly<{| + type: 'ReservedPropTypeAnnotation', + name: + | 'ColorPrimitive' + | 'ImageSourcePrimitive' + | 'PointPrimitive' + | 'EdgeInsetsPrimitive', +|}>; + export type CommandTypeAnnotation = FunctionTypeAnnotation< CommandParamTypeAnnotation, VoidTypeAnnotation, From 052e578ed666f2749ec06d1d928bb622cada8841 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 6 Nov 2020 00:30:56 -0800 Subject: [PATCH 0023/1810] Set up experiment to dispatch promise methods asynchronously to NativeModules thread Summary: TurboModule methods that return promises are synchronously run on the JavaScript thread. Back in D22489338 (https://github.com/facebook/react-native/commit/9c35b5b8c4710dfe6a4b689a5565aa78ae5b37d3), we wrote code to make them dispatch on the NativeModules thread. That code, however, was just left disabled. In this diff, I wire up the TurboModules infra to a MobileConfig, which should allow us to assess the performance impact of async dispatch of promise methods to the NativeModules thread in production, before we roll it out more widely. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D24685389 fbshipit-source-id: 8ceb2e6effc125abecfa76e5e90bd310676aefc9 --- .../main/java/com/facebook/react/config/ReactFeatureFlags.java | 3 +++ .../facebook/react/turbomodule/core/TurboModuleManager.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 04a8a88eb5ca6d..9d8f1c4859a0d8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -23,6 +23,9 @@ public class ReactFeatureFlags { */ public static volatile boolean useTurboModules = false; + /** Should we dispatch TurboModule methods with promise returns to the NativeModules thread? */ + public static volatile boolean enableTurboModulePromiseAsyncDispatch = false; + /* * This feature flag enables logs for Fabric */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index e6e6fcce69e099..8303d153f618db 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -17,6 +17,7 @@ import com.facebook.react.bridge.JSIModule; import com.facebook.react.bridge.JavaScriptContextHolder; import com.facebook.react.bridge.NativeModule; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; import com.facebook.react.turbomodule.core.interfaces.TurboModule; import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry; @@ -60,7 +61,7 @@ public TurboModuleManager( (CallInvokerHolderImpl) jsCallInvokerHolder, (CallInvokerHolderImpl) nativeCallInvokerHolder, delegate, - false); + ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch); installJSIBindings(); mEagerInitModuleNames = From 2af406b88d4256d0f4cddbe6ffee0f45be5b2509 Mon Sep 17 00:00:00 2001 From: Alessandro Sisto Date: Fri, 6 Nov 2020 05:46:49 -0800 Subject: [PATCH 0024/1810] Revert D24685389: Set up experiment to dispatch promise methods asynchronously to NativeModules thread Differential Revision: D24685389 (https://github.com/facebook/react-native/commit/052e578ed666f2749ec06d1d928bb622cada8841) Original commit changeset: 8ceb2e6effc1 fbshipit-source-id: e48186dd0e928fe95cc7f2420fc02c00a62b8360 --- .../main/java/com/facebook/react/config/ReactFeatureFlags.java | 3 --- .../facebook/react/turbomodule/core/TurboModuleManager.java | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 9d8f1c4859a0d8..04a8a88eb5ca6d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -23,9 +23,6 @@ public class ReactFeatureFlags { */ public static volatile boolean useTurboModules = false; - /** Should we dispatch TurboModule methods with promise returns to the NativeModules thread? */ - public static volatile boolean enableTurboModulePromiseAsyncDispatch = false; - /* * This feature flag enables logs for Fabric */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index 8303d153f618db..e6e6fcce69e099 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -17,7 +17,6 @@ import com.facebook.react.bridge.JSIModule; import com.facebook.react.bridge.JavaScriptContextHolder; import com.facebook.react.bridge.NativeModule; -import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; import com.facebook.react.turbomodule.core.interfaces.TurboModule; import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry; @@ -61,7 +60,7 @@ public TurboModuleManager( (CallInvokerHolderImpl) jsCallInvokerHolder, (CallInvokerHolderImpl) nativeCallInvokerHolder, delegate, - ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch); + false); installJSIBindings(); mEagerInitModuleNames = From d8b0997aa936f903becd2c4a64448134853ea37a Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 6 Nov 2020 06:33:47 -0800 Subject: [PATCH 0025/1810] Upgrade metro to 0.64.0 Summary: Upgrade metro to 0.64.0 Changelog: [Internal] Reviewed By: cpojer Differential Revision: D24753886 fbshipit-source-id: af679ec912c5cd8049a998d045ce8a75bf30e5d3 --- package.json | 8 ++--- template/package.json | 2 +- yarn.lock | 82 +++++++++++++++++++++++-------------------- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index 531c984680fdf4..b743a22c696aa1 100644 --- a/package.json +++ b/package.json @@ -99,10 +99,10 @@ "hermes-engine": "~0.7.0", "invariant": "^2.2.4", "jsc-android": "^245459.0.0", - "metro-babel-register": "0.63.0", - "metro-react-native-babel-transformer": "0.63.0", - "metro-runtime": "0.63.0", - "metro-source-map": "0.63.0", + "metro-babel-register": "0.64.0", + "metro-react-native-babel-transformer": "0.64.0", + "metro-runtime": "0.64.0", + "metro-source-map": "0.64.0", "nullthrows": "^1.1.1", "pretty-format": "^26.5.2", "promise": "^8.0.3", diff --git a/template/package.json b/template/package.json index edf653d6a4a8bb..6bfd86bef39e79 100644 --- a/template/package.json +++ b/template/package.json @@ -20,7 +20,7 @@ "babel-jest": "^25.1.0", "eslint": "^6.5.1", "jest": "^25.1.0", - "metro-react-native-babel-preset": "^0.63.0", + "metro-react-native-babel-preset": "^0.64.0", "react-test-renderer": "17.0.1", "react-native-codegen": "0.0.4" }, diff --git a/yarn.lock b/yarn.lock index 6f93398d711c4f..8c9d469a21887e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4757,10 +4757,10 @@ metro-babel-register@0.58.0: core-js "^2.2.2" escape-string-regexp "^1.0.5" -metro-babel-register@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-babel-register/-/metro-babel-register-0.63.0.tgz#8e196535d4c77ff3103a681e8217f8661f5850c9" - integrity sha512-y1XBXtHX3Wp25a5+Yfx0oxmjDR4aIzjOy5ywfRaz+2GLUkT6JngRQ2inyQ66wWDj8fjifPpH74j8vf7LGfyICQ== +metro-babel-register@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-babel-register/-/metro-babel-register-0.64.0.tgz#1a2d23f68da8b8ee42e78dca37ad21a5f4d3647d" + integrity sha512-Kf6YvE3kIRumGnjK0Q9LqGDIdnsX9eFGtNBmBuCVDuB9wGGA/5CgX8We8W7Y44dz1RGTcHJRhfw5iGg+pwC3aQ== dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" @@ -4779,13 +4779,14 @@ metro-babel-transformer@0.58.0: "@babel/core" "^7.0.0" metro-source-map "0.58.0" -metro-babel-transformer@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-babel-transformer/-/metro-babel-transformer-0.63.0.tgz#0fe7dd2d58fba8a64917d431ba0dcbbdd874f076" - integrity sha512-u8s6wKua9G0P/uLcw6hwPA1RCTKwlauvxMUoceci8HrK6FQyZamYbAM4fGxMSgjb2ogqKG7oGfBneTIrAn9HvA== +metro-babel-transformer@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-babel-transformer/-/metro-babel-transformer-0.64.0.tgz#a21f8a989a5ea60c1109456e21bd4d9374194ea0" + integrity sha512-itZaxKTgmKGEZWxNzbSZBc22NngrMZzoUNuU92aHSTGkYi2WH4XlvzEHsstmIKHMsRVKl75cA+mNmgk4gBFJKw== dependencies: "@babel/core" "^7.0.0" - metro-source-map "0.63.0" + metro-source-map "0.64.0" + nullthrows "^1.1.1" metro-cache@0.58.0: version "0.58.0" @@ -4878,10 +4879,10 @@ metro-react-native-babel-preset@0.58.0: "@babel/template" "^7.0.0" react-refresh "^0.4.0" -metro-react-native-babel-preset@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.63.0.tgz#bc67d4d251ac72f30b7f3d92a069aea825577751" - integrity sha512-iTM6V/hzqTd2dg0LHtD4f/TU+d4A7MFiMPUmIYDb0OZmCq6avfcxHQTXk/ZNbAr+eRoN/owx9OIkjt/CvG4vUA== +metro-react-native-babel-preset@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.64.0.tgz#76861408681dfda3c1d962eb31a8994918c976f8" + integrity sha512-HcZ0RWQRuJfpPiaHyFQJzcym+/dDIVUPwUAXWoub/C4GkGu+mPjp8vqK6g0FxokCnnI2TK0gZTza2IDfiNNscQ== dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" @@ -4923,16 +4924,17 @@ metro-react-native-babel-preset@0.63.0: "@babel/template" "^7.0.0" react-refresh "^0.4.0" -metro-react-native-babel-transformer@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-react-native-babel-transformer/-/metro-react-native-babel-transformer-0.63.0.tgz#527e1e5ef7b63512189a5b5bb4cb06d1fdb57815" - integrity sha512-HbyGvCoGJZ2WrstyTgHg05O5UOYgkatRLpalAnhHjPt+1Wr0Z3vr33SesibHRlnT5ETUBZME+txukcnN9eSdIA== +metro-react-native-babel-transformer@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-react-native-babel-transformer/-/metro-react-native-babel-transformer-0.64.0.tgz#eafef756972f20efdc51bd5361d55f8598355623" + integrity sha512-K1sHO3ODBFCr7uEiCQ4RvVr+cQg0EHQF8ChVPnecGh/WDD8udrTq9ECwB0dRfMjAvlsHtRUlJm6ZSI8UPgum2w== dependencies: "@babel/core" "^7.0.0" babel-preset-fbjs "^3.3.0" - metro-babel-transformer "0.63.0" - metro-react-native-babel-preset "0.63.0" - metro-source-map "0.63.0" + metro-babel-transformer "0.64.0" + metro-react-native-babel-preset "0.64.0" + metro-source-map "0.64.0" + nullthrows "^1.1.1" metro-react-native-babel-transformer@^0.58.0: version "0.58.0" @@ -4952,10 +4954,10 @@ metro-resolver@0.58.0, metro-resolver@^0.58.0: dependencies: absolute-path "^0.0.0" -metro-runtime@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-runtime/-/metro-runtime-0.63.0.tgz#7cb397eb45b5f605886251cd2ccd40d0b9ad7a97" - integrity sha512-iE3B2zFQBtSomz73extpfS/qvd4iEc2zbCEnytThPBtHY9g/pBTeR+sVqVlkG2Vl3sVXgxKx+Pq0QXuLz1ipLg== +metro-runtime@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-runtime/-/metro-runtime-0.64.0.tgz#cdaa1121d91041bf6345f2a69eb7c2fb289eff7b" + integrity sha512-m7XbWOaIOeFX7YcxUhmnOi6Pg8EaeL89xyZ+quZyZVF1aNoTr4w8FfbKxvijpjsytKHIZtd+43m2Wt5JrqyQmQ== metro-source-map@0.58.0: version "0.58.0" @@ -4970,16 +4972,17 @@ metro-source-map@0.58.0: source-map "^0.5.6" vlq "^1.0.0" -metro-source-map@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-source-map/-/metro-source-map-0.63.0.tgz#bbfdfd2ce317dcccb7d52999d30bdbca69c8086c" - integrity sha512-gDa91b9jeZJfzV3f9tq4++AEicrX95+cnvkpXx1f5X+VktQYDUhoTJ/WSCYAZOwoeE1+QC3+TfKpFKWNs1Siqw== +metro-source-map@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-source-map/-/metro-source-map-0.64.0.tgz#4310e17c3d4539c6369688022494ad66fa4d39a1" + integrity sha512-OCG2rtcp5cLEGYvAbfkl6mEc0J2FPRP4/UCEly+juBk7hawS9bCBMBfhJm/HIsvY1frk6nT2Vsl1O8YBbwyx2g== dependencies: "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" invariant "^2.2.4" - metro-symbolicate "0.63.0" - ob1 "0.63.0" + metro-symbolicate "0.64.0" + nullthrows "^1.1.1" + ob1 "0.64.0" source-map "^0.5.6" vlq "^1.0.0" @@ -4994,13 +4997,14 @@ metro-symbolicate@0.58.0: through2 "^2.0.1" vlq "^1.0.0" -metro-symbolicate@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/metro-symbolicate/-/metro-symbolicate-0.63.0.tgz#c099605f38a1ff1857712f49d15e7eab743bcc7d" - integrity sha512-bJtz+hpHNHtUib9OUzxj/wShRm6p3qG0MtkLJKzWPe9SwxeGUH1mV0IUec4cgJL9csQ2iPMB00OknVH8K1eDaw== +metro-symbolicate@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-symbolicate/-/metro-symbolicate-0.64.0.tgz#405c21438ab553c29f6841da52ca76ee87bb06ac" + integrity sha512-qIi+YRrDWnLVmydj6gwidYLPaBsakZRibGWSspuXgHAxOI3UuLwlo4dpQ73Et0gyHjI7ZvRMRY8JPiOntf9AQQ== dependencies: invariant "^2.2.4" - metro-source-map "0.63.0" + metro-source-map "0.64.0" + nullthrows "^1.1.1" source-map "^0.5.6" through2 "^2.0.1" vlq "^1.0.0" @@ -5435,10 +5439,10 @@ ob1@0.58.0: resolved "https://registry.yarnpkg.com/ob1/-/ob1-0.58.0.tgz#484a1e9a63a8b79d9ea6f3a83b2a42110faac973" integrity sha512-uZP44cbowAfHafP1k4skpWItk5iHCoRevMfrnUvYCfyNNPPJd3rfDCyj0exklWi2gDXvjlj2ObsfiqP/bs/J7Q== -ob1@0.63.0: - version "0.63.0" - resolved "https://registry.yarnpkg.com/ob1/-/ob1-0.63.0.tgz#2f34b178b5918028a0d76072a7b155b91f9cb6bd" - integrity sha512-y7AtRIuISHuA5sc0Alcw/Cj2azU1ruuAmJIKSKk//IryxmHtmyA/M5DFcmpDAisaIB255bBt/P9aqc8jr1ocsg== +ob1@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/ob1/-/ob1-0.64.0.tgz#f254a55a53ca395c4f9090e28a85483eac5eba19" + integrity sha512-CO1N+5dhvy+MoAwxz8+fymEUcwsT4a+wHhrHFb02LppcJdHxgcBWviwEhUwKOD2kLMQ7ijrrzybOqpGcqEtvpQ== object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" From 00d9deaf6ba26c605694d303bb0cb072fceae5a1 Mon Sep 17 00:00:00 2001 From: Hank Chen Date: Fri, 6 Nov 2020 11:47:07 -0800 Subject: [PATCH 0026/1810] `Android`: font-family is not apply when secureTextEntry is true (#30164) Summary: This pr fixes: https://github.com/facebook/react-native/issues/30123 . When secureTextEntry is true, setInputType will set the inputType of textInput to password type. Password type default font-family will be monospace font, so we need to setTypeface after the setInputType. ## Changelog [Android] [Fixed] - Font family is not apply when secureTextEntry is true. Pull Request resolved: https://github.com/facebook/react-native/pull/30164 Test Plan: Before this pr: ![alt text](https://i.imgur.com/mAxLhnB.png) After this pr: ![alt text](https://i.imgur.com/zoGYDxN.png) Please initiated a new project and replaced the App.js with the following code: ``` iimport React from 'react'; import {SafeAreaView, TextInput} from 'react-native'; const App = () => { return ( ); }; export default App; ``` Thanks you so much for your code review! Reviewed By: cpojer Differential Revision: D24686222 Pulled By: hramos fbshipit-source-id: 863ebe1dba36cac7d91b2735fe6e914ac839ed44 --- .../com/facebook/react/views/textinput/ReactEditText.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index db843323724aa0..058e154849dfce 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -419,11 +419,10 @@ public String getReturnKeyType() { @Override public void setInputType(int type) { Typeface tf = super.getTypeface(); - // Input type password defaults to monospace font, so we need to re-apply the font - super.setTypeface(tf); - super.setInputType(type); mStagedInputType = type; + // Input type password defaults to monospace font, so we need to re-apply the font + super.setTypeface(tf); /** * If set forces multiline on input, because of a restriction on Android source that enables From f1e292b9c1e349ce7df1404dacbaf1c1195d296f Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 6 Nov 2020 13:08:51 -0800 Subject: [PATCH 0027/1810] Set up experiment to dispatch promise methods asynchronously to NativeModules thread Summary: TurboModule methods that return promises are synchronously run on the JavaScript thread. Back in D22489338 (https://github.com/facebook/react-native/commit/9c35b5b8c4710dfe6a4b689a5565aa78ae5b37d3), we wrote code to make them dispatch on the NativeModules thread. That code, however, was just left disabled. In this diff, I wire up the TurboModules infra to a MobileConfig, which should allow us to assess the performance impact of async dispatch of promise methods to the NativeModules thread in production, before we roll it out more widely. Changelog: [Internal] NOTE: This diff was reverted, beacuse we landed it it without D24685387. Reviewed By: ejanzer Differential Revision: D24787573 fbshipit-source-id: 324bd22ce79c2c16c7f7b6996496d255a2c6256e --- .../main/java/com/facebook/react/config/ReactFeatureFlags.java | 3 +++ .../facebook/react/turbomodule/core/TurboModuleManager.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 04a8a88eb5ca6d..9d8f1c4859a0d8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -23,6 +23,9 @@ public class ReactFeatureFlags { */ public static volatile boolean useTurboModules = false; + /** Should we dispatch TurboModule methods with promise returns to the NativeModules thread? */ + public static volatile boolean enableTurboModulePromiseAsyncDispatch = false; + /* * This feature flag enables logs for Fabric */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index e6e6fcce69e099..8303d153f618db 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -17,6 +17,7 @@ import com.facebook.react.bridge.JSIModule; import com.facebook.react.bridge.JavaScriptContextHolder; import com.facebook.react.bridge.NativeModule; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; import com.facebook.react.turbomodule.core.interfaces.TurboModule; import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry; @@ -60,7 +61,7 @@ public TurboModuleManager( (CallInvokerHolderImpl) jsCallInvokerHolder, (CallInvokerHolderImpl) nativeCallInvokerHolder, delegate, - false); + ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch); installJSIBindings(); mEagerInitModuleNames = From cb7f3f4499232797ce8e60b00270f30641923ddc Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 6 Nov 2020 13:08:51 -0800 Subject: [PATCH 0028/1810] Setup TurboModule JS Codegen experiment Summary: ## Android API ``` // Before we initialize TurboModuleManager ReactFeatureFlags.useTurboModuleJSCodegen = true ``` ## iOS API ``` // Before we initialize RCTBridge RCTEnableTurboModuleJSCodegen(true); ``` ## How is the JS Codegen actually enabled? The above native flags are translated to the following global variable in JavaScript: ``` global.RN$JSTurboModuleCodegenEnabled = true; ``` Then, all our NativeModule specs are transpiled to contain this logic: ``` interface Foo extends TurboModule { // ... } function __getModuleSchema() { if (!global.RN$JSTurboModuleCodegenEnabled) { return undefined; } // Return the schema of this spec. return {...}; } export default TurboModuleRegistry.get('foo', __getModuleSchema()); ``` Then, in our C++ JavaTurboModule, and ObjCTurboModule classes, we use the TurboModule JS codegen when the jsi::Object schema is provided from JavaScript in the TurboModuleRegistry.get call. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D24636307 fbshipit-source-id: 80dcd604cc1121b8a69df875bbfc87e9bb8e4814 --- React/Base/RCTBridge.h | 4 ++++ React/Base/RCTBridge.m | 11 +++++++++++ .../facebook/react/config/ReactFeatureFlags.java | 3 +++ .../turbomodule/core/TurboModuleManager.java | 6 ++++-- .../core/jni/ReactCommon/TurboModuleManager.cpp | 15 ++++++++++----- .../core/jni/ReactCommon/TurboModuleManager.h | 7 +++++-- .../core/ReactCommon/TurboModuleBinding.cpp | 8 +++++++- .../core/ReactCommon/TurboModuleBinding.h | 3 ++- .../core/platform/ios/RCTTurboModuleManager.mm | 2 +- 9 files changed, 47 insertions(+), 12 deletions(-) diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index 1331f5009cbacf..5ce3ebe35a3c39 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -164,6 +164,10 @@ RCT_EXTERN void RCTEnableTurboModuleSharedMutexInit(BOOL enabled); RCT_EXTERN BOOL RCTTurboModuleBlockCopyEnabled(void); RCT_EXTERN void RCTEnableTurboModuleBlockCopy(BOOL enabled); +// Turn on TurboModule JS Codegen +RCT_EXTERN BOOL RCTTurboModuleJSCodegenEnabled(void); +RCT_EXTERN void RCTEnableTurboModuleJSCodegen(BOOL enabled); + /** * Async batched bridge used to communicate with the JavaScript application. */ diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 2429d58f86b00e..1adc463bf060e1 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -146,6 +146,17 @@ void RCTEnableTurboModuleBlockCopy(BOOL enabled) turboModuleBlockCopyEnabled = enabled; } +static BOOL turboModuleJSCodegenEnabled = NO; +BOOL RCTTurboModuleJSCodegenEnabled(void) +{ + return turboModuleJSCodegenEnabled; +} + +void RCTEnableTurboModuleJSCodegen(BOOL enabled) +{ + turboModuleJSCodegenEnabled = enabled; +} + @interface RCTBridge () @end diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 9d8f1c4859a0d8..a304728a3b26b7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -26,6 +26,9 @@ public class ReactFeatureFlags { /** Should we dispatch TurboModule methods with promise returns to the NativeModules thread? */ public static volatile boolean enableTurboModulePromiseAsyncDispatch = false; + /** Enable TurboModule JS Codegen. */ + public static volatile boolean useTurboModuleJSCodegen = false; + /* * This feature flag enables logs for Fabric */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index 8303d153f618db..8cd4c67037022c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -61,7 +61,8 @@ public TurboModuleManager( (CallInvokerHolderImpl) jsCallInvokerHolder, (CallInvokerHolderImpl) nativeCallInvokerHolder, delegate, - ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch); + ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch, + ReactFeatureFlags.useTurboModuleJSCodegen); installJSIBindings(); mEagerInitModuleNames = @@ -294,7 +295,8 @@ private native HybridData initHybrid( CallInvokerHolderImpl jsCallInvokerHolder, CallInvokerHolderImpl nativeCallInvokerHolder, TurboModuleManagerDelegate tmmDelegate, - boolean enablePromiseAsyncDispatch); + boolean enablePromiseAsyncDispatch, + boolean enableTurboModuleJSCodegen); private native void installJSIBindings(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp index 131b41b075ecb3..52d9861de96da8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp @@ -26,13 +26,15 @@ TurboModuleManager::TurboModuleManager( jsi::Runtime *rt, std::shared_ptr jsCallInvoker, std::shared_ptr nativeCallInvoker, - jni::alias_ref delegate) + jni::alias_ref delegate, + bool enableJSCodegen) : javaPart_(jni::make_global(jThis)), runtime_(rt), jsCallInvoker_(jsCallInvoker), nativeCallInvoker_(nativeCallInvoker), delegate_(jni::make_global(delegate)), - turboModuleCache_(std::make_shared()) {} + turboModuleCache_(std::make_shared()), + enableJSCodegen_(enableJSCodegen) {} jni::local_ref TurboModuleManager::initHybrid( jni::alias_ref jThis, @@ -40,7 +42,8 @@ jni::local_ref TurboModuleManager::initHybrid( jni::alias_ref jsCallInvokerHolder, jni::alias_ref nativeCallInvokerHolder, jni::alias_ref delegate, - bool enablePromiseAsyncDispatch) { + bool enablePromiseAsyncDispatch, + bool enableJSCodegen) { auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker(); auto nativeCallInvoker = nativeCallInvokerHolder->cthis()->getCallInvoker(); @@ -51,7 +54,8 @@ jni::local_ref TurboModuleManager::initHybrid( (jsi::Runtime *)jsContext, jsCallInvoker, nativeCallInvoker, - delegate); + delegate, + enableJSCodegen); } void TurboModuleManager::registerNatives() { @@ -146,7 +150,8 @@ void TurboModuleManager::installJSIBindings() { jsCallInvoker_->invokeAsync( [this, turboModuleProvider = std::move(turboModuleProvider)]() -> void { - TurboModuleBinding::install(*runtime_, std::move(turboModuleProvider)); + TurboModuleBinding::install( + *runtime_, std::move(turboModuleProvider), enableJSCodegen_); }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h index 899d2a1d1cf8e4..2a6a95aed2dc56 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h @@ -31,7 +31,8 @@ class TurboModuleManager : public jni::HybridClass { jni::alias_ref jsCallInvokerHolder, jni::alias_ref nativeCallInvokerHolder, jni::alias_ref delegate, - bool enablePromiseAsyncDispatch); + bool enablePromiseAsyncDispatch, + bool enableJSCodegen); static void registerNatives(); private: @@ -52,6 +53,7 @@ class TurboModuleManager : public jni::HybridClass { * they want to be long-lived or short-lived. */ std::shared_ptr turboModuleCache_; + bool enableJSCodegen_; void installJSIBindings(); explicit TurboModuleManager( @@ -59,7 +61,8 @@ class TurboModuleManager : public jni::HybridClass { jsi::Runtime *rt, std::shared_ptr jsCallInvoker, std::shared_ptr nativeCallInvoker, - jni::alias_ref delegate); + jni::alias_ref delegate, + bool enableJSCodegen); }; } // namespace react diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp index 0b04ac69b10d66..d35ad88dfd7ee3 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp @@ -27,7 +27,13 @@ TurboModuleBinding::TurboModuleBinding( void TurboModuleBinding::install( jsi::Runtime &runtime, - const TurboModuleProviderFunctionType &&moduleProvider) { + const TurboModuleProviderFunctionType &&moduleProvider, + bool enableJSTurboModuleCodegen) { + runtime.global().setProperty( + runtime, + "RN$JSTurboModuleCodegenEnabled", + jsi::Value(enableJSTurboModuleCodegen)); + runtime.global().setProperty( runtime, "__turboModuleProxy", diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h index 2546730959fc12..d1c9abcdec04b7 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h @@ -28,7 +28,8 @@ class TurboModuleBinding { */ static void install( jsi::Runtime &runtime, - const TurboModuleProviderFunctionType &&moduleProvider); + const TurboModuleProviderFunctionType &&moduleProvider, + bool enableJSTurboModuleCodegen); TurboModuleBinding(const TurboModuleProviderFunctionType &&moduleProvider); virtual ~TurboModuleBinding(); diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index 223522eb684f4b..cd7ba02c510bbd 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -718,7 +718,7 @@ - (void)installJSBindingWithRuntimeExecutor:(facebook::react::RuntimeExecutor)ru }; runtimeExecutor([turboModuleProvider = std::move(turboModuleProvider)](jsi::Runtime &runtime) { - react::TurboModuleBinding::install(runtime, std::move(turboModuleProvider)); + react::TurboModuleBinding::install(runtime, std::move(turboModuleProvider), RCTTurboModuleJSCodegenEnabled()); }); } From 00cfb0f919207fcdc8fe8b6c3b7d76591447b91d Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 6 Nov 2020 16:06:19 -0800 Subject: [PATCH 0029/1810] Remove pipes from Object literal Flow types Summary: ## Changes {| ... |} -> { ... } **Motivation:** In Flow, object literals are exact by default. So, there's no need for the pipes. Also: Now, the syntax for object literals is consistent across react-native-codegen. Changelog: [Internal] Reviewed By: hramos Differential Revision: D24774771 fbshipit-source-id: 24ceb6f5876122aa8ad9e08c7e903215864ad6f5 --- .../react-native-codegen/src/CodegenSchema.js | 178 +++++++++--------- .../src/generators/RNCodegen.js | 8 +- .../generators/components/GenerateTests.js | 4 +- .../generators/modules/GenerateModuleCpp.js | 8 +- .../src/generators/modules/GenerateModuleH.js | 6 +- .../modules/GenerateModuleJavaSpec.js | 8 +- .../modules/GenerateModuleJniCpp.js | 24 +-- .../generators/modules/GenerateModuleJniH.js | 4 +- .../GenerateModuleObjCpp/StructCollector.js | 12 +- .../header/serializeConstantsStruct.js | 8 +- .../header/serializeRegularStruct.js | 8 +- .../header/serializeStruct.js | 4 +- .../modules/GenerateModuleObjCpp/index.js | 12 +- .../GenerateModuleObjCpp/serializeMethod.js | 20 +- .../source/serializeModule.js | 16 +- .../src/generators/modules/Utils.js | 4 +- .../src/parsers/flow/components/options.js | 4 +- .../src/parsers/flow/components/schema.js | 4 +- .../__tests__/module-parser-e2e-test.js | 40 ++-- .../src/parsers/flow/modules/index.js | 12 +- .../src/parsers/flow/utils.js | 10 +- 21 files changed, 195 insertions(+), 199 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 4aec6a45332099..8b8673f0e5d62d 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -12,54 +12,54 @@ export type PlatformType = 'iOS' | 'android'; -export type SchemaType = $ReadOnly<{| - modules: $ReadOnly<{| +export type SchemaType = $ReadOnly<{ + modules: $ReadOnly<{ [hasteModuleName: string]: ComponentSchema | NativeModuleSchema, - |}>, -|}>; + }>, +}>; /** * Component Type Annotations */ -export type DoubleTypeAnnotation = $ReadOnly<{| +export type DoubleTypeAnnotation = $ReadOnly<{ type: 'DoubleTypeAnnotation', -|}>; +}>; -export type FloatTypeAnnotation = $ReadOnly<{| +export type FloatTypeAnnotation = $ReadOnly<{ type: 'FloatTypeAnnotation', -|}>; +}>; -export type BooleanTypeAnnotation = $ReadOnly<{| +export type BooleanTypeAnnotation = $ReadOnly<{ type: 'BooleanTypeAnnotation', -|}>; +}>; -export type Int32TypeAnnotation = $ReadOnly<{| +export type Int32TypeAnnotation = $ReadOnly<{ type: 'Int32TypeAnnotation', -|}>; +}>; -export type StringTypeAnnotation = $ReadOnly<{| +export type StringTypeAnnotation = $ReadOnly<{ type: 'StringTypeAnnotation', -|}>; +}>; -export type StringEnumTypeAnnotation = $ReadOnly<{| +export type StringEnumTypeAnnotation = $ReadOnly<{ type: 'StringEnumTypeAnnotation', options: $ReadOnlyArray, -|}>; +}>; -export type VoidTypeAnnotation = $ReadOnly<{| +export type VoidTypeAnnotation = $ReadOnly<{ type: 'VoidTypeAnnotation', -|}>; +}>; -type ObjectTypeAnnotation<+T> = $ReadOnly<{| +type ObjectTypeAnnotation<+T> = $ReadOnly<{ type: 'ObjectTypeAnnotation', properties: $ReadOnlyArray>, -|}>; +}>; -type FunctionTypeAnnotation<+P, +R> = $ReadOnly<{| +type FunctionTypeAnnotation<+P, +R> = $ReadOnly<{ type: 'FunctionTypeAnnotation', params: $ReadOnlyArray>, returnTypeAnnotation: R, -|}>; +}>; export type NamedShape<+T> = $ReadOnly<{ name: string, @@ -67,22 +67,22 @@ export type NamedShape<+T> = $ReadOnly<{ typeAnnotation: T, }>; -export type ComponentSchema = $ReadOnly<{| +export type ComponentSchema = $ReadOnly<{ type: 'Component', - components: $ReadOnly<{| + components: $ReadOnly<{ [componentName: string]: ComponentShape, - |}>, -|}>; + }>, +}>; -export type ComponentShape = $ReadOnly<{| +export type ComponentShape = $ReadOnly<{ ...OptionsShape, extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, props: $ReadOnlyArray>, commands: $ReadOnlyArray>, -|}>; +}>; -export type OptionsShape = $ReadOnly<{| +export type OptionsShape = $ReadOnly<{ interfaceOnly?: boolean, // Use for components with no current paper rename in progress @@ -95,23 +95,23 @@ export type OptionsShape = $ReadOnly<{| // Use for components currently being renamed in paper // Will use new name if it is available and fallback to this name paperComponentNameDeprecated?: string, -|}>; +}>; -export type ExtendsPropsShape = $ReadOnly<{| +export type ExtendsPropsShape = $ReadOnly<{ type: 'ReactNativeBuiltInType', knownTypeName: 'ReactNativeCoreViewProps', -|}>; +}>; -export type EventTypeShape = $ReadOnly<{| +export type EventTypeShape = $ReadOnly<{ name: string, bubblingType: 'direct' | 'bubble', optional: boolean, paperTopLevelNameDeprecated?: string, - typeAnnotation: $ReadOnly<{| + typeAnnotation: $ReadOnly<{ type: 'EventTypeAnnotation', argument?: ObjectTypeAnnotation, - |}>, -|}>; + }>, +}>; export type EventTypeAnnotation = | BooleanTypeAnnotation @@ -123,39 +123,39 @@ export type EventTypeAnnotation = | ObjectTypeAnnotation; export type PropTypeAnnotation = - | $ReadOnly<{| + | $ReadOnly<{ type: 'BooleanTypeAnnotation', default: boolean | null, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ type: 'StringTypeAnnotation', default: string | null, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ type: 'DoubleTypeAnnotation', default: number, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ type: 'FloatTypeAnnotation', default: number | null, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ type: 'Int32TypeAnnotation', default: number, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ type: 'StringEnumTypeAnnotation', default: string, options: $ReadOnlyArray, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ type: 'Int32EnumTypeAnnotation', default: number, options: $ReadOnlyArray, - |}> + }> | ReservedPropTypeAnnotation | ObjectTypeAnnotation - | $ReadOnly<{| + | $ReadOnly<{ type: 'ArrayTypeAnnotation', elementType: | BooleanTypeAnnotation @@ -163,27 +163,27 @@ export type PropTypeAnnotation = | DoubleTypeAnnotation | FloatTypeAnnotation | Int32TypeAnnotation - | $ReadOnly<{| + | $ReadOnly<{ type: 'StringEnumTypeAnnotation', default: string, options: $ReadOnlyArray, - |}> + }> | ObjectTypeAnnotation | ReservedPropTypeAnnotation - | $ReadOnly<{| + | $ReadOnly<{ type: 'ArrayTypeAnnotation', elementType: ObjectTypeAnnotation, - |}>, - |}>; + }>, + }>; -type ReservedPropTypeAnnotation = $ReadOnly<{| +type ReservedPropTypeAnnotation = $ReadOnly<{ type: 'ReservedPropTypeAnnotation', name: | 'ColorPrimitive' | 'ImageSourcePrimitive' | 'PointPrimitive' | 'EdgeInsetsPrimitive', -|}>; +}>; export type CommandTypeAnnotation = FunctionTypeAnnotation< CommandParamTypeAnnotation, @@ -198,10 +198,10 @@ export type CommandParamTypeAnnotation = | FloatTypeAnnotation | StringTypeAnnotation; -export type ReservedTypeAnnotation = $ReadOnly<{| +export type ReservedTypeAnnotation = $ReadOnly<{ type: 'ReservedTypeAnnotation', name: 'RootTag', // Union with more custom types. -|}>; +}>; /** * NativeModule Types @@ -210,14 +210,12 @@ export type Nullable<+T: NativeModuleTypeAnnotation> = | NullableTypeAnnotation | T; -export type NullableTypeAnnotation< - +T: NativeModuleTypeAnnotation, -> = $ReadOnly<{| +export type NullableTypeAnnotation<+T: NativeModuleTypeAnnotation> = $ReadOnly<{ type: 'NullableTypeAnnotation', typeAnnotation: T, -|}>; +}>; -export type NativeModuleSchema = $ReadOnly<{| +export type NativeModuleSchema = $ReadOnly<{ type: 'NativeModule', aliases: NativeModuleAliasMap, spec: NativeModuleSpec, @@ -226,19 +224,19 @@ export type NativeModuleSchema = $ReadOnly<{| // TODO: It's clearer to define `restrictedToPlatforms` instead, but // `excludedPlatforms` is used here to be consistent with ComponentSchema. excludedPlatforms?: $ReadOnlyArray, -|}>; +}>; -type NativeModuleSpec = $ReadOnly<{| +type NativeModuleSpec = $ReadOnly<{ properties: $ReadOnlyArray, -|}>; +}>; export type NativeModulePropertyShape = NamedShape< Nullable, >; -export type NativeModuleAliasMap = $ReadOnly<{| +export type NativeModuleAliasMap = $ReadOnly<{ [aliasName: string]: NativeModuleObjectTypeAnnotation, -|}>; +}>; export type NativeModuleFunctionTypeAnnotation = FunctionTypeAnnotation< Nullable, @@ -251,51 +249,51 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation< export type NativeModuleArrayTypeAnnotation< +T: Nullable, -> = $ReadOnly<{| +> = $ReadOnly<{ type: 'ArrayTypeAnnotation', /** * TODO(T72031674): Migrate all our NativeModule specs to not use * invalid Array ElementTypes. Then, make the elementType required. */ elementType?: T, -|}>; +}>; -export type NativeModuleStringTypeAnnotation = $ReadOnly<{| +export type NativeModuleStringTypeAnnotation = $ReadOnly<{ type: 'StringTypeAnnotation', -|}>; +}>; -export type NativeModuleNumberTypeAnnotation = $ReadOnly<{| +export type NativeModuleNumberTypeAnnotation = $ReadOnly<{ type: 'NumberTypeAnnotation', -|}>; +}>; -export type NativeModuleInt32TypeAnnotation = $ReadOnly<{| +export type NativeModuleInt32TypeAnnotation = $ReadOnly<{ type: 'Int32TypeAnnotation', -|}>; +}>; -export type NativeModuleDoubleTypeAnnotation = $ReadOnly<{| +export type NativeModuleDoubleTypeAnnotation = $ReadOnly<{ type: 'DoubleTypeAnnotation', -|}>; +}>; -export type NativeModuleFloatTypeAnnotation = $ReadOnly<{| +export type NativeModuleFloatTypeAnnotation = $ReadOnly<{ type: 'FloatTypeAnnotation', -|}>; +}>; -export type NativeModuleBooleanTypeAnnotation = $ReadOnly<{| +export type NativeModuleBooleanTypeAnnotation = $ReadOnly<{ type: 'BooleanTypeAnnotation', -|}>; +}>; -export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{| +export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{ type: 'GenericObjectTypeAnnotation', -|}>; +}>; -export type NativeModuleTypeAliasTypeAnnotation = $ReadOnly<{| +export type NativeModuleTypeAliasTypeAnnotation = $ReadOnly<{ type: 'TypeAliasTypeAnnotation', name: string, -|}>; +}>; -export type NativeModulePromiseTypeAnnotation = $ReadOnly<{| +export type NativeModulePromiseTypeAnnotation = $ReadOnly<{ type: 'PromiseTypeAnnotation', -|}>; +}>; export type NativeModuleBaseTypeAnnotation = | NativeModuleStringTypeAnnotation diff --git a/packages/react-native-codegen/src/generators/RNCodegen.js b/packages/react-native-codegen/src/generators/RNCodegen.js index 113fb98c962c87..2a8520fb64643d 100644 --- a/packages/react-native-codegen/src/generators/RNCodegen.js +++ b/packages/react-native-codegen/src/generators/RNCodegen.js @@ -40,13 +40,13 @@ const schemaValidator = require('../SchemaValidator.js'); import type {SchemaType} from '../CodegenSchema'; -type Options = $ReadOnly<{| +type Options = $ReadOnly<{ libraryName: string, schema: SchemaType, outputDirectory: string, moduleSpecName: string, packageName?: string, // Some platforms have a notion of package, which should be configurable. -|}>; +}>; type Generators = | 'descriptors' @@ -58,10 +58,10 @@ type Generators = | 'modulesCxx' | 'modulesIOS'; -type Config = $ReadOnly<{| +type Config = $ReadOnly<{ generators: Array, test?: boolean, -|}>; +}>; const GENERATORS = { descriptors: [generateComponentDescriptorH.generate], diff --git a/packages/react-native-codegen/src/generators/components/GenerateTests.js b/packages/react-native-codegen/src/generators/components/GenerateTests.js index 155c41fe5119c7..b8fde56ab584b1 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateTests.js +++ b/packages/react-native-codegen/src/generators/components/GenerateTests.js @@ -16,12 +16,12 @@ const {getImports, toSafeCppString} = require('./CppHelpers'); type FilesOutput = Map; type PropValueType = string | number | boolean; -type TestCase = $ReadOnly<{| +type TestCase = $ReadOnly<{ propName: string, propValue: ?PropValueType, testName?: string, raw?: boolean, -|}>; +}>; const fileTemplate = ` /** diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index e20396e768197d..bd94bb33cfb7a4 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -51,14 +51,12 @@ const ModuleTemplate = ({ hostFunctions, moduleName, methods, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, hostFunctions: $ReadOnlyArray, moduleName: string, - methods: $ReadOnlyArray< - $ReadOnly<{|methodName: string, paramCount: number|}>, - >, -|}>) => { + methods: $ReadOnlyArray<$ReadOnly<{methodName: string, paramCount: number}>>, +}>) => { return `${hostFunctions.join('\n')} ${hasteModuleName}CxxSpecJSI::${hasteModuleName}CxxSpecJSI(std::shared_ptr jsInvoker) diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index 7b53dea5bfb022..e1925f02eed790 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -26,7 +26,7 @@ type FilesOutput = Map; const ModuleClassDeclarationTemplate = ({ hasteModuleName, moduleProperties, -}: $ReadOnly<{|hasteModuleName: string, moduleProperties: string|}>) => { +}: $ReadOnly<{hasteModuleName: string, moduleProperties: string}>) => { return `class JSI_EXPORT ${hasteModuleName}CxxSpecJSI : public TurboModule { protected: ${hasteModuleName}CxxSpecJSI(std::shared_ptr jsInvoker); @@ -39,9 +39,9 @@ ${moduleProperties} const FileTemplate = ({ modules, -}: $ReadOnly<{| +}: $ReadOnly<{ modules: string, -|}>) => { +}>) => { return `/** * ${'C'}opyright (c) Facebook, Inc. and its affiliates. * diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index 539268b369202c..b8238cf4786d52 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -27,12 +27,12 @@ const {unwrapNullable} = require('../../parsers/flow/modules/utils'); type FilesOutput = Map; function FileTemplate( - config: $ReadOnly<{| + config: $ReadOnly<{ packageName: string, className: string, methods: string, imports: string, - |}>, + }>, ): string { const {packageName, className, methods, imports} = config; return ` @@ -62,14 +62,14 @@ ${methods} } function MethodTemplate( - config: $ReadOnly<{| + config: $ReadOnly<{ abstract: boolean, methodBody: ?string, methodJavaAnnotation: string, methodName: string, translatedReturnType: string, traversedArgs: Array, - |}>, + }>, ): string { const { abstract, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index 9c8a599cc3245c..b75aea926b731d 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -40,12 +40,12 @@ const HostFunctionTemplate = ({ propertyName, jniSignature, jsReturnType, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, propertyName: string, jniSignature: string, jsReturnType: JSReturnType, -|}>) => { +}>) => { return `static facebook::jsi::Value __hostFunction_${hasteModuleName}SpecJSI_${propertyName}(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { return static_cast(turboModule).invokeJavaMethod(rt, ${jsReturnType}, "${propertyName}", "${jniSignature}", args, count); }`; @@ -54,13 +54,13 @@ const HostFunctionTemplate = ({ const ModuleClassConstructorTemplate = ({ hasteModuleName, methods, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, - methods: $ReadOnlyArray<{| + methods: $ReadOnlyArray<{ propertyName: string, argCount: number, - |}>, -|}>) => { + }>, +}>) => { return ` ${hasteModuleName}SpecJSI::${hasteModuleName}SpecJSI(const JavaTurboModule::InitParams ¶ms) : JavaTurboModule(params) { @@ -75,7 +75,7 @@ ${methods const ModuleLookupTemplate = ({ moduleName, hasteModuleName, -}: $ReadOnly<{|moduleName: string, hasteModuleName: string|}>) => { +}: $ReadOnly<{moduleName: string, hasteModuleName: string}>) => { return ` if (moduleName == "${moduleName}") { return std::make_shared<${hasteModuleName}SpecJSI>(params); }`; @@ -86,17 +86,17 @@ const FileTemplate = ({ include, modules, moduleLookups, -}: $ReadOnly<{| +}: $ReadOnly<{ libraryName: string, include: string, modules: string, moduleLookups: $ReadOnlyArray< - $ReadOnly<{| + $ReadOnly<{ hasteModuleName: string, moduleName: string, - |}>, + }>, >, -|}>) => { +}>) => { return ` /** * ${'C'}opyright (c) Facebook, Inc. and its affiliates. @@ -441,7 +441,7 @@ module.exports = { } return 0; }) - .flatMap<{|moduleName: string, hasteModuleName: string|}>( + .flatMap<{moduleName: string, hasteModuleName: string}>( (hasteModuleName: string) => { const {moduleNames} = nativeModules[hasteModuleName]; return moduleNames.map(moduleName => ({ diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js index 83618968675d4f..d611a6be20bd0a 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js @@ -18,7 +18,7 @@ const {getModules} = require('./Utils'); const ModuleClassDeclarationTemplate = ({ hasteModuleName, -}: $ReadOnly<{|hasteModuleName: string|}>) => { +}: $ReadOnly<{hasteModuleName: string}>) => { return `/** * JNI C++ class for module '${hasteModuleName}' */ @@ -32,7 +32,7 @@ public: const HeaderFileTemplate = ({ modules, libraryName, -}: $ReadOnly<{|modules: string, libraryName: string|}>) => { +}: $ReadOnly<{modules: string, libraryName: string}>) => { return ` /** * ${'C'}opyright (c) Facebook, Inc. and its affiliates. diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js index ae48982139a247..fda5f8466a7758 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js @@ -36,25 +36,25 @@ const { type StructContext = 'CONSTANTS' | 'REGULAR'; -export type RegularStruct = $ReadOnly<{| +export type RegularStruct = $ReadOnly<{ context: 'REGULAR', name: string, properties: $ReadOnlyArray, -|}>; +}>; -export type ConstantsStruct = $ReadOnly<{| +export type ConstantsStruct = $ReadOnly<{ context: 'CONSTANTS', name: string, properties: $ReadOnlyArray, -|}>; +}>; export type Struct = RegularStruct | ConstantsStruct; -export type StructProperty = $ReadOnly<{| +export type StructProperty = $ReadOnly<{ name: string, optional: boolean, typeAnnotation: Nullable, -|}>; +}>; export type StructTypeAnnotation = | NativeModuleStringTypeAnnotation diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js index 0579c28f925ea0..9b39bf1560db51 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js @@ -26,11 +26,11 @@ const StructTemplate = ({ hasteModuleName, structName, builderInputProps, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, structName: string, builderInputProps: string, -|}>) => `namespace JS { +}>) => `namespace JS { namespace ${hasteModuleName} { struct ${structName} { @@ -62,11 +62,11 @@ const MethodTemplate = ({ hasteModuleName, structName, properties, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, structName: string, properties: string, -|}>) => `inline JS::${hasteModuleName}::${structName}::Builder::Builder(const Input i) : _factory(^{ +}>) => `inline JS::${hasteModuleName}::${structName}::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; ${properties} return d; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js index 3eb5155201d5df..14b8f7b4e9c379 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js @@ -26,11 +26,11 @@ const StructTemplate = ({ hasteModuleName, structName, structProperties, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, structName: string, structProperties: string, -|}>) => `namespace JS { +}>) => `namespace JS { namespace ${hasteModuleName} { struct ${structName} { ${structProperties} @@ -52,13 +52,13 @@ const MethodTemplate = ({ hasteModuleName, structName, propertyName, -}: $ReadOnly<{| +}: $ReadOnly<{ returnType: string, returnValue: string, hasteModuleName: string, structName: string, propertyName: string, -|}>) => `inline ${returnType}JS::${hasteModuleName}::${structName}::${propertyName}() const +}>) => `inline ${returnType}JS::${hasteModuleName}::${structName}::${propertyName}() const { id const p = _v[@"${propertyName}"]; return ${returnValue}; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js index fa851d24f017d6..170ac77c8fe863 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js @@ -15,10 +15,10 @@ import type {Struct} from '../StructCollector'; const {serializeConstantsStruct} = require('./serializeConstantsStruct'); const {serializeRegularStruct} = require('./serializeRegularStruct'); -export type StructSerilizationOutput = $ReadOnly<{| +export type StructSerilizationOutput = $ReadOnly<{ methods: string, declaration: string, -|}>; +}>; function serializeStruct( hasteModuleName: string, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js index 2d5dfa78adaf66..69fecf7e0e336c 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js @@ -26,11 +26,11 @@ const ModuleDeclarationTemplate = ({ hasteModuleName, structDeclarations, protocolMethods, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, structDeclarations: string, protocolMethods: string, -|}>) => `${structDeclarations} +}>) => `${structDeclarations} @protocol ${hasteModuleName}Spec ${protocolMethods} @@ -51,10 +51,10 @@ namespace facebook { const HeaderFileTemplate = ({ moduleDeclarations, structInlineMethods, -}: $ReadOnly<{| +}: $ReadOnly<{ moduleDeclarations: string, structInlineMethods: string, -|}>) => `/** +}>) => `/** * ${'C'}opyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -88,10 +88,10 @@ ${structInlineMethods} const SourceFileTemplate = ({ headerFileName, moduleImplementations, -}: $ReadOnly<{| +}: $ReadOnly<{ headerFileName: string, moduleImplementations: string, -|}>) => `/** +}>) => `/** * ${'C'}opyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index e3b5d39bc9b165..da2ec00739de80 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -32,16 +32,16 @@ const ProtocolMethodTemplate = ({ returnObjCType, methodName, params, -}: $ReadOnly<{| +}: $ReadOnly<{ returnObjCType: string, methodName: string, params: string, -|}>) => `- (${returnObjCType})${methodName}${params};`; +}>) => `- (${returnObjCType})${methodName}${params};`; -export type StructParameterRecord = $ReadOnly<{| +export type StructParameterRecord = $ReadOnly<{ paramIndex: number, structName: string, -|}>; +}>; type ReturnJSType = | 'VoidKind' @@ -51,14 +51,14 @@ type ReturnJSType = | 'NumberKind' | 'StringKind'; -export type MethodSerializationOutput = $ReadOnly<{| +export type MethodSerializationOutput = $ReadOnly<{ methodName: string, protocolMethod: string, selector: string, structParamRecords: $ReadOnlyArray, returnJSType: ReturnJSType, argCount: number, -|}>; +}>; function serializeMethod( hasteModuleName: string, @@ -79,7 +79,7 @@ function serializeMethod( ); } - const methodParams: Array<{|paramName: string, objCType: string|}> = []; + const methodParams: Array<{paramName: string, objCType: string}> = []; const structParamRecords: Array = []; params.forEach((param, index) => { @@ -183,7 +183,7 @@ function getParamObjCType( structName: string, structCollector: StructCollector, resolveAlias: AliasResolver, -): $ReadOnly<{|objCType: string, isStruct: boolean|}> { +): $ReadOnly<{objCType: string, isStruct: boolean}> { const {name: paramName, typeAnnotation: nullableTypeAnnotation} = param; const [typeAnnotation, nullable] = unwrapNullable(nullableTypeAnnotation); const notRequired = param.optional || nullable; @@ -215,7 +215,7 @@ function getParamObjCType( * * For example: * Array => NSArray - * type Animal = {||}; + * type Animal = {}; * Array => NSArray, etc. */ return notStruct(wrapIntoNullableIfNeeded('NSArray *')); @@ -398,7 +398,7 @@ function serializeConstantsProtocolMethods( const {returnTypeAnnotation} = propertyTypeAnnotation; if (returnTypeAnnotation.type !== 'ObjectTypeAnnotation') { throw new Error( - `${hasteModuleName}.getConstants() may only return an object literal: {|...|}.`, + `${hasteModuleName}.getConstants() may only return an object literal: {...}.`, ); } diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js index c930f98b7d8000..14796e88a65d67 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js @@ -20,11 +20,11 @@ const ModuleTemplate = ({ hasteModuleName, structs, methodSerializationOutputs, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, structs: $ReadOnlyArray, methodSerializationOutputs: $ReadOnlyArray, -|}>) => `${structs +}>) => `${structs .map(struct => RCTCxxConvertCategoryTemplate({hasteModuleName, structName: struct.name}), ) @@ -61,10 +61,10 @@ namespace facebook { const RCTCxxConvertCategoryTemplate = ({ hasteModuleName, structName, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, structName: string, -|}>) => `@implementation RCTCxxConvert (${hasteModuleName}_${structName}) +}>) => `@implementation RCTCxxConvert (${hasteModuleName}_${structName}) + (RCTManagedPointer *)JS_${hasteModuleName}_${structName}:(id)json { return facebook::react::managedPointer(json); @@ -76,12 +76,12 @@ const InlineHostFunctionTemplate = ({ methodName, returnJSType, selector, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, methodName: string, returnJSType: string, selector: string, -|}>) => ` +}>) => ` static facebook::jsi::Value __hostFunction_${hasteModuleName}SpecJSI_${methodName}(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { return static_cast(turboModule).invokeObjCMethod(rt, ${returnJSType}, "${methodName}", ${selector}, args, count); }`; @@ -91,12 +91,12 @@ const MethodMapEntryTemplate = ({ methodName, structParamRecords, argCount, -}: $ReadOnly<{| +}: $ReadOnly<{ hasteModuleName: string, methodName: string, structParamRecords: $ReadOnlyArray, argCount: number, -|}>) => ` +}>) => ` methodMap_["${methodName}"] = MethodMetadata {${argCount}, __hostFunction_${hasteModuleName}SpecJSI_${methodName}}; ${structParamRecords .map(({paramIndex, structName}) => { diff --git a/packages/react-native-codegen/src/generators/modules/Utils.js b/packages/react-native-codegen/src/generators/modules/Utils.js index e5b50c2ddd1e02..10017bb420bb0c 100644 --- a/packages/react-native-codegen/src/generators/modules/Utils.js +++ b/packages/react-native-codegen/src/generators/modules/Utils.js @@ -33,8 +33,8 @@ function createAliasResolver(aliasMap: NativeModuleAliasMap): AliasResolver { function getModules( schema: SchemaType, -): $ReadOnly<{|[hasteModuleName: string]: NativeModuleSchema|}> { - return Object.keys(schema.modules).reduce<{|[string]: NativeModuleSchema|}>( +): $ReadOnly<{[hasteModuleName: string]: NativeModuleSchema}> { + return Object.keys(schema.modules).reduce<{[string]: NativeModuleSchema}>( (modules, hasteModuleName: string) => { const module = schema.modules[hasteModuleName]; if (module == null || module.type === 'Component') { diff --git a/packages/react-native-codegen/src/parsers/flow/components/options.js b/packages/react-native-codegen/src/parsers/flow/components/options.js index 8044575db15913..607ac526aabce7 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/options.js +++ b/packages/react-native-codegen/src/parsers/flow/components/options.js @@ -15,9 +15,9 @@ import type {OptionsShape} from '../../../CodegenSchema.js'; // $FlowFixMe there's no flowtype for ASTs type OptionsAST = Object; -export type CommandOptions = $ReadOnly<{| +export type CommandOptions = $ReadOnly<{ supportedCommands: $ReadOnlyArray, -|}>; +}>; function getCommandOptions( commandOptionsExpression: OptionsAST, diff --git a/packages/react-native-codegen/src/parsers/flow/components/schema.js b/packages/react-native-codegen/src/parsers/flow/components/schema.js index d48e186d7e089b..21ce46d6856ea0 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/schema.js +++ b/packages/react-native-codegen/src/parsers/flow/components/schema.js @@ -20,7 +20,7 @@ import type { OptionsShape, } from '../../../CodegenSchema.js'; -export type ComponentSchemaBuilderConfig = $ReadOnly<{| +export type ComponentSchemaBuilderConfig = $ReadOnly<{ filename: string, componentName: string, extendsProps: $ReadOnlyArray, @@ -28,7 +28,7 @@ export type ComponentSchemaBuilderConfig = $ReadOnly<{| props: $ReadOnlyArray>, commands: $ReadOnlyArray>, options?: ?OptionsShape, -|}>; +}>; function wrapComponentSchema({ filename, diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js index fc03e16e360ad8..ef3354df45f3e2 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js @@ -49,9 +49,9 @@ const RESERVED_FUNCTION_VALUE_TYPE_NAME: $ReadOnlyArray<'RootTag'> = [ const MODULE_NAME = 'NativeFoo'; const TYPE_ALIAS_DECLARATIONS = ` -type Animal = {| +type Animal = { name: string, -|}; +}; type AnimalPointer = Animal; `; @@ -288,10 +288,10 @@ describe('Flow Module Parser', () => { expectAnimalTypeAliasToExist(module); }); - it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array<{|foo: ?string|}>'`, () => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array<{foo: ?string}>'`, () => { const [elementType] = parseParamArrayElementType( 'arg', - '{|foo: ?string|}', + '{foo: ?string}', ); expect(elementType).not.toBe(null); @@ -351,9 +351,9 @@ describe('Flow Module Parser', () => { import type {TurboModule} from 'RCTExport'; import * as TurboModuleRegistry from 'TurboModuleRegistry'; - type Animal = ?{| + type Animal = ?{ name: string, - |}; + }; type AnimalPointer = Animal; @@ -428,7 +428,7 @@ describe('Flow Module Parser', () => { ] { const [paramTypeAnnotation, module] = parseParamType( 'arg', - `{|${annotateProp(propName, propType)}|}`, + `{${annotateProp(propName, propType)}}`, ); expect(paramTypeAnnotation.type).toBe('ObjectTypeAnnotation'); @@ -608,10 +608,10 @@ describe('Flow Module Parser', () => { expectAnimalTypeAliasToExist(module); }); - it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of 'Array<{|foo: ?string|}>'`, () => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of 'Array<{foo: ?string}>'`, () => { const [elementType] = parseArrayElementType( 'prop', - '{|foo: ?string|}', + '{foo: ?string}', ); expect(elementType.type).toBe('ObjectTypeAnnotation'); @@ -638,10 +638,10 @@ describe('Flow Module Parser', () => { }); }); - it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type '{|foo: ?string|}'`, () => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type '{foo: ?string}'`, () => { const [property] = parseParamTypeObjectLiteralProp( 'prop', - '{|foo: ?string|}', + '{foo: ?string}', ); expect(property.typeAnnotation.type).toBe( @@ -764,7 +764,7 @@ describe('Flow Module Parser', () => { describe( IS_RETURN_TYPE_NULLABLE ? 'Nullable Returns' : 'Non-Nullable Returns', () => { - ['Promise', 'Promise<{||}>', 'Promise<*>'].forEach( + ['Promise', 'Promise<{}>', 'Promise<*>'].forEach( promiseFlowType => { it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type '${promiseFlowType}'`, () => { const [returnTypeAnnotation] = parseReturnType(promiseFlowType); @@ -872,9 +872,9 @@ describe('Flow Module Parser', () => { expectAnimalTypeAliasToExist(module); }); - it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<{|foo: ?string|}>'`, () => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<{foo: ?string}>'`, () => { const [elementType] = parseArrayElementReturnType( - '{|foo: ?string|}', + '{foo: ?string}', ); expect(elementType.type).toBe('ObjectTypeAnnotation'); invariant(elementType.type === 'ObjectTypeAnnotation', ''); @@ -926,7 +926,7 @@ describe('Flow Module Parser', () => { // TODO: Inexact vs exact object literals? it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an empty object literal`, () => { - const [returnTypeAnnotation] = parseReturnType('{||}'); + const [returnTypeAnnotation] = parseReturnType('{}'); expect(returnTypeAnnotation.type).toBe('ObjectTypeAnnotation'); invariant( returnTypeAnnotation.type === 'ObjectTypeAnnotation', @@ -978,7 +978,7 @@ describe('Flow Module Parser', () => { NativeModuleSchema, ] { const [returnTypeAnnotation, module] = parseReturnType( - `{|${annotateProp(propName, propType)}|}`, + `{${annotateProp(propName, propType)}}`, ); expect(returnTypeAnnotation.type).toBe('ObjectTypeAnnotation'); invariant( @@ -1168,10 +1168,10 @@ describe('Flow Module Parser', () => { expectAnimalTypeAliasToExist(module); }); - it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<{|foo: ?string|}>'`, () => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<{foo: ?string}>'`, () => { const [elementType] = parseArrayElementType( 'prop', - '{|foo: ?string|}', + '{foo: ?string}', ); expect(elementType.type).toBe('ObjectTypeAnnotation'); invariant( @@ -1198,10 +1198,10 @@ describe('Flow Module Parser', () => { }); }); - it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of '{|foo: ?string|}'`, () => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of '{foo: ?string}'`, () => { const [property] = parseObjectLiteralReturnTypeProp( 'prop', - '{|foo: ?string|}', + '{foo: ?string}', ); expect(property.typeAnnotation.type).toBe( diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 7bcff0dd894db9..c95308c7e5e802 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -288,9 +288,9 @@ function translateTypeAnnotation( * * Consider this case: * - * type Animal = ?{| + * type Animal = ?{ * name: string, - * |}; + * }; * * type B = Animal * @@ -298,11 +298,11 @@ function translateTypeAnnotation( * +greet: (animal: B) => void; * } * - * In this case, we follow B to Animal, and then Animal to ?{|name: string|}. + * In this case, we follow B to Animal, and then Animal to ?{name: string}. * * We: * 1. Replace `+greet: (animal: B) => void;` with `+greet: (animal: ?Animal) => void;`, - * 2. Pretend that Animal = {|name: string|}. + * 2. Pretend that Animal = {name: string}. * * Why do we do this? * 1. In ObjC, we need to generate a struct called Animal, not B. @@ -572,10 +572,10 @@ function buildModuleSchema( const declaration = types[moduleInterfaceName]; return (declaration.body.properties: $ReadOnlyArray<$FlowFixMe>) .filter(property => property.type === 'ObjectTypeProperty') - .map(property => { + }>(property => { const aliasMap: {...NativeModuleAliasMap} = {}; return guard(() => ({ diff --git a/packages/react-native-codegen/src/parsers/flow/utils.js b/packages/react-native-codegen/src/parsers/flow/utils.js index 8bc2770b44ea4b..d96f4d1b52ef99 100644 --- a/packages/react-native-codegen/src/parsers/flow/utils.js +++ b/packages/react-native-codegen/src/parsers/flow/utils.js @@ -20,7 +20,7 @@ const {ParserError} = require('./errors'); * * TODO(T71778680): Flow type AST Nodes */ -export type TypeDeclarationMap = {|[declarationName: string]: $FlowFixMe|}; +export type TypeDeclarationMap = {[declarationName: string]: $FlowFixMe}; function getTypes(ast: $FlowFixMe): TypeDeclarationMap { return ast.body.reduce((types, node) => { @@ -47,13 +47,13 @@ export type ASTNode = Object; const invariant = require('invariant'); type TypeAliasResolutionStatus = - | $ReadOnly<{| + | $ReadOnly<{ successful: true, aliasName: string, - |}> - | $ReadOnly<{| + }> + | $ReadOnly<{ successful: false, - |}>; + }>; function resolveTypeAnnotation( // TODO(T71778680): This is an Flow TypeAnnotation. Flow-type this From 017bc911928472e20f37dd9512a2113a7d93c81b Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Sat, 7 Nov 2020 01:31:01 -0800 Subject: [PATCH 0030/1810] Log prefetched image's view controller moduleName and GraphQL queryRootName Reviewed By: fkgozali, rubennorte Differential Revision: D24683194 fbshipit-source-id: 5a3f37123c0d9f6f40124e131212e6bf190193cc --- Libraries/Image/Image.android.js | 22 +++++++++++++++ Libraries/Image/Image.ios.js | 28 +++++++++++++++++++ Libraries/Image/NativeImageLoaderIOS.js | 5 ++++ Libraries/Image/RCTImageLoader.mm | 25 +++++++++++++++-- .../Image/RCTImageURLLoaderWithAttribution.h | 1 + 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 5e57732a855424..90b1a2652e7e0c 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -194,6 +194,16 @@ function getSizeWithHeaders( ); } +function prefetchWithMetadata( + url: string, + queryRootName: string, + rootTag?: ?number, + callback: ?Function, +): any { + // TODO: T79192300 Log queryRootName and rootTag + prefetch(url, callback); +} + function prefetch(url: string, callback: ?Function): any { const requestId = generateRequestId(); callback && callback(requestId); @@ -219,6 +229,7 @@ type ImageComponentStatics = $ReadOnly<{| getSize: typeof getSize, getSizeWithHeaders: typeof getSizeWithHeaders, prefetch: typeof prefetch, + prefetchWithMetadata: typeof prefetchWithMetadata, abortPrefetch: typeof abortPrefetch, queryCache: typeof queryCache, resolveAssetSource: typeof resolveAssetSource, @@ -358,6 +369,17 @@ Image.getSizeWithHeaders = getSizeWithHeaders; * comment and run Flow. */ Image.prefetch = prefetch; +/** + * Prefetches a remote image for later use by downloading it to the disk + * cache, and adds metadata for queryRootName and rootTag. + * + * See https://reactnative.dev/docs/image.html#prefetch + */ +/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an + * error found when Flow v0.89 was deployed. To see the error, delete this + * comment and run Flow. */ +Image.prefetchWithMetadata = prefetchWithMetadata; + /** * Abort prefetch request. * diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index e5ff46e73827bf..5938d48e80651f 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -59,6 +59,22 @@ function getSizeWithHeaders( ); } +function prefetchWithMetadata( + url: string, + queryRootName: string, + rootTag?: ?number, +): any { + if (NativeImageLoaderIOS.prefetchImageWithMetadata) { + return NativeImageLoaderIOS.prefetchImageWithMetadata( + url, + queryRootName, + rootTag, + ); + } else { + return NativeImageLoaderIOS.prefetchImage(url); + } +} + function prefetch(url: string): any { return NativeImageLoaderIOS.prefetchImage(url); } @@ -73,6 +89,7 @@ type ImageComponentStatics = $ReadOnly<{| getSize: typeof getSize, getSizeWithHeaders: typeof getSizeWithHeaders, prefetch: typeof prefetch, + prefetchWithMetadata: typeof prefetchWithMetadata, queryCache: typeof queryCache, resolveAssetSource: typeof resolveAssetSource, propTypes: typeof DeprecatedImagePropType, @@ -181,6 +198,17 @@ Image.getSizeWithHeaders = getSizeWithHeaders; * comment and run Flow. */ Image.prefetch = prefetch; +/** + * Prefetches a remote image for later use by downloading it to the disk + * cache, and adds metadata for queryRootName and rootTag. + * + * See https://reactnative.dev/docs/image.html#prefetch + */ +/* $FlowFixMe(>=0.89.0 site=react_native_ios_fb) This comment suppresses an + * error found when Flow v0.89 was deployed. To see the error, delete this + * comment and run Flow. */ +Image.prefetchWithMetadata = prefetchWithMetadata; + /** * Performs cache interrogation. * diff --git a/Libraries/Image/NativeImageLoaderIOS.js b/Libraries/Image/NativeImageLoaderIOS.js index 842294d0af2a75..cee864e675a872 100644 --- a/Libraries/Image/NativeImageLoaderIOS.js +++ b/Libraries/Image/NativeImageLoaderIOS.js @@ -26,6 +26,11 @@ export interface Spec extends TurboModule { ... }>; +prefetchImage: (uri: string) => Promise; + +prefetchImageWithMetadata?: ( + uri: string, + queryRootName: string, + rootTag?: ?number, + ) => Promise; +queryCache: (uris: Array) => Promise; } diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index a1962a92c4e9f7..f6a6dbb59eba88 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -187,7 +187,7 @@ - (void)setImageCache:(id)cache if (!_loaders) { std::unique_lock guard(_loadersMutex); if (!_loaders) { - + // Get loaders, sorted in reverse priority order (highest priority first) if (_loadersProvider) { _loaders = _loadersProvider(); @@ -1196,11 +1196,30 @@ - (void)cancelRequest:(id)requestToken RCT_EXPORT_METHOD(prefetchImage:(NSString *)uri resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) +{ + [self prefetchImageWithMetadata:uri queryRootName:nil rootTag:nil resolve:resolve reject:reject]; +} + +RCT_EXPORT_METHOD(prefetchImageWithMetadata:(NSString *)uri + queryRootName:(NSString *)queryRootName + rootTag:(NSNumber *)rootTag + resolve:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) { NSURLRequest *request = [RCTConvert NSURLRequest:uri]; [self loadImageWithURLRequest:request - priority:RCTImageLoaderPriorityPrefetch - callback:^(NSError *error, UIImage *image) { + size:CGSizeZero + scale:1 + clipped:YES + resizeMode:RCTResizeModeStretch + priority:RCTImageLoaderPriorityPrefetch + attribution:{ + .queryRootName = queryRootName ? [queryRootName UTF8String] : "", + .surfaceId = [rootTag intValue], + } + progressBlock:nil + partialLoadBlock:nil + completionBlock:^(NSError *error, UIImage *image, id completionMetadata) { if (error) { reject(@"E_PREFETCH_FAILURE", nil, error); return; diff --git a/Libraries/Image/RCTImageURLLoaderWithAttribution.h b/Libraries/Image/RCTImageURLLoaderWithAttribution.h index ae6a333b26a296..118bed138057e9 100644 --- a/Libraries/Image/RCTImageURLLoaderWithAttribution.h +++ b/Libraries/Image/RCTImageURLLoaderWithAttribution.h @@ -17,6 +17,7 @@ namespace react { struct ImageURLLoaderAttribution { int32_t nativeViewTag = 0; int32_t surfaceId = 0; + std::string queryRootName; NSString *analyticTag; }; From a99b46aabb827280be55257459ad741e1a772947 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 8 Nov 2020 06:07:07 -0800 Subject: [PATCH 0031/1810] Upgrade to Babel 7.12.6 Summary: Monthly Babel update. As usual, I wait until there are multiple point releases because the Babel team tends to always break a lot of things in the first ~3 patch releases. Release Notes: https://github.com/babel/babel/releases from 7.12.0 -> 7.12.6 inclusive. From a check of each change, nothing immediately jumps out as something that would impact us. Changelog: [Internal] Reviewed By: MichaReiser Differential Revision: D24723845 fbshipit-source-id: 7db8daa119a4e34cd1fd4f61e7a635fcaf4e4a91 --- yarn.lock | 913 +++++++++++++++++++++++++++--------------------------- 1 file changed, 459 insertions(+), 454 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8c9d469a21887e..e35673ccc6d4be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,305 +2,309 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" - integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g== +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" + integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== dependencies: - "@babel/highlight" "^7.8.3" + "@babel/highlight" "^7.10.4" "@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.4.5", "@babel/core@^7.7.5": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.10.0.tgz#a6fe5db77ebfb61e0da6c5c36aaf14aab07b2b44" - integrity sha512-FGgV2XyPoVtYDvbFXlukEWt13Afka4mBRQ2CoTsHxpgVGO6XfgtT6eI+WyjQRGGTL90IDkIVmme8riFCLZ8lUw== - dependencies: - "@babel/code-frame" "^7.8.3" - "@babel/generator" "^7.10.0" - "@babel/helper-module-transforms" "^7.9.0" - "@babel/helpers" "^7.10.0" - "@babel/parser" "^7.10.0" - "@babel/template" "^7.10.0" - "@babel/traverse" "^7.10.0" - "@babel/types" "^7.10.0" + version "7.12.3" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.3.tgz#1b436884e1e3bff6fb1328dc02b208759de92ad8" + integrity sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/generator" "^7.12.1" + "@babel/helper-module-transforms" "^7.12.1" + "@babel/helpers" "^7.12.1" + "@babel/parser" "^7.12.3" + "@babel/template" "^7.10.4" + "@babel/traverse" "^7.12.1" + "@babel/types" "^7.12.1" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.1" json5 "^2.1.2" - lodash "^4.17.13" + lodash "^4.17.19" resolve "^1.3.2" semver "^5.4.1" source-map "^0.5.0" -"@babel/generator@^7.10.0", "@babel/generator@^7.5.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.10.0.tgz#a238837896edf35ee5fbfb074548d3256b4bc55d" - integrity sha512-ThoWCJHlgukbtCP79nAK4oLqZt5fVo70AHUni/y8Jotyg5rtJiG2FVl+iJjRNKIyl4hppqztLyAoEWcCvqyOFQ== +"@babel/generator@^7.12.1", "@babel/generator@^7.12.5", "@babel/generator@^7.5.0": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.5.tgz#a2c50de5c8b6d708ab95be5e6053936c1884a4de" + integrity sha512-m16TQQJ8hPt7E+OS/XVQg/7U184MLXtvuGbCdA7na61vha+ImkyyNM/9DDA0unYCVZn3ZOhng+qz48/KBOT96A== dependencies: - "@babel/types" "^7.10.0" + "@babel/types" "^7.12.5" jsesc "^2.5.1" - lodash "^4.17.13" source-map "^0.5.0" -"@babel/helper-annotate-as-pure@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.8.3.tgz#60bc0bc657f63a0924ff9a4b4a0b24a13cf4deee" - integrity sha512-6o+mJrZBxOoEX77Ezv9zwW7WV8DdluouRKNY/IR5u/YTMuKHgugHOzYWlYvYLpLA9nPsQCAAASpCIbjI9Mv+Uw== +"@babel/helper-annotate-as-pure@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3" + integrity sha512-XQlqKQP4vXFB7BN8fEEerrmYvHp3fK/rBkRFz9jaJbzK0B1DSfej9Kc7ZzE8Z/OnId1jpJdNAZ3BFQjWG68rcA== dependencies: - "@babel/types" "^7.8.3" + "@babel/types" "^7.10.4" -"@babel/helper-builder-binary-assignment-operator-visitor@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.8.3.tgz#c84097a427a061ac56a1c30ebf54b7b22d241503" - integrity sha512-5eFOm2SyFPK4Rh3XMMRDjN7lBH0orh3ss0g3rTYZnBQ+r6YPj7lgDyCvPphynHvUrobJmeMignBr6Acw9mAPlw== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.8.3" - "@babel/types" "^7.8.3" - -"@babel/helper-builder-react-jsx-experimental@^7.9.0": - version "7.9.5" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx-experimental/-/helper-builder-react-jsx-experimental-7.9.5.tgz#0b4b3e04e6123f03b404ca4dfd6528fe6bb92fe3" - integrity sha512-HAagjAC93tk748jcXpZ7oYRZH485RCq/+yEv9SIWezHRPv9moZArTnkUNciUNzvwHUABmiWKlcxJvMcu59UwTg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.8.3" - "@babel/helper-module-imports" "^7.8.3" - "@babel/types" "^7.9.5" - -"@babel/helper-builder-react-jsx@^7.9.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.9.0.tgz#16bf391990b57732700a3278d4d9a81231ea8d32" - integrity sha512-weiIo4gaoGgnhff54GQ3P5wsUQmnSwpkvU0r6ZHq6TzoSzKy4JxHEgnxNytaKbov2a9z/CVNyzliuCOUPEX3Jw== - dependencies: - "@babel/helper-annotate-as-pure" "^7.8.3" - "@babel/types" "^7.9.0" - -"@babel/helper-create-class-features-plugin@^7.10.0", "@babel/helper-create-class-features-plugin@^7.8.3": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.10.0.tgz#3a2b7b86f6365ea4ac3837a49ec5791e65217944" - integrity sha512-n4tPJaI0iuLRayriXTQ8brP3fMA/fNmxpxswfNuhe4qXQbcCWzeAqm6SeR/KExIOcdCvOh/KkPQVgBsjcb0oqA== - dependencies: - "@babel/helper-function-name" "^7.9.5" - "@babel/helper-member-expression-to-functions" "^7.10.0" - "@babel/helper-optimise-call-expression" "^7.10.0" - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/helper-replace-supers" "^7.10.0" - "@babel/helper-split-export-declaration" "^7.8.3" - -"@babel/helper-create-regexp-features-plugin@^7.8.3": - version "7.8.8" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.8.8.tgz#5d84180b588f560b7864efaeea89243e58312087" - integrity sha512-LYVPdwkrQEiX9+1R29Ld/wTrmQu1SSKYnuOk3g0CkcZMA1p0gsNxJFj/3gBdaJ7Cg0Fnek5z0DsMULePP7Lrqg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.8.3" - "@babel/helper-regex" "^7.8.3" - regexpu-core "^4.7.0" - -"@babel/helper-define-map@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.8.3.tgz#a0655cad5451c3760b726eba875f1cd8faa02c15" - integrity sha512-PoeBYtxoZGtct3md6xZOCWPcKuMuk3IHhgxsRRNtnNShebf4C8YonTSblsK4tvDbm+eJAw2HAPOfCr+Q/YRG/g== +"@babel/helper-builder-binary-assignment-operator-visitor@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.10.4.tgz#bb0b75f31bf98cbf9ff143c1ae578b87274ae1a3" + integrity sha512-L0zGlFrGWZK4PbT8AszSfLTM5sDU1+Az/En9VrdT8/LmEiJt4zXt+Jve9DCAnQcbqDhCI+29y/L93mrDzddCcg== dependencies: - "@babel/helper-function-name" "^7.8.3" - "@babel/types" "^7.8.3" - lodash "^4.17.13" + "@babel/helper-explode-assignable-expression" "^7.10.4" + "@babel/types" "^7.10.4" -"@babel/helper-explode-assignable-expression@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.8.3.tgz#a728dc5b4e89e30fc2dfc7d04fa28a930653f982" - integrity sha512-N+8eW86/Kj147bO9G2uclsg5pwfs/fqqY5rwgIL7eTBklgXjcOJ3btzS5iM6AitJcftnY7pm2lGsrJVYLGjzIw== +"@babel/helper-builder-react-jsx-experimental@^7.12.1": + version "7.12.4" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx-experimental/-/helper-builder-react-jsx-experimental-7.12.4.tgz#55fc1ead5242caa0ca2875dcb8eed6d311e50f48" + integrity sha512-AjEa0jrQqNk7eDQOo0pTfUOwQBMF+xVqrausQwT9/rTKy0g04ggFNaJpaE09IQMn9yExluigWMJcj0WC7bq+Og== dependencies: - "@babel/traverse" "^7.8.3" - "@babel/types" "^7.8.3" + "@babel/helper-annotate-as-pure" "^7.10.4" + "@babel/helper-module-imports" "^7.12.1" + "@babel/types" "^7.12.1" -"@babel/helper-function-name@^7.8.3", "@babel/helper-function-name@^7.9.5": - version "7.9.5" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz#2b53820d35275120e1874a82e5aabe1376920a5c" - integrity sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw== +"@babel/helper-builder-react-jsx@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.10.4.tgz#8095cddbff858e6fa9c326daee54a2f2732c1d5d" + integrity sha512-5nPcIZ7+KKDxT1427oBivl9V9YTal7qk0diccnh7RrcgrT/pGFOjgGw1dgryyx1GvHEpXVfoDF6Ak3rTiWh8Rg== dependencies: - "@babel/helper-get-function-arity" "^7.8.3" - "@babel/template" "^7.8.3" - "@babel/types" "^7.9.5" + "@babel/helper-annotate-as-pure" "^7.10.4" + "@babel/types" "^7.10.4" -"@babel/helper-get-function-arity@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz#b894b947bd004381ce63ea1db9f08547e920abd5" - integrity sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA== +"@babel/helper-create-class-features-plugin@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.1.tgz#3c45998f431edd4a9214c5f1d3ad1448a6137f6e" + integrity sha512-hkL++rWeta/OVOBTRJc9a5Azh5mt5WgZUGAKMD8JM141YsE08K//bp1unBBieO6rUKkIPyUE0USQ30jAy3Sk1w== dependencies: - "@babel/types" "^7.8.3" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-member-expression-to-functions" "^7.12.1" + "@babel/helper-optimise-call-expression" "^7.10.4" + "@babel/helper-replace-supers" "^7.12.1" + "@babel/helper-split-export-declaration" "^7.10.4" -"@babel/helper-member-expression-to-functions@^7.10.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.0.tgz#e8cf57470bfd1247f2b41aa621a527e952efa6f1" - integrity sha512-xKLTpbMkJcvwEsDaTfs9h0IlfUiBLPFfybxaPpPPsQDsZTRg+UKh+86oK7sctHF3OUiRQkb10oS9MXSqgyV6/g== +"@babel/helper-create-regexp-features-plugin@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.12.1.tgz#18b1302d4677f9dc4740fe8c9ed96680e29d37e8" + integrity sha512-rsZ4LGvFTZnzdNZR5HZdmJVuXK8834R5QkF3WvcnBhrlVtF0HSIUC6zbreL9MgjTywhKokn8RIYRiq99+DLAxA== dependencies: - "@babel/types" "^7.10.0" + "@babel/helper-annotate-as-pure" "^7.10.4" + "@babel/helper-regex" "^7.10.4" + regexpu-core "^4.7.1" -"@babel/helper-module-imports@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz#7fe39589b39c016331b6b8c3f441e8f0b1419498" - integrity sha512-R0Bx3jippsbAEtzkpZ/6FIiuzOURPcMjHp+Z6xPe6DtApDJx+w7UYyOLanZqO8+wKR9G10s/FmHXvxaMd9s6Kg== +"@babel/helper-define-map@^7.10.4": + version "7.10.5" + resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.10.5.tgz#b53c10db78a640800152692b13393147acb9bb30" + integrity sha512-fMw4kgFB720aQFXSVaXr79pjjcW5puTCM16+rECJ/plGS+zByelE8l9nCpV1GibxTnFVmUuYG9U8wYfQHdzOEQ== dependencies: - "@babel/types" "^7.8.3" + "@babel/helper-function-name" "^7.10.4" + "@babel/types" "^7.10.5" + lodash "^4.17.19" -"@babel/helper-module-transforms@^7.9.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.9.0.tgz#43b34dfe15961918707d247327431388e9fe96e5" - integrity sha512-0FvKyu0gpPfIQ8EkxlrAydOWROdHpBmiCiRwLkUiBGhCUPRRbVD2/tm3sFr/c/GWFrQ/ffutGUAnx7V0FzT2wA== +"@babel/helper-explode-assignable-expression@^7.10.4": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.12.1.tgz#8006a466695c4ad86a2a5f2fb15b5f2c31ad5633" + integrity sha512-dmUwH8XmlrUpVqgtZ737tK88v07l840z9j3OEhCLwKTkjlvKpfqXVIZ0wpK3aeOxspwGrf/5AP5qLx4rO3w5rA== dependencies: - "@babel/helper-module-imports" "^7.8.3" - "@babel/helper-replace-supers" "^7.8.6" - "@babel/helper-simple-access" "^7.8.3" - "@babel/helper-split-export-declaration" "^7.8.3" - "@babel/template" "^7.8.6" - "@babel/types" "^7.9.0" - lodash "^4.17.13" + "@babel/types" "^7.12.1" -"@babel/helper-optimise-call-expression@^7.10.0", "@babel/helper-optimise-call-expression@^7.8.3": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.0.tgz#6dcfb565842f43bed31b24f3e4277f18826e5e79" - integrity sha512-HgMd8QKA8wMJs5uK/DYKdyzJAEuGt1zyDp9wLMlMR6LitTQTHPUE+msC82ZsEDwq+U3/yHcIXIngRm9MS4IcIg== +"@babel/helper-function-name@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz#d2d3b20c59ad8c47112fa7d2a94bc09d5ef82f1a" + integrity sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ== dependencies: - "@babel/types" "^7.10.0" + "@babel/helper-get-function-arity" "^7.10.4" + "@babel/template" "^7.10.4" + "@babel/types" "^7.10.4" -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": +"@babel/helper-get-function-arity@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz#98c1cbea0e2332f33f9a4661b8ce1505b2c19ba2" + integrity sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A== + dependencies: + "@babel/types" "^7.10.4" + +"@babel/helper-member-expression-to-functions@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.1.tgz#fba0f2fcff3fba00e6ecb664bb5e6e26e2d6165c" + integrity sha512-k0CIe3tXUKTRSoEx1LQEPFU9vRQfqHtl+kf8eNnDqb4AUJEy5pz6aIiog+YWtVm2jpggjS1laH68bPsR+KWWPQ== + dependencies: + "@babel/types" "^7.12.1" + +"@babel/helper-module-imports@^7.12.1": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.5.tgz#1bfc0229f794988f76ed0a4d4e90860850b54dfb" + integrity sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA== + dependencies: + "@babel/types" "^7.12.5" + +"@babel/helper-module-transforms@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.12.1.tgz#7954fec71f5b32c48e4b303b437c34453fd7247c" + integrity sha512-QQzehgFAZ2bbISiCpmVGfiGux8YVFXQ0abBic2Envhej22DVXV9nCFaS5hIQbkyo1AdGb+gNME2TSh3hYJVV/w== + dependencies: + "@babel/helper-module-imports" "^7.12.1" + "@babel/helper-replace-supers" "^7.12.1" + "@babel/helper-simple-access" "^7.12.1" + "@babel/helper-split-export-declaration" "^7.11.0" + "@babel/helper-validator-identifier" "^7.10.4" + "@babel/template" "^7.10.4" + "@babel/traverse" "^7.12.1" + "@babel/types" "^7.12.1" + lodash "^4.17.19" + +"@babel/helper-optimise-call-expression@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz#50dc96413d594f995a77905905b05893cd779673" + integrity sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg== + dependencies: + "@babel/types" "^7.10.4" + +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.8.0": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== -"@babel/helper-regex@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.8.3.tgz#139772607d51b93f23effe72105b319d2a4c6965" - integrity sha512-BWt0QtYv/cg/NecOAZMdcn/waj/5P26DR4mVLXfFtDokSR6fyuG0Pj+e2FqtSME+MqED1khnSMulkmGl8qWiUQ== +"@babel/helper-regex@^7.10.4": + version "7.10.5" + resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.10.5.tgz#32dfbb79899073c415557053a19bd055aae50ae0" + integrity sha512-68kdUAzDrljqBrio7DYAEgCoJHxppJOERHOgOrDN7WjOzP0ZQ1LsSDRXcemzVZaLvjaJsJEESb6qt+znNuENDg== dependencies: - lodash "^4.17.13" + lodash "^4.17.19" -"@babel/helper-remap-async-to-generator@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.8.3.tgz#273c600d8b9bf5006142c1e35887d555c12edd86" - integrity sha512-kgwDmw4fCg7AVgS4DukQR/roGp+jP+XluJE5hsRZwxCYGg+Rv9wSGErDWhlI90FODdYfd4xG4AQRiMDjjN0GzA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.8.3" - "@babel/helper-wrap-function" "^7.8.3" - "@babel/template" "^7.8.3" - "@babel/traverse" "^7.8.3" - "@babel/types" "^7.8.3" - -"@babel/helper-replace-supers@^7.10.0", "@babel/helper-replace-supers@^7.8.3", "@babel/helper-replace-supers@^7.8.6": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.10.0.tgz#26bc22ee1a35450934d2e2a9b27de10a22fac9d6" - integrity sha512-erl4iVeiANf14JszXP7b69bSrz3e3+qW09pVvEmTWwzRQEOoyb1WFlYCA8d/VjVZGYW8+nGpLh7swf9CifH5wg== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.10.0" - "@babel/helper-optimise-call-expression" "^7.10.0" - "@babel/traverse" "^7.10.0" - "@babel/types" "^7.10.0" - -"@babel/helper-simple-access@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.8.3.tgz#7f8109928b4dab4654076986af575231deb639ae" - integrity sha512-VNGUDjx5cCWg4vvCTR8qQ7YJYZ+HBjxOgXEl7ounz+4Sn7+LMD3CFrCTEU6/qXKbA2nKg21CwhhBzO0RpRbdCw== +"@babel/helper-remap-async-to-generator@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.12.1.tgz#8c4dbbf916314f6047dc05e6a2217074238347fd" + integrity sha512-9d0KQCRM8clMPcDwo8SevNs+/9a8yWVVmaE80FGJcEP8N1qToREmWEGnBn8BUlJhYRFz6fqxeRL1sl5Ogsed7A== dependencies: - "@babel/template" "^7.8.3" - "@babel/types" "^7.8.3" + "@babel/helper-annotate-as-pure" "^7.10.4" + "@babel/helper-wrap-function" "^7.10.4" + "@babel/types" "^7.12.1" -"@babel/helper-split-export-declaration@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz#31a9f30070f91368a7182cf05f831781065fc7a9" - integrity sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA== +"@babel/helper-replace-supers@^7.12.1": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.12.5.tgz#f009a17543bbbbce16b06206ae73b63d3fca68d9" + integrity sha512-5YILoed0ZyIpF4gKcpZitEnXEJ9UoDRki1Ey6xz46rxOzfNMAhVIJMoune1hmPVxh40LRv1+oafz7UsWX+vyWA== + dependencies: + "@babel/helper-member-expression-to-functions" "^7.12.1" + "@babel/helper-optimise-call-expression" "^7.10.4" + "@babel/traverse" "^7.12.5" + "@babel/types" "^7.12.5" + +"@babel/helper-simple-access@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.12.1.tgz#32427e5aa61547d38eb1e6eaf5fd1426fdad9136" + integrity sha512-OxBp7pMrjVewSSC8fXDFrHrBcJATOOFssZwv16F3/6Xtc138GHybBfPbm9kfiqQHKhYQrlamWILwlDCeyMFEaA== dependencies: - "@babel/types" "^7.8.3" + "@babel/types" "^7.12.1" -"@babel/helper-validator-identifier@^7.9.0", "@babel/helper-validator-identifier@^7.9.5": - version "7.9.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80" - integrity sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g== +"@babel/helper-skip-transparent-expression-wrappers@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.12.1.tgz#462dc63a7e435ade8468385c63d2b84cce4b3cbf" + integrity sha512-Mf5AUuhG1/OCChOJ/HcADmvcHM42WJockombn8ATJG3OnyiSxBK/Mm5x78BQWvmtXZKHgbjdGL2kin/HOLlZGA== + dependencies: + "@babel/types" "^7.12.1" -"@babel/helper-wrap-function@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.8.3.tgz#9dbdb2bb55ef14aaa01fe8c99b629bd5352d8610" - integrity sha512-LACJrbUET9cQDzb6kG7EeD7+7doC3JNvUgTEQOx2qaO1fKlzE/Bf05qs9w1oXQMmXlPO65lC3Tq9S6gZpTErEQ== +"@babel/helper-split-export-declaration@^7.10.4", "@babel/helper-split-export-declaration@^7.11.0": + version "7.11.0" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz#f8a491244acf6a676158ac42072911ba83ad099f" + integrity sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg== + dependencies: + "@babel/types" "^7.11.0" + +"@babel/helper-validator-identifier@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" + integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== + +"@babel/helper-wrap-function@^7.10.4": + version "7.12.3" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.12.3.tgz#3332339fc4d1fbbf1c27d7958c27d34708e990d9" + integrity sha512-Cvb8IuJDln3rs6tzjW3Y8UeelAOdnpB8xtQ4sme2MSZ9wOxrbThporC0y/EtE16VAtoyEfLM404Xr1e0OOp+ow== dependencies: - "@babel/helper-function-name" "^7.8.3" - "@babel/template" "^7.8.3" - "@babel/traverse" "^7.8.3" - "@babel/types" "^7.8.3" + "@babel/helper-function-name" "^7.10.4" + "@babel/template" "^7.10.4" + "@babel/traverse" "^7.10.4" + "@babel/types" "^7.10.4" -"@babel/helpers@^7.10.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.10.0.tgz#634400a0977b8dcf7b311761a77ca94ed974b3b6" - integrity sha512-lQtFJoDZAGf/t2PgR6Z59Q2MwjvOGGsxZ0BAlsrgyDhKuMbe63EfbQmVmcLfyTBj8J4UtiadQimcotvYVg/kVQ== +"@babel/helpers@^7.12.1": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.12.5.tgz#1a1ba4a768d9b58310eda516c449913fe647116e" + integrity sha512-lgKGMQlKqA8meJqKsW6rUnc4MdUk35Ln0ATDqdM1a/UpARODdI4j5Y5lVfUScnSNkJcdCRAaWkspykNoFg9sJA== dependencies: - "@babel/template" "^7.10.0" - "@babel/traverse" "^7.10.0" - "@babel/types" "^7.10.0" + "@babel/template" "^7.10.4" + "@babel/traverse" "^7.12.5" + "@babel/types" "^7.12.5" -"@babel/highlight@^7.8.3": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079" - integrity sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ== +"@babel/highlight@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" + integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== dependencies: - "@babel/helper-validator-identifier" "^7.9.0" + "@babel/helper-validator-identifier" "^7.10.4" chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.10.0", "@babel/parser@^7.7.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.10.0.tgz#8eca3e71a73dd562c5222376b08253436bb4995b" - integrity sha512-fnDUl1Uy2gThM4IFVW4ISNHqr3cJrCsRkSCasFgx0XDO9JcttDS5ytyBc4Cu4X1+fjoo3IVvFbRD6TeFlHJlEQ== +"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.10.4", "@babel/parser@^7.12.3", "@babel/parser@^7.12.5", "@babel/parser@^7.7.0": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.5.tgz#b4af32ddd473c0bfa643bd7ff0728b8e71b81ea0" + integrity sha512-FVM6RZQ0mn2KCf1VUED7KepYeUWoVShczewOCfm3nzoBybaih51h+sYVVGthW9M6lPByEPTQf+xm27PBdlpwmQ== "@babel/plugin-external-helpers@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-external-helpers/-/plugin-external-helpers-7.8.3.tgz#5a94164d9af393b2820a3cdc407e28ebf237de4b" - integrity sha512-mx0WXDDiIl5DwzMtzWGRSPugXi9BxROS05GQrhLNbEamhBiicgn994ibwkyiBH+6png7bm/yA7AUsvHyCXi4Vw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-external-helpers/-/plugin-external-helpers-7.12.1.tgz#df474775860b3b8bdfeaedd45596cd2c7f36a2be" + integrity sha512-5VBqan0daXhDSRjrq2miABuELRwWJWFdM42Jvs/CDuhp+Es+fW+ISA5l+co8d+9oN3WLz/N3VvzyeseL3AvjxA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.1.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.8.3.tgz#5e06654af5cd04b608915aada9b2a6788004464e" - integrity sha512-EqFhbo7IosdgPgZggHaNObkmO1kNUe3slaKu54d5OWvy+p9QIKOzK1GAEpAIsZtWVtPXUHSMcT4smvDrCfY4AA== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de" + integrity sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w== dependencies: - "@babel/helper-create-class-features-plugin" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-create-class-features-plugin" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-proposal-export-default-from@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-default-from/-/plugin-proposal-export-default-from-7.8.3.tgz#4cb7c2fdeaed490b60d9bfd3dc8a20f81f9c2e7c" - integrity sha512-PYtv2S2OdCdp7GSPDg5ndGZFm9DmWFvuLoS5nBxZCgOBggluLnhTScspJxng96alHQzPyrrHxvC9/w4bFuspeA== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-default-from/-/plugin-proposal-export-default-from-7.12.1.tgz#c6e62d668a8abcfe0d28b82f560395fecb611c5a" + integrity sha512-z5Q4Ke7j0AexQRfgUvnD+BdCSgpTEKnqQ3kskk2jWtOBulxICzd1X9BGt7kmWftxZ2W3++OZdt5gtmC8KLxdRQ== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-export-default-from" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/plugin-syntax-export-default-from" "^7.12.1" "@babel/plugin-proposal-nullish-coalescing-operator@^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator@^7.1.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.8.3.tgz#e4572253fdeed65cddeecfdab3f928afeb2fd5d2" - integrity sha512-TS9MlfzXpXKt6YYomudb/KU7nQI6/xnapG6in1uZxoxDghuSMZsPb6D2fyUwNYSAp4l1iR7QtFOjkqcRYcUsfw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.12.1.tgz#3ed4fff31c015e7f3f1467f190dbe545cd7b046c" + integrity sha512-nZY0ESiaQDI1y96+jk6VxMOaL4LPo/QDHBqL+SF3/vl6dHkTwHlOI8L4ZwuRBHgakRBw5zsVylel7QPbbGuYgg== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0" "@babel/plugin-proposal-object-rest-spread@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.10.0.tgz#d27b0910b637f7c9d9a5629f2adcd04dc9ea4e69" - integrity sha512-DOD+4TqMcRKJdAfN08+v9cciK5d0HW5hwTndOoKZEfEzU/mRrKboheD5mnWU4Q96VOnDdAj86kKjZhoQyG6s+A== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.12.1.tgz#def9bd03cea0f9b72283dac0ec22d289c7691069" + integrity sha512-s6SowJIjzlhx8o7lsFx5zmY4At6CTtDvgNQDdPzkBQucle58A6b/TTeEBYtyDgmcXjUTM+vE8YOGHZzzbc/ioA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-object-rest-spread" "^7.8.0" - "@babel/plugin-transform-parameters" "^7.9.5" + "@babel/plugin-transform-parameters" "^7.12.1" "@babel/plugin-proposal-optional-catch-binding@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.8.3.tgz#9dee96ab1650eed88646ae9734ca167ac4a9c5c9" - integrity sha512-0gkX7J7E+AtAw9fcwlVQj8peP61qhdg/89D5swOkjYbkboA2CVckn3kiyum1DE0wskGb7KJJxBdyEBApDLLVdw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.12.1.tgz#ccc2421af64d3aae50b558a71cede929a5ab2942" + integrity sha512-hFvIjgprh9mMw5v42sJWLI1lzU5L2sznP805zeT6rySVRA0Y18StRhDqhSxlap0oVgItRsB6WSROp4YnJTJz0g== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" "@babel/plugin-proposal-optional-chaining@^7.0.0", "@babel/plugin-proposal-optional-chaining@^7.1.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.10.0.tgz#f9bdcd5cbf2e3037674903a45e56ed0cbaea1550" - integrity sha512-bn+9XT8Y6FJCO37ewj4E1gIirR35nDm+mGcqQV4dM3LKSVp3QTAU3f65Z0ld4y6jdfAlv2VKzCh4mezhRnl+6Q== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.1.tgz#cce122203fc8a32794296fc377c6dedaf4363797" + integrity sha512-c2uRpY6WzaVDzynVY9liyykS+kVU+WRZPMPYpkelXH8KBt1oXoI89kPbZKKG/jDT5UK92FTW2fZkZaJhdiBabw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" "@babel/plugin-syntax-optional-chaining" "^7.8.0" "@babel/plugin-syntax-async-generators@^7.8.4": @@ -318,11 +322,11 @@ "@babel/helper-plugin-utils" "^7.8.0" "@babel/plugin-syntax-class-properties@^7.0.0", "@babel/plugin-syntax-class-properties@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.8.3.tgz#6cb933a8872c8d359bfde69bbeaae5162fd1e8f7" - integrity sha512-UcAyQWg2bAN647Q+O811tG9MrJ38Z10jjhQdKNAL8fsyPzE3cCN/uT+f55cFVY4aGO4jqJAvmqsuY3GQDwAoXg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.1.tgz#bcb297c5366e79bebadef509549cd93b04f19978" + integrity sha512-U40A76x5gTwmESz+qiqssqmeEsKvcSyvtgktrm0uzcARAmM9I1jR221f6Oq+GmHrcD+LvZDag1UTOTe2fL3TeA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-dynamic-import@^7.0.0": version "7.8.3" @@ -331,19 +335,19 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-export-default-from@^7.0.0", "@babel/plugin-syntax-export-default-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-default-from/-/plugin-syntax-export-default-from-7.8.3.tgz#f1e55ce850091442af4ba9c2550106035b29d678" - integrity sha512-a1qnnsr73KLNIQcQlcQ4ZHxqqfBKM6iNQZW2OMTyxNbA2WC7SHWHtGVpFzWtQAuS2pspkWVzdEBXXx8Ik0Za4w== +"@babel/plugin-syntax-export-default-from@^7.0.0", "@babel/plugin-syntax-export-default-from@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-default-from/-/plugin-syntax-export-default-from-7.12.1.tgz#a9eb31881f4f9a1115a3d2c6d64ac3f6016b5a9d" + integrity sha512-dP5eGg6tHEkhnRD2/vRG/KJKRSg8gtxu2i+P/8/yFPJn/CfPU5G0/7Gks2i3M6IOVAPQekmsLN9LPsmXFFL4Uw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-flow@^7.0.0", "@babel/plugin-syntax-flow@^7.2.0", "@babel/plugin-syntax-flow@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.8.3.tgz#f2c883bd61a6316f2c89380ae5122f923ba4527f" - integrity sha512-innAx3bUbA0KSYj2E2MNFSn9hiCeowOFLxlsuhXzw8hMQnzkDomUr9QCD7E9VF60NmnG1sNTuuv6Qf4f8INYsg== +"@babel/plugin-syntax-flow@^7.0.0", "@babel/plugin-syntax-flow@^7.12.1", "@babel/plugin-syntax-flow@^7.2.0": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.12.1.tgz#a77670d9abe6d63e8acadf4c31bb1eb5a506bbdd" + integrity sha512-1lBLLmtxrwpm4VKmtVFselI/P3pX+G63fAtUUt6b2Nzgao77KNDwyuRt90Mj2/9pKobtt68FdvjfqohZjg/FCA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-import-meta@^7.8.3": version "7.10.4" @@ -359,19 +363,19 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-jsx@^7.0.0", "@babel/plugin-syntax-jsx@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.8.3.tgz#521b06c83c40480f1e58b4fd33b92eceb1d6ea94" - integrity sha512-WxdW9xyLgBdefoo0Ynn3MRSkhe5tFVxxKNVdnZSh318WrG2e2jH+E9wd/++JsqcLJZPfz87njQJ8j2Upjm0M0A== +"@babel/plugin-syntax-jsx@^7.0.0", "@babel/plugin-syntax-jsx@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.12.1.tgz#9d9d357cc818aa7ae7935917c1257f67677a0926" + integrity sha512-1yRi7yAtB0ETgxdY9ti/p2TivUxJkTdhu/ZbF9MshVGqOx1TdB3b7xCXs49Fupgg50N45KcAsRP/ZqWjs9SRjg== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-logical-assignment-operators@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.8.3.tgz#3995d7d7ffff432f6ddc742b47e730c054599897" - integrity sha512-Zpg2Sgc++37kuFl6ppq2Q7Awc6E6AIW671x5PY8E/f7MCIyPPGK/EoeZXvvY3P42exZ3Q4/t3YOzP/HiN79jDg== + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" + integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator@^7.0.0", "@babel/plugin-syntax-nullish-coalescing-operator@^7.8.0", "@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": version "7.8.3" @@ -381,11 +385,11 @@ "@babel/helper-plugin-utils" "^7.8.0" "@babel/plugin-syntax-numeric-separator@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.8.3.tgz#0e3fb63e09bea1b11e96467271c8308007e7c41f" - integrity sha512-H7dCMAdN83PcCmqmkHB5dtp+Xa9a6LKSvA2hiFBC/5alSHxM5VgWZXFqDi0YFe8XNGT6iCa+z4V4zSt/PdZ7Dw== + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" + integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-object-rest-spread@^7.0.0", "@babel/plugin-syntax-object-rest-spread@^7.8.0", "@babel/plugin-syntax-object-rest-spread@^7.8.3": version "7.8.3" @@ -408,319 +412,315 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-typescript@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.8.3.tgz#c1f659dda97711a569cef75275f7e15dcaa6cabc" - integrity sha512-GO1MQ/SGGGoiEXY0e0bSpHimJvxqB7lktLLIq2pv8xG7WZ8IMEle74jIe1FhprHBWjwjZtXHkycDLZXIWM5Wfg== +"@babel/plugin-syntax-typescript@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.12.1.tgz#460ba9d77077653803c3dd2e673f76d66b4029e5" + integrity sha512-UZNEcCY+4Dp9yYRCAHrHDU+9ZXLYaY9MgBXSRLkB9WjYFRR6quJBumfVrEkUxrePPBwFcpWfNKXqVRQQtm7mMA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-arrow-functions@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.8.3.tgz#82776c2ed0cd9e1a49956daeb896024c9473b8b6" - integrity sha512-0MRF+KC8EqH4dbuITCWwPSzsyO3HIWWlm30v8BbbpOrS1B++isGxPnnuq/IZvOX5J2D/p7DQalQm+/2PnlKGxg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.12.1.tgz#8083ffc86ac8e777fbe24b5967c4b2521f3cb2b3" + integrity sha512-5QB50qyN44fzzz4/qxDPQMBCTHgxg3n0xRBLJUmBlLoU/sFvxVWGZF/ZUfMVDQuJUKXaBhbupxIzIfZ6Fwk/0A== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-async-to-generator@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.8.3.tgz#4308fad0d9409d71eafb9b1a6ee35f9d64b64086" - integrity sha512-imt9tFLD9ogt56Dd5CI/6XgpukMwd/fLGSrix2httihVe7LOGVPhyhMh1BU5kDM7iHD08i8uUtmV2sWaBFlHVQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.12.1.tgz#3849a49cc2a22e9743cbd6b52926d30337229af1" + integrity sha512-SDtqoEcarK1DFlRJ1hHRY5HvJUj5kX4qmtpMAm2QnhOlyuMC4TMdCRgW6WXpv93rZeYNeLP22y8Aq2dbcDRM1A== dependencies: - "@babel/helper-module-imports" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/helper-remap-async-to-generator" "^7.8.3" + "@babel/helper-module-imports" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-remap-async-to-generator" "^7.12.1" "@babel/plugin-transform-block-scoped-functions@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.8.3.tgz#437eec5b799b5852072084b3ae5ef66e8349e8a3" - integrity sha512-vo4F2OewqjbB1+yaJ7k2EJFHlTP3jR634Z9Cj9itpqNjuLXvhlVxgnjsHsdRgASR8xYDrx6onw4vW5H6We0Jmg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.12.1.tgz#f2a1a365bde2b7112e0a6ded9067fdd7c07905d9" + integrity sha512-5OpxfuYnSgPalRpo8EWGPzIYf0lHBWORCkj5M0oLBwHdlux9Ri36QqGW3/LR13RSVOAoUUMzoPI/jpE4ABcHoA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-block-scoping@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.10.0.tgz#5d7aa0cf921ec91bdc97c9b311bf1fce0ea979b0" - integrity sha512-AoMn0D3nLG9i71useuBrZZTnHbjnhcaTXCckUtOx3JPuhGGJdOUYMwOV9niPJ+nZCk52dfLLqbmV3pBMCRQLNw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.12.1.tgz#f0ee727874b42a208a48a586b84c3d222c2bbef1" + integrity sha512-zJyAC9sZdE60r1nVQHblcfCj29Dh2Y0DOvlMkcqSo0ckqjiCwNiUezUKw+RjOCwGfpLRwnAeQ2XlLpsnGkvv9w== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - lodash "^4.17.13" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-classes@^7.0.0": - version "7.9.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.9.5.tgz#800597ddb8aefc2c293ed27459c1fcc935a26c2c" - integrity sha512-x2kZoIuLC//O5iA7PEvecB105o7TLzZo8ofBVhP79N+DO3jaX+KYfww9TQcfBEZD0nikNyYcGB1IKtRq36rdmg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.8.3" - "@babel/helper-define-map" "^7.8.3" - "@babel/helper-function-name" "^7.9.5" - "@babel/helper-optimise-call-expression" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/helper-replace-supers" "^7.8.6" - "@babel/helper-split-export-declaration" "^7.8.3" + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.12.1.tgz#65e650fcaddd3d88ddce67c0f834a3d436a32db6" + integrity sha512-/74xkA7bVdzQTBeSUhLLJgYIcxw/dpEpCdRDiHgPJ3Mv6uC11UhjpOhl72CgqbBCmt1qtssCyB2xnJm1+PFjog== + dependencies: + "@babel/helper-annotate-as-pure" "^7.10.4" + "@babel/helper-define-map" "^7.10.4" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-optimise-call-expression" "^7.10.4" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-replace-supers" "^7.12.1" + "@babel/helper-split-export-declaration" "^7.10.4" globals "^11.1.0" "@babel/plugin-transform-computed-properties@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.8.3.tgz#96d0d28b7f7ce4eb5b120bb2e0e943343c86f81b" - integrity sha512-O5hiIpSyOGdrQZRQ2ccwtTVkgUDBBiCuK//4RJ6UfePllUTCENOzKxfh6ulckXKc0DixTFLCfb2HVkNA7aDpzA== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.12.1.tgz#d68cf6c9b7f838a8a4144badbe97541ea0904852" + integrity sha512-vVUOYpPWB7BkgUWPo4C44mUQHpTZXakEqFjbv8rQMg7TC6S6ZhGZ3otQcRH6u7+adSlE5i0sp63eMC/XGffrzg== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-destructuring@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.10.0.tgz#59145194029721e49e511afb4bdd1d2f38369180" - integrity sha512-yKoghHpYbC0eM+6o6arPUJT9BQBvOOn8iOCEHwFvkJ5gjAxYmoUaAuLwaoA9h2YvC6dzcRI0KPQOpRXr8qQTxQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.12.1.tgz#b9a570fe0d0a8d460116413cb4f97e8e08b2f847" + integrity sha512-fRMYFKuzi/rSiYb2uRLiUENJOKq4Gnl+6qOv5f8z0TZXg3llUwUhsNNwrwaT/6dUhJTzNpBr+CUvEWBtfNY1cw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-exponentiation-operator@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.8.3.tgz#581a6d7f56970e06bf51560cd64f5e947b70d7b7" - integrity sha512-zwIpuIymb3ACcInbksHaNcR12S++0MDLKkiqXHl3AzpgdKlFNhog+z/K0+TGW+b0w5pgTq4H6IwV/WhxbGYSjQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.12.1.tgz#b0f2ed356ba1be1428ecaf128ff8a24f02830ae0" + integrity sha512-7tqwy2bv48q+c1EHbXK0Zx3KXd2RVQp6OC7PbwFNt/dPTAV3Lu5sWtWuAj8owr5wqtWnqHfl2/mJlUmqkChKug== dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-builder-binary-assignment-operator-visitor" "^7.10.4" + "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-flow-strip-types@^7.0.0", "@babel/plugin-transform-flow-strip-types@^7.9.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.9.0.tgz#8a3538aa40434e000b8f44a3c5c9ac7229bd2392" - integrity sha512-7Qfg0lKQhEHs93FChxVLAvhBshOPQDtJUTVHr/ZwQNRccCm4O9D79r9tVSoV8iNwjP1YgfD+e/fgHcPkN1qEQg== +"@babel/plugin-transform-flow-strip-types@^7.0.0", "@babel/plugin-transform-flow-strip-types@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.12.1.tgz#8430decfa7eb2aea5414ed4a3fa6e1652b7d77c4" + integrity sha512-8hAtkmsQb36yMmEtk2JZ9JnVyDSnDOdlB+0nEGzIDLuK4yR3JcEjfuFPYkdEPSh8Id+rAMeBEn+X0iVEyho6Hg== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-flow" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/plugin-syntax-flow" "^7.12.1" "@babel/plugin-transform-for-of@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.10.0.tgz#ff2bf95dc1deb9b309c7fd78d9620ac9266a3efe" - integrity sha512-0ldl5xEe9kbuhB1cDqs17JiBPEm1+6/LH7loo29+MAJOyB/xbpLI/u6mRzDPjr0nYL7z0S14FPT4hs2gH8Im9Q== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.12.1.tgz#07640f28867ed16f9511c99c888291f560921cfa" + integrity sha512-Zaeq10naAsuHo7heQvyV0ptj4dlZJwZgNAtBYBnu5nNKJoW62m0zKcIEyVECrUKErkUkg6ajMy4ZfnVZciSBhg== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-function-name@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.8.3.tgz#279373cb27322aaad67c2683e776dfc47196ed8b" - integrity sha512-rO/OnDS78Eifbjn5Py9v8y0aR+aSYhDhqAwVfsTl0ERuMZyr05L1aFSCJnbv2mmsLkit/4ReeQ9N2BgLnOcPCQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.12.1.tgz#2ec76258c70fe08c6d7da154003a480620eba667" + integrity sha512-JF3UgJUILoFrFMEnOJLJkRHSk6LUSXLmEFsA23aR2O5CSLUxbeUX1IZ1YQ7Sn0aXb601Ncwjx73a+FVqgcljVw== dependencies: - "@babel/helper-function-name" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-literals@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.8.3.tgz#aef239823d91994ec7b68e55193525d76dbd5dc1" - integrity sha512-3Tqf8JJ/qB7TeldGl+TT55+uQei9JfYaregDcEAyBZ7akutriFrt6C/wLYIer6OYhleVQvH/ntEhjE/xMmy10A== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.12.1.tgz#d73b803a26b37017ddf9d3bb8f4dc58bfb806f57" + integrity sha512-+PxVGA+2Ag6uGgL0A5f+9rklOnnMccwEBzwYFL3EUaKuiyVnUipyXncFcfjSkbimLrODoqki1U9XxZzTvfN7IQ== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-member-expression-literals@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.8.3.tgz#963fed4b620ac7cbf6029c755424029fa3a40410" - integrity sha512-3Wk2EXhnw+rP+IDkK6BdtPKsUE5IeZ6QOGrPYvw52NwBStw9V1ZVzxgK6fSKSxqUvH9eQPR3tm3cOq79HlsKYA== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.12.1.tgz#496038602daf1514a64d43d8e17cbb2755e0c3ad" + integrity sha512-1sxePl6z9ad0gFMB9KqmYofk34flq62aqMt9NqliS/7hPEpURUCMbyHXrMPlo282iY7nAvUB1aQd5mg79UD9Jg== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.1.0": - version "7.9.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.9.6.tgz#64b7474a4279ee588cacd1906695ca721687c277" - integrity sha512-7H25fSlLcn+iYimmsNe3uK1at79IE6SKW9q0/QeEHTMC9MdOZ+4bA+T1VFB5fgOqBWoqlifXRzYD0JPdmIrgSQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.12.1.tgz#fa403124542636c786cf9b460a0ffbb48a86e648" + integrity sha512-dY789wq6l0uLY8py9c1B48V8mVL5gZh/+PQ5ZPrylPYsnAvnEMjqsUXkuoDVPeVK+0VyGar+D08107LzDQ6pag== dependencies: - "@babel/helper-module-transforms" "^7.9.0" - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/helper-simple-access" "^7.8.3" + "@babel/helper-module-transforms" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-simple-access" "^7.12.1" babel-plugin-dynamic-import-node "^2.3.3" "@babel/plugin-transform-object-assign@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.8.3.tgz#dc3b8dd50ef03837868a37b7df791f64f288538e" - integrity sha512-i3LuN8tPDqUCRFu3dkzF2r1Nx0jp4scxtm7JxtIqI9he9Vk20YD+/zshdzR9JLsoBMlJlNR82a62vQExNEVx/Q== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.12.1.tgz#9102b06625f60a5443cc292d32b565373665e1e4" + integrity sha512-geUHn4XwHznRAFiuROTy0Hr7bKbpijJCmr1Svt/VNGhpxmp0OrdxURNpWbOAf94nUbL+xj6gbxRVPHWIbRpRoA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-object-super@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.8.3.tgz#ebb6a1e7a86ffa96858bd6ac0102d65944261725" - integrity sha512-57FXk+gItG/GejofIyLIgBKTas4+pEU47IXKDBWFTxdPd7F80H8zybyAY7UoblVfBhBGs2EKM+bJUu2+iUYPDQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.12.1.tgz#4ea08696b8d2e65841d0c7706482b048bed1066e" + integrity sha512-AvypiGJH9hsquNUn+RXVcBdeE3KHPZexWRdimhuV59cSoOt5kFBmqlByorAeUlGG2CJWd0U+4ZtNKga/TB0cAw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/helper-replace-supers" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-replace-supers" "^7.12.1" -"@babel/plugin-transform-parameters@^7.0.0", "@babel/plugin-transform-parameters@^7.9.5": - version "7.9.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.9.5.tgz#173b265746f5e15b2afe527eeda65b73623a0795" - integrity sha512-0+1FhHnMfj6lIIhVvS4KGQJeuhe1GI//h5uptK4PvLt+BGBxsoUJbd3/IW002yk//6sZPlFgsG1hY6OHLcy6kA== +"@babel/plugin-transform-parameters@^7.0.0", "@babel/plugin-transform-parameters@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.12.1.tgz#d2e963b038771650c922eff593799c96d853255d" + integrity sha512-xq9C5EQhdPK23ZeCdMxl8bbRnAgHFrw5EOC3KJUsSylZqdkCaFEXxGSBuTSObOpiiHHNyb82es8M1QYgfQGfNg== dependencies: - "@babel/helper-get-function-arity" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-property-literals@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.8.3.tgz#33194300d8539c1ed28c62ad5087ba3807b98263" - integrity sha512-uGiiXAZMqEoQhRWMK17VospMZh5sXWg+dlh2soffpkAl96KAm+WZuJfa6lcELotSRmooLqg0MWdH6UUq85nmmg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.12.1.tgz#41bc81200d730abb4456ab8b3fbd5537b59adecd" + integrity sha512-6MTCR/mZ1MQS+AwZLplX4cEySjCpnIF26ToWo942nqn8hXSm7McaHQNeGx/pt7suI1TWOWMfa/NgBhiqSnX0cQ== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-react-display-name@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.8.3.tgz#70ded987c91609f78353dd76d2fb2a0bb991e8e5" - integrity sha512-3Jy/PCw8Fe6uBKtEgz3M82ljt+lTg+xJaM4og+eyu83qLT87ZUSckn0wy7r31jflURWLO83TW6Ylf7lyXj3m5A== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.12.1.tgz#1cbcd0c3b1d6648c55374a22fc9b6b7e5341c00d" + integrity sha512-cAzB+UzBIrekfYxyLlFqf/OagTvHLcVBb5vpouzkYkBclRPraiygVnafvAoipErZLI8ANv8Ecn6E/m5qPXD26w== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-react-jsx-self@^7.0.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.9.0.tgz#f4f26a325820205239bb915bad8e06fcadabb49b" - integrity sha512-K2ObbWPKT7KUTAoyjCsFilOkEgMvFG+y0FqOl6Lezd0/13kMkkjHskVsZvblRPj1PHA44PrToaZANrryppzTvQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.12.1.tgz#ef43cbca2a14f1bd17807dbe4376ff89d714cf28" + integrity sha512-FbpL0ieNWiiBB5tCldX17EtXgmzeEZjFrix72rQYeq9X6nUK38HCaxexzVQrZWXanxKJPKVVIU37gFjEQYkPkA== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-jsx" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-react-jsx-source@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.10.0.tgz#0e24978505130a79bb8ee1af15a1a7d8e783347d" - integrity sha512-EmUZ2YYXK6YFIdSxUJ1thg7gIBMHSEp8nGS6GwkXGpGdplpmOhj6azYjszT8YcFt6HyPElycDOd2lXckzN+OEw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.12.1.tgz#d07de6863f468da0809edcf79a1aa8ce2a82a26b" + integrity sha512-keQ5kBfjJNRc6zZN1/nVHCd6LLIHq4aUKcVnvE/2l+ZZROSbqoiGFRtT5t3Is89XJxBQaP7NLZX2jgGHdZvvFQ== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-jsx" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-react-jsx@^7.0.0": - version "7.9.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.9.4.tgz#86f576c8540bd06d0e95e0b61ea76d55f6cbd03f" - integrity sha512-Mjqf3pZBNLt854CK0C/kRuXAnE6H/bo7xYojP+WGtX8glDGSibcwnsWwhwoSuRg0+EBnxPC1ouVnuetUIlPSAw== + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.12.5.tgz#39ede0e30159770561b6963be143e40af3bde00c" + integrity sha512-2xkcPqqrYiOQgSlM/iwto1paPijjsDbUynN13tI6bosDz/jOW3CRzYguIE8wKX32h+msbBM22Dv5fwrFkUOZjQ== dependencies: - "@babel/helper-builder-react-jsx" "^7.9.0" - "@babel/helper-builder-react-jsx-experimental" "^7.9.0" - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-jsx" "^7.8.3" + "@babel/helper-builder-react-jsx" "^7.10.4" + "@babel/helper-builder-react-jsx-experimental" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/plugin-syntax-jsx" "^7.12.1" "@babel/plugin-transform-regenerator@^7.0.0": - version "7.8.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.8.7.tgz#5e46a0dca2bee1ad8285eb0527e6abc9c37672f8" - integrity sha512-TIg+gAl4Z0a3WmD3mbYSk+J9ZUH6n/Yc57rtKRnlA/7rcCvpekHXe0CMZHP1gYp7/KLe9GHTuIba0vXmls6drA== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.12.1.tgz#5f0a28d842f6462281f06a964e88ba8d7ab49753" + integrity sha512-gYrHqs5itw6i4PflFX3OdBPMQdPbF4bj2REIUxlMRUFk0/ZOAIpDFuViuxPjUL7YC8UPnf+XG7/utJvqXdPKng== dependencies: regenerator-transform "^0.14.2" "@babel/plugin-transform-runtime@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.10.0.tgz#16e50ba682aa9925b94123a622d996cadd4cbef7" - integrity sha512-SWIc5IJnoLHk9qVRvvpebUW5lafStcKlLcqELMiNOApVIxPbCtkQfLRMCdaEKw4X92JItFKdoBxv2udiyGwFtg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.12.1.tgz#04b792057eb460389ff6a4198e377614ea1e7ba5" + integrity sha512-Ac/H6G9FEIkS2tXsZjL4RAdS3L3WHxci0usAnz7laPWUmFiGtj7tIASChqKZMHTSQTQY6xDbOq+V1/vIq3QrWg== dependencies: - "@babel/helper-module-imports" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-module-imports" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" resolve "^1.8.1" semver "^5.5.1" "@babel/plugin-transform-shorthand-properties@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.8.3.tgz#28545216e023a832d4d3a1185ed492bcfeac08c8" - integrity sha512-I9DI6Odg0JJwxCHzbzW08ggMdCezoWcuQRz3ptdudgwaHxTjxw5HgdFJmZIkIMlRymL6YiZcped4TTCB0JcC8w== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.12.1.tgz#0bf9cac5550fce0cfdf043420f661d645fdc75e3" + integrity sha512-GFZS3c/MhX1OusqB1MZ1ct2xRzX5ppQh2JU1h2Pnfk88HtFTM+TWQqJNfwkmxtPQtb/s1tk87oENfXJlx7rSDw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-spread@^7.0.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.10.0.tgz#6918d9b2b52c604802bd50a5f22b649efddf9af6" - integrity sha512-P3Zj04ylqumJBjmjylNl05ZHRo4j4gFNG7P70loys0//q5BTe30E8xIj6PnqEWAfsPYu2sdIPcJeeQdclqlM6A== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.12.1.tgz#527f9f311be4ec7fdc2b79bb89f7bf884b3e1e1e" + integrity sha512-vuLp8CP0BE18zVYjsEBZ5xoCecMK6LBMMxYzJnh01rxQRvhNhH1csMMmBfNo5tGpGO+NhdSNW2mzIvBu3K1fng== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" "@babel/plugin-transform-sticky-regex@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.8.3.tgz#be7a1290f81dae767475452199e1f76d6175b100" - integrity sha512-9Spq0vGCD5Bb4Z/ZXXSK5wbbLFMG085qd2vhL1JYu1WcQ5bXqZBAYRzU1d+p79GcHs2szYv5pVQCX13QgldaWw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.12.1.tgz#5c24cf50de396d30e99afc8d1c700e8bce0f5caf" + integrity sha512-CiUgKQ3AGVk7kveIaPEET1jNDhZZEl1RPMWdTBE1799bdz++SwqDHStmxfCtDfBhQgCl38YRiSnrMuUMZIWSUQ== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/helper-regex" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-regex" "^7.10.4" "@babel/plugin-transform-template-literals@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.8.3.tgz#7bfa4732b455ea6a43130adc0ba767ec0e402a80" - integrity sha512-820QBtykIQOLFT8NZOcTRJ1UNuztIELe4p9DCgvj4NK+PwluSJ49we7s9FB1HIGNIYT7wFUJ0ar2QpCDj0escQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.12.1.tgz#b43ece6ed9a79c0c71119f576d299ef09d942843" + integrity sha512-b4Zx3KHi+taXB1dVRBhVJtEPi9h1THCeKmae2qP0YdUHIFhVjtpqqNfxeVAa1xeHVhAy4SbHxEwx5cltAu5apw== dependencies: - "@babel/helper-annotate-as-pure" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-typescript@^7.5.0", "@babel/plugin-transform-typescript@^7.9.0": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.10.0.tgz#00273cddb1f5321af09db5c096bb865eab137124" - integrity sha512-BGH4yn+QwYFfzh8ITmChwrcvhLf+jaYBlz+T87CNKTP49SbqrjqTsMqtFijivYWYjcYHvac8II53RYd82vRaAw== +"@babel/plugin-transform-typescript@^7.12.1", "@babel/plugin-transform-typescript@^7.5.0": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.1.tgz#d92cc0af504d510e26a754a7dbc2e5c8cd9c7ab4" + integrity sha512-VrsBByqAIntM+EYMqSm59SiMEf7qkmI9dqMt6RbD/wlwueWmYcI0FFK5Fj47pP6DRZm+3teXjosKlwcZJ5lIMw== dependencies: - "@babel/helper-create-class-features-plugin" "^7.10.0" - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-typescript" "^7.8.3" + "@babel/helper-create-class-features-plugin" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/plugin-syntax-typescript" "^7.12.1" "@babel/plugin-transform-unicode-regex@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.8.3.tgz#0cef36e3ba73e5c57273effb182f46b91a1ecaad" - integrity sha512-+ufgJjYdmWfSQ+6NS9VGUR2ns8cjJjYbrbi11mZBTaWm+Fui/ncTLFF28Ei1okavY+xkojGr1eJxNsWYeA5aZw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.12.1.tgz#cc9661f61390db5c65e3febaccefd5c6ac3faecb" + integrity sha512-SqH4ClNngh/zGwHZOOQMTD+e8FGWexILV+ePMyiDJttAWRh5dhDL8rcl5lSgU3Huiq6Zn6pWTMvdPAb21Dwdyg== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.8.3" - "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-create-regexp-features-plugin" "^7.12.1" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/preset-flow@^7.0.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.9.0.tgz#fee847c3e090b0b2d9227c1949e4da1d1379280d" - integrity sha512-88uSmlshIrlmPkNkEcx3UpSZ6b8n0UGBq0/0ZMZCF/uxAW0XIAUuDHBhIOAh0pvweafH4RxOwi/H3rWhtqOYPA== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.12.1.tgz#1a81d376c5a9549e75352a3888f8c273455ae940" + integrity sha512-UAoyMdioAhM6H99qPoKvpHMzxmNVXno8GYU/7vZmGaHk6/KqfDYL1W0NxszVbJ2EP271b7e6Ox+Vk2A9QsB3Sw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-transform-flow-strip-types" "^7.9.0" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/plugin-transform-flow-strip-types" "^7.12.1" "@babel/preset-typescript@^7.1.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.9.0.tgz#87705a72b1f0d59df21c179f7c3d2ef4b16ce192" - integrity sha512-S4cueFnGrIbvYJgwsVFKdvOmpiL0XGw9MFW9D0vgRys5g36PBhZRL8NX8Gr2akz8XRtzq6HuDXPD/1nniagNUg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.1.tgz#86480b483bb97f75036e8864fe404cc782cc311b" + integrity sha512-hNK/DhmoJPsksdHuI/RVrcEws7GN5eamhi28JkO52MqIxU8Z0QpmiSOQxZHWOHV7I3P4UjHV97ay4TcamMA6Kw== dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-transform-typescript" "^7.9.0" + "@babel/helper-plugin-utils" "^7.10.4" + "@babel/plugin-transform-typescript" "^7.12.1" "@babel/register@^7.0.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.9.0.tgz#02464ede57548bddbb5e9f705d263b7c3f43d48b" - integrity sha512-Tv8Zyi2J2VRR8g7pC5gTeIN8Ihultbmk0ocyNz8H2nEZbmhp1N6q0A1UGsQbDvGP/sNinQKUHf3SqXwqjtFv4Q== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.12.1.tgz#cdb087bdfc4f7241c03231f22e15d211acf21438" + integrity sha512-XWcmseMIncOjoydKZnWvWi0/5CUCD+ZYKhRwgYlWOrA8fGZ/FjuLRpqtIhLOVD/fvR1b9DQHtZPn68VvhpYf+Q== dependencies: find-cache-dir "^2.0.0" - lodash "^4.17.13" + lodash "^4.17.19" make-dir "^2.1.0" pirates "^4.0.0" source-map-support "^0.5.16" "@babel/runtime@^7.8.4": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.0.tgz#2cdcd6d7a391c24f7154235134c830cfb58ac0b1" - integrity sha512-tgYb3zVApHbLHYOPWtVwg25sBqHhfBXRKeKoTIyoheIxln1nA7oBl7SfHfiTG2GhDPI8EUBkOD/0wJCP/3HN4Q== + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" + integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== dependencies: regenerator-runtime "^0.13.4" -"@babel/template@^7.0.0", "@babel/template@^7.10.0", "@babel/template@^7.3.3", "@babel/template@^7.8.3", "@babel/template@^7.8.6": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.0.tgz#f15d852ce16cd5fb3e219097a75f662710b249b1" - integrity sha512-aMLEQn5tcG49LEWrsEwxiRTdaJmvLem3+JMCMSeCy2TILau0IDVyWdm/18ACx7XOCady64FLt6KkHy28tkDQHQ== - dependencies: - "@babel/code-frame" "^7.8.3" - "@babel/parser" "^7.10.0" - "@babel/types" "^7.10.0" - -"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.10.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.8.3": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.10.0.tgz#290935529881baf619398d94fd453838bef36740" - integrity sha512-NZsFleMaLF1zX3NxbtXI/JCs2RPOdpGru6UBdGsfhdsDsP+kFF+h2QQJnMJglxk0kc69YmMFs4A44OJY0tKo5g== - dependencies: - "@babel/code-frame" "^7.8.3" - "@babel/generator" "^7.10.0" - "@babel/helper-function-name" "^7.9.5" - "@babel/helper-split-export-declaration" "^7.8.3" - "@babel/parser" "^7.10.0" - "@babel/types" "^7.10.0" +"@babel/template@^7.0.0", "@babel/template@^7.10.4", "@babel/template@^7.3.3": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278" + integrity sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/parser" "^7.10.4" + "@babel/types" "^7.10.4" + +"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.5", "@babel/traverse@^7.7.0": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.5.tgz#78a0c68c8e8a35e4cacfd31db8bb303d5606f095" + integrity sha512-xa15FbQnias7z9a62LwYAA5SZZPkHIXpd42C6uW68o8uTuua96FHZy1y61Va5P/i83FAAcMpW8+A/QayntzuqA== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/generator" "^7.12.5" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-split-export-declaration" "^7.11.0" + "@babel/parser" "^7.12.5" + "@babel/types" "^7.12.5" debug "^4.1.0" globals "^11.1.0" - lodash "^4.17.13" + lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.10.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.7.0", "@babel/types@^7.8.3", "@babel/types@^7.9.0", "@babel/types@^7.9.5": - version "7.10.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.10.0.tgz#d47d92249e42393a5723aad5319035ae411e3e38" - integrity sha512-t41W8yWFyQFPOAAvPvjyRhejcLGnJTA3iRpFcDbEKwVJ3UnHQePFzLk8GagTsucJlImyNwrGikGsYURrWbQG8w== +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.7.0": + version "7.12.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.6.tgz#ae0e55ef1cce1fbc881cd26f8234eb3e657edc96" + integrity sha512-hwyjw6GvjBLiyy3W0YQf0Z5Zf4NpYejUnKFcfcUhZCSffoBBp30w6wP2Wn6pk31jMYZvcOrB/1b7cGXvEoKogA== dependencies: - "@babel/helper-validator-identifier" "^7.9.5" - lodash "^4.17.13" + "@babel/helper-validator-identifier" "^7.10.4" + lodash "^4.17.19" to-fast-properties "^2.0.0" "@bcoe/v8-coverage@^0.2.3": @@ -4636,11 +4636,16 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= -lodash@4.x.x, lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.5, lodash@^4.3.0: +lodash@4.x.x, lodash@^4.17.10, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.5, lodash@^4.3.0: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.19: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + log-driver@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8" @@ -6082,10 +6087,10 @@ regexpp@^2.0.1: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== -regexpu-core@^4.7.0: - version "4.7.0" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.0.tgz#fcbf458c50431b0bb7b45d6967b8192d91f3d938" - integrity sha512-TQ4KXRnIn6tz6tjnrXEkD/sshygKH/j5KzK86X8MkeHyZ8qst/LZ89j3X4/8HEIfHANTFIP/AbXakeRhWIl5YQ== +regexpu-core@^4.7.1: + version "4.7.1" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.1.tgz#2dea5a9a07233298fbf0db91fa9abc4c6e0f8ad6" + integrity sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ== dependencies: regenerate "^1.4.0" regenerate-unicode-properties "^8.2.0" From b6a72bac698486a96748365c8f67c8177afe317e Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sun, 8 Nov 2020 14:02:02 -0800 Subject: [PATCH 0032/1810] Extend babel-plugin-codegen to generate TurboModule JS codegen Summary: ## New Functionality - Detect if the JS file represents a NativeModule spec. - **Note:** A JS file is a NativeModule spec if it contains a flow `interface` that extends `TurboModule`. This logic is copied over from the OSS Codegen, here: https://github.com/facebook/react-native/blob/7ccb67a49c087e7ee536c2ffb71717e68a79324b/packages/react-native-codegen/src/parsers/flow/index.js#L60-L75 - For all NativeModule specs, generate the spec's schema using the OSS Codegen for Modules, and conditionally inline it into every `TurboModuleRegistry.get(Enforcing)?` call in the spec, like so: **Before:** ``` /** * flow */ import type {TurboModule} from 'RCTExport'; export interface Spec extends TurboModule { //... } export default TurboModuleRegistry.get('FooModule'); ``` **After:** ``` /** * flow */ import type {TurboModule} from 'RCTExport'; export interface Spec extends TurboModule { //... } export default TurboModuleRegistry.get('FooModule', __getModuleShape()); function __getModuleShape() { if (!(global.RN$EnableTurboModuleJSCodegen === true)) { return undefined; } return {...}; } ``` Changelog: [General][Added] Extend react-native/babel-plugin-codegen to generate TurboModule JS codegen Reviewed By: TheSavior Differential Revision: D22803845 fbshipit-source-id: 18c157a1dbfcc575012184de31c38908acd53c36 --- .../__test_fixtures__/fixtures.js | 134 +++ .../__snapshots__/index-test.js.snap | 991 ++++++++++++++++++ packages/babel-plugin-codegen/index.js | 92 +- 3 files changed, 1214 insertions(+), 3 deletions(-) diff --git a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js index 946b622ea87d66..2d845b8ad994b1 100644 --- a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js +++ b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js @@ -103,8 +103,142 @@ export default (codegenNativeComponent('Module', { }): NativeType); `; +const SAMPLE_TURBO_MODULE_SINGLE_DEFAULT_EXPORT = ` +// @flow + +import type {RootTag, TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}; + +voidFunc: () => void; + +getBool: (arg: boolean) => boolean; + +getNumber: (arg: number) => number; + +getString: (arg: string) => string; + +getArray: (arg: Array) => Array; + +getObject: (arg: Object) => Object; + +getRootTag: (arg: RootTag) => RootTag; + +getValue: (x: number, y: string, z: Object) => Object; + +getValueWithCallback: (callback: (value: string) => void) => void; + +getValueWithPromise: (error: boolean) => Promise; +} + +export default (TurboModuleRegistry.getEnforcing( + 'SampleTurboModule', +): Spec); +`; + +const SAMPLE_TURBO_MODULE_VARIABLE_ASSIGNMENT = ` +// @flow + +import type {RootTag, TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}; + +voidFunc: () => void; + +getBool: (arg: boolean) => boolean; + +getNumber: (arg: number) => number; + +getString: (arg: string) => string; + +getArray: (arg: Array) => Array; + +getObject: (arg: Object) => Object; + +getRootTag: (arg: RootTag) => RootTag; + +getValue: (x: number, y: string, z: Object) => Object; + +getValueWithCallback: (callback: (value: string) => void) => void; + +getValueWithPromise: (error: boolean) => Promise; +} + +const module = TurboModuleRegistry.getEnforcing( + 'SampleTurboModule', +); + +export default (module: Spec); +`; + +const SAMPLE_TURBO_MODULE_MANY_MODULES_DEFAULT_EXPORT = ` +// @flow + +import type {RootTag, TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}; + +voidFunc: () => void; + +getBool: (arg: boolean) => boolean; + +getNumber: (arg: number) => number; + +getString: (arg: string) => string; + +getArray: (arg: Array) => Array; + +getObject: (arg: Object) => Object; + +getRootTag: (arg: RootTag) => RootTag; + +getValue: (x: number, y: string, z: Object) => Object; + +getValueWithCallback: (callback: (value: string) => void) => void; + +getValueWithPromise: (error: boolean) => Promise; +} + +export default ( + ( + TurboModuleRegistry.getEnforcing('SampleTurboModule') || + TurboModuleRegistry.getEnforcing('SampleTurboModule2') + ): Spec); +`; + +const SAMPLE_TURBO_MODULE_MANY_MODULES_VARIABLE_ASSIGNMENT = ` +// @flow + +import type {RootTag, TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}; + +voidFunc: () => void; + +getBool: (arg: boolean) => boolean; + +getNumber: (arg: number) => number; + +getString: (arg: string) => string; + +getArray: (arg: Array) => Array; + +getObject: (arg: Object) => Object; + +getRootTag: (arg: RootTag) => RootTag; + +getValue: (x: number, y: string, z: Object) => Object; + +getValueWithCallback: (callback: (value: string) => void) => void; + +getValueWithPromise: (error: boolean) => Promise; +} + +const module1 = TurboModuleRegistry.getEnforcing( + 'SampleTurboModule', +); + +const module2 = TurboModuleRegistry.getEnforcing( + 'SampleTurboModule2', +); + +export default ((module1 || module2): Spec); +`; + module.exports = { 'NotANativeComponent.js': NOT_A_NATIVE_COMPONENT, 'FullNativeComponent.js': FULL_NATIVE_COMPONENT, 'FullTypedNativeComponent.js': FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT, + 'NativeSampleTurboModule0.js': SAMPLE_TURBO_MODULE_SINGLE_DEFAULT_EXPORT, + 'NativeSampleTurboModule1.js': SAMPLE_TURBO_MODULE_VARIABLE_ASSIGNMENT, + 'NativeSampleTurboModule2.js': SAMPLE_TURBO_MODULE_MANY_MODULES_DEFAULT_EXPORT, + 'NativeSampleTurboModule3.js': SAMPLE_TURBO_MODULE_MANY_MODULES_VARIABLE_ASSIGNMENT, }; diff --git a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap index 85c8e4580aa169..6ce4b2b73c6b1c 100644 --- a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap @@ -130,6 +130,997 @@ export const Commands = { };" `; +exports[`Babel plugin inline view configs can inline config for NativeSampleTurboModule0.js 1`] = ` +"// @flow +import type { RootTag, TurboModule } from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}, + +voidFunc: () => void, + +getBool: (arg: boolean) => boolean, + +getNumber: (arg: number) => number, + +getString: (arg: string) => string, + +getArray: (arg: Array) => Array, + +getObject: (arg: Object) => Object, + +getRootTag: (arg: RootTag) => RootTag, + +getValue: (x: number, y: string, z: Object) => Object, + +getValueWithCallback: (callback: (value: string) => void) => void, + +getValueWithPromise: (error: boolean) => Promise, +} +export default (TurboModuleRegistry.getEnforcing('SampleTurboModule', __getModuleSchema()): Spec); + +function __getModuleSchema() { + if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { + return undefined; + } + + return { + \\"type\\": \\"NativeModule\\", + \\"aliases\\": {}, + \\"spec\\": { + \\"properties\\": [{ + \\"name\\": \\"getConstants\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ObjectTypeAnnotation\\", + \\"properties\\": [{ + \\"name\\": \\"const1\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }, { + \\"name\\": \\"const2\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"const3\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"voidFunc\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"getBool\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getNumber\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getString\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getArray\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getObject\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getRootTag\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + } + }] + } + }, { + \\"name\\": \\"getValue\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"x\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"y\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }, { + \\"name\\": \\"z\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getValueWithCallback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"callback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"value\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }] + } + }, { + \\"name\\": \\"getValueWithPromise\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"PromiseTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"error\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }] + }, + \\"moduleNames\\": [\\"SampleTurboModule\\"] + }; +}" +`; + +exports[`Babel plugin inline view configs can inline config for NativeSampleTurboModule1.js 1`] = ` +"// @flow +import type { RootTag, TurboModule } from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}, + +voidFunc: () => void, + +getBool: (arg: boolean) => boolean, + +getNumber: (arg: number) => number, + +getString: (arg: string) => string, + +getArray: (arg: Array) => Array, + +getObject: (arg: Object) => Object, + +getRootTag: (arg: RootTag) => RootTag, + +getValue: (x: number, y: string, z: Object) => Object, + +getValueWithCallback: (callback: (value: string) => void) => void, + +getValueWithPromise: (error: boolean) => Promise, +} +const module = TurboModuleRegistry.getEnforcing('SampleTurboModule', __getModuleSchema()); +export default (module: Spec); + +function __getModuleSchema() { + if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { + return undefined; + } + + return { + \\"type\\": \\"NativeModule\\", + \\"aliases\\": {}, + \\"spec\\": { + \\"properties\\": [{ + \\"name\\": \\"getConstants\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ObjectTypeAnnotation\\", + \\"properties\\": [{ + \\"name\\": \\"const1\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }, { + \\"name\\": \\"const2\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"const3\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"voidFunc\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"getBool\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getNumber\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getString\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getArray\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getObject\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getRootTag\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + } + }] + } + }, { + \\"name\\": \\"getValue\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"x\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"y\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }, { + \\"name\\": \\"z\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getValueWithCallback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"callback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"value\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }] + } + }, { + \\"name\\": \\"getValueWithPromise\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"PromiseTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"error\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }] + }, + \\"moduleNames\\": [\\"SampleTurboModule\\"] + }; +}" +`; + +exports[`Babel plugin inline view configs can inline config for NativeSampleTurboModule2.js 1`] = ` +"// @flow +import type { RootTag, TurboModule } from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}, + +voidFunc: () => void, + +getBool: (arg: boolean) => boolean, + +getNumber: (arg: number) => number, + +getString: (arg: string) => string, + +getArray: (arg: Array) => Array, + +getObject: (arg: Object) => Object, + +getRootTag: (arg: RootTag) => RootTag, + +getValue: (x: number, y: string, z: Object) => Object, + +getValueWithCallback: (callback: (value: string) => void) => void, + +getValueWithPromise: (error: boolean) => Promise, +} +export default (TurboModuleRegistry.getEnforcing('SampleTurboModule', __getModuleSchema()) || TurboModuleRegistry.getEnforcing('SampleTurboModule2', __getModuleSchema()): Spec); + +function __getModuleSchema() { + if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { + return undefined; + } + + return { + \\"type\\": \\"NativeModule\\", + \\"aliases\\": {}, + \\"spec\\": { + \\"properties\\": [{ + \\"name\\": \\"getConstants\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ObjectTypeAnnotation\\", + \\"properties\\": [{ + \\"name\\": \\"const1\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }, { + \\"name\\": \\"const2\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"const3\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"voidFunc\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"getBool\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getNumber\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getString\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getArray\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getObject\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getRootTag\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + } + }] + } + }, { + \\"name\\": \\"getValue\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"x\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"y\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }, { + \\"name\\": \\"z\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getValueWithCallback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"callback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"value\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }] + } + }, { + \\"name\\": \\"getValueWithPromise\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"PromiseTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"error\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }] + }, + \\"moduleNames\\": [\\"SampleTurboModule\\", \\"SampleTurboModule2\\"] + }; +}" +`; + +exports[`Babel plugin inline view configs can inline config for NativeSampleTurboModule3.js 1`] = ` +"// @flow +import type { RootTag, TurboModule } from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; +export interface Spec extends TurboModule { + // Exported methods. + +getConstants: () => {| + const1: boolean, + const2: number, + const3: string, + |}, + +voidFunc: () => void, + +getBool: (arg: boolean) => boolean, + +getNumber: (arg: number) => number, + +getString: (arg: string) => string, + +getArray: (arg: Array) => Array, + +getObject: (arg: Object) => Object, + +getRootTag: (arg: RootTag) => RootTag, + +getValue: (x: number, y: string, z: Object) => Object, + +getValueWithCallback: (callback: (value: string) => void) => void, + +getValueWithPromise: (error: boolean) => Promise, +} +const module1 = TurboModuleRegistry.getEnforcing('SampleTurboModule', __getModuleSchema()); +const module2 = TurboModuleRegistry.getEnforcing('SampleTurboModule2', __getModuleSchema()); +export default (module1 || module2: Spec); + +function __getModuleSchema() { + if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { + return undefined; + } + + return { + \\"type\\": \\"NativeModule\\", + \\"aliases\\": {}, + \\"spec\\": { + \\"properties\\": [{ + \\"name\\": \\"getConstants\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ObjectTypeAnnotation\\", + \\"properties\\": [{ + \\"name\\": \\"const1\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }, { + \\"name\\": \\"const2\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"const3\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"voidFunc\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [] + } + }, { + \\"name\\": \\"getBool\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getNumber\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getString\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getArray\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ArrayTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getObject\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getRootTag\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + }, + \\"params\\": [{ + \\"name\\": \\"arg\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"ReservedTypeAnnotation\\", + \\"name\\": \\"RootTag\\" + } + }] + } + }, { + \\"name\\": \\"getValue\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"x\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"NumberTypeAnnotation\\" + } + }, { + \\"name\\": \\"y\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }, { + \\"name\\": \\"z\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"GenericObjectTypeAnnotation\\" + } + }] + } + }, { + \\"name\\": \\"getValueWithCallback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"callback\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"VoidTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"value\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"StringTypeAnnotation\\" + } + }] + } + }] + } + }, { + \\"name\\": \\"getValueWithPromise\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"FunctionTypeAnnotation\\", + \\"returnTypeAnnotation\\": { + \\"type\\": \\"PromiseTypeAnnotation\\" + }, + \\"params\\": [{ + \\"name\\": \\"error\\", + \\"optional\\": false, + \\"typeAnnotation\\": { + \\"type\\": \\"BooleanTypeAnnotation\\" + } + }] + } + }] + }, + \\"moduleNames\\": [\\"SampleTurboModule\\", \\"SampleTurboModule2\\"] + }; +}" +`; + exports[`Babel plugin inline view configs can inline config for NotANativeComponent.js 1`] = ` "const requireNativeComponent = require('requireNativeComponent'); diff --git a/packages/babel-plugin-codegen/index.js b/packages/babel-plugin-codegen/index.js index 1a80f9c60b4580..a2b139838bc29f 100644 --- a/packages/babel-plugin-codegen/index.js +++ b/packages/babel-plugin-codegen/index.js @@ -53,7 +53,40 @@ function isCodegenDeclaration(declaration) { return false; } -module.exports = function(context) { +function isTurboModuleRequire(path) { + if (path.node.type !== 'CallExpression') { + return false; + } + + const callExpression = path.node; + + if (callExpression.callee.type !== 'MemberExpression') { + return false; + } + + const memberExpression = callExpression.callee; + if ( + !( + memberExpression.object.type === 'Identifier' && + memberExpression.object.name === 'TurboModuleRegistry' + ) + ) { + return false; + } + + if ( + !( + memberExpression.property.type === 'Identifier' && + (memberExpression.property.name === 'get' || + memberExpression.property.name === 'getEnforcing') + ) + ) { + return false; + } + return true; +} + +module.exports = function({parse, types: t}) { return { pre(state) { this.code = state.code; @@ -61,6 +94,11 @@ module.exports = function(context) { this.defaultExport = null; this.commandsExport = null; this.codeInserted = false; + + /** + * TurboModule JS Codegen State + */ + this.turboModuleRequireCallExpressions = []; }, visitor: { ExportNamedDeclaration(path) { @@ -118,18 +156,66 @@ module.exports = function(context) { this.defaultExport = path; } }, + + CallExpression(path) { + if (isTurboModuleRequire(path)) { + this.turboModuleRequireCallExpressions.push(path); + } + }, + Program: { - exit() { + exit(path) { if (this.defaultExport) { const viewConfig = generateViewConfig(this.filename, this.code); this.defaultExport.replaceWithMultiple( - context.parse(viewConfig).program.body, + parse(viewConfig).program.body, ); if (this.commandsExport != null) { this.commandsExport.remove(); } this.codeInserted = true; } + + /** + * Insert the TurboModule schema into the TurboModuleRegistry.(get|getEnforcing) + * call. + */ + if (this.turboModuleRequireCallExpressions.length > 0) { + const schema = parseString(this.code, this.filename); + const hasteModuleName = basename(this.filename).replace( + /\.js$/, + '', + ); + const actualSchema = schema.modules[hasteModuleName]; + + if (actualSchema.type !== 'NativeModule') { + throw path.buildCodeFrameError( + `Detected NativeModule require in module '${hasteModuleName}', but generated schema wasn't for a NativeModule.`, + ); + } + + path.pushContainer( + 'body', + parse( + `function __getModuleSchema() { + if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { + return undefined; + } + + return ${JSON.stringify(actualSchema, null, 2)}; + }`, + ).program.body[0], + ); + + this.turboModuleRequireCallExpressions.forEach( + callExpressionPath => { + callExpressionPath.pushContainer( + 'arguments', + t.callExpression(t.identifier('__getModuleSchema'), []), + ); + }, + ); + } }, }, }, From 165dcccc58eb7352224d8b372b36c05d15860555 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sun, 8 Nov 2020 14:02:02 -0800 Subject: [PATCH 0033/1810] Introduce TurboModuleSchema Summary: JavaTurboModule will use instances of this class to perform method invocation. TurboModuleSchema is created by parsing the `jsi::Value` that represents the TurboModule's schema. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D22832729 fbshipit-source-id: 792736e176c33a302f6a41c6f63a4812b09af585 --- .../android/ReactCommon/TurboModuleSchema.cpp | 533 ++++++++++++++++++ .../android/ReactCommon/TurboModuleSchema.h | 56 ++ 2 files changed, 589 insertions(+) create mode 100644 ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp create mode 100644 ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp new file mode 100644 index 00000000000000..dfa51d287cdc25 --- /dev/null +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp @@ -0,0 +1,533 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "TurboModuleSchema.h" +#include +#include +#include + +namespace facebook { +namespace react { + +std::ostream &operator<<(std::ostream &os, const TurboModuleSchema &schema) { + os << "TurboModuleSchema {" << std::endl; + os << " .moduleName = " << schema.moduleName_ << "," << std::endl; + os << " .methods = [" << std::endl; + + for (const TurboModuleSchema::Method &method : schema.methods_) { + os << " {" << std::endl; + os << " .jsReturnType = "; + if (method.jsReturnType == VoidKind) { + os << "VoidKind"; + } else if (method.jsReturnType == BooleanKind) { + os << "BooleanKind"; + } else if (method.jsReturnType == NumberKind) { + os << "NumberKind"; + } else if (method.jsReturnType == StringKind) { + os << "StringKind"; + } else if (method.jsReturnType == ObjectKind) { + os << "ObjectKind"; + } else if (method.jsReturnType == ArrayKind) { + os << "ArrayKind"; + } else if (method.jsReturnType == FunctionKind) { + os << "FunctionKind"; + } else if (method.jsReturnType == PromiseKind) { + os << "PromiseKind"; + } + os << "," << std::endl; + os << " .name = \"" << method.name << "\"," << std::endl; + os << " .jniSignature = \"" << method.jniSignature << "\"," + << std::endl; + os << " .isOptional = " << (method.isOptional ? "true" : "false") + << std::endl; + os << " }," << std::endl; + } + + os << " ]" << std::endl; + os << "}" << std::endl; + return os; +} + +namespace { +struct UnwrappedTypeAnnotation { + jsi::Object typeAnnotation; + bool nullable; +}; + +UnwrappedTypeAnnotation unwrapTypeAnnotation( + jsi::Runtime &runtime, + jsi::Object &&typeAnnotation) { + std::string type = typeAnnotation.getProperty(runtime, "type") + .asString(runtime) + .utf8(runtime); + if (type == "NullableTypeAnnotation") { + return UnwrappedTypeAnnotation{ + .typeAnnotation = typeAnnotation.getProperty(runtime, "typeAnnotation") + .asObject(runtime), + .nullable = true, + }; + } + + return UnwrappedTypeAnnotation{ + .typeAnnotation = std::move(typeAnnotation), + .nullable = false, + }; +} +} // namespace + +TurboModuleSchema::ParseException::ParseException(std::string what) + : jsi::JSIException(what) {} + +TurboModuleSchema::TurboModuleSchema( + const std::string &moduleName, + std::vector &&methods) + : moduleName_(moduleName), methods_(std::move(methods)) {} + +bool TurboModuleSchema::hasMethod(const std::string &methodName) const { + for (const Method &method : methods_) { + if (method.name == methodName) { + return true; + } + } + return false; +} + +const TurboModuleSchema::Method &TurboModuleSchema::getMethod( + const std::string &methodName) const { + for (const Method &method : methods_) { + if (method.name == methodName) { + return method; + } + } + + throw std::runtime_error( + std::string("TurboModuleSchema::getMethod: TurboModule method \"") + + moduleName_ + "." + methodName + "()\" doesn't exist"); +} + +static TurboModuleMethodValueKind convertFunctionTypeAnnotationReturnToJSType( + jsi::Runtime &runtime, + std::string moduleName, + std::string methodName, + UnwrappedTypeAnnotation &unwrappedTypeAnnotation) { + jsi::Object &returnTypeAnnotation = unwrappedTypeAnnotation.typeAnnotation; + std::string returnType = returnTypeAnnotation.getProperty(runtime, "type") + .asString(runtime) + .utf8(runtime); + /** + * NativeModuleReturnOnlyTypeAnnotation + */ + if (returnType == "PromiseTypeAnnotation") { + return PromiseKind; + } + + if (returnType == "VoidTypeAnnotation") { + return VoidKind; + } + + /** + * NativeModuleBaseTypeAnnotation + */ + if (returnType == "StringTypeAnnotation") { + return StringKind; + } + + if (returnType == "NumberTypeAnnotation" || + returnType == "Int32TypeAnnotation" || + returnType == "DoubleTypeAnnotation" || + returnType == "FloatTypeAnnotation") { + return NumberKind; + } + + if (returnType == "BooleanTypeAnnotation") { + return BooleanKind; + } + + if (returnType == "GenericObjectTypeAnnotation") { + return ObjectKind; + } + + std::string errorHeader = + "TurboModuleSchema::parse(): Failed to parse JS return type for TurboModule method " + + moduleName + "." + methodName + "(): "; + + if (returnType == "ReservedTypeAnnotation") { + std::string reservedFunctionValueTypeName = + returnTypeAnnotation.getProperty(runtime, "name") + .asString(runtime) + .utf8(runtime); + + if (reservedFunctionValueTypeName == "RootTag") { + return NumberKind; + } + + throw TurboModuleSchema::ParseException( + errorHeader + "Detected invalid ReservedTypeAnnotation \"" + + reservedFunctionValueTypeName + "\""); + } + + if (returnType == "ArrayTypeAnnotation") { + return ArrayKind; + } + + if (returnType == "ObjectTypeAnnotation" || + returnType == "TypeAliasTypeAnnotation") { + return ObjectKind; + } + + throw TurboModuleSchema::ParseException( + errorHeader + "Unsupported return type \"" + returnType + "\""); +} + +static std::string convertFunctionTypeAnnotationReturnToJNIType( + jsi::Runtime &runtime, + std::string moduleName, + std::string methodName, + UnwrappedTypeAnnotation &unwrappedTypedAnnotation) { + jsi::Object &returnTypeAnnotation = unwrappedTypedAnnotation.typeAnnotation; + std::string returnType = returnTypeAnnotation.getProperty(runtime, "type") + .asString(runtime) + .utf8(runtime); + /** + * NativeModuleReturnOnlyTypeAnnotation + */ + if (returnType == "PromiseTypeAnnotation" || + returnType == "VoidTypeAnnotation") { + return "V"; + } + + /** + * NativeModuleBaseTypeAnnotation + */ + if (returnType == "StringTypeAnnotation") { + return "Ljava/lang/String;"; + } + + bool isReturnNullable = unwrappedTypedAnnotation.nullable; + + if (returnType == "NumberTypeAnnotation" || + returnType == "Int32TypeAnnotation" || + returnType == "DoubleTypeAnnotation" || + returnType == "FloatTypeAnnotation") { + if (isReturnNullable) { + return "Ljava/lang/Double;"; + } + + return "D"; + } + + if (returnType == "BooleanTypeAnnotation") { + if (isReturnNullable) { + return "Ljava/lang/Boolean;"; + } + + return "Z"; + } + + if (returnType == "GenericObjectTypeAnnotation") { + return "Lcom/facebook/react/bridge/WritableMap;"; + } + + std::string errorHeader = + "TurboModuleSchema::parse(): Failed to parse JNI return type for TurboModule method " + + moduleName + "." + methodName + "(): "; + + if (returnType == "ReservedTypeAnnotation") { + std::string reservedFunctionValueTypeName = + returnTypeAnnotation.getProperty(runtime, "name") + .asString(runtime) + .utf8(runtime); + + if (reservedFunctionValueTypeName == "RootTag") { + if (isReturnNullable) { + return "Ljava/lang/Double;"; + } + return "D"; + } + + throw TurboModuleSchema::ParseException( + errorHeader + "Detected invalid ReservedTypeAnnotation \"" + + reservedFunctionValueTypeName + "\""); + } + + if (returnType == "ArrayTypeAnnotation") { + return "Lcom/facebook/react/bridge/WritableArray;"; + } + + if (returnType == "ObjectTypeAnnotation" || + returnType == "TypeAliasTypeAnnotation") { + return "Lcom/facebook/react/bridge/WritableMap;"; + } + + throw TurboModuleSchema::ParseException( + errorHeader + "Unsupported return type \"" + returnType + "\""); +} + +static std::string convertFunctionTypeAnnotationParamToJNIType( + jsi::Runtime &runtime, + std::string moduleName, + std::string methodName, + std::string paramName, + bool isParamOptional, + UnwrappedTypeAnnotation &unwrappedParamTypeAnnotation) { + jsi::Object ¶mTypeAnnotation = + unwrappedParamTypeAnnotation.typeAnnotation; + + std::string paramType = paramTypeAnnotation.getProperty(runtime, "type") + .asString(runtime) + .utf8(runtime); + + /** + * NativeModuleParamOnlyTypeAnnotation + */ + if (paramType == "FunctionTypeAnnotation") { + return "Lcom/facebook/react/bridge/Callback;"; + } + + /** + * NativeModuleBaseTypeAnnotation + */ + if (paramType == "StringTypeAnnotation") { + return "Ljava/lang/String;"; + } + + bool isParamRequired = + !(unwrappedParamTypeAnnotation.nullable || isParamOptional); + + if (paramType == "NumberTypeAnnotation" || + paramType == "Int32TypeAnnotation" || + paramType == "DoubleTypeAnnotation" || + paramType == "FloatTypeAnnotation") { + if (!isParamRequired) { + return "Ljava/lang/Double;"; + } + + return "D"; + } + + if (paramType == "BooleanTypeAnnotation") { + if (!isParamRequired) { + return "Ljava/lang/Boolean;"; + } + + return "Z"; + } + + if (paramType == "GenericObjectTypeAnnotation") { + return "Lcom/facebook/react/bridge/ReadableMap;"; + } + + std::string errorHeader = + "TurboModuleSchema::parse(): Failed to parse JNI type for param \"" + + paramName + "\" in TurboModule method " + moduleName + "." + methodName + + "(): "; + + if (paramType == "ReservedTypeAnnotation") { + std::string reservedFunctionValueTypeName = + paramTypeAnnotation.getProperty(runtime, "name") + .asString(runtime) + .utf8(runtime); + + if (reservedFunctionValueTypeName == "RootTag") { + if (!isParamRequired) { + return "Ljava/lang/Double;"; + } + return "D"; + } + + throw TurboModuleSchema::ParseException( + errorHeader + "Detected invalid ReservedTypeAnnotation \"" + + reservedFunctionValueTypeName + "\""); + } + + if (paramType == "ArrayTypeAnnotation") { + return "Lcom/facebook/react/bridge/ReadableArray;"; + } + + if (paramType == "ObjectTypeAnnotation" || + paramType == "TypeAliasTypeAnnotation") { + return "Lcom/facebook/react/bridge/ReadableMap;"; + } + + throw TurboModuleSchema::ParseException( + errorHeader + "Unsupported param type \"" + paramType + "\""); +} + +TurboModuleSchema::Method parseMethod( + jsi::Runtime &runtime, + const std::string &moduleName, + const std::string &methodName, + bool isMethodOptional, + UnwrappedTypeAnnotation &unwrappedFunctionTypeAnnotation) { + jsi::Object &functionTypeAnnotation = + unwrappedFunctionTypeAnnotation.typeAnnotation; + bool isMethodRequired = + !(unwrappedFunctionTypeAnnotation.nullable || isMethodOptional); + + /** + * Step 1: Take care of getConstants special case. + */ + if (methodName == "getConstants") { + return TurboModuleSchema::Method{ + .jsReturnType = ObjectKind, + .name = methodName, + .jniSignature = "()Ljava/util/Map;", + .isOptional = !isMethodRequired, + }; + } + + /** + * Step 2: Get JS and JNI return type + */ + UnwrappedTypeAnnotation unwrappedReturnTypeAnnotation = unwrapTypeAnnotation( + runtime, + functionTypeAnnotation.getProperty(runtime, "returnTypeAnnotation") + .asObject(runtime)); + + TurboModuleMethodValueKind returnType = + convertFunctionTypeAnnotationReturnToJSType( + runtime, moduleName, methodName, unwrappedReturnTypeAnnotation); + + std::string jniReturnType = convertFunctionTypeAnnotationReturnToJNIType( + runtime, moduleName, methodName, unwrappedReturnTypeAnnotation); + + /** + * Step 3: Get method param types + */ + jsi::Array functionTypeAnnotationParams = + functionTypeAnnotation.getProperty(runtime, "params") + .asObject(runtime) + .asArray(runtime); + + size_t numFunctionTypeAnnotationParams = + functionTypeAnnotationParams.size(runtime); + + std::string jniSignatureParams = ""; + + for (size_t j = 0; j < numFunctionTypeAnnotationParams; j += 1) { + jsi::Object functionTypeAnnotationParam = + functionTypeAnnotationParams.getValueAtIndex(runtime, j) + .asObject(runtime); + + std::string paramName = + functionTypeAnnotationParam.getProperty(runtime, "name") + .asString(runtime) + .utf8(runtime); + + bool isParamOptional = jsi::Value::strictEquals( + runtime, + functionTypeAnnotationParam.getProperty(runtime, "optional"), + jsi::Value(true)); + + UnwrappedTypeAnnotation unwrappedParamTypeAnnotation = unwrapTypeAnnotation( + runtime, + functionTypeAnnotationParam.getProperty(runtime, "typeAnnotation") + .asObject(runtime)); + + std::string jniParamType = convertFunctionTypeAnnotationParamToJNIType( + runtime, + moduleName, + methodName, + paramName, + isParamOptional, + unwrappedParamTypeAnnotation); + + jniSignatureParams += jniParamType; + } + + /** + * Step 4a: Append Promise param if return type is promise + */ + + if (returnType == PromiseKind) { + jniSignatureParams += "Lcom/facebook/react/bridge/Promise;"; + } + + /** + * Step 5: Create jni Signature + */ + std::string jniSignature = "(" + jniSignatureParams + ")" + jniReturnType; + + /** + * Create method + */ + return TurboModuleSchema::Method{ + .jsReturnType = returnType, + .name = methodName, + .jniSignature = jniSignature, + .isOptional = !isMethodRequired, + }; +} + +TurboModuleSchema TurboModuleSchema::parse( + jsi::Runtime &runtime, + const std::string &moduleName, + const jsi::Value &schema) { + if (schema.isNull() || schema.isUndefined()) { + throw std::invalid_argument( + std::string("TurboModuleSchema::parse(): TurboModule schema was ") + + (schema.isNull() ? "null" : "undefined ") + " for module \"" + + moduleName + "\""); + } + + jsi::Array properties = schema.asObject(runtime) + .getProperty(runtime, "spec") + .asObject(runtime) + .getProperty(runtime, "properties") + .asObject(runtime) + .asArray(runtime); + + size_t numProperties = properties.size(runtime); + std::vector methods; + methods.reserve(numProperties); + + for (size_t i = 0; i < numProperties; i += 1) { + jsi::Object property = + properties.getValueAtIndex(runtime, i).asObject(runtime); + + bool isPropertyOptional = jsi::Value::strictEquals( + runtime, property.getProperty(runtime, "optional"), jsi::Value(true)); + + std::string propertyName = + property.getProperty(runtime, "name").asString(runtime).utf8(runtime); + + /** + * Step 0: Ignore non-function property keys + */ + UnwrappedTypeAnnotation unwrappedPropertyTypeAnnotation = + unwrapTypeAnnotation( + runtime, + property.getProperty(runtime, "typeAnnotation").asObject(runtime)); + + if (unwrappedPropertyTypeAnnotation.typeAnnotation + .getProperty(runtime, "type") + .asString(runtime) + .utf8(runtime) != "FunctionTypeAnnotation") { + continue; + } + + try { + methods.push_back(parseMethod( + runtime, + moduleName, + propertyName, + isPropertyOptional, + unwrappedPropertyTypeAnnotation)); + } catch (const TurboModuleSchema::ParseException &ex) { + /** + * If we fail parsing the method, assume that it doesn't exist. + */ + LOG(ERROR) << ex.what() << std::endl; + continue; + } + } + + return TurboModuleSchema{moduleName, std::move(methods)}; +} + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h new file mode 100644 index 00000000000000..76e0839c2ce7af --- /dev/null +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include +#include +#include + +namespace facebook { +namespace react { + +class TurboModuleSchema { + public: + struct Method { + const TurboModuleMethodValueKind jsReturnType; + const std::string name; + const std::string jniSignature; + const bool isOptional; + }; + + class ParseException : public jsi::JSIException { + public: + ParseException(std::string what); + }; + + private: + const std::string moduleName_; + const std::vector methods_; + + TurboModuleSchema( + const std::string &moduleName, + std::vector &&methods); + + public: + TurboModuleSchema() = delete; + bool hasMethod(const std::string &methodName) const; + const Method &getMethod(const std::string &methodName) const; + + static TurboModuleSchema parse( + jsi::Runtime &runtime, + const std::string &moduleName, + const jsi::Value &schema); + + friend std::ostream &operator<<( + std::ostream &os, + const TurboModuleSchema &schema); +}; + +} // namespace react +} // namespace facebook From 610dcf488ba67eace90f4847fdaeeb411e42ad09 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sun, 8 Nov 2020 14:02:02 -0800 Subject: [PATCH 0034/1810] Implement method dispatch using TurboModuleSchema Summary: This is the final diff in the JS TurboModule codegen stack for Android. It implements method dispatch using the TurboModuleSchema object. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D22837486 fbshipit-source-id: f91b03f064941457d4b8c5e37e011468559dee71 --- .../jni/ReactCommon/TurboModuleManager.cpp | 11 +++- .../android/ReactCommon/JavaTurboModule.cpp | 62 +++++++++++++++++++ .../android/ReactCommon/JavaTurboModule.h | 8 +++ .../android/ReactCommon/TurboModuleSchema.cpp | 11 +++- .../android/ReactCommon/TurboModuleSchema.h | 18 +++++- 5 files changed, 104 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp index 52d9861de96da8..81c17fabb955d5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "TurboModuleManager.h" @@ -76,7 +77,8 @@ void TurboModuleManager::installJSIBindings() { jsCallInvoker_ = std::weak_ptr(jsCallInvoker_), nativeCallInvoker_ = std::weak_ptr(nativeCallInvoker_), delegate_ = jni::make_weak(delegate_), - javaPart_ = jni::make_weak(javaPart_)]( + javaPart_ = jni::make_weak(javaPart_), + runtime_ = runtime_]( const std::string &name, const jsi::Value *schema) -> std::shared_ptr { auto turboModuleCache = turboModuleCache_.lock(); @@ -139,6 +141,13 @@ void TurboModuleManager::installJSIBindings() { .jsInvoker = jsCallInvoker, .nativeInvoker = nativeCallInvoker}; + if (schema->isObject() && !schema->isNull()) { + auto turboModule = std::make_shared( + params, TurboModuleSchema::parse(*runtime_, name, *schema)); + TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); + return turboModule; + } + auto turboModule = delegate->cthis()->getTurboModule(name, params); turboModuleCache->insert({name, turboModule}); TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index f4b3f967e91c48..f7af1f517f53ed 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -56,6 +56,68 @@ void JavaTurboModule::enablePromiseAsyncDispatch(bool enable) { isPromiseAsyncDispatchEnabled_ = enable; } +JavaTurboModule::JavaTurboModule( + const InitParams ¶ms, + TurboModuleSchema &&schema) + : TurboModule(params.moduleName, params.jsInvoker), + instance_(jni::make_global(params.instance)), + nativeInvoker_(params.nativeInvoker), + turboModuleSchema_(std::move(schema)) {} + +jsi::Value JavaTurboModule::get( + jsi::Runtime &runtime, + const jsi::PropNameID &propName) { + if (!turboModuleSchema_) { + return TurboModule::get(runtime, propName); + } + + std::string methodName = propName.utf8(runtime); + if (!turboModuleSchema_->hasMethod(methodName)) { + return jsi::Value::undefined(); + } + + using MethodImplStatus = TurboModuleSchema::Method::ImplStatus; + TurboModuleSchema::Method &method = turboModuleSchema_->getMethod(methodName); + + if (method.isOptional) { + if (method.implStatus == MethodImplStatus::Unknown) { + auto instance = instance_.get(); + JNIEnv *env = jni::Environment::current(); + jclass cls = env->GetObjectClass(instance); + jmethodID methodID = env->GetMethodID( + cls, methodName.c_str(), method.jniSignature.c_str()); + + // If the method signature doesn't match, show a redbox here instead of + // crashing later. + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + method.implStatus = methodID != nullptr ? MethodImplStatus::Implemented + : MethodImplStatus::Unimplemented; + } + + if (method.implStatus == MethodImplStatus::Unimplemented) { + return jsi::Value::undefined(); + } + } + + return jsi::Function::createFromHostFunction( + runtime, + propName, + method.jsParamCount, + [this, method]( + facebook::jsi::Runtime &runtime, + const facebook::jsi::Value &thisVal, + const facebook::jsi::Value *args, + size_t count) { + return invokeJavaMethod( + runtime, + method.jsReturnType, + method.name, + method.jniSignature, + args, + count); + }); +} + namespace { jni::local_ref createJavaCallbackFromJSIFunction( jsi::Function &&function, diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h index 93acda48fcff56..2e15fea7176dae 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h @@ -13,9 +13,12 @@ #include #include #include +#include #include #include +#include "TurboModuleSchema.h" + namespace facebook { namespace react { @@ -41,7 +44,9 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { }; JavaTurboModule(const InitParams ¶ms); + JavaTurboModule(const InitParams ¶ms, TurboModuleSchema &&schema); virtual ~JavaTurboModule(); + jsi::Value invokeJavaMethod( jsi::Runtime &runtime, TurboModuleMethodValueKind valueKind, @@ -51,10 +56,13 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { size_t argCount); static void enablePromiseAsyncDispatch(bool enable); + jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &propName) + override; private: jni::global_ref instance_; std::shared_ptr nativeInvoker_; + folly::Optional turboModuleSchema_; /** * Experiments diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp index dfa51d287cdc25..484a3e98e4de64 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.cpp @@ -44,6 +44,7 @@ std::ostream &operator<<(std::ostream &os, const TurboModuleSchema &schema) { << std::endl; os << " .isOptional = " << (method.isOptional ? "true" : "false") << std::endl; + os << " .jsParamCount = " << method.jsParamCount << "," << std::endl; os << " }," << std::endl; } @@ -96,9 +97,9 @@ bool TurboModuleSchema::hasMethod(const std::string &methodName) const { return false; } -const TurboModuleSchema::Method &TurboModuleSchema::getMethod( - const std::string &methodName) const { - for (const Method &method : methods_) { +TurboModuleSchema::Method &TurboModuleSchema::getMethod( + const std::string &methodName) { + for (Method &method : methods_) { if (method.name == methodName) { return method; } @@ -377,6 +378,8 @@ TurboModuleSchema::Method parseMethod( .name = methodName, .jniSignature = "()Ljava/util/Map;", .isOptional = !isMethodRequired, + .jsParamCount = 0, + .implStatus = TurboModuleSchema::Method::ImplStatus::Unknown, }; } @@ -460,6 +463,8 @@ TurboModuleSchema::Method parseMethod( .name = methodName, .jniSignature = jniSignature, .isOptional = !isMethodRequired, + .jsParamCount = numFunctionTypeAnnotationParams, + .implStatus = TurboModuleSchema::Method::ImplStatus::Unknown, }; } diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h index 76e0839c2ce7af..585739de76c718 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/TurboModuleSchema.h @@ -18,10 +18,24 @@ namespace react { class TurboModuleSchema { public: struct Method { + /** + * Optional methods might not be implemented on the Java NativeModule class. + * - Unknown: We must check if the method exists using JNI + * - Implemented: Using JNI, we verified that the method exists + * - Unimplemented: Using JNI, we verified that the method doesn't exist + */ + enum class ImplStatus { + Unknown, + Implemented, + Unimplemented, + }; + const TurboModuleMethodValueKind jsReturnType; const std::string name; const std::string jniSignature; const bool isOptional; + const size_t jsParamCount; + ImplStatus implStatus; }; class ParseException : public jsi::JSIException { @@ -31,7 +45,7 @@ class TurboModuleSchema { private: const std::string moduleName_; - const std::vector methods_; + std::vector methods_; TurboModuleSchema( const std::string &moduleName, @@ -40,7 +54,7 @@ class TurboModuleSchema { public: TurboModuleSchema() = delete; bool hasMethod(const std::string &methodName) const; - const Method &getMethod(const std::string &methodName) const; + Method &getMethod(const std::string &methodName); static TurboModuleSchema parse( jsi::Runtime &runtime, From 803a26cb003e6b790e3a1ab31beb0c95795fff0c Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 9 Nov 2020 01:40:57 -0800 Subject: [PATCH 0035/1810] TM Android: Avoid creating TM instance if the module is not TM enabled Summary: There is a flow where TM registry is creating a module instance (as registered in the TurboReactPackage), only to discard it if it's not a TM enabled module. This may be fine for many modules, but for module like `UIManagerModule`, this may cause a race condition or other issues, including potential perf regression when accessing UIManager from JS (e.g. for getting native viewConfigs). Changelog: [Internal] Reviewed By: RSNara Differential Revision: D24811838 fbshipit-source-id: 6e1cce6993a6e5c9763773f175083bf52925c910 --- .../react/config/ReactFeatureFlags.java | 5 +++ ...eactPackageTurboModuleManagerDelegate.java | 31 ++++++++++++++++--- .../react/uiapp/RNTesterApplication.java | 1 + 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index a304728a3b26b7..5a5cfeee2f78ec 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -29,6 +29,11 @@ public class ReactFeatureFlags { /** Enable TurboModule JS Codegen. */ public static volatile boolean useTurboModuleJSCodegen = false; + /** + * Enable the fix to validate the TurboReactPackage's module info before resolving a TurboModule. + */ + public static volatile boolean enableTurboModulePackageInfoValidation = false; + /* * This feature flag enables logs for Fabric */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java index 65ee5186e476bc..74a7ca72d2f4c9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java @@ -15,13 +15,18 @@ import com.facebook.react.bridge.CxxModuleWrapper; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.module.model.ReactModuleInfo; import com.facebook.react.turbomodule.core.interfaces.TurboModule; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public abstract class ReactPackageTurboModuleManagerDelegate extends TurboModuleManagerDelegate { private final List mPackages = new ArrayList<>(); + private final Map> mPackageModuleInfos = + new HashMap<>(); private final ReactApplicationContext mReactApplicationContext; protected ReactPackageTurboModuleManagerDelegate( @@ -30,7 +35,11 @@ protected ReactPackageTurboModuleManagerDelegate( mReactApplicationContext = reactApplicationContext; for (ReactPackage reactPackage : packages) { if (reactPackage instanceof TurboReactPackage) { - mPackages.add((TurboReactPackage) reactPackage); + TurboReactPackage pkg = (TurboReactPackage) reactPackage; + mPackages.add(pkg); + if (ReactFeatureFlags.enableTurboModulePackageInfoValidation) { + mPackageModuleInfos.put(pkg, pkg.getReactModuleInfoProvider().getReactModuleInfos()); + } } } } @@ -72,9 +81,23 @@ private TurboModule resolveModule(String moduleName) { for (final TurboReactPackage pkg : mPackages) { try { - NativeModule module = pkg.getModule(moduleName, mReactApplicationContext); - if (resolvedModule == null || module != null && module.canOverrideExistingModule()) { - resolvedModule = module; + if (ReactFeatureFlags.enableTurboModulePackageInfoValidation) { + final ReactModuleInfo moduleInfo = mPackageModuleInfos.get(pkg).get(moduleName); + if (moduleInfo == null + || !moduleInfo.isTurboModule() + || resolvedModule != null && !moduleInfo.canOverrideExistingModule()) { + continue; + } + + final NativeModule module = pkg.getModule(moduleName, mReactApplicationContext); + if (module != null) { + resolvedModule = module; + } + } else { + final NativeModule module = pkg.getModule(moduleName, mReactApplicationContext); + if (resolvedModule == null || module != null && module.canOverrideExistingModule()) { + resolvedModule = module; + } } } catch (IllegalArgumentException ex) { /** diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index a101b8cef9e872..0c2e08f91c3b76 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -206,6 +206,7 @@ public double getDouble(final String s) { @Override public void onCreate() { ReactFeatureFlags.useTurboModules = BuildConfig.ENABLE_TURBOMODULE; + ReactFeatureFlags.enableTurboModulePackageInfoValidation = true; ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik); super.onCreate(); SoLoader.init(this, /* native exopackage */ false); From b6362c24f9b538b14748457045294ee3acb20a99 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 9 Nov 2020 01:40:57 -0800 Subject: [PATCH 0036/1810] TM Android proguard: keep com.facebook.react.turbomodule.core.** Summary: Various TM infra classes previously were stripped by proguard. This updates the rule to not remove TM Android core infra. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D24812999 fbshipit-source-id: 3b713c63e25a209b17869f7e5311ee54a113a567 --- ReactAndroid/build.gradle | 1 + ReactAndroid/proguard-rules.pro | 1 + 2 files changed, 2 insertions(+) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 70c245c1fd5f21..daa5a0c75d3e18 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -305,6 +305,7 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) { inputs.dir("$projectDir/../ReactCommon") inputs.dir("src/main/jni") + inputs.dir("src/main/java/com/facebook/react/turbomodule/core/jni") inputs.dir("src/main/java/com/facebook/react/modules/blob") outputs.dir("$buildDir/react-ndk/all") commandLine(getNdkBuildFullPath(), diff --git a/ReactAndroid/proguard-rules.pro b/ReactAndroid/proguard-rules.pro index e13dfef7ec70ad..ce3f77b22ee9df 100644 --- a/ReactAndroid/proguard-rules.pro +++ b/ReactAndroid/proguard-rules.pro @@ -50,6 +50,7 @@ -dontwarn com.facebook.react.** -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } +-keep,includedescriptorclasses class com.facebook.react.turbomodule.core.** { *; } # hermes -keep class com.facebook.jni.** { *; } From 8e956b3afd2ec8ecfcc6498a99dd878e3de4e041 Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Mon, 9 Nov 2020 06:42:10 -0800 Subject: [PATCH 0037/1810] Back out "Change StatusBar default style handling strategy" Summary: Original commit changeset: 76e7d0d45fd3 Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D24783092 fbshipit-source-id: 876eaeaffbed63599553456f189f3675aa406e13 --- Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js | 1 - Libraries/Components/StatusBar/StatusBar.js | 2 +- .../com/facebook/react/modules/statusbar/StatusBarModule.java | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js b/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js index b451b90827ed30..5b00b2a4c218a6 100644 --- a/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +++ b/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js @@ -55,7 +55,6 @@ const NativeStatusBarManager = { /** * - statusBarStyles can be: * - 'default' - * - 'light-content' * - 'dark-content' */ setStyle(statusBarStyle?: ?string): void { diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 75b51a082829ef..021e75494d12fa 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -25,7 +25,7 @@ import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS'; */ export type StatusBarStyle = $Keys<{ /** - * Default status bar style (dark for iOS, no change for Android) + * Default status bar style (dark for iOS, light for Android) */ default: string, /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java index 44391965e63b31..b4a4e80e68485e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java @@ -194,7 +194,7 @@ public void run() { int systemUiVisibilityFlags = decorView.getSystemUiVisibility(); if ("dark-content".equals(style)) { systemUiVisibilityFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } else if ("light-content".equals(style)) { + } else { systemUiVisibilityFlags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } decorView.setSystemUiVisibility(systemUiVisibilityFlags); From d021000b9e358a9379ca5d6208f24757c0c8ce97 Mon Sep 17 00:00:00 2001 From: Martin Sherburn Date: Mon, 9 Nov 2020 10:32:42 -0800 Subject: [PATCH 0038/1810] Fix race condition in Inspector shutdown Summary: The `state_` member variable was getting destroyed before the `executor_` (because `state_` is declared after `executor_` https://stackoverflow.com/questions/2254263/order-of-member-constructor-and-destructor-calls). This lead to a race condition where items still pending on the `executor_` thread could try to run and access `state_` after it had already been reset. Changelog: [General][Fixed] - Fix race condition in Debug Inspector shutdown Reviewed By: mhorowitz Differential Revision: D24705062 fbshipit-source-id: e575d66322ab980b1a8c3e6083a0b3d40b9c944b --- ReactCommon/hermes/inspector/Inspector.cpp | 1 - ReactCommon/hermes/inspector/Inspector.h | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ReactCommon/hermes/inspector/Inspector.cpp b/ReactCommon/hermes/inspector/Inspector.cpp index 21b7bd2108de11..c17e43030428a0 100644 --- a/ReactCommon/hermes/inspector/Inspector.cpp +++ b/ReactCommon/hermes/inspector/Inspector.cpp @@ -132,7 +132,6 @@ Inspector::Inspector( } Inspector::~Inspector() { - // TODO: think about expected detach flow debugger_.setEventObserver(nullptr); } diff --git a/ReactCommon/hermes/inspector/Inspector.h b/ReactCommon/hermes/inspector/Inspector.h index 3e4612530ea869..a55f1c45b9cfb0 100644 --- a/ReactCommon/hermes/inspector/Inspector.h +++ b/ReactCommon/hermes/inspector/Inspector.h @@ -319,11 +319,6 @@ class Inspector : public facebook::hermes::debugger::EventObserver, facebook::hermes::debugger::Debugger &debugger_; InspectorObserver &observer_; - // All client methods (e.g. enable, setBreakpoint, resume, etc.) are executed - // on executor_ to prevent deadlocking on mutex_. See the implementation for - // more comments on the threading invariants used in this class. - std::unique_ptr executor_; - // All of the following member variables are guarded by mutex_. std::mutex mutex_; std::unique_ptr state_; @@ -360,6 +355,12 @@ class Inspector : public facebook::hermes::debugger::EventObserver, // Are we currently waiting for a debugger to attach, because we // requested 'pauseOnFirstStatement'? bool awaitingDebuggerOnStart_; + + // All client methods (e.g. enable, setBreakpoint, resume, etc.) are executed + // on executor_ to prevent deadlocking on mutex_. See the implementation for + // more comments on the threading invariants used in this class. + // NOTE: This needs to be declared LAST because it should be destroyed FIRST. + std::unique_ptr executor_; }; } // namespace inspector From 69ade5996f7073d16082af6277eb1388110b171c Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Mon, 9 Nov 2020 13:27:38 -0800 Subject: [PATCH 0039/1810] React Native sync for revisions 4e5d7fa...454c221 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Base sync before adding Flight files. This sync includes the following changes: - **[454c2211c](https://github.com/facebook/react/commit/454c2211c )**: Refactor SchedulerHostConfigs ([#20025](https://github.com/facebook/react/pull/20025)) //// - **[56e9feead](https://github.com/facebook/react/commit/56e9feead )**: Remove Blocks ([#20138](https://github.com/facebook/react/pull/20138)) //// - **[3fbd47b86](https://github.com/facebook/react/commit/3fbd47b86 )**: Serialize pending server components by reference (lazy component) ([#20137](https://github.com/facebook/react/pull/20137)) //// - **[930ce7c15](https://github.com/facebook/react/commit/930ce7c15 )**: Allow values to be encoded by "reference" to a value rather than the value itself ([#20136](https://github.com/facebook/react/pull/20136)) //// - **[39eb6d176](https://github.com/facebook/react/commit/39eb6d176 )**: Rename ([#20134](https://github.com/facebook/react/pull/20134)) //// - **[ffd842335](https://github.com/facebook/react/commit/ffd842335 )**: [Flight] Add support for Module References in transport protocol ([#20121](https://github.com/facebook/react/pull/20121)) //// - **[343d7a4a7](https://github.com/facebook/react/commit/343d7a4a7 )**: Fast Refresh: Don't block DevTools commit hook ([#20129](https://github.com/facebook/react/pull/20129)) //// - **[779a472b0](https://github.com/facebook/react/commit/779a472b0 )**: Prevent inlining into recursive commit functions ([#20105](https://github.com/facebook/react/pull/20105)) //// - **[25b18d31c](https://github.com/facebook/react/commit/25b18d31c )**: Traverse commit phase effects iteratively ([#20094](https://github.com/facebook/react/pull/20094)) //// Changelog: [General][Changed] - React Native sync for revisions 4e5d7fa...454c221 Reviewed By: rickhanlonii Differential Revision: D24698701 fbshipit-source-id: dfaf692b1051150355dece1657764a484b7ae603 --- Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 69 +++++-------------- .../implementations/ReactFabric-dev.js | 69 +++++-------------- .../implementations/ReactFabric-prod.fb.js | 38 ++++------ .../implementations/ReactFabric-prod.js | 38 ++++------ .../ReactFabric-profiling.fb.js | 38 ++++------ .../implementations/ReactFabric-profiling.js | 38 ++++------ .../ReactNativeRenderer-dev.fb.js | 69 +++++-------------- .../ReactNativeRenderer-dev.js | 69 +++++-------------- .../ReactNativeRenderer-prod.fb.js | 40 ++++------- .../ReactNativeRenderer-prod.js | 40 ++++------- .../ReactNativeRenderer-profiling.fb.js | 40 ++++------- .../ReactNativeRenderer-profiling.js | 40 ++++------- 13 files changed, 165 insertions(+), 425 deletions(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 25abc612cfd324..6a7b5011ed80d0 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -4e5d7faf54b38ebfc7a2dcadbd09a25d6f330ac0 \ No newline at end of file +454c2211c09bfa2fd5475c25665f3bbeb6882841 \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index bf59a6a287948b..af66172f68f0b3 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -1239,9 +1239,8 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; -var Block = 22; -var OffscreenComponent = 23; -var LegacyHiddenComponent = 24; +var OffscreenComponent = 22; +var LegacyHiddenComponent = 23; /** * Instance of element that should respond to touch/move types of interactions, @@ -2548,8 +2547,6 @@ var REACT_SUSPENSE_TYPE = 0xead1; var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; var REACT_FUNDAMENTAL_TYPE = 0xead5; var REACT_SCOPE_TYPE = 0xead7; var REACT_OPAQUE_ID_TYPE = 0xeae0; @@ -2571,8 +2568,6 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); REACT_SCOPE_TYPE = symbolFor("react.scope"); REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); @@ -2670,9 +2665,6 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -4227,9 +4219,6 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { // Memo may contain any component type so we recursively resolve it. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - case REACT_BLOCK_TYPE: - return describeFunctionComponentFrame(type._render, source, ownerFn); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -5714,7 +5703,7 @@ function flushSyncCallbackQueueImpl() { } // TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.1-4e5d7faf5"; +var ReactVersion = "17.0.1-454c2211c"; var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root @@ -5808,9 +5797,6 @@ function describeFiber(fiber) { case ForwardRef: return describeFunctionComponentFrame(fiber.type.render, source, owner); - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - case ClassComponent: return describeClassComponentFrame(fiber.type, source, owner); @@ -8303,7 +8289,7 @@ function warnOnFunctionType(returnFiber) { "Or maybe you meant to call this function rather than return it." ); } -} // We avoid inlining this to avoid potential deopts from using try/catch. +} // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -9161,11 +9147,6 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - case Block: - - // We intentionally fallthrough here if enableBlocksAPI is not on. - // eslint-disable-next-lined no-fallthrough - default: { if ( child.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -9173,17 +9154,17 @@ function ChildReconciler(shouldTrackSideEffects) { ) { deleteRemainingChildren(returnFiber, child.sibling); - var _existing3 = useFiber(child, element.props); + var _existing = useFiber(child, element.props); - _existing3.ref = coerceRef(returnFiber, child, element); - _existing3.return = returnFiber; + _existing.ref = coerceRef(returnFiber, child, element); + _existing.return = returnFiber; { - _existing3._debugSource = element._source; - _existing3._debugOwner = element._owner; + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; } - return _existing3; + return _existing; } break; @@ -9364,7 +9345,6 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case Block: case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { @@ -14764,10 +14744,6 @@ function beginWork(current, workInProgress, renderLanes) { break; } - case Block: { - break; - } - case OffscreenComponent: { return updateOffscreenComponent(current, workInProgress, renderLanes); } @@ -15661,9 +15637,6 @@ function completeWork(current, workInProgress, renderLanes) { break; } - case Block: - break; - case OffscreenComponent: case LegacyHiddenComponent: { popRenderLanes(workInProgress); @@ -16341,8 +16314,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { return; } @@ -16538,8 +16510,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // At this point layout effects have already been destroyed (during mutation phase). // This is done to prevent sibling component effects from interfering with each other, // e.g. a destroy function in one component should never override a ref set @@ -16837,8 +16808,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { var updateQueue = current.updateQueue; if (updateQueue !== null) { @@ -17032,8 +17002,7 @@ function commitWork(current, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // Layout effects are destroyed during the mutation phase so that all // destroy functions for all fibers are called before any create functions. // This prevents sibling component effects from interfering with each other, @@ -19355,8 +19324,7 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -19408,8 +19376,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -20609,10 +20576,6 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; - - case REACT_BLOCK_TYPE: - fiberTag = Block; - break getTag; } } diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.js b/Libraries/Renderer/implementations/ReactFabric-dev.js index 07748f8a596994..e08d68b542c96c 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.js @@ -1240,9 +1240,8 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; -var Block = 22; -var OffscreenComponent = 23; -var LegacyHiddenComponent = 24; +var OffscreenComponent = 22; +var LegacyHiddenComponent = 23; /** * Instance of element that should respond to touch/move types of interactions, @@ -2549,8 +2548,6 @@ var REACT_SUSPENSE_TYPE = 0xead1; var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; var REACT_FUNDAMENTAL_TYPE = 0xead5; var REACT_SCOPE_TYPE = 0xead7; var REACT_OPAQUE_ID_TYPE = 0xeae0; @@ -2572,8 +2569,6 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); REACT_SCOPE_TYPE = symbolFor("react.scope"); REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); @@ -2671,9 +2666,6 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -4130,9 +4122,6 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { // Memo may contain any component type so we recursively resolve it. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - case REACT_BLOCK_TYPE: - return describeFunctionComponentFrame(type._render, source, ownerFn); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -5617,7 +5606,7 @@ function flushSyncCallbackQueueImpl() { } // TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.1-4e5d7faf5"; +var ReactVersion = "17.0.1-454c2211c"; var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root @@ -5711,9 +5700,6 @@ function describeFiber(fiber) { case ForwardRef: return describeFunctionComponentFrame(fiber.type.render, source, owner); - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - case ClassComponent: return describeClassComponentFrame(fiber.type, source, owner); @@ -8148,7 +8134,7 @@ function warnOnFunctionType(returnFiber) { "Or maybe you meant to call this function rather than return it." ); } -} // We avoid inlining this to avoid potential deopts from using try/catch. +} // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -9006,11 +8992,6 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - case Block: - - // We intentionally fallthrough here if enableBlocksAPI is not on. - // eslint-disable-next-lined no-fallthrough - default: { if ( child.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -9018,17 +8999,17 @@ function ChildReconciler(shouldTrackSideEffects) { ) { deleteRemainingChildren(returnFiber, child.sibling); - var _existing3 = useFiber(child, element.props); + var _existing = useFiber(child, element.props); - _existing3.ref = coerceRef(returnFiber, child, element); - _existing3.return = returnFiber; + _existing.ref = coerceRef(returnFiber, child, element); + _existing.return = returnFiber; { - _existing3._debugSource = element._source; - _existing3._debugOwner = element._owner; + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; } - return _existing3; + return _existing; } break; @@ -9209,7 +9190,6 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case Block: case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { @@ -14546,10 +14526,6 @@ function beginWork(current, workInProgress, renderLanes) { break; } - case Block: { - break; - } - case OffscreenComponent: { return updateOffscreenComponent(current, workInProgress, renderLanes); } @@ -15443,9 +15419,6 @@ function completeWork(current, workInProgress, renderLanes) { break; } - case Block: - break; - case OffscreenComponent: case LegacyHiddenComponent: { popRenderLanes(workInProgress); @@ -16123,8 +16096,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { return; } @@ -16320,8 +16292,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // At this point layout effects have already been destroyed (during mutation phase). // This is done to prevent sibling component effects from interfering with each other, // e.g. a destroy function in one component should never override a ref set @@ -16619,8 +16590,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { var updateQueue = current.updateQueue; if (updateQueue !== null) { @@ -16814,8 +16784,7 @@ function commitWork(current, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // Layout effects are destroyed during the mutation phase so that all // destroy functions for all fibers are called before any create functions. // This prevents sibling component effects from interfering with each other, @@ -19137,8 +19106,7 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -19190,8 +19158,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -20380,10 +20347,6 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; - - case REACT_BLOCK_TYPE: - fiberTag = Block; - break getTag; } } diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index f6394cfd93c547..00a3503a192280 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -1018,7 +1018,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1036,7 +1035,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1083,8 +1081,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2077,8 +2073,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3186,7 +3180,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5244,8 +5237,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5298,8 +5291,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5396,7 +5389,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5429,7 +5421,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5509,8 +5500,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5535,7 +5526,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5560,8 +5550,8 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; + case 22: case 23: - case 24: return; } a: { @@ -6007,8 +5997,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6256,7 +6246,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -6418,7 +6408,6 @@ function commitRootImpl(root, renderPriorityLevel) { case 11: case 14: case 15: - case 22: var updateQueue = index$10.updateQueue; if (null !== updateQueue) { var lastEffect = updateQueue.lastEffect; @@ -6831,8 +6820,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7275,9 +7264,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7404,7 +7393,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7428,9 +7417,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7450,7 +7436,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -7604,7 +7590,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_865 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.js b/Libraries/Renderer/implementations/ReactFabric-prod.js index a5f870980f11a8..0ef34f37bb0d1d 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.js @@ -1019,7 +1019,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1037,7 +1036,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1084,8 +1082,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2078,8 +2074,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3187,7 +3181,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5245,8 +5238,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5299,8 +5292,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5397,7 +5390,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5430,7 +5422,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5510,8 +5501,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5536,7 +5527,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5561,8 +5551,8 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; + case 22: case 23: - case 24: return; } a: { @@ -6008,8 +5998,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6257,7 +6247,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -6419,7 +6409,6 @@ function commitRootImpl(root, renderPriorityLevel) { case 11: case 14: case 15: - case 22: var updateQueue = index$10.updateQueue; if (null !== updateQueue) { var lastEffect = updateQueue.lastEffect; @@ -6832,8 +6821,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7276,9 +7265,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7405,7 +7394,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7429,9 +7418,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7451,7 +7437,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -7605,7 +7591,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_865 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 7f8d5d62270acd..f066762ac44df9 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -1019,7 +1019,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1037,7 +1036,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1084,8 +1082,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2093,8 +2089,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3202,7 +3196,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5307,8 +5300,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5367,8 +5360,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5465,7 +5458,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5498,7 +5490,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5590,8 +5581,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5616,7 +5607,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5641,8 +5631,8 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; + case 22: case 23: - case 24: return; } a: { @@ -6098,8 +6088,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6373,7 +6363,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -6571,7 +6561,6 @@ function commitRootImpl(root, renderPriorityLevel) { case 11: case 14: case 15: - case 22: var updateQueue = lane.updateQueue; if (null !== updateQueue) { var lastEffect = updateQueue.lastEffect; @@ -7017,8 +7006,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7465,9 +7454,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7689,7 +7678,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7713,9 +7702,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7735,7 +7721,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -7892,7 +7878,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_887 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.js b/Libraries/Renderer/implementations/ReactFabric-profiling.js index 995495a12c799f..65acff0cff3217 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.js @@ -1020,7 +1020,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1038,7 +1037,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1085,8 +1083,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2094,8 +2090,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3203,7 +3197,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5308,8 +5301,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5368,8 +5361,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5466,7 +5459,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5499,7 +5491,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5591,8 +5582,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5617,7 +5608,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5642,8 +5632,8 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; + case 22: case 23: - case 24: return; } a: { @@ -6099,8 +6089,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6374,7 +6364,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -6572,7 +6562,6 @@ function commitRootImpl(root, renderPriorityLevel) { case 11: case 14: case 15: - case 22: var updateQueue = lane.updateQueue; if (null !== updateQueue) { var lastEffect = updateQueue.lastEffect; @@ -7018,8 +7007,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7466,9 +7455,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7690,7 +7679,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7714,9 +7703,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7736,7 +7722,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -7893,7 +7879,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_887 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 3cbae57ed62639..1dfd6b73f36c5d 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -1239,9 +1239,8 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; -var Block = 22; -var OffscreenComponent = 23; -var LegacyHiddenComponent = 24; +var OffscreenComponent = 22; +var LegacyHiddenComponent = 23; /** * Instance of element that should respond to touch/move types of interactions, @@ -2865,8 +2864,6 @@ var REACT_SUSPENSE_TYPE = 0xead1; var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; var REACT_FUNDAMENTAL_TYPE = 0xead5; var REACT_SCOPE_TYPE = 0xead7; var REACT_OPAQUE_ID_TYPE = 0xeae0; @@ -2888,8 +2885,6 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); REACT_SCOPE_TYPE = symbolFor("react.scope"); REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); @@ -2987,9 +2982,6 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -4542,9 +4534,6 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { // Memo may contain any component type so we recursively resolve it. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - case REACT_BLOCK_TYPE: - return describeFunctionComponentFrame(type._render, source, ownerFn); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -6029,7 +6018,7 @@ function flushSyncCallbackQueueImpl() { } // TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.1-4e5d7faf5"; +var ReactVersion = "17.0.1-454c2211c"; var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root @@ -6123,9 +6112,6 @@ function describeFiber(fiber) { case ForwardRef: return describeFunctionComponentFrame(fiber.type.render, source, owner); - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - case ClassComponent: return describeClassComponentFrame(fiber.type, source, owner); @@ -8618,7 +8604,7 @@ function warnOnFunctionType(returnFiber) { "Or maybe you meant to call this function rather than return it." ); } -} // We avoid inlining this to avoid potential deopts from using try/catch. +} // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -9476,11 +9462,6 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - case Block: - - // We intentionally fallthrough here if enableBlocksAPI is not on. - // eslint-disable-next-lined no-fallthrough - default: { if ( child.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -9488,17 +9469,17 @@ function ChildReconciler(shouldTrackSideEffects) { ) { deleteRemainingChildren(returnFiber, child.sibling); - var _existing3 = useFiber(child, element.props); + var _existing = useFiber(child, element.props); - _existing3.ref = coerceRef(returnFiber, child, element); - _existing3.return = returnFiber; + _existing.ref = coerceRef(returnFiber, child, element); + _existing.return = returnFiber; { - _existing3._debugSource = element._source; - _existing3._debugOwner = element._owner; + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; } - return _existing3; + return _existing; } break; @@ -9679,7 +9660,6 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case Block: case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { @@ -15101,10 +15081,6 @@ function beginWork(current, workInProgress, renderLanes) { break; } - case Block: { - break; - } - case OffscreenComponent: { return updateOffscreenComponent(current, workInProgress, renderLanes); } @@ -15800,9 +15776,6 @@ function completeWork(current, workInProgress, renderLanes) { break; } - case Block: - break; - case OffscreenComponent: case LegacyHiddenComponent: { popRenderLanes(workInProgress); @@ -16480,8 +16453,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { return; } @@ -16684,8 +16656,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // At this point layout effects have already been destroyed (during mutation phase). // This is done to prevent sibling component effects from interfering with each other, // e.g. a destroy function in one component should never override a ref set @@ -17035,8 +17006,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { var updateQueue = current.updateQueue; if (updateQueue !== null) { @@ -17479,8 +17449,7 @@ function commitWork(current, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // Layout effects are destroyed during the mutation phase so that all // destroy functions for all fibers are called before any create functions. // This prevents sibling component effects from interfering with each other, @@ -19888,8 +19857,7 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -19941,8 +19909,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -21243,10 +21210,6 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; - - case REACT_BLOCK_TYPE: - fiberTag = Block; - break getTag; } } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js index 773e112c1ff12c..33085b40dcd9ec 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js @@ -1240,9 +1240,8 @@ var DehydratedFragment = 18; var SuspenseListComponent = 19; var FundamentalComponent = 20; var ScopeComponent = 21; -var Block = 22; -var OffscreenComponent = 23; -var LegacyHiddenComponent = 24; +var OffscreenComponent = 22; +var LegacyHiddenComponent = 23; /** * Instance of element that should respond to touch/move types of interactions, @@ -2866,8 +2865,6 @@ var REACT_SUSPENSE_TYPE = 0xead1; var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; var REACT_FUNDAMENTAL_TYPE = 0xead5; var REACT_SCOPE_TYPE = 0xead7; var REACT_OPAQUE_ID_TYPE = 0xeae0; @@ -2889,8 +2886,6 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); REACT_SCOPE_TYPE = symbolFor("react.scope"); REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); @@ -2988,9 +2983,6 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -4445,9 +4437,6 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { // Memo may contain any component type so we recursively resolve it. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - case REACT_BLOCK_TYPE: - return describeFunctionComponentFrame(type._render, source, ownerFn); - case REACT_LAZY_TYPE: { var lazyComponent = type; var payload = lazyComponent._payload; @@ -5932,7 +5921,7 @@ function flushSyncCallbackQueueImpl() { } // TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.1-4e5d7faf5"; +var ReactVersion = "17.0.1-454c2211c"; var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root @@ -6026,9 +6015,6 @@ function describeFiber(fiber) { case ForwardRef: return describeFunctionComponentFrame(fiber.type.render, source, owner); - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - case ClassComponent: return describeClassComponentFrame(fiber.type, source, owner); @@ -8463,7 +8449,7 @@ function warnOnFunctionType(returnFiber) { "Or maybe you meant to call this function rather than return it." ); } -} // We avoid inlining this to avoid potential deopts from using try/catch. +} // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -9321,11 +9307,6 @@ function ChildReconciler(shouldTrackSideEffects) { break; } - case Block: - - // We intentionally fallthrough here if enableBlocksAPI is not on. - // eslint-disable-next-lined no-fallthrough - default: { if ( child.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -9333,17 +9314,17 @@ function ChildReconciler(shouldTrackSideEffects) { ) { deleteRemainingChildren(returnFiber, child.sibling); - var _existing3 = useFiber(child, element.props); + var _existing = useFiber(child, element.props); - _existing3.ref = coerceRef(returnFiber, child, element); - _existing3.return = returnFiber; + _existing.ref = coerceRef(returnFiber, child, element); + _existing.return = returnFiber; { - _existing3._debugSource = element._source; - _existing3._debugOwner = element._owner; + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; } - return _existing3; + return _existing; } break; @@ -9524,7 +9505,6 @@ function ChildReconciler(shouldTrackSideEffects) { // functions and classes // eslint-disable-next-lined no-fallthrough - case Block: case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { @@ -14883,10 +14863,6 @@ function beginWork(current, workInProgress, renderLanes) { break; } - case Block: { - break; - } - case OffscreenComponent: { return updateOffscreenComponent(current, workInProgress, renderLanes); } @@ -15582,9 +15558,6 @@ function completeWork(current, workInProgress, renderLanes) { break; } - case Block: - break; - case OffscreenComponent: case LegacyHiddenComponent: { popRenderLanes(workInProgress); @@ -16262,8 +16235,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { return; } @@ -16466,8 +16438,7 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // At this point layout effects have already been destroyed (during mutation phase). // This is done to prevent sibling component effects from interfering with each other, // e.g. a destroy function in one component should never override a ref set @@ -16817,8 +16788,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { var updateQueue = current.updateQueue; if (updateQueue !== null) { @@ -17261,8 +17231,7 @@ function commitWork(current, finishedWork) { case FunctionComponent: case ForwardRef: case MemoComponent: - case SimpleMemoComponent: - case Block: { + case SimpleMemoComponent: { // Layout effects are destroyed during the mutation phase so that all // destroy functions for all fibers are called before any create functions. // This prevents sibling component effects from interfering with each other, @@ -19670,8 +19639,7 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -19723,8 +19691,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block + tag !== SimpleMemoComponent ) { // Only warn for user-defined components, not internal ones like Suspense. return; @@ -21014,10 +20981,6 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; - - case REACT_BLOCK_TYPE: - fiberTag = Block; - break getTag; } } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index b113a690434868..18bc9ba73eff45 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -1137,7 +1137,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1155,7 +1154,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1202,8 +1200,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2103,8 +2099,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3224,7 +3218,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5142,8 +5135,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5196,8 +5189,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5288,7 +5281,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5321,7 +5313,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5400,8 +5391,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5447,7 +5438,7 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { } else { if (6 === node.tag) throw Error("Not yet implemented."); if ( - ((23 !== node.tag && 24 !== node.tag) || + ((22 !== node.tag && 23 !== node.tag) || null === node.memoizedState || node === finishedWork) && null !== node.child @@ -5476,7 +5467,6 @@ function commitUnmount(finishedRoot, current) { case 11: case 14: case 15: - case 22: finishedRoot = current.updateQueue; if ( null !== finishedRoot && @@ -5795,7 +5785,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: var updateQueue = finishedWork.updateQueue; updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; if (null !== updateQueue) { @@ -5861,8 +5850,8 @@ function commitWork(current, finishedWork) { return; case 17: return; + case 22: case 23: - case 24: hideOrUnhideAllChildren( finishedWork, null !== finishedWork.memoizedState @@ -6300,8 +6289,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6549,7 +6538,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -7045,8 +7034,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7489,9 +7478,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7618,7 +7607,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7642,9 +7631,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7664,7 +7650,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -7825,7 +7811,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_908 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js index 0c2b0f6f04e58a..f5ba497464b7eb 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js @@ -1138,7 +1138,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1156,7 +1155,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1203,8 +1201,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2104,8 +2100,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3225,7 +3219,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5143,8 +5136,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5197,8 +5190,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5289,7 +5282,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5322,7 +5314,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5401,8 +5392,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5448,7 +5439,7 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { } else { if (6 === node.tag) throw Error("Not yet implemented."); if ( - ((23 !== node.tag && 24 !== node.tag) || + ((22 !== node.tag && 23 !== node.tag) || null === node.memoizedState || node === finishedWork) && null !== node.child @@ -5477,7 +5468,6 @@ function commitUnmount(finishedRoot, current) { case 11: case 14: case 15: - case 22: finishedRoot = current.updateQueue; if ( null !== finishedRoot && @@ -5796,7 +5786,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: var updateQueue = finishedWork.updateQueue; updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; if (null !== updateQueue) { @@ -5862,8 +5851,8 @@ function commitWork(current, finishedWork) { return; case 17: return; + case 22: case 23: - case 24: hideOrUnhideAllChildren( finishedWork, null !== finishedWork.memoizedState @@ -6301,8 +6290,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6550,7 +6539,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -7046,8 +7035,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7490,9 +7479,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7619,7 +7608,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7643,9 +7632,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7665,7 +7651,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -7826,7 +7812,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_908 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 9beda430185462..cdb80f6b2e1d17 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -1138,7 +1138,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1156,7 +1155,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1203,8 +1201,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2119,8 +2115,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3240,7 +3234,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5205,8 +5198,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5265,8 +5258,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5357,7 +5350,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5390,7 +5382,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5481,8 +5472,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5528,7 +5519,7 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { } else { if (6 === node.tag) throw Error("Not yet implemented."); if ( - ((23 !== node.tag && 24 !== node.tag) || + ((22 !== node.tag && 23 !== node.tag) || null === node.memoizedState || node === finishedWork) && null !== node.child @@ -5557,7 +5548,6 @@ function commitUnmount(finishedRoot, current) { case 11: case 14: case 15: - case 22: finishedRoot = current.updateQueue; if ( null !== finishedRoot && @@ -5876,7 +5866,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: var updateQueue = finishedWork.updateQueue; updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; if (null !== updateQueue) { @@ -5942,8 +5931,8 @@ function commitWork(current, finishedWork) { return; case 17: return; + case 22: case 23: - case 24: hideOrUnhideAllChildren( finishedWork, null !== finishedWork.memoizedState @@ -6391,8 +6380,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6666,7 +6655,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -7228,8 +7217,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7676,9 +7665,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7900,7 +7889,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7924,9 +7913,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7946,7 +7932,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -8110,7 +8096,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_930 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js index 3f75533f6cc439..726a064c70b56a 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js @@ -1139,7 +1139,6 @@ var ReactSharedInternals = REACT_SUSPENSE_LIST_TYPE = 60120, REACT_MEMO_TYPE = 60115, REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131; @@ -1157,7 +1156,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); symbolFor("react.scope"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); @@ -1204,8 +1202,6 @@ function getComponentName(type) { ); case REACT_MEMO_TYPE: return getComponentName(type.type); - case REACT_BLOCK_TYPE: - return getComponentName(type._render); case REACT_LAZY_TYPE: innerType = type._payload; type = type._init; @@ -2120,8 +2116,6 @@ function describeFiber(fiber) { return describeFunctionComponentFrame(fiber.type, null); case 11: return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); case 1: return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; default: @@ -3241,7 +3235,6 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 1: - case 22: case 0: case 11: case 15: @@ -5206,8 +5199,8 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; + case 22: case 23: - case 24: return ( popRenderLanes(), null !== current && @@ -5266,8 +5259,8 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; + case 22: case 23: - case 24: return popRenderLanes(), null; default: return null; @@ -5358,7 +5351,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { case 0: case 11: case 15: - case 22: return; case 1: if (finishedWork.flags & 256 && null !== current) { @@ -5391,7 +5383,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 0: case 11: case 15: - case 22: current = finishedWork.updateQueue; current = null !== current ? current.lastEffect : null; if (null !== current) { @@ -5482,8 +5473,8 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: + case 22: case 23: - case 24: return; } throw Error( @@ -5529,7 +5520,7 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { } else { if (6 === node.tag) throw Error("Not yet implemented."); if ( - ((23 !== node.tag && 24 !== node.tag) || + ((22 !== node.tag && 23 !== node.tag) || null === node.memoizedState || node === finishedWork) && null !== node.child @@ -5558,7 +5549,6 @@ function commitUnmount(finishedRoot, current) { case 11: case 14: case 15: - case 22: finishedRoot = current.updateQueue; if ( null !== finishedRoot && @@ -5877,7 +5867,6 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - case 22: var updateQueue = finishedWork.updateQueue; updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; if (null !== updateQueue) { @@ -5943,8 +5932,8 @@ function commitWork(current, finishedWork) { return; case 17: return; + case 22: case 23: - case 24: hideOrUnhideAllChildren( finishedWork, null !== finishedWork.memoizedState @@ -6392,8 +6381,8 @@ function prepareFreshStack(root, lanes) { case 10: popProvider(interruptedWork); break; + case 22: case 23: - case 24: popRenderLanes(); } timeoutHandle = timeoutHandle.return; @@ -6667,7 +6656,7 @@ function completeUnitOfWork(unitOfWork) { } current = completedWork; if ( - (24 !== current.tag && 23 !== current.tag) || + (23 !== current.tag && 22 !== current.tag) || null === current.memoizedState || 0 !== (subtreeRenderLanes & 1073741824) || 0 === (current.mode & 4) @@ -7229,8 +7218,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { push(suspenseStackCursor, suspenseStackCursor.current); if (updateLanes) break; else return null; + case 22: case 23: - case 24: return ( (workInProgress.lanes = 0), updateOffscreenComponent(current, workInProgress, renderLanes) @@ -7677,9 +7666,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); case 19: return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: + case 22: return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: + case 23: return updateOffscreenComponent(current, workInProgress, renderLanes); } throw Error( @@ -7901,7 +7890,7 @@ function createFiberFromTypeAndProps( return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return ( - (type = createFiber(24, pendingProps, key, mode)), + (type = createFiber(23, pendingProps, key, mode)), (type.elementType = REACT_LEGACY_HIDDEN_TYPE), (type.lanes = lanes), type @@ -7925,9 +7914,6 @@ function createFiberFromTypeAndProps( fiberTag = 16; owner = null; break a; - case REACT_BLOCK_TYPE: - fiberTag = 22; - break a; } throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + @@ -7947,7 +7933,7 @@ function createFiberFromFragment(elements, mode, lanes, key) { return elements; } function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); + pendingProps = createFiber(22, pendingProps, key, mode); pendingProps.elementType = REACT_OFFSCREEN_TYPE; pendingProps.lanes = lanes; return pendingProps; @@ -8111,7 +8097,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_930 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.1-4e5d7faf5", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { From c7ab78036070b70c014c15029504caa43eaf6925 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Mon, 9 Nov 2020 13:27:38 -0800 Subject: [PATCH 0040/1810] React Native sync for revisions 454c221...c3e20f1 Reviewed By: rickhanlonii Differential Revision: D24700276 fbshipit-source-id: 877759c60632985753f3cd02ad0ded50144b6744 --- Libraries/Renderer/REVISION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 6a7b5011ed80d0..974273dc6854dd 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -454c2211c09bfa2fd5475c25665f3bbeb6882841 \ No newline at end of file +c3e20f18fe37993ddcbf11dccb55663b4c0d02fd \ No newline at end of file From 8f5656b347c72961af027770a1d4420c7c06cc30 Mon Sep 17 00:00:00 2001 From: Nadiia D Date: Tue, 10 Nov 2020 00:06:12 -0800 Subject: [PATCH 0041/1810] Update to eslint@7.12 Summary: Changelog: [Internal] - Upgrades eslint to 7.12 Reviewed By: cpojer Differential Revision: D24552901 fbshipit-source-id: ede66ac9367702512436bfe3cf0254686300e10b --- .../package.json | 4 +- .../yarn.lock | 622 +++++------------- repo-config/package.json | 4 +- template/package.json | 2 +- yarn.lock | 317 +++++---- 5 files changed, 357 insertions(+), 592 deletions(-) diff --git a/packages/eslint-config-react-native-community/package.json b/packages/eslint-config-react-native-community/package.json index 3b8bc5635a3812..e079f7c7b4d600 100644 --- a/packages/eslint-config-react-native-community/package.json +++ b/packages/eslint-config-react-native-community/package.json @@ -26,9 +26,9 @@ "prettier": "^2.0.2" }, "peerDependencies": { - "eslint": ">=6" + "eslint": ">=7" }, "devDependencies": { - "eslint": "^6.5.1" + "eslint": "7.12.0" } } diff --git a/packages/eslint-config-react-native-community/yarn.lock b/packages/eslint-config-react-native-community/yarn.lock index b4d6255c4cd3f0..8fdadf1d775bec 100644 --- a/packages/eslint-config-react-native-community/yarn.lock +++ b/packages/eslint-config-react-native-community/yarn.lock @@ -2,14 +2,7 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" - integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== - dependencies: - "@babel/highlight" "^7.0.0" - -"@babel/code-frame@^7.8.3": +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g== @@ -54,15 +47,6 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz#ad53562a7fc29b3b9a91bbf7d10397fd146346ed" integrity sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw== -"@babel/highlight@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" - integrity sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw== - dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^4.0.0" - "@babel/highlight@^7.8.3": version "7.9.0" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079" @@ -118,6 +102,22 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" +"@eslint/eslintrc@^0.2.0": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" + integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== + dependencies: + ajv "^6.12.4" + debug "^4.1.1" + espree "^7.3.0" + globals "^12.1.0" + ignore "^4.0.6" + import-fresh "^3.2.1" + js-yaml "^3.13.1" + lodash "^4.17.19" + minimatch "^3.0.4" + strip-json-comments "^3.1.1" + "@react-native-community/eslint-plugin@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.1.0.tgz#e42b1bef12d2415411519fd528e64b593b1363dc" @@ -187,37 +187,25 @@ acorn-jsx@^5.2.0: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.2.0.tgz#4c66069173d6fdd68ed85239fc256226182b2ebe" integrity sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ== -acorn@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" - integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg== +acorn@^7.4.0: + version "7.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" + integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -ajv@^6.10.0: - version "6.12.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7" - integrity sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw== +ajv@^6.10.0, ajv@^6.12.4, ajv@^6.9.1: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== dependencies: fast-deep-equal "^3.1.1" fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^6.9.1: - version "6.10.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1" - integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg== - dependencies: - fast-deep-equal "^2.0.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-escapes@^4.2.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.1.tgz#a5c47cc43181f1f38ffd7076837700d395522a61" - integrity sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA== - dependencies: - type-fest "^0.11.0" +ansi-colors@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== ansi-regex@^4.1.0: version "4.1.0" @@ -251,15 +239,7 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -array-includes@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.0.3.tgz#184b48f62d92d7452bb31b323165c7f8bd02266d" - integrity sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0= - dependencies: - define-properties "^1.1.2" - es-abstract "^1.7.0" - -array-includes@^3.1.1: +array-includes@^3.0.3, array-includes@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.1.tgz#cdd67e6852bdf9c1215460786732255ed2459348" integrity sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ== @@ -303,7 +283,7 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.0.0.tgz#fb7eb569b72ad7a45812f93fd9430a3e410b3dd3" integrity sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw== -chalk@^2.0.0, chalk@^2.1.0: +chalk@^2.0.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -312,31 +292,14 @@ chalk@^2.0.0, chalk@^2.1.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== +chalk@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== dependencies: ansi-styles "^4.1.0" supports-color "^7.1.0" -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== - -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - -cli-width@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" - integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= - color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -371,16 +334,14 @@ core-js-pure@^3.0.0: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.4.tgz#4bf1ba866e25814f149d4e9aaa08c36173506e3a" integrity sha512-epIhRLkXdgv32xIUFaaAry2wdxZYBi6bgM7cB136dzzXXa+dFyRLTZeLUJxnd8ShrmyVXBub63n2NHo2JAt8Cw== -cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== +cross-spawn@^7.0.2: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" @@ -389,7 +350,7 @@ debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: dependencies: ms "^2.1.1" -deep-is@~0.1.3: +deep-is@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= @@ -420,10 +381,12 @@ emoji-regex@^7.0.1: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +enquirer@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" + integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== + dependencies: + ansi-colors "^4.1.1" es-abstract@^1.17.0, es-abstract@^1.17.0-next.1: version "1.17.5" @@ -442,27 +405,6 @@ es-abstract@^1.17.0, es-abstract@^1.17.0-next.1: string.prototype.trimleft "^2.1.1" string.prototype.trimright "^2.1.1" -es-abstract@^1.7.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.13.0.tgz#ac86145fdd5099d8dd49558ccba2eaf9b88e24e9" - integrity sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg== - dependencies: - es-to-primitive "^1.2.0" - function-bind "^1.1.1" - has "^1.0.3" - is-callable "^1.1.4" - is-regex "^1.0.4" - object-keys "^1.0.12" - -es-to-primitive@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" - integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -545,54 +487,49 @@ eslint-plugin-react@^7.20.0: string.prototype.matchall "^4.0.2" xregexp "^4.3.0" -eslint-scope@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" - integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw== +eslint-scope@^5.0.0, eslint-scope@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== dependencies: - esrecurse "^4.1.0" + esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-utils@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" - integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== - dependencies: - eslint-visitor-keys "^1.1.0" - -eslint-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.0.0.tgz#7be1cc70f27a72a76cd14aa698bcabed6890e1cd" - integrity sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA== +eslint-utils@^2.0.0, eslint-utils@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== dependencies: eslint-visitor-keys "^1.1.0" -eslint-visitor-keys@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" - integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ== +eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== -eslint-visitor-keys@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" - integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== +eslint-visitor-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" + integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== -eslint@^6.5.1: - version "6.8.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" - integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== +eslint@7.12.0: + version "7.12.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.12.0.tgz#7b6a85f87a9adc239e979bb721cde5ce0dc27da6" + integrity sha512-n5pEU27DRxCSlOhJ2rO57GDLcNsxO0LPpAbpFdh7xmcDmjmlGUfoyrsB3I7yYdQXO5N3gkSTiDrPSPNFiiirXA== dependencies: "@babel/code-frame" "^7.0.0" + "@eslint/eslintrc" "^0.2.0" ajv "^6.10.0" - chalk "^2.1.0" - cross-spawn "^6.0.5" + chalk "^4.0.0" + cross-spawn "^7.0.2" debug "^4.0.1" doctrine "^3.0.0" - eslint-scope "^5.0.0" - eslint-utils "^1.4.3" - eslint-visitor-keys "^1.1.0" - espree "^6.1.2" - esquery "^1.0.1" + enquirer "^2.3.5" + eslint-scope "^5.1.1" + eslint-utils "^2.1.0" + eslint-visitor-keys "^2.0.0" + espree "^7.3.0" + esquery "^1.2.0" esutils "^2.0.2" file-entry-cache "^5.0.1" functional-red-black-tree "^1.0.1" @@ -601,77 +538,66 @@ eslint@^6.5.1: ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^7.0.0" is-glob "^4.0.0" js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.14" + levn "^0.4.1" + lodash "^4.17.19" minimatch "^3.0.4" - mkdirp "^0.5.1" natural-compare "^1.4.0" - optionator "^0.8.3" + optionator "^0.9.1" progress "^2.0.0" - regexpp "^2.0.1" - semver "^6.1.2" - strip-ansi "^5.2.0" - strip-json-comments "^3.0.1" + regexpp "^3.1.0" + semver "^7.2.1" + strip-ansi "^6.0.0" + strip-json-comments "^3.1.0" table "^5.2.3" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^6.1.2: - version "6.2.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" - integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== +espree@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" + integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== dependencies: - acorn "^7.1.1" + acorn "^7.4.0" acorn-jsx "^5.2.0" - eslint-visitor-keys "^1.1.0" + eslint-visitor-keys "^1.3.0" esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" - integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== +esquery@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" + integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== dependencies: - estraverse "^4.0.0" + estraverse "^5.1.0" -esrecurse@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" - integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== dependencies: - estraverse "^4.1.0" + estraverse "^5.2.0" -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: +estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM= +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" + integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== + esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= -external-editor@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.0.3.tgz#5866db29a97826dbe4bf3afd24070ead9ea43a27" - integrity sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - -fast-deep-equal@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" - integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= - fast-deep-equal@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" @@ -687,18 +613,11 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= -fast-levenshtein@~2.0.6: +fast-levenshtein@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= -figures@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" - integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== - dependencies: - escape-string-regexp "^1.0.5" - file-entry-cache@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" @@ -747,19 +666,7 @@ glob-parent@^5.0.0: dependencies: is-glob "^4.0.1" -glob@^7.1.3: - version "7.1.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" - integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^7.1.6: +glob@^7.1.3, glob@^7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -793,30 +700,18 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" - integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= - -has-symbols@^1.0.1: +has-symbols@^1.0.0, has-symbols@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== -has@^1.0.1, has@^1.0.3: +has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== dependencies: function-bind "^1.1.1" -iconv-lite@^0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -827,10 +722,10 @@ ignore@^5.0.5: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.0.5.tgz#c663c548d6ce186fb33616a8ccb5d46e56bdbbf9" integrity sha512-kOC8IUb8HSDMVcYrDVezCxpJkzSQWTAzf3olpKM6o9rM5zpojx23O0Fl8Wr4+qJ6ZbPEHqf1fdwev/DS7v7pmA== -import-fresh@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.0.0.tgz#a3d897f420cab0e671236897f75bc14b4885c390" - integrity sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ== +import-fresh@^3.0.0, import-fresh@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66" + integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ== dependencies: parent-module "^1.0.0" resolve-from "^4.0.0" @@ -853,25 +748,6 @@ inherits@2: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -inquirer@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.1.0.tgz#1298a01859883e17c7264b82870ae1034f92dd29" - integrity sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg== - dependencies: - ansi-escapes "^4.2.1" - chalk "^3.0.0" - cli-cursor "^3.1.0" - cli-width "^2.0.0" - external-editor "^3.0.3" - figures "^3.0.0" - lodash "^4.17.15" - mute-stream "0.0.8" - run-async "^2.4.0" - rxjs "^6.5.3" - string-width "^4.1.0" - strip-ansi "^6.0.0" - through "^2.3.6" - internal-slot@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.2.tgz#9c2e9fb3cd8e5e4256c6f45fe310067fcfa378a3" @@ -881,12 +757,7 @@ internal-slot@^1.0.2: has "^1.0.3" side-channel "^1.0.2" -is-callable@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" - integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== - -is-callable@^1.1.5: +is-callable@^1.1.4, is-callable@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== @@ -906,11 +777,6 @@ is-fullwidth-code-point@^2.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - is-glob@^4.0.0, is-glob@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" @@ -918,18 +784,6 @@ is-glob@^4.0.0, is-glob@^4.0.1: dependencies: is-extglob "^2.1.1" -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= - -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE= - dependencies: - has "^1.0.1" - is-regex@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" @@ -990,23 +844,18 @@ jsx-ast-utils@^2.2.3: array-includes "^3.0.3" object.assign "^4.1.0" -levn@^0.3.0, levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" + prelude-ls "^1.2.1" + type-check "~0.4.0" -lodash@^4.17.10, lodash@^4.17.11: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== - -lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== loose-envify@^1.4.0: version "1.4.0" @@ -1015,11 +864,6 @@ loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -1044,21 +888,11 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -1069,16 +903,11 @@ object-inspect@^1.7.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== -object-keys@^1.0.11, object-keys@^1.1.1: +object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== -object-keys@^1.0.12: - version "1.1.0" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.0.tgz#11bd22348dd2e096a045ab06f6c85bcc340fa032" - integrity sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg== - object.assign@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" @@ -1126,29 +955,17 @@ once@^1.3.0: dependencies: wrappy "1" -onetime@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.0.tgz#fff0f3c91617fe62bb50189636e99ac8a6df7be5" - integrity sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q== - dependencies: - mimic-fn "^2.1.0" - -optionator@^0.8.3: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" - -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" parent-module@^1.0.0: version "1.0.0" @@ -1162,20 +979,20 @@ path-is-absolute@^1.0.0: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== prettier-linter-helpers@^1.0.0: version "1.0.0" @@ -1226,43 +1043,23 @@ regexp.prototype.flags@^1.3.0: define-properties "^1.1.3" es-abstract "^1.17.0-next.1" -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== - -regexpp@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.0.0.tgz#dd63982ee3300e67b41c1956f850aa680d9d330e" - integrity sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g== +regexpp@^3.0.0, regexpp@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" + integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve@^1.12.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.0.tgz#3fc644a35c84a48554609ff26ec52b66fa577df6" - integrity sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w== - dependencies: - path-parse "^1.0.6" - -resolve@^1.15.1: +resolve@^1.12.0, resolve@^1.15.1: version "1.15.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w== dependencies: path-parse "^1.0.6" -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - rimraf@2.6.3: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" @@ -1270,51 +1067,22 @@ rimraf@2.6.3: dependencies: glob "^7.1.3" -run-async@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.0.tgz#e59054a5b86876cfae07f431d18cbaddc594f1e8" - integrity sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg== - dependencies: - is-promise "^2.1.0" - -rxjs@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c" - integrity sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q== - dependencies: - tslib "^1.9.0" - -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -semver@^5.5.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" - integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== - -semver@^6.1.2: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -semver@^7.3.2: +semver@^7.2.1, semver@^7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== dependencies: - shebang-regex "^1.0.0" + shebang-regex "^3.0.0" -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== side-channel@^1.0.2: version "1.0.2" @@ -1324,11 +1092,6 @@ side-channel@^1.0.2: es-abstract "^1.17.0-next.1" object-inspect "^1.7.0" -signal-exit@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= - slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -1357,15 +1120,6 @@ string-width@^3.0.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - string.prototype.matchall@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.2.tgz#48bb510326fb9fdeb6a33ceaa81a6ea04ef7648e" @@ -1401,13 +1155,6 @@ strip-ansi@^5.1.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - strip-ansi@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" @@ -1415,10 +1162,10 @@ strip-ansi@^6.0.0: dependencies: ansi-regex "^5.0.0" -strip-json-comments@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" - integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== supports-color@^5.3.0: version "5.5.0" @@ -1449,24 +1196,12 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= -tslib@^1.8.1, tslib@^1.9.0: +tslib@^1.8.1: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== @@ -1478,17 +1213,12 @@ tsutils@^3.17.1: dependencies: tslib "^1.8.1" -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== dependencies: - prelude-ls "~1.1.2" - -type-fest@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" - integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== + prelude-ls "^1.2.1" type-fest@^0.8.1: version "0.8.1" @@ -1507,14 +1237,14 @@ v8-compile-cache@^2.0.3: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e" integrity sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g== -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" -word-wrap@~1.2.3: +word-wrap@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== diff --git a/repo-config/package.json b/repo-config/package.json index 250896ade2f492..f1da3a5d82d8a9 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -19,7 +19,7 @@ "connect": "^3.6.5", "coveralls": "^3.0.2", "detox": "16.7.2", - "eslint": "6.8.0", + "eslint": "7.12.0", "eslint-config-fb-strict": "^24.9.0", "eslint-config-fbjs": "2.1.0", "eslint-config-prettier": "^6.0.0", @@ -32,7 +32,7 @@ "eslint-plugin-react": "7.21.5", "eslint-plugin-react-hooks": "^4.0.7", "eslint-plugin-react-native": "3.8.1", - "eslint-plugin-relay": "1.7.1", + "eslint-plugin-relay": "1.8.1", "flow-bin": "^0.137.0", "jest": "^26.5.2", "jest-junit": "^10.0.0", diff --git a/template/package.json b/template/package.json index 6bfd86bef39e79..c7a6edda8b1fbc 100644 --- a/template/package.json +++ b/template/package.json @@ -18,7 +18,7 @@ "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^1.1.0", "babel-jest": "^25.1.0", - "eslint": "^6.5.1", + "eslint": "7.12.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.64.0", "react-test-renderer": "17.0.1", diff --git a/yarn.lock b/yarn.lock index e35673ccc6d4be..4e295bc2b49e0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -736,6 +736,22 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@eslint/eslintrc@^0.2.0": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" + integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== + dependencies: + ajv "^6.12.4" + debug "^4.1.1" + espree "^7.3.0" + globals "^12.1.0" + ignore "^4.0.6" + import-fresh "^3.2.1" + js-yaml "^3.13.1" + lodash "^4.17.19" + minimatch "^3.0.4" + strip-json-comments "^3.1.1" + "@hapi/address@2.x.x": version "2.0.0" resolved "https://registry.npmjs.org/@hapi/address/-/address-2.0.0.tgz#9f05469c88cb2fd3dcd624776b54ee95c312126a" @@ -1325,6 +1341,11 @@ acorn@^7.1.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg== +acorn@^7.4.0: + version "7.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" + integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== + ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: version "6.12.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.2.tgz#c629c5eced17baf314437918d2da88c99d5958cd" @@ -1335,11 +1356,26 @@ ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + anser@^1.4.9: version "1.4.9" resolved "https://registry.yarnpkg.com/anser/-/anser-1.4.9.tgz#1f85423a5dcf8da4631a341665ff675b96845760" integrity sha512-AI+BjTeGt2+WFk4eWcqbQ7snZpDBt8SaLlj0RT2h5xfdWaiy51OjYvqwMrNzJLGy8iOAL6nKDITWO+rd4MkYEA== +ansi-colors@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" @@ -1889,7 +1925,7 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1924,11 +1960,6 @@ chardet@^0.4.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" integrity sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I= -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== - child-process-promise@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/child-process-promise/-/child-process-promise-2.2.1.tgz#4730a11ef610fad450b8f223c79d31d7bdad8074" @@ -1974,13 +2005,6 @@ cli-cursor@^2.1.0: dependencies: restore-cursor "^2.0.0" -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - cli-spinners@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.1.0.tgz#22c34b4d51f573240885b201efda4e4ec9fff3c7" @@ -2214,7 +2238,7 @@ cross-spawn@^4.0.2: lru-cache "^4.0.1" which "^1.2.9" -cross-spawn@^6.0.0, cross-spawn@^6.0.5: +cross-spawn@^6.0.0: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== @@ -2234,6 +2258,15 @@ cross-spawn@^7.0.0: shebang-command "^2.0.0" which "^2.0.1" +cross-spawn@^7.0.2: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + cssom@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10" @@ -2311,7 +2344,7 @@ deep-extend@^0.6.0: resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== -deep-is@~0.1.3: +deep-is@^0.1.3, deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= @@ -2505,6 +2538,13 @@ end-of-stream@^1.1.0: dependencies: once "^1.4.0" +enquirer@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" + integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== + dependencies: + ansi-colors "^4.1.1" + envinfo@^7.7.2: version "7.7.3" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.3.tgz#4b2d8622e3e7366afb8091b23ed95569ea0208cc" @@ -2703,10 +2743,10 @@ eslint-plugin-react@7.21.5: resolve "^1.18.1" string.prototype.matchall "^4.0.2" -eslint-plugin-relay@1.7.1: - version "1.7.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-relay/-/eslint-plugin-relay-1.7.1.tgz#70f479becb06320e57dd86ebc0d38938cb8a5e6e" - integrity sha512-K7j5BF8raseLfgA97udZMGKEtWan+y5BLrBYlApy952saStF0ghYzU9WElIwoVIkcBO8QP+pT4AOuNFFNRzcUw== +eslint-plugin-relay@1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-relay/-/eslint-plugin-relay-1.8.1.tgz#7363b1c134cfa3468377d46eadaa3a2b9b73dfcf" + integrity sha512-7xhyLDq3Bv5q+lKZUMYcRHq1OdFsgjuY5hAu3NNY+TkPPsdcp80de7eEJ8Ux5M3YJpnyr2UAHGksx5Exx6+I7g== dependencies: graphql "^14.0.0 || ^15.0.0-rc.1" @@ -2715,18 +2755,18 @@ eslint-rule-composer@^0.3.0: resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9" integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg== -eslint-scope@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" - integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw== +eslint-scope@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== dependencies: - esrecurse "^4.1.0" + esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-utils@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" - integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== +eslint-utils@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== dependencies: eslint-visitor-keys "^1.1.0" @@ -2735,22 +2775,34 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== -eslint@6.8.0: - version "6.8.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" - integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== +eslint-visitor-keys@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== + +eslint-visitor-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" + integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== + +eslint@7.12.0: + version "7.12.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.12.0.tgz#7b6a85f87a9adc239e979bb721cde5ce0dc27da6" + integrity sha512-n5pEU27DRxCSlOhJ2rO57GDLcNsxO0LPpAbpFdh7xmcDmjmlGUfoyrsB3I7yYdQXO5N3gkSTiDrPSPNFiiirXA== dependencies: "@babel/code-frame" "^7.0.0" + "@eslint/eslintrc" "^0.2.0" ajv "^6.10.0" - chalk "^2.1.0" - cross-spawn "^6.0.5" + chalk "^4.0.0" + cross-spawn "^7.0.2" debug "^4.0.1" doctrine "^3.0.0" - eslint-scope "^5.0.0" - eslint-utils "^1.4.3" - eslint-visitor-keys "^1.1.0" - espree "^6.1.2" - esquery "^1.0.1" + enquirer "^2.3.5" + eslint-scope "^5.1.1" + eslint-utils "^2.1.0" + eslint-visitor-keys "^2.0.0" + espree "^7.3.0" + esquery "^1.2.0" esutils "^2.0.2" file-entry-cache "^5.0.1" functional-red-black-tree "^1.0.1" @@ -2759,58 +2811,61 @@ eslint@6.8.0: ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^7.0.0" is-glob "^4.0.0" js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.14" + levn "^0.4.1" + lodash "^4.17.19" minimatch "^3.0.4" - mkdirp "^0.5.1" natural-compare "^1.4.0" - optionator "^0.8.3" + optionator "^0.9.1" progress "^2.0.0" - regexpp "^2.0.1" - semver "^6.1.2" - strip-ansi "^5.2.0" - strip-json-comments "^3.0.1" + regexpp "^3.1.0" + semver "^7.2.1" + strip-ansi "^6.0.0" + strip-json-comments "^3.1.0" table "^5.2.3" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^6.1.2: - version "6.2.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" - integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== +espree@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" + integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== dependencies: - acorn "^7.1.1" + acorn "^7.4.0" acorn-jsx "^5.2.0" - eslint-visitor-keys "^1.1.0" + eslint-visitor-keys "^1.3.0" esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" - integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== +esquery@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" + integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== dependencies: - estraverse "^4.0.0" + estraverse "^5.1.0" -esrecurse@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" - integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== dependencies: - estraverse "^4.1.0" + estraverse "^5.2.0" -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM= +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" + integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== + esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -2930,15 +2985,6 @@ external-editor@^2.0.4: iconv-lite "^0.4.17" tmp "^0.0.33" -external-editor@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" - integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - extglob@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" @@ -2973,7 +3019,7 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= -fast-levenshtein@~2.0.6: +fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= @@ -3011,13 +3057,6 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" -figures@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" - integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== - dependencies: - escape-string-regexp "^1.0.5" - file-entry-cache@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" @@ -3449,7 +3488,7 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -3494,6 +3533,14 @@ import-fresh@^3.0.0: parent-module "^1.0.0" resolve-from "^4.0.0" +import-fresh@^3.2.1: + version "3.2.2" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.2.tgz#fc129c160c5d68235507f4331a6baad186bdbc3e" + integrity sha512-cTPNrlvJT6twpYy+YmKUKrTSjWFs3bjYjAhCwm+z4EOCubZxAuO+hHpRN64TqjEaYSHs7tJAE0w1CKMGmsG/lw== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + import-local@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6" @@ -3545,25 +3592,6 @@ inquirer@^3.0.6: strip-ansi "^4.0.0" through "^2.3.6" -inquirer@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.1.0.tgz#1298a01859883e17c7264b82870ae1034f92dd29" - integrity sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg== - dependencies: - ansi-escapes "^4.2.1" - chalk "^3.0.0" - cli-cursor "^3.1.0" - cli-width "^2.0.0" - external-editor "^3.0.3" - figures "^3.0.0" - lodash "^4.17.15" - mute-stream "0.0.8" - run-async "^2.4.0" - rxjs "^6.5.3" - string-width "^4.1.0" - strip-ansi "^6.0.0" - through "^2.3.6" - internal-slot@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.2.tgz#9c2e9fb3cd8e5e4256c6f45fe310067fcfa378a3" @@ -4598,7 +4626,15 @@ leven@^3.1.0: resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== -levn@^0.3.0, levn@~0.3.0: +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= @@ -5214,11 +5250,6 @@ mute-stream@0.0.7: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - mv@~2: version "2.1.1" resolved "https://registry.yarnpkg.com/mv/-/mv-2.1.1.tgz#ae6ce0d6f6d5e0a4f7d893798d03c1ea9559b6a2" @@ -5566,7 +5597,7 @@ open@^6.2.0: dependencies: is-wsl "^1.1.0" -optionator@^0.8.1, optionator@^0.8.3: +optionator@^0.8.1: version "0.8.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== @@ -5578,6 +5609,18 @@ optionator@^0.8.1, optionator@^0.8.3: type-check "~0.3.2" word-wrap "~1.2.3" +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== + dependencies: + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" + options@>=0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" @@ -5800,6 +5843,11 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -6082,10 +6130,10 @@ regexp.prototype.flags@^1.3.0: define-properties "^1.1.3" es-abstract "^1.17.0-next.1" -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== +regexpp@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" + integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== regexpu-core@^4.7.1: version "4.7.1" @@ -6221,14 +6269,6 @@ restore-cursor@^2.0.0: onetime "^2.0.0" signal-exit "^3.0.2" -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" @@ -6270,7 +6310,7 @@ rsvp@^3.3.3: resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a" integrity sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw== -run-async@^2.2.0, run-async@^2.4.0: +run-async@^2.2.0: version "2.4.1" resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== @@ -6294,13 +6334,6 @@ rxjs@^5.4.3: dependencies: symbol-observable "1.0.1" -rxjs@^6.5.3: - version "6.5.5" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.5.tgz#c5c884e3094c8cfee31bf27eb87e54ccfc87f9ec" - integrity sha512-WfQI+1gohdf0Dai/Bbmk5L5ItH5tYqm3ki2c5GdWhKjalzjg93N3avFjVStyZZz+A2Em+ZxKH5bNghw9UeylGQ== - dependencies: - tslib "^1.9.0" - safe-buffer@5.1.2, safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -6370,12 +6403,12 @@ scheduler@^0.20.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@^6.0.0, semver@^6.1.2, semver@^6.3.0: +semver@^6.0.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.3.2: +semver@^7.2.1, semver@^7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== @@ -6860,10 +6893,10 @@ strip-final-newline@^2.0.0: resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== -strip-json-comments@^3.0.1: - version "3.1.0" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180" - integrity sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w== +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== strip-json-comments@~2.0.1: version "2.0.1" @@ -7095,11 +7128,6 @@ truncate-utf8-bytes@^1.0.0: dependencies: utf8-byte-length "^1.0.1" -tslib@^1.9.0: - version "1.11.2" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.2.tgz#9c79d83272c9a7aaf166f73915c9667ecdde3cc9" - integrity sha512-tTSkux6IGPnUGUd1XAZHcpu85MOkIl5zX49pO+jfsie3eP0B6pyhOlLXm3cAC6T7s+euSDDUUV+Acop5WmtkVg== - tslib@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" @@ -7117,6 +7145,13 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== + dependencies: + prelude-ls "^1.2.1" + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -7408,7 +7443,7 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" -word-wrap@~1.2.3: +word-wrap@^1.2.3, word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== From f27e305056152ff9ad7aeb9018bf289d51719eb9 Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Tue, 10 Nov 2020 08:37:00 -0800 Subject: [PATCH 0042/1810] Fix prefetchImageWithMetadata redbox in AMA Reviewed By: RSNara Differential Revision: D24837264 fbshipit-source-id: b2aeef2c051fa15c06cf2eb6350c152b722196c2 --- Libraries/Image/Image.ios.js | 3 ++- Libraries/Image/NativeImageLoaderIOS.js | 2 +- Libraries/Image/RCTImageLoader.mm | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 5938d48e80651f..48b9c398717802 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -65,10 +65,11 @@ function prefetchWithMetadata( rootTag?: ?number, ): any { if (NativeImageLoaderIOS.prefetchImageWithMetadata) { + // number params like rootTag cannot be nullable before TurboModules is available return NativeImageLoaderIOS.prefetchImageWithMetadata( url, queryRootName, - rootTag, + rootTag ? rootTag : 0, ); } else { return NativeImageLoaderIOS.prefetchImage(url); diff --git a/Libraries/Image/NativeImageLoaderIOS.js b/Libraries/Image/NativeImageLoaderIOS.js index cee864e675a872..d0cf74846cfc45 100644 --- a/Libraries/Image/NativeImageLoaderIOS.js +++ b/Libraries/Image/NativeImageLoaderIOS.js @@ -29,7 +29,7 @@ export interface Spec extends TurboModule { +prefetchImageWithMetadata?: ( uri: string, queryRootName: string, - rootTag?: ?number, + rootTag: number, ) => Promise; +queryCache: (uris: Array) => Promise; } diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index f6a6dbb59eba88..d35d0bb44270da 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -1197,12 +1197,12 @@ - (void)cancelRequest:(id)requestToken resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { - [self prefetchImageWithMetadata:uri queryRootName:nil rootTag:nil resolve:resolve reject:reject]; + [self prefetchImageWithMetadata:uri queryRootName:nil rootTag:0 resolve:resolve reject:reject]; } RCT_EXPORT_METHOD(prefetchImageWithMetadata:(NSString *)uri queryRootName:(NSString *)queryRootName - rootTag:(NSNumber *)rootTag + rootTag:(double)rootTag resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { @@ -1215,7 +1215,7 @@ - (void)cancelRequest:(id)requestToken priority:RCTImageLoaderPriorityPrefetch attribution:{ .queryRootName = queryRootName ? [queryRootName UTF8String] : "", - .surfaceId = [rootTag intValue], + .surfaceId = (int)rootTag, } progressBlock:nil partialLoadBlock:nil From 46be292f671c70aac4ecc178c96e3a2a6a3d16da Mon Sep 17 00:00:00 2001 From: Kacie Bawiec Date: Tue, 10 Nov 2020 09:05:52 -0800 Subject: [PATCH 0043/1810] Fix nested FlatList not firing onScrollDragEnd and onMomentum methods Summary: With nested FlatLists, three methods aren't firing: `onMomentumScrollBegin`, `onMomentumScrollEnd`, and `onScrollDragEnd`. This is because the nested child lists' methods are not being called. This copies the solution for this from `onScrollBeginDrag` to the other three methods. Changelog: [Fixed] Fix nested FlatList not firing onScrollDragEnd and onMomentum methods Reviewed By: nadiia Differential Revision: D24803418 fbshipit-source-id: 8685b1ab9f1bd5f67a88d93ac5de628d4bd69024 --- Libraries/Lists/VirtualizedList.js | 14 ++++++++++++++ .../__tests__/__snapshots__/FlatList-test.js.snap | 7 +++++++ .../__snapshots__/SectionList-test.js.snap | 5 +++++ .../__snapshots__/VirtualizedList-test.js.snap | 15 +++++++++++++++ .../VirtualizedSectionList-test.js.snap | 12 ++++++++++++ 5 files changed, 53 insertions(+) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 2249d54c4aaa94..78939ed26af49a 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1061,6 +1061,7 @@ class VirtualizedList extends React.PureComponent { onScroll: this._onScroll, onScrollBeginDrag: this._onScrollBeginDrag, onScrollEndDrag: this._onScrollEndDrag, + onMomentumScrollBegin: this._onMomentumScrollBegin, onMomentumScrollEnd: this._onMomentumScrollEnd, scrollEventThrottle: this.props.scrollEventThrottle, // TODO: Android support invertStickyHeaders: @@ -1662,6 +1663,9 @@ class VirtualizedList extends React.PureComponent { }; _onScrollEndDrag = (e): void => { + this._nestedChildLists.forEach(childList => { + childList.ref && childList.ref._onScrollEndDrag(e); + }); const {velocity} = e.nativeEvent; if (velocity) { this._scrollMetrics.velocity = this._selectOffset(velocity); @@ -1670,7 +1674,17 @@ class VirtualizedList extends React.PureComponent { this.props.onScrollEndDrag && this.props.onScrollEndDrag(e); }; + _onMomentumScrollBegin = (e): void => { + this._nestedChildLists.forEach(childList => { + childList.ref && childList.ref._onMomentumScrollBegin(e); + }); + this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e); + }; + _onMomentumScrollEnd = (e): void => { + this._nestedChildLists.forEach(childList => { + childList.ref && childList.ref._onMomentumScrollEnd(e); + }); this._scrollMetrics.velocity = 0; this._computeBlankness(); this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e); diff --git a/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap index 9c9d3e69bd8d1d..d783999955c23e 100644 --- a/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +++ b/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap @@ -36,6 +36,7 @@ exports[`FlatList renders all the bells and whistles 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onRefresh={[MockFunction]} onScroll={[Function]} @@ -138,6 +139,7 @@ exports[`FlatList renders empty list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -166,6 +168,7 @@ exports[`FlatList renders null list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -207,6 +210,7 @@ exports[`FlatList renders simple list (multiple columns) 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -284,6 +288,7 @@ exports[`FlatList renders simple list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -351,6 +356,7 @@ exports[`FlatList renders simple list using ListItemComponent (multiple columns) onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -428,6 +434,7 @@ exports[`FlatList renders simple list using ListItemComponent 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} diff --git a/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap index 49c4debe34392c..9cbbcbd2bec220 100644 --- a/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap +++ b/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap @@ -27,6 +27,7 @@ exports[`SectionList rendering empty section headers is fine 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -90,6 +91,7 @@ exports[`SectionList renders a footer when there is no data 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -145,6 +147,7 @@ exports[`SectionList renders a footer when there is no data and no header 1`] = onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -231,6 +234,7 @@ exports[`SectionList renders all the bells and whistles 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onRefresh={[MockFunction]} onScroll={[Function]} @@ -423,6 +427,7 @@ exports[`SectionList renders empty list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} diff --git a/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap index 86faf0fa8aa0cb..c666835c3fd638 100644 --- a/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +++ b/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap @@ -22,6 +22,7 @@ exports[`VirtualizedList handles nested lists 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -58,6 +59,7 @@ exports[`VirtualizedList handles nested lists 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -111,6 +113,7 @@ exports[`VirtualizedList handles nested lists 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -185,6 +188,7 @@ exports[`VirtualizedList handles separators correctly 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -266,6 +270,7 @@ exports[`VirtualizedList handles separators correctly 2`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -347,6 +352,7 @@ exports[`VirtualizedList handles separators correctly 3`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -441,6 +447,7 @@ exports[`VirtualizedList renders all the bells and whistles 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onRefresh={[MockFunction]} onScroll={[Function]} @@ -622,6 +629,7 @@ exports[`VirtualizedList renders empty list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -652,6 +660,7 @@ exports[`VirtualizedList renders empty list with empty component 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -698,6 +707,7 @@ exports[`VirtualizedList renders list with empty component 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -733,6 +743,7 @@ exports[`VirtualizedList renders null list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -772,6 +783,7 @@ exports[`VirtualizedList renders simple list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -837,6 +849,7 @@ exports[`VirtualizedList renders simple list using ListItemComponent 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -894,6 +907,7 @@ exports[`VirtualizedList test getItem functionality where data is not an Array 1 onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -937,6 +951,7 @@ exports[`VirtualizedList warns if both renderItem or ListItemComponent are speci onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} diff --git a/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap index 23e1317571b8ef..e53b506b0a4413 100644 --- a/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +++ b/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap @@ -27,6 +27,7 @@ exports[`VirtualizedSectionList handles nested lists 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -72,6 +73,7 @@ exports[`VirtualizedSectionList handles nested lists 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -138,6 +140,7 @@ exports[`VirtualizedSectionList handles nested lists 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -242,6 +245,7 @@ exports[`VirtualizedSectionList handles separators correctly 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -381,6 +385,7 @@ exports[`VirtualizedSectionList handles separators correctly 2`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -520,6 +525,7 @@ exports[`VirtualizedSectionList handles separators correctly 3`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -672,6 +678,7 @@ exports[`VirtualizedSectionList renders all the bells and whistles 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onRefresh={[MockFunction]} onScroll={[Function]} @@ -893,6 +900,7 @@ exports[`VirtualizedSectionList renders empty list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -923,6 +931,7 @@ exports[`VirtualizedSectionList renders empty list with empty component 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -974,6 +983,7 @@ exports[`VirtualizedSectionList renders list with empty component 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -1017,6 +1027,7 @@ exports[`VirtualizedSectionList renders null list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} @@ -1061,6 +1072,7 @@ exports[`VirtualizedSectionList renders simple list 1`] = ` onContentSizeChange={[Function]} onEndReachedThreshold={2} onLayout={[Function]} + onMomentumScrollBegin={[Function]} onMomentumScrollEnd={[Function]} onScroll={[Function]} onScrollBeginDrag={[Function]} From 3a0927ce4336a1fb8ab7daf10e3048216fb34ce3 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 11 Nov 2020 01:57:38 -0800 Subject: [PATCH 0044/1810] Fix memory leak in ScrollViewStickyHeader Summary: Changelog: [internal] `addListener` call needs a matching `removeListener` call. Otherwise a memory leak is introduced to the app. This memory leak can retain a UIImage on iOS in Fabric and cause OOM. Reviewed By: JoshuaGross Differential Revision: D24860489 fbshipit-source-id: 2625e4bfec416d59e048d9b5ada3813019dd107c --- .../Components/ScrollView/ScrollViewStickyHeader.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 8d53db0f9eed61..05e1af3ad03faf 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -67,6 +67,15 @@ class ScrollViewStickyHeader extends React.Component { this.setState({nextHeaderLayoutY: y}); } + componentWillUnmount() { + if (this._translateY != null && this._animatedValueListenerId != null) { + this._translateY.removeListener(this._animatedValueListenerId); + } + if (this._timer) { + clearTimeout(this._timer); + } + } + UNSAFE_componentWillReceiveProps(nextProps: Props) { if ( nextProps.scrollViewHeight !== this.props.scrollViewHeight || From 97a4598babeea9a16adda60cdfd97a797862a4ec Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 11 Nov 2020 10:54:06 -0800 Subject: [PATCH 0045/1810] Fabric: Strengthening StubView mutating validation Summary: This diff adds more enforcement for consistency of `ShadowNodeMutation`s, including: * `Props` object for newly created or updated view must not be nullptr; * `oldShadowView` must describe the previous state of the view for `Update` instruction; * `ignoreDuplicateCreates` option was removed. I suspect some of the crashes we see in Fabric are caused by a violation of one of these constraints. If one of these fails in debug builds, we will get an early signal. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D24880821 fbshipit-source-id: 8c8a3d8e205ce34f6e0335e8a2b0cf676930c284 --- .../react/renderer/mounting/StubView.cpp | 12 ++++++ .../react/renderer/mounting/StubView.h | 2 + .../react/renderer/mounting/StubViewTree.cpp | 38 +++++++------------ .../react/renderer/mounting/StubViewTree.h | 4 +- ReactCommon/react/renderer/mounting/stubs.cpp | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/StubView.cpp b/ReactCommon/react/renderer/mounting/StubView.cpp index f476de31184899..4d6b140da20a04 100644 --- a/ReactCommon/react/renderer/mounting/StubView.cpp +++ b/ReactCommon/react/renderer/mounting/StubView.cpp @@ -10,6 +10,18 @@ namespace facebook { namespace react { +StubView::operator ShadowView() const { + auto shadowView = ShadowView{}; + shadowView.componentName = componentName; + shadowView.componentHandle = componentHandle; + shadowView.tag = tag; + shadowView.props = props; + shadowView.eventEmitter = eventEmitter; + shadowView.layoutMetrics = layoutMetrics; + shadowView.state = state; + return shadowView; +} + void StubView::update(ShadowView const &shadowView) { componentName = shadowView.componentName; componentHandle = shadowView.componentHandle; diff --git a/ReactCommon/react/renderer/mounting/StubView.h b/ReactCommon/react/renderer/mounting/StubView.h index 8546baa157aee5..3c95f68f5be24f 100644 --- a/ReactCommon/react/renderer/mounting/StubView.h +++ b/ReactCommon/react/renderer/mounting/StubView.h @@ -25,6 +25,8 @@ class StubView final { StubView() = default; StubView(StubView const &stubView) = default; + operator ShadowView() const; + void update(ShadowView const &shadowView); ComponentName componentName; diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index 0c9dedee025294..c2e3e3d62c5f76 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -38,30 +38,19 @@ StubView const &StubViewTree::getRootStubView() const { return *registry.at(rootTag); } -/** - * ignoreDuplicateCreates: when stubs generates "fake" mutation instructions, in - * some cases it can produce too many "create" instructions. We ignore - * duplicates and treat them as noops. In the case of verifying actual diffing, - * that assert is left on. - * - * @param mutations - * @param ignoreDuplicateCreates - */ -void StubViewTree::mutate( - ShadowViewMutationList const &mutations, - bool ignoreDuplicateCreates) { +void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Mutating Begin"; }); for (auto const &mutation : mutations) { switch (mutation.type) { case ShadowViewMutation::Create: { STUB_VIEW_ASSERT(mutation.parentShadowView == ShadowView{}); STUB_VIEW_ASSERT(mutation.oldChildShadowView == ShadowView{}); + STUB_VIEW_ASSERT(mutation.newChildShadowView.props); auto stubView = std::make_shared(); + stubView->update(mutation.newChildShadowView); auto tag = mutation.newChildShadowView.tag; STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Create: " << tag; }); - if (!ignoreDuplicateCreates) { - STUB_VIEW_ASSERT(registry.find(tag) == registry.end()); - } + STUB_VIEW_ASSERT(registry.find(tag) == registry.end()); registry[tag] = stubView; break; } @@ -73,6 +62,9 @@ void StubViewTree::mutate( STUB_VIEW_ASSERT(mutation.newChildShadowView == ShadowView{}); auto tag = mutation.oldChildShadowView.tag; STUB_VIEW_ASSERT(registry.find(tag) != registry.end()); + auto stubView = registry[tag]; + STUB_VIEW_ASSERT( + (ShadowView)(*stubView) == mutation.oldChildShadowView); registry.erase(tag); break; } @@ -137,19 +129,15 @@ void StubViewTree::mutate( STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Update: " << mutation.newChildShadowView.tag; }); - - // We don't have a strict requirement that oldChildShadowView has any - // data. In particular, LayoutAnimations can produce UPDATEs with only a - // new node. + STUB_VIEW_ASSERT(mutation.newChildShadowView.props); STUB_VIEW_ASSERT( - mutation.newChildShadowView.tag == - mutation.oldChildShadowView.tag || - mutation.oldChildShadowView.tag == 0); - + mutation.newChildShadowView.tag == mutation.oldChildShadowView.tag); STUB_VIEW_ASSERT( registry.find(mutation.newChildShadowView.tag) != registry.end()); - auto stubView = registry[mutation.newChildShadowView.tag]; - stubView->update(mutation.newChildShadowView); + auto oldStubView = registry[mutation.newChildShadowView.tag]; + STUB_VIEW_ASSERT( + (ShadowView)(*oldStubView) == mutation.oldChildShadowView); + oldStubView->update(mutation.newChildShadowView); break; } } diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.h b/ReactCommon/react/renderer/mounting/StubViewTree.h index 3dceaba3dc7e97..6ffb00e63ce96a 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.h +++ b/ReactCommon/react/renderer/mounting/StubViewTree.h @@ -21,9 +21,7 @@ class StubViewTree { StubViewTree() = default; StubViewTree(ShadowView const &shadowView); - void mutate( - ShadowViewMutationList const &mutations, - bool ignoreDuplicateCreates = false); + void mutate(ShadowViewMutationList const &mutations); StubView const &getRootStubView() const; diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index 47ce20e9e2c400..370989a21a8d7a 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -54,7 +54,7 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { ShadowNode::emptySharedShadowNodeSharedList()}); auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode)); - stubViewTree.mutate(mutations, true); + stubViewTree.mutate(mutations); return stubViewTree; } From 0e9296b95da06789121f052e6cd6d7cac808464c Mon Sep 17 00:00:00 2001 From: ajpaulingalls Date: Wed, 11 Nov 2020 11:00:07 -0800 Subject: [PATCH 0046/1810] Update the cached dimensions when orientation changes (#30324) Summary: Currently the dimensions are created once, and then cached. This change will reload the dimensions when the device orientation changes to insure that dimension update events follow orientation changed events. this should help address the following issues, that I know of: https://github.com/facebook/react-native/issues/29105 https://github.com/facebook/react-native/issues/29451 https://github.com/facebook/react-native/issues/29323 ## Changelog [Android] [Fixed] - Dimension update events are now properly sent following orientation change Pull Request resolved: https://github.com/facebook/react-native/pull/30324 Test Plan: Open up RNTester app. Select the Dimensions API list item. Rotate the device and verify that the dimensions are correct based on orientation. Reviewed By: fkgozali Differential Revision: D24874733 Pulled By: ejanzer fbshipit-source-id: 867681ecb009d368a2ae7b67d94d6355e67dea7b --- ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 9098fa1a2fc4db..a205467c094287 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -756,6 +756,7 @@ private void checkForDeviceOrientationChanges() { return; } mDeviceRotation = rotation; + DisplayMetricsHolder.initDisplayMetrics(getContext().getApplicationContext()); emitOrientationChanged(rotation); } From eb6fefa508bef0699ca432d8e24f11b793390705 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 11 Nov 2020 16:41:56 -0800 Subject: [PATCH 0047/1810] Back out "Use ConcreteStateTeller in RCTImageComponentView" Summary: We don't need ConcreteStateTeller in component because we don't even update the state from the component. I will change the logic around the state in the next diff, so we have to remove ConcreteStateTeller first. Reviewed By: sammy-SC Differential Revision: D24880822 fbshipit-source-id: bc993bc04ef9f6df79bcbc51941ad6bf64baae58 --- .../ComponentViews/Image/RCTImageComponentView.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm index 9e66149b98d0fb..6847214e00b86f 100644 --- a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm @@ -22,7 +22,7 @@ @interface RCTImageComponentView () @end @implementation RCTImageComponentView { - ImageShadowNode::ConcreteStateTeller _stateTeller; + ImageShadowNode::ConcreteState::Shared _state; ImageResponseObserverCoordinator const *_coordinator; RCTImageResponseObserverProxy _imageResponseObserverProxy; } @@ -80,9 +80,9 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); auto _oldState = std::static_pointer_cast(oldState); - auto data = _stateTeller.getData().value(); + auto data = _state->getData(); // This call (setting `coordinator`) must be unconditional (at the same block as setting `State`) // because the setter stores a raw pointer to object that `State` owns. @@ -116,7 +116,7 @@ - (void)prepareForRecycle [super prepareForRecycle]; self.coordinator = nullptr; _imageView.image = nil; - _stateTeller.invalidate(); + _state.reset(); } - (void)dealloc @@ -128,7 +128,7 @@ - (void)dealloc - (void)didReceiveImage:(UIImage *)image metadata:(id)metadata fromObserver:(void const *)observer { - if (!_eventEmitter || !_stateTeller.isValid()) { + if (!_eventEmitter || !_state) { // Notifications are delivered asynchronously and might arrive after the view is already recycled. // In the future, we should incorporate an `EventEmitter` into a separate object owned by `ImageRequest` or `State`. // See for more info: T46311063. From 28cb7a77db4f07f523e8ae3f6cdf891121803445 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 11 Nov 2020 16:41:56 -0800 Subject: [PATCH 0048/1810] Fabric: Stop storing a raw pointer to ImageResponseObserverCoordinator in RCTImageComponentView Summary: Before this change, RCTImageComponentView on every state update extracted the raw pointer to ImageResponseObserverCoordinator and stored this as an instance variable. This worked fine but the code relied on an assumption that `oldState` argument of `updateState:oldState` is always valid (because the `oldState` is what retained that pointer). Now, because of some issue, seems that `oldState` value is not always correct, so to work around this problem and to make the code more robust, this diff implements a slightly different approach. Now we don't store the raw pointer to ImageResponseObserverCoordinator as an instance variable; instead, we store a retaining pointer to a state object and retrieve the pointer to an ImageResponseObserverCoordinator on demand. The diff also introduces a new function `_setStateAndResubscribeImageResponseObserver` that incapsulates updating `_state` object, unsubscribing from the previous coordinator, and subscribing for a new one. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D24880820 fbshipit-source-id: 1c4d8ea91ae07dd217447e43cd3dde7b6f02dc40 --- .../Image/RCTImageComponentView.mm | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm index 6847214e00b86f..105e55257b4517 100644 --- a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm @@ -18,12 +18,8 @@ using namespace facebook::react; -@interface RCTImageComponentView () -@end - @implementation RCTImageComponentView { ImageShadowNode::ConcreteState::Shared _state; - ImageResponseObserverCoordinator const *_coordinator; RCTImageResponseObserverProxy _imageResponseObserverProxy; } @@ -80,17 +76,14 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { - _state = std::static_pointer_cast(state); - auto _oldState = std::static_pointer_cast(oldState); - auto data = _state->getData(); + auto oldImageState = std::static_pointer_cast(_state); + auto newImageState = std::static_pointer_cast(state); - // This call (setting `coordinator`) must be unconditional (at the same block as setting `State`) - // because the setter stores a raw pointer to object that `State` owns. - self.coordinator = &data.getImageRequest().getObserverCoordinator(); + [self _setStateAndResubscribeImageResponseObserver:newImageState]; - bool havePreviousData = _oldState && _oldState->getData().getImageSource() != ImageSource{}; + bool havePreviousData = oldImageState && oldImageState->getData().getImageSource() != ImageSource{}; - if (!havePreviousData || data.getImageSource() != _oldState->getData().getImageSource()) { + if (!havePreviousData || newImageState->getData().getImageSource() != oldImageState->getData().getImageSource()) { // Loading actually starts a little before this, but this is the first time we know // the image is loading and can fire an event from this component std::static_pointer_cast(_eventEmitter)->onLoadStart(); @@ -100,28 +93,26 @@ - (void)updateState:(State::Shared const &)state oldState:(State::Shared const & } } -- (void)setCoordinator:(ImageResponseObserverCoordinator const *)coordinator +- (void)_setStateAndResubscribeImageResponseObserver:(ImageShadowNode::ConcreteState::Shared const &)state { - if (_coordinator) { - _coordinator->removeObserver(_imageResponseObserverProxy); + if (_state) { + auto &observerCoordinator = _state->getData().getImageRequest().getObserverCoordinator(); + observerCoordinator.removeObserver(_imageResponseObserverProxy); } - _coordinator = coordinator; - if (_coordinator != nullptr) { - _coordinator->addObserver(_imageResponseObserverProxy); + + _state = state; + + if (_state) { + auto &observerCoordinator = _state->getData().getImageRequest().getObserverCoordinator(); + observerCoordinator.addObserver(_imageResponseObserverProxy); } } - (void)prepareForRecycle { [super prepareForRecycle]; - self.coordinator = nullptr; + [self _setStateAndResubscribeImageResponseObserver:nullptr]; _imageView.image = nil; - _state.reset(); -} - -- (void)dealloc -{ - self.coordinator = nullptr; } #pragma mark - RCTImageResponseDelegate From d5db2cb5d134e96f591f9a7e988f05d29212e68a Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 11 Nov 2020 19:14:21 -0800 Subject: [PATCH 0049/1810] Build rn-codegen in a temporary directory (#30292) Summary: When running yarn install from the codegen directory it will reinstall all dependencies for the react-native workspace inside the react-native package. In my case this caused issues with metro because it would now have 2 copies of it (node_modules/metro and node_modules/react-native/node_modules/metro). To avoid this copy the react-native-codegen source in a temporary directory and yarn install from there, then copy the built files back. ## Changelog [Internal] - Build rn-codegen in a temporary directory Pull Request resolved: https://github.com/facebook/react-native/pull/30292 Test Plan: Tested the script in an app with codegen enabled. Fresh install with rn-codegen not built, made sure no extra modules are installed under node_modules/react-native/node_modules. Reviewed By: yungsters Differential Revision: D24893216 Pulled By: fkgozali fbshipit-source-id: 2c372b755632ea6f50ad5d4562248612b349a9a6 --- .../react-native-codegen/scripts/oss/build.sh | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/react-native-codegen/scripts/oss/build.sh b/packages/react-native-codegen/scripts/oss/build.sh index 7092fdf1aa739d..09b62e80928d37 100755 --- a/packages/react-native-codegen/scripts/oss/build.sh +++ b/packages/react-native-codegen/scripts/oss/build.sh @@ -11,9 +11,35 @@ THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOUR set -e set -u -pushd "$THIS_DIR/../.." >/dev/null +CODEGEN_DIR="$THIS_DIR/../.." -yarn install 2> >(grep -v '^warning' 1>&2) -yarn run build +rm -rf "${CODEGEN_DIR:?}/lib" "${CODEGEN_DIR:?}/node_modules" -popd >/dev/null +YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" + +if [[ "$FBSOURCE_ENV" -eq "1" ]]; then + # Custom FB-specific setup + pushd "$CODEGEN_DIR" >/dev/null + + "$YARN_BINARY" install 2> >(grep -v '^warning' 1>&2) + # Note: Within FBSOURCE_ENV, this has to explicitly run build. + "$YARN_BINARY" run build + + popd >/dev/null +else + # Run yarn install in a separate tmp dir to avoid conflict with the rest of the repo. + # Note: OSS-only. + TMP_DIR=$(mktemp -d) + + cp -R "$CODEGEN_DIR/." "$TMP_DIR" + + pushd "$TMP_DIR" >/dev/null + + # Note: this automatically runs build as well. + "$YARN_BINARY" install 2> >(grep -v '^warning' 1>&2) + + popd >/dev/null + + mv "$TMP_DIR/lib" "$TMP_DIR/node_modules" "$CODEGEN_DIR" + rm -rf "$TMP_DIR" +fi From 1bbcbd55ff94087c0a86b87164c223cee302fe4e Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Wed, 11 Nov 2020 22:37:30 -0800 Subject: [PATCH 0050/1810] Android OSS: fixed unbound variable error for codegen build script Summary: If $FBSOURCE_ENV isn't set, this failed with `/root/react-native/packages/react-native-codegen/android/../scripts/oss/build.sh: line 20: FBSOURCE_ENV: unbound variable`. This commit fixes https://app.circleci.com/pipelines/github/facebook/react-native/7080/workflows/5cf18a1f-e6d2-4648-8217-d42e9a61fef1/jobs/176451 Changelog: [Internal] Reviewed By: yungsters Differential Revision: D24912950 fbshipit-source-id: 113e3dd7f78c75fc3adea0b21c9e38910be8c065 --- packages/react-native-codegen/scripts/oss/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-codegen/scripts/oss/build.sh b/packages/react-native-codegen/scripts/oss/build.sh index 09b62e80928d37..28fe87693b4454 100755 --- a/packages/react-native-codegen/scripts/oss/build.sh +++ b/packages/react-native-codegen/scripts/oss/build.sh @@ -17,7 +17,7 @@ rm -rf "${CODEGEN_DIR:?}/lib" "${CODEGEN_DIR:?}/node_modules" YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" -if [[ "$FBSOURCE_ENV" -eq "1" ]]; then +if [[ ${FBSOURCE_ENV:-0} -eq 1 ]]; then # Custom FB-specific setup pushd "$CODEGEN_DIR" >/dev/null From 96ace8779155f6a1edccb04032c8cf062ebffae6 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 12 Nov 2020 09:11:57 -0800 Subject: [PATCH 0051/1810] remove android support library (#30347) Summary: This PR removes remains of Android Support Library, now replaced with AndroidX. ## Changelog [Internal] [Changed] - remove Android Support Library from Buck Pull Request resolved: https://github.com/facebook/react-native/pull/30347 Test Plan: CI is green Reviewed By: JoshuaGross Differential Revision: D24914088 Pulled By: fkgozali fbshipit-source-id: 0ff18dfd7c684642a5c27308112b6fddc27608a7 --- .../main/third-party/android/support/v4/BUCK | 685 ------------------ .../android/support/v7/appcompat/BUCK | 62 -- .../support/v7/appcompat/aar-unpacker.py | 20 - tools/build_defs/oss/rn_defs.bzl | 26 +- 4 files changed, 2 insertions(+), 791 deletions(-) delete mode 100644 ReactAndroid/src/main/third-party/android/support/v4/BUCK delete mode 100644 ReactAndroid/src/main/third-party/android/support/v7/appcompat/BUCK delete mode 100644 ReactAndroid/src/main/third-party/android/support/v7/appcompat/aar-unpacker.py diff --git a/ReactAndroid/src/main/third-party/android/support/v4/BUCK b/ReactAndroid/src/main/third-party/android/support/v4/BUCK deleted file mode 100644 index 25a3662a1c4703..00000000000000 --- a/ReactAndroid/src/main/third-party/android/support/v4/BUCK +++ /dev/null @@ -1,685 +0,0 @@ -load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") - -fb_native.android_library( - name = "lib-support-v4", - visibility = ["PUBLIC"], - exported_deps = [ - ":appcompat", - ":asynclayoutinflater", - ":collection", - ":coordinatorlayout", - ":core", - ":core-common", - ":core-runtime", - ":cursoradapter", - ":customview", - ":documentfile", - ":drawerlayout", - ":fragment", - ":interpolator", - ":legacy-support-core-ui", - ":legacy-support-core-utils", - ":lifecycle-common", - ":lifecycle-livedata", - ":lifecycle-livedata-core", - ":lifecycle-runtime", - ":lifecycle-viewmodel", - ":loader", - ":localbroadcastmanager", - ":print", - ":slidingpanelayout", - ":swiperefreshlayout", - ":vectordrawable", - ":vectordrawable-animated", - ":versionedparcelable", - ":viewpager", - ], -) - -fb_native.prebuilt_jar( - name = "annotation", - binary_jar = ":annotation.jar", - visibility = ["PUBLIC"], -) - -fb_native.android_library( - name = "appcompat", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":collection", - ":core", - ":cursoradapter", - ":fragment", - ":legacy-support-core-utils", - ":vectordrawable", - ":vectordrawable-animated", - ], -) - -fb_native.android_library( - name = "asynclayoutinflater", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":asynclayoutinflater-binary", - ":core", - ], -) - -fb_native.android_library( - name = "collection", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":collection-binary", - ], -) - -fb_native.android_library( - name = "coordinatorlayout", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":coordinatorlayout-binary", - ":core", - ":customview", - ], -) - -fb_native.android_library( - name = "core", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":collection", - ":core-binary", - ":lifecycle-runtime", - ":versionedparcelable", - ], -) - -fb_native.android_library( - name = "core-common", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core-common-binary", - ], -) - -fb_native.android_library( - name = "core-runtime", - visibility = ["PUBLIC"], - exported_deps = [ - ":core-common", - ":core-runtime-binary", - ], -) - -fb_native.android_library( - name = "cursoradapter", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":cursoradapter-binary", - ], -) - -fb_native.android_library( - name = "customview", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":customview-binary", - ], -) - -fb_native.android_library( - name = "documentfile", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":documentfile-binary", - ], -) - -fb_native.android_library( - name = "drawerlayout", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":customview", - ":drawerlayout-binary", - ], -) - -fb_native.android_library( - name = "fragment", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":fragment-binary", - ":legacy-support-core-ui", - ":legacy-support-core-utils", - ":lifecycle-viewmodel", - ":loader", - ], -) - -fb_native.android_library( - name = "interpolator", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":interpolator-binary", - ], -) - -fb_native.android_library( - name = "legacy-support-core-ui", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":asynclayoutinflater", - ":coordinatorlayout", - ":core", - ":cursoradapter", - ":customview", - ":drawerlayout", - ":interpolator", - ":legacy-support-core-ui-binary", - ":legacy-support-core-utils", - ":slidingpanelayout", - ":swiperefreshlayout", - ":viewpager", - ], -) - -fb_native.android_library( - name = "legacy-support-core-utils", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":documentfile", - ":legacy-support-core-utils-binary", - ":loader", - ":localbroadcastmanager", - ":print", - ], -) - -fb_native.android_library( - name = "lifecycle-common", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":lifecycle-common-binary", - ], -) - -fb_native.android_library( - name = "lifecycle-livedata", - visibility = ["PUBLIC"], - exported_deps = [ - ":core-common", - ":core-runtime", - ":lifecycle-livedata-binary", - ":lifecycle-livedata-core", - ], -) - -fb_native.android_library( - name = "lifecycle-livedata-core", - visibility = ["PUBLIC"], - exported_deps = [ - ":core-common", - ":core-runtime", - ":lifecycle-common", - ":lifecycle-livedata-core-binary", - ], -) - -fb_native.android_library( - name = "lifecycle-runtime", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core-common", - ":lifecycle-common", - ":lifecycle-runtime-binary", - ], -) - -fb_native.android_library( - name = "lifecycle-viewmodel", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":lifecycle-viewmodel-binary", - ], -) - -fb_native.android_library( - name = "localbroadcastmanager", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":localbroadcastmanager-binary", - ], -) - -fb_native.android_library( - name = "loader", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":lifecycle-livedata", - ":lifecycle-viewmodel", - ":loader-binary", - ], -) - -fb_native.android_library( - name = "print", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":print-binary", - ], -) - -fb_native.android_library( - name = "slidingpanelayout", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":customview", - ":slidingpanelayout-binary", - ], -) - -fb_native.android_library( - name = "swiperefreshlayout", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":interpolator", - ":swiperefreshlayout-binary", - ], -) - -fb_native.android_library( - name = "vectordrawable", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":vectordrawable-binary", - ], -) - -fb_native.android_library( - name = "vectordrawable-animated", - visibility = ["PUBLIC"], - exported_deps = [ - ":legacy-support-core-ui", - ":vectordrawable", - ":vectordrawable-animated-binary", - ], -) - -fb_native.android_library( - name = "versionedparcelable", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":collection", - ":versionedparcelable-binary", - ], -) - -fb_native.android_library( - name = "viewpager", - visibility = ["PUBLIC"], - exported_deps = [ - ":annotation", - ":core", - ":customview", - ":viewpager-binary", - ], -) - -# Internal targets -fb_native.android_prebuilt_aar( - name = "appcompat-binary", - aar = ":appcompat-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "asynclayoutinflater-binary", - aar = ":asynclayoutinflater-binary-aar", -) - -fb_native.prebuilt_jar( - name = "collection-binary", - binary_jar = ":collection-binary.jar", -) - -fb_native.android_prebuilt_aar( - name = "coordinatorlayout-binary", - aar = ":coordinatorlayout-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "core-binary", - aar = ":core-binary-aar", -) - -fb_native.prebuilt_jar( - name = "core-common-binary", - binary_jar = ":core-common-binary.jar", -) - -fb_native.android_prebuilt_aar( - name = "core-runtime-binary", - aar = ":core-runtime-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "cursoradapter-binary", - aar = ":cursoradapter-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "customview-binary", - aar = ":customview-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "documentfile-binary", - aar = ":documentfile-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "drawerlayout-binary", - aar = ":drawerlayout-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "fragment-binary", - aar = ":fragment-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "interpolator-binary", - aar = ":interpolator-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "legacy-support-core-ui-binary", - aar = ":legacy-support-core-ui-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "legacy-support-core-utils-binary", - aar = ":legacy-support-core-utils-binary-aar", -) - -fb_native.prebuilt_jar( - name = "lifecycle-common-binary", - binary_jar = ":lifecycle-common-binary.jar", -) - -fb_native.android_prebuilt_aar( - name = "lifecycle-livedata-binary", - aar = ":lifecycle-livedata-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "lifecycle-livedata-core-binary", - aar = ":lifecycle-livedata-core-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "lifecycle-runtime-binary", - aar = ":lifecycle-runtime-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "lifecycle-viewmodel-binary", - aar = ":lifecycle-viewmodel-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "loader-binary", - aar = ":loader-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "localbroadcastmanager-binary", - aar = ":localbroadcastmanager-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "print-binary", - aar = ":print-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "slidingpanelayout-binary", - aar = ":slidingpanelayout-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "swiperefreshlayout-binary", - aar = ":swiperefreshlayout-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "vectordrawable-binary", - aar = ":vectordrawable-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "vectordrawable-animated-binary", - aar = ":vectordrawable-animated-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "versionedparcelable-binary", - aar = ":versionedparcelable-binary-aar", -) - -fb_native.android_prebuilt_aar( - name = "viewpager-binary", - aar = ":viewpager-binary-aar", -) - -# Remote files -fb_native.remote_file( - name = "annotation.jar", - sha1 = "2dfd8f6b2a8fc466a1ae4e329fb79cd580f6393f", - url = "mvn:androidx.annotation:annotation:jar:1.0.1", -) - -fb_native.remote_file( - name = "appcompat-binary-aar", - sha1 = "002533a36c928bb27a3cc6843a25f83754b3c3ae", - url = "mvn:androidx.appcompat:appcompat:aar:1.0.2", -) - -fb_native.remote_file( - name = "asynclayoutinflater-binary-aar", - sha1 = "5ffa788d19a6863799f25cb50d4fdfb0ec649037", - url = "mvn:androidx.asynclayoutinflater:asynclayoutinflater:aar:1.0.0", -) - -fb_native.remote_file( - name = "collection-binary.jar", - sha1 = "42858b26cafdaa69b6149f45dfc2894007bc2c7a", - url = "mvn:androidx.collection:collection:jar:1.0.0", -) - -fb_native.remote_file( - name = "core-binary-aar", - sha1 = "263deba7f9c24bd0cefb93c0aaaf402cc50828ee", - url = "mvn:androidx.core:core:aar:1.0.1", -) - -fb_native.remote_file( - name = "core-common-binary.jar", - sha1 = "bb21b9a11761451b51624ac428d1f1bb5deeac38", - url = "mvn:androidx.arch.core:core-common:jar:2.0.0", -) - -fb_native.remote_file( - name = "core-runtime-binary-aar", - sha1 = "c5be9edf9ca9135a465d23939f6e7d0e1cf90b41", - url = "mvn:androidx.arch.core:core-runtime:aar:2.0.0", -) - -fb_native.remote_file( - name = "coordinatorlayout-binary-aar", - sha1 = "7664385a7e39112b780baf8819ee880dcd3c4094", - url = "mvn:androidx.coordinatorlayout:coordinatorlayout:aar:1.0.0", -) - -fb_native.remote_file( - name = "cursoradapter-binary-aar", - sha1 = "74014983a86b83cbce534dec4e7aa9312f5f5d82", - url = "mvn:androidx.cursoradapter:cursoradapter:aar:1.0.0", -) - -fb_native.remote_file( - name = "customview-binary-aar", - sha1 = "30f5ff6075d112f8076e733b24410e68159735b6", - url = "mvn:androidx.customview:customview:aar:1.0.0", -) - -fb_native.remote_file( - name = "documentfile-binary-aar", - sha1 = "66104345c90cd8c2fd5ad2d3aad692b280e10c32", - url = "mvn:androidx.documentfile:documentfile:aar:1.0.0", -) - -fb_native.remote_file( - name = "drawerlayout-binary-aar", - sha1 = "dd02c7e207136e1272b33815cc61e57676ed13a2", - url = "mvn:androidx.drawerlayout:drawerlayout:aar:1.0.0", -) - -fb_native.remote_file( - name = "fragment-binary-aar", - sha1 = "0b40f6a2ae814f72d1e71a5df6dc1283c00cd52f", - url = "mvn:androidx.fragment:fragment:aar:1.0.0", -) - -fb_native.remote_file( - name = "interpolator-binary-aar", - sha1 = "8a01fa254a23b9388571eb6334b03707c7d122d7", - url = "mvn:androidx.interpolator:interpolator:aar:1.0.0", -) - -fb_native.remote_file( - name = "legacy-support-core-ui-binary-aar", - sha1 = "61a264f996046e059f889914050fae1e75d3b702", - url = "mvn:androidx.legacy:legacy-support-core-ui:aar:1.0.0", -) - -fb_native.remote_file( - name = "legacy-support-core-utils-binary-aar", - sha1 = "9b9570042115da8629519090dfeb71df75da59fc", - url = "mvn:androidx.legacy:legacy-support-core-utils:aar:1.0.0", -) - -fb_native.remote_file( - name = "lifecycle-common-binary.jar", - sha1 = "e070ffae07452331bc5684734fce6831d531785c", - url = "mvn:androidx.lifecycle:lifecycle-common:jar:2.0.0", -) - -fb_native.remote_file( - name = "lifecycle-livedata-binary-aar", - sha1 = "c17007cd0b21d6401910b0becdd16c438c68a9af", - url = "mvn:androidx.lifecycle:lifecycle-livedata:aar:2.0.0", -) - -fb_native.remote_file( - name = "lifecycle-livedata-core-binary-aar", - sha1 = "1a7cee84b43fa935231b016f0665cd56a72fa9db", - url = "mvn:androidx.lifecycle:lifecycle-livedata-core:aar:2.0.0", -) - -fb_native.remote_file( - name = "lifecycle-runtime-binary-aar", - sha1 = "ea27e9e79e9a0fbedfa4dbbef5ddccf0e1d9d73f", - url = "mvn:androidx.lifecycle:lifecycle-runtime:aar:2.0.0", -) - -fb_native.remote_file( - name = "lifecycle-viewmodel-binary-aar", - sha1 = "6417c576c458137456d996914c50591e7f4acc24", - url = "mvn:androidx.lifecycle:lifecycle-viewmodel:aar:2.0.0", -) - -fb_native.remote_file( - name = "loader-binary-aar", - sha1 = "8af8b6cec0da85c207d03e15840e0722cbc71e70", - url = "mvn:androidx.loader:loader:aar:1.0.0", -) - -fb_native.remote_file( - name = "localbroadcastmanager-binary-aar", - sha1 = "2734f31c8321e83ce6b60570d14777fc33cc2ece", - url = "mvn:androidx.localbroadcastmanager:localbroadcastmanager:aar:1.0.0", -) - -fb_native.remote_file( - name = "print-binary-aar", - sha1 = "7722094652c48ebe27acc94d74a55e759e4635ff", - url = "mvn:androidx.print:print:aar:1.0.0", -) - -fb_native.remote_file( - name = "slidingpanelayout-binary-aar", - sha1 = "37eba9ccbf09b75cc4aa78a5e182d5b8ba79ad6a", - url = "mvn:androidx.slidingpanelayout:slidingpanelayout:aar:1.0.0", -) - -fb_native.remote_file( - name = "swiperefreshlayout-binary-aar", - sha1 = "4fd265b80a2b0fbeb062ab2bc4b1487521507762", - url = "mvn:androidx.swiperefreshlayout:swiperefreshlayout:aar:1.0.0", -) - -fb_native.remote_file( - name = "vectordrawable-binary-aar", - sha1 = "33d1eb71849dffbad12add134a25eb63cad4a1eb", - url = "mvn:androidx.vectordrawable:vectordrawable:aar:1.0.1", -) - -fb_native.remote_file( - name = "vectordrawable-animated-binary-aar", - sha1 = "0a41681ac4e1747f87237e489699089ad46b7a5e", - url = "mvn:androidx.vectordrawable:vectordrawable-animated:aar:1.0.0", -) - -fb_native.remote_file( - name = "versionedparcelable-binary-aar", - sha1 = "52718baf7e51ccba173b468a1034caba8140752e", - url = "mvn:androidx.versionedparcelable:versionedparcelable:aar:1.0.0", -) - -fb_native.remote_file( - name = "viewpager-binary-aar", - sha1 = "1f90e13820f96c2fb868f9674079a551678d68b2", - url = "mvn:androidx.viewpager:viewpager:aar:1.0.0", -) diff --git a/ReactAndroid/src/main/third-party/android/support/v7/appcompat/BUCK b/ReactAndroid/src/main/third-party/android/support/v7/appcompat/BUCK deleted file mode 100644 index d2521c4d03ad40..00000000000000 --- a/ReactAndroid/src/main/third-party/android/support/v7/appcompat/BUCK +++ /dev/null @@ -1,62 +0,0 @@ -load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") -load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_android_resource", "rn_genrule", "rn_prebuilt_jar") - -# This is a bit messy and hopefully a temporary thing -# The problem is that Gradle extracts appcompat resources into app namespace, com.facebook.react -# While BUCK behaves properly and extracts them into androidx.appcompat package. -# We want to support both Gradle and BUCK builds so we hack a bit how BUCK extracts resources. -# Besides that we still need JAVA classes from appcompat-v7.aar, that is why rn_android_library -# extracts classes.jar but the trick is that we can't take full appcompat.aar because resources -# extracted from it by BUCK would conflict with resources we use under Gradelified package -# All this mumbo jumbo will go away after t10182713 - -rn_android_library( - name = "appcompat", - visibility = [ - "PUBLIC", - ], - deps = [ - ":res-for-appcompat", - ], - exported_deps = [ - ":classes-for-react-native", - ], -) - -# still used by appcompat library internally, so we need both during the build -rn_android_resource( - name = "res-for-appcompat", - package = "androidx.appcompat", - res = ":res-unpacker-cmd", - visibility = ["//ReactAndroid/..."], -) - -rn_prebuilt_jar( - name = "classes-for-react-native", - binary_jar = ":classes-unpacker-cmd", - visibility = ["//ReactAndroid/..."], -) - -rn_genrule( - name = "classes-unpacker-cmd", - out = "classes.jar", - cmd = "$(exe :aar-unpacker) $(location :appcompat-binary-aar) classes.jar $OUT", -) - -rn_genrule( - name = "res-unpacker-cmd", - out = "res", - cmd = "$(exe :aar-unpacker) $(location :appcompat-binary-aar) res/ $OUT", - visibility = ["//ReactAndroid/..."], -) - -fb_native.python_binary( - name = "aar-unpacker", - main = "aar-unpacker.py", -) - -fb_native.remote_file( - name = "appcompat-binary-aar", - sha1 = "002533a36c928bb27a3cc6843a25f83754b3c3ae", - url = "mvn:androidx.appcompat:appcompat:aar:1.0.2", -) diff --git a/ReactAndroid/src/main/third-party/android/support/v7/appcompat/aar-unpacker.py b/ReactAndroid/src/main/third-party/android/support/v7/appcompat/aar-unpacker.py deleted file mode 100644 index ddb65efb21927e..00000000000000 --- a/ReactAndroid/src/main/third-party/android/support/v7/appcompat/aar-unpacker.py +++ /dev/null @@ -1,20 +0,0 @@ -import contextlib -import os -import shutil -import sys -import tempfile -import zipfile - -# Helper that unpacks the contents of an .aar file -# into given destination. - -@contextlib.contextmanager -def cleanup(path): - yield path - shutil.rmtree(path) - -if __name__ == '__main__': - with zipfile.ZipFile(sys.argv[1], 'r') as z: - with cleanup(tempfile.mkdtemp()) as temp_path: - z.extractall(temp_path, filter(lambda n: n.startswith(sys.argv[2]), z.namelist())) - shutil.move(os.path.join(temp_path, sys.argv[2]), sys.argv[3]) diff --git a/tools/build_defs/oss/rn_defs.bzl b/tools/build_defs/oss/rn_defs.bzl index c255f62bc0ecab..30b911c2ec4276 100644 --- a/tools/build_defs/oss/rn_defs.bzl +++ b/tools/build_defs/oss/rn_defs.bzl @@ -122,6 +122,7 @@ def rn_extra_build_flags(): # React property preprocessor def rn_android_library(name, deps = [], plugins = [], *args, **kwargs): + _ = kwargs.pop("is_androidx", False) if react_native_target( "java/com/facebook/react/uimanager/annotations:annotations", ) in deps and name != "processing": @@ -144,30 +145,7 @@ def rn_android_library(name, deps = [], plugins = [], *args, **kwargs): plugins = list(set(plugins + react_module_plugins)) - is_androidx = kwargs.pop("is_androidx", False) - provided_deps = kwargs.pop("provided_deps", []) - appcompat = react_native_dep("third-party/android/support/v7/appcompat-orig:appcompat") - support_v4 = react_native_dep("third-party/android/support/v4:lib-support-v4") - - if is_androidx and (appcompat in deps or appcompat in provided_deps): - # add androidx target to provided_deps - pass - # provided_deps.append( - # react_native_dep( - # "" - # ) - # ) - - if is_androidx and (support_v4 in deps or support_v4 in provided_deps): - # add androidx target to provided_deps - pass - # provided_deps.append( - # react_native_dep( - # "" - # ) - # ) - - native.android_library(name = name, deps = deps, plugins = plugins, provided_deps = provided_deps, *args, **kwargs) + native.android_library(name = name, deps = deps, plugins = plugins, *args, **kwargs) def rn_android_binary(*args, **kwargs): native.android_binary(*args, **kwargs) From 0bbab028d8da0ac7ae6df4626db264127c83f074 Mon Sep 17 00:00:00 2001 From: Chris Ewald Date: Thu, 12 Nov 2020 15:27:02 -0800 Subject: [PATCH 0052/1810] Update yarn.lock (#30361) Summary: This yarn.lock file was regenerated by deleting the existing yarn.lock file and rerunning `yarn install`. The current `yarn.lock` file is fairly out of date and is affecting the CI servers. More specifically, fsevents@1.2.7, [referenced in yarn.lock here](https://github.com/facebook/react-native/blob/46be292f671c70aac4ecc178c96e3a2a6a3d16da/yarn.lock#L3215), [fails to compile](https://github.com/fsevents/fsevents/issues/272) on node 12 or later. This causes the [yarn install step on CI to error](https://app.circleci.com/pipelines/github/facebook/react-native/7065/workflows/de2bebff-33a5-4d2e-bc73-f7f380641452/jobs/176266/parallel-runs/0/steps/0-104). This PR is being made as 1 step in getting [the RNTester detox tests running again](https://github.com/facebook/react-native/pull/30312). We can alternatively manually update the `yarn.lock` file with [the minimum needed fsevent changes](https://github.com/facebook/react-native/compare/master...MLH-Fellowship:update-yarn-lock-fsevents?expand=1#diff-51e4f558fae534656963876761c95b83b6ef5da5103c4adef6768219ed76c2deL3215-L3221) if this PR changes too much. ## Changelog [Internal] [Changed] - Bump fsevents from 1.2.7 to 1.2.13. Pull Request resolved: https://github.com/facebook/react-native/pull/30361 Test Plan: Verify yarn install step on CI is fixed. Reviewed By: hramos Differential Revision: D24910611 Pulled By: cpojer fbshipit-source-id: 45a2f25a14d368d2f464e489924b1a2befbdf784 --- yarn.lock | 249 ++++++++---------------------------------------------- 1 file changed, 33 insertions(+), 216 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4e295bc2b49e0a..fb9fe1dbf7717a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1293,11 +1293,6 @@ abab@^2.0.3: resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a" integrity sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg== -abbrev@1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" - integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - abort-controller@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" @@ -1448,19 +1443,6 @@ anymatch@^3.0.3: normalize-path "^3.0.0" picomatch "^2.0.4" -aproba@^1.0.3: - version "1.2.0" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" - integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== - -are-we-there-yet@~1.1.2: - version "1.1.5" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" - integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== - dependencies: - delegates "^1.0.0" - readable-stream "^2.0.6" - argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -1769,6 +1751,13 @@ big-integer@^1.6.7: resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.36.tgz#78631076265d4ae3555c04f85e7d9d2f3a071a36" integrity sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg== +bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + bluebird@^3.5.4: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" @@ -1969,11 +1958,6 @@ child-process-promise@^2.2.0: node-version "^1.0.0" promise-polyfill "^6.0.1" -chownr@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" - integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== - ci-info@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" @@ -2181,11 +2165,6 @@ connect@^3.6.5: parseurl "~1.3.2" utils-merge "1.0.1" -console-control-strings@^1.0.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= - convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" @@ -2310,7 +2289,7 @@ dayjs@^1.8.15: resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.8.15.tgz#7121bc04e6a7f2621ed6db566be4a8aaf8c3913e" integrity sha512-HYHCI1nohG52B45vCQg8Re3hNDZbMroWPkhz50yaX7Lu0ATyjGsTdoYZBpjED9ar6chqTx2dmSmM8A51mojnAg== -debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: +debug@2.6.9, debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -2339,11 +2318,6 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -deep-extend@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - deep-is@^0.1.3, deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -2400,11 +2374,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= - denodeify@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz#3a36287f5034e699e7577901052c2e6c94251631" @@ -2420,11 +2389,6 @@ destroy@~1.0.4: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - detect-newline@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" @@ -3064,6 +3028,11 @@ file-entry-cache@^5.0.1: dependencies: flat-cache "^2.0.1" +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -3200,25 +3169,18 @@ fs-extra@^8.1.0: jsonfile "^4.0.0" universalify "^0.1.0" -fs-minipass@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" - integrity sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ== - dependencies: - minipass "^2.2.1" - fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= fsevents@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.7.tgz#4851b664a3783e52003b3c66eb0eee1074933aa4" - integrity sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw== + version "1.2.13" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.13.tgz#f325cb0455592428bcf11b383370ef70e3bfcc38" + integrity sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw== dependencies: - nan "^2.9.2" - node-pre-gyp "^0.10.0" + bindings "^1.5.0" + nan "^2.12.1" fsevents@^2.1.2: version "2.1.2" @@ -3240,20 +3202,6 @@ funpermaproxy@^1.0.1: resolved "https://registry.yarnpkg.com/funpermaproxy/-/funpermaproxy-1.0.1.tgz#4650e69b7c334d9717c06beba9b339cc08ac3335" integrity sha512-9pEzs5vnNtR7ZGihly98w/mQ7blsvl68Wj30ZCDAXy7qDN4CWLLjdfjtH/P2m6whsnaJkw15hysCNHMXue+wdA== -gauge@~2.7.3: - version "2.7.4" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" - gensync@^1.0.0-beta.1: version "1.0.0-beta.1" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269" @@ -3392,11 +3340,6 @@ has-symbols@^1.0.0, has-symbols@^1.0.1: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== -has-unicode@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= - has-value@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" @@ -3488,20 +3431,13 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== dependencies: safer-buffer ">= 2.1.2 < 3" -ignore-walk@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" - integrity sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ== - dependencies: - minimatch "^3.0.4" - ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -3567,7 +3503,7 @@ inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -ini@^1.3.4, ini@~1.3.0: +ini@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -5200,21 +5136,6 @@ minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -minipass@^2.2.1, minipass@^2.3.3: - version "2.3.4" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.4.tgz#4768d7605ed6194d6d576169b9e12ef71e9d9957" - integrity sha512-mlouk1OHlaUE8Odt1drMtG1bAJA4ZA6B/ehysgV0LUIrDHdKgo1KorZq3pK0b/7Z7LJIQ12MNM6aC+Tn6lUZ5w== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.1.1.tgz#6734acc045a46e61d596a43bb9d9cd326e19cc42" - integrity sha512-TrfjCjk4jLhcJyGMYymBH6oTXcWjYbUAXTHDbtnWHjZC25h0cdajHuPE1zxb4DVmu8crfh+HwH/WMuyLG0nHBg== - dependencies: - minipass "^2.2.1" - mixin-deep@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" @@ -5223,7 +5144,7 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: +mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= @@ -5259,11 +5180,16 @@ mv@~2: ncp "~2.0.0" rimraf "~2.4.0" -nan@^2.10.0, nan@^2.9.2: +nan@^2.10.0: version "2.11.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA== +nan@^2.12.1: + version "2.14.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" + integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -5291,15 +5217,6 @@ ncp@~2.0.0: resolved "https://registry.yarnpkg.com/ncp/-/ncp-2.0.0.tgz#195a21d6c46e361d2fb1281ba38b91e9df7bdbb3" integrity sha1-GVoh1sRuNh0vsSgbo4uR6d9727M= -needle@^2.2.1: - version "2.2.4" - resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.4.tgz#51931bff82533b1928b7d1d69e01f1b00ffd2a4e" - integrity sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA== - dependencies: - debug "^2.1.2" - iconv-lite "^0.4.4" - sax "^1.2.4" - negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" @@ -5357,22 +5274,6 @@ node-notifier@^8.0.0: uuid "^8.3.0" which "^2.0.2" -node-pre-gyp@^0.10.0: - version "0.10.3" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" - integrity sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4" - node-stream-zip@^1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/node-stream-zip/-/node-stream-zip-1.9.1.tgz#66d210204da7c60e2d6d685eb21a11d016981fd0" @@ -5383,14 +5284,6 @@ node-version@^1.0.0: resolved "https://registry.yarnpkg.com/node-version/-/node-version-1.2.0.tgz#34fde3ffa8e1149bd323983479dda620e1b5060d" integrity sha512-ma6oU4Sk0qOoKEAymVoTvk8EdXEobdS7m/mAGhDJ8Rouugho48crHBORAmy5BoOcv8wraPM6xumapQp5hl4iIQ== -nopt@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" - integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00= - dependencies: - abbrev "1" - osenv "^0.1.4" - normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" @@ -5413,19 +5306,6 @@ normalize-path@^3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -npm-bundled@^1.0.1: - version "1.0.5" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.5.tgz#3c1732b7ba936b3a10325aef616467c0ccbcc979" - integrity sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g== - -npm-packlist@^1.1.6: - version "1.1.12" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.12.tgz#22bde2ebc12e72ca482abd67afc51eb49377243a" - integrity sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -5440,16 +5320,6 @@ npm-run-path@^4.0.0: dependencies: path-key "^3.0.0" -npmlog@^4.0.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" - integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.3" - set-blocking "~2.0.0" - nullthrows@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/nullthrows/-/nullthrows-1.1.1.tgz#7818258843856ae971eae4208ad7d7eb19a431b1" @@ -5638,11 +5508,6 @@ ora@^3.4.0: strip-ansi "^5.2.0" wcwidth "^1.0.1" -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= - os-locale@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" @@ -5657,14 +5522,6 @@ os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -osenv@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" - integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" - p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -5980,16 +5837,6 @@ range-parser@~1.2.0: resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= -rc@^1.2.7: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - react-devtools-core@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.6.0.tgz#2443b3c6fac78b801702af188abc6d83d56224e6" @@ -6058,7 +5905,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@~2.3.6: +readable-stream@^2.0.1, readable-stream@^2.2.2, readable-stream@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== @@ -6279,7 +6126,7 @@ retry@^0.10.1: resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4" integrity sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q= -rimraf@2.6.3, rimraf@^2.5.4, rimraf@^2.6.1: +rimraf@2.6.3, rimraf@^2.5.4: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== @@ -6378,7 +6225,7 @@ sanitize-filename@^1.6.1: dependencies: truncate-utf8-bytes "^1.0.0" -sax@^1.2.1, sax@^1.2.4: +sax@^1.2.1: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -6398,7 +6245,7 @@ scheduler@^0.20.1: loose-envify "^1.1.0" object-assign "^4.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -6447,7 +6294,7 @@ serve-static@^1.13.1: parseurl "~1.3.2" send "0.16.2" -set-blocking@^2.0.0, set-blocking@~2.0.0: +set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= @@ -6789,7 +6636,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2", string-width@^2.1.0, string-width@^2.1.1: +string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -6898,11 +6745,6 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - sudo-prompt@^9.0.0: version "9.1.1" resolved "https://registry.yarnpkg.com/sudo-prompt/-/sudo-prompt-9.1.1.tgz#73853d729770392caec029e2470db9c221754db0" @@ -6962,19 +6804,6 @@ tail@^2.0.0: resolved "https://registry.yarnpkg.com/tail/-/tail-2.0.2.tgz#86073f3a9a568807b7fd886897a7350314275b5f" integrity sha512-raFipiKWdGKEzxbvZwnhUGqjvsv0gpa/1A479rL//NOxnNwYZDN4MPk6xJJdUFs8P2Xrff3nbH5fcyYRLU4UHQ== -tar@^4: - version "4.4.6" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.6.tgz#63110f09c00b4e60ac8bcfe1bf3c8660235fbc9b" - integrity sha512-tMkTnh9EdzxyfW+6GK6fCahagXsnYk6kE6S9Gr9pjVdys769+laCTbodXDhPAjzVtEBazRgP0gYqOjnk9dQzLg== - dependencies: - chownr "^1.0.1" - fs-minipass "^1.2.5" - minipass "^2.3.3" - minizlib "^1.1.0" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.2" - telnet-client@1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/telnet-client/-/telnet-client-1.2.8.tgz#946c0dadc8daa3f19bb40a3e898cb870403a4ca4" @@ -7436,13 +7265,6 @@ which@^2.0.1, which@^2.0.2: dependencies: isexe "^2.0.0" -wide-align@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" - integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== - dependencies: - string-width "^1.0.2 || 2" - word-wrap@^1.2.3, word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" @@ -7608,11 +7430,6 @@ yallist@^2.1.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= -yallist@^3.0.0, yallist@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" - integrity sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k= - yargs-parser@^13.0.0: version "13.0.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.0.0.tgz#3fc44f3e76a8bdb1cc3602e860108602e5ccde8b" From 68126ed470f59d519dd2e81d66ee1fbcb565d32c Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 12 Nov 2020 15:52:41 -0800 Subject: [PATCH 0053/1810] Skip execution of IntBufferBatchMountItem if surface has stopped Summary: Fixes crashes in surface teardown / navigating away from a surface. Changelog: [Internal] Reviewed By: shergin Differential Revision: D24907216 fbshipit-source-id: 7bd7578c81687c7e64e8f70fecf8446bb333a1ed --- .../com/facebook/react/fabric/FabricUIManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index a61694b67c2fb4..f769f708f43cd0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -968,6 +968,16 @@ private boolean dispatchMountItems() { } } + // Make sure surface associated with this MountItem has been started, and not stopped. + // TODO T68118357: clean up this logic and simplify this method overall + if (mountItem instanceof IntBufferBatchMountItem) { + IntBufferBatchMountItem batchMountItem = (IntBufferBatchMountItem) mountItem; + if (!surfaceActiveForExecution( + batchMountItem.getRootTag(), "dispatchMountItems IntBufferBatchMountItem")) { + continue; + } + } + mountItem.execute(mMountingManager); } catch (Throwable e) { // If there's an exception, we want to log diagnostics in prod and rethrow. From f1fbfebccbe0e4fc48d305b51efc373f69bf93f7 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 12 Nov 2020 15:52:41 -0800 Subject: [PATCH 0054/1810] Add ReactRootView perf markers Summary: Add three markers for ReactRootView perf logging: onMeasure, attachToReactInstanceManager, and updateLayoutSpecs. It is suspected that one or all of these have regressed under Fabric in some cases. Changelog: [Internal] Reviewed By: shergin Differential Revision: D24909635 fbshipit-source-id: 6b6c0cc792c4b2d72f2360d6cffc02ef00e8a88b --- .../java/com/facebook/react/ReactRootView.java | 16 ++++++++++++---- .../react/bridge/ReactMarkerConstants.java | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index a205467c094287..b48c71ccdd69bb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -122,6 +122,7 @@ private void init() { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.onMeasure"); + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ON_MEASURE_START); try { boolean measureSpecsUpdated = widthMeasureSpec != mWidthMeasureSpec || heightMeasureSpec != mHeightMeasureSpec; @@ -171,6 +172,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { mLastHeight = height; } finally { + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ON_MEASURE_END); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } } @@ -437,7 +439,9 @@ public static Point getViewportOffset(View v) { */ private void updateRootLayoutSpecs( boolean measureSpecsChanged, final int widthMeasureSpec, final int heightMeasureSpec) { + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_START); if (mReactInstanceManager == null) { + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_END); FLog.w(TAG, "Unable to update root layout specs for uninitialized ReactInstanceManager"); return; } @@ -466,6 +470,8 @@ private void updateRootLayoutSpecs( mLastOffsetY = offsetY; } } + + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_END); } /** @@ -623,16 +629,18 @@ private CustomGlobalLayoutListener getCustomGlobalLayoutListener() { private void attachToReactInstanceManager() { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachToReactInstanceManager"); - - if (mIsAttachedToInstance) { - return; - } + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_START); try { + if (mIsAttachedToInstance) { + return; + } + mIsAttachedToInstance = true; Assertions.assertNotNull(mReactInstanceManager).attachRootView(this); getViewTreeObserver().addOnGlobalLayoutListener(getCustomGlobalLayoutListener()); } finally { + ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_END); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java index 8c5f38d4d89c06..91e13be6f040ee 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java @@ -94,6 +94,12 @@ public enum ReactMarkerConstants { JAVASCRIPT_EXECUTOR_FACTORY_INJECT_END, LOAD_REACT_NATIVE_SO_FILE_START, LOAD_REACT_NATIVE_SO_FILE_END, + ROOT_VIEW_ON_MEASURE_START, + ROOT_VIEW_ON_MEASURE_END, + ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_START, + ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_END, + ROOT_VIEW_UPDATE_LAYOUT_SPECS_START, + ROOT_VIEW_UPDATE_LAYOUT_SPECS_END, // Fabric-specific constants below this line LOAD_REACT_NATIVE_FABRIC_SO_FILE_START, LOAD_REACT_NATIVE_FABRIC_SO_FILE_END, From 6a039d7be36cbf29d6efa3b4b9557f4f19f878a4 Mon Sep 17 00:00:00 2001 From: George Zahariev Date: Thu, 12 Nov 2020 21:12:10 -0800 Subject: [PATCH 0055/1810] Remove usage of deprecated @flow weak in Xplat Summary: This is the one usage of `flow weak` in Xplat - change it to normal `flow` and add a suppression where an error appears. Changelog: [Internal] Reviewed By: Hans-Halverson Differential Revision: D24878970 fbshipit-source-id: 16e459c261b41e04de1555ed7ef4ecf2f5b3721e --- .../rn-tester/js/examples/PanResponder/PanResponderExample.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/rn-tester/js/examples/PanResponder/PanResponderExample.js b/packages/rn-tester/js/examples/PanResponder/PanResponderExample.js index fcb807edb9d391..f45ec746a84e81 100644 --- a/packages/rn-tester/js/examples/PanResponder/PanResponderExample.js +++ b/packages/rn-tester/js/examples/PanResponder/PanResponderExample.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow weak + * @flow */ 'use strict'; @@ -110,6 +110,7 @@ class PanResponderExample extends React.Component { }} style={[ styles.circle, + // $FlowFixMe[incompatible-type] { translateX: this.state.left, translateY: this.state.top, From 58c80d4f8d82d3867626bb51f3c9fcd917850a4f Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Thu, 12 Nov 2020 22:28:13 -0800 Subject: [PATCH 0056/1810] Use codegen from source in default iOS template apps Summary: Add the `react-native-codegen` source to the `react-native` npm package. Instead of using `react-native-codegen` from npm, the iOS app template will now build the package from source. Doing so removes the need to carefully time `react-native-codegen` npm releases to oss `react-native` releases, as the codegen and the oss release will be cut at the same time. Changelog: [Internal] - Removed react-native-codegen dependency from iOS app template Reviewed By: TheSavior Differential Revision: D24904655 fbshipit-source-id: a07932bc748e2afb9359de584181bcb9dd0810ea --- package.json | 1 + packages/rn-tester/Podfile | 4 +--- packages/rn-tester/Podfile.lock | 2 +- scripts/generate-native-modules-specs.sh | 2 +- scripts/react_native_pods.rb | 4 ++-- template/package.json | 3 +-- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index b743a22c696aa1..53f4cc10e9333e 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "Libraries", "LICENSE", "local-cli", + "packages/react-native-codegen", "React-Core.podspec", "react-native.config.js", "react.gradle", diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index feb884bd0b84a8..021f13970c392d 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -64,9 +64,7 @@ pre_install do |installer| frameworks_pre_install(installer) if ENV['USE_FRAMEWORKS'] == '1' if ENV['USE_CODEGEN'] != '0' prefix_path = "../.." - codegen_path = "../../packages/react-native-codegen" - system("(cd #{codegen_path} && yarn install && yarn run build)") - codegen_pre_install(installer, {path:prefix_path, codegen_path:codegen_path}) + codegen_pre_install(installer, {path:prefix_path}) end end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 2af3e3e873ef87..4034f23bda4545 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -528,6 +528,6 @@ SPEC CHECKSUMS: Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 497dba59a3312b3cb22d518b96672409db90460d +PODFILE CHECKSUM: 961e081223f82b7e9208869de4d73534d949ae9e COCOAPODS: 1.10.0 diff --git a/scripts/generate-native-modules-specs.sh b/scripts/generate-native-modules-specs.sh index e72916bc138da1..5edfa3e421e14d 100755 --- a/scripts/generate-native-modules-specs.sh +++ b/scripts/generate-native-modules-specs.sh @@ -25,7 +25,7 @@ RN_DIR=$(cd "$THIS_DIR/.." && pwd) CODEGEN_DIR=$(cd "$RN_DIR/packages/react-native-codegen" && pwd) OUTPUT_DIR="${1:-$RN_DIR/Libraries/FBReactNativeSpec/FBReactNativeSpec}" SCHEMA_FILE="$RN_DIR/schema-native-modules.json" -YARN_BINARY="${YARN_BINARY:-yarn}" +YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" describe () { printf "\\n\\n>>>>> %s\\n\\n\\n" "$1" diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 5b97c630af4eb7..f184a5c8784177 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -112,13 +112,13 @@ def flipper_post_install(installer) # Pre Install processing for Native Modules def codegen_pre_install(installer, options={}) prefix = options[:path] ||= "../node_modules/react-native" - codegen_path = options[:codegen_path] ||= "../node_modules/react-native-codegen" + system("./#{prefix}/packages/react-native-codegen/scripts/oss/build.sh") Dir.mktmpdir do |dir| native_module_spec_name = "FBReactNativeSpec" schema_file = dir + "/schema-#{native_module_spec_name}.json" srcs_dir = "#{prefix}/Libraries" - schema_generated = system("node #{codegen_path}/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}") + schema_generated = system("node #{prefix}/packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}") specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}") end end diff --git a/template/package.json b/template/package.json index c7a6edda8b1fbc..2c481b9ec10034 100644 --- a/template/package.json +++ b/template/package.json @@ -21,8 +21,7 @@ "eslint": "7.12.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.64.0", - "react-test-renderer": "17.0.1", - "react-native-codegen": "0.0.4" + "react-test-renderer": "17.0.1" }, "jest": { "preset": "react-native" From 53862a1b5a58d3617bc2c0d5248f80e9d4397208 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 13 Nov 2020 08:48:49 -0800 Subject: [PATCH 0057/1810] Back out "Fabric: Strengthening StubView mutating validation" Summary: Changelog: [internal] Original commit changeset: 8c8a3d8e205c Reviewed By: ShikaSD Differential Revision: D24951341 fbshipit-source-id: b6109a45f1537a9edc702eafac1736e801fbedc9 --- .../react/renderer/mounting/StubView.cpp | 12 ------ .../react/renderer/mounting/StubView.h | 2 - .../react/renderer/mounting/StubViewTree.cpp | 38 ++++++++++++------- .../react/renderer/mounting/StubViewTree.h | 4 +- ReactCommon/react/renderer/mounting/stubs.cpp | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/StubView.cpp b/ReactCommon/react/renderer/mounting/StubView.cpp index 4d6b140da20a04..f476de31184899 100644 --- a/ReactCommon/react/renderer/mounting/StubView.cpp +++ b/ReactCommon/react/renderer/mounting/StubView.cpp @@ -10,18 +10,6 @@ namespace facebook { namespace react { -StubView::operator ShadowView() const { - auto shadowView = ShadowView{}; - shadowView.componentName = componentName; - shadowView.componentHandle = componentHandle; - shadowView.tag = tag; - shadowView.props = props; - shadowView.eventEmitter = eventEmitter; - shadowView.layoutMetrics = layoutMetrics; - shadowView.state = state; - return shadowView; -} - void StubView::update(ShadowView const &shadowView) { componentName = shadowView.componentName; componentHandle = shadowView.componentHandle; diff --git a/ReactCommon/react/renderer/mounting/StubView.h b/ReactCommon/react/renderer/mounting/StubView.h index 3c95f68f5be24f..8546baa157aee5 100644 --- a/ReactCommon/react/renderer/mounting/StubView.h +++ b/ReactCommon/react/renderer/mounting/StubView.h @@ -25,8 +25,6 @@ class StubView final { StubView() = default; StubView(StubView const &stubView) = default; - operator ShadowView() const; - void update(ShadowView const &shadowView); ComponentName componentName; diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index c2e3e3d62c5f76..0c9dedee025294 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -38,19 +38,30 @@ StubView const &StubViewTree::getRootStubView() const { return *registry.at(rootTag); } -void StubViewTree::mutate(ShadowViewMutationList const &mutations) { +/** + * ignoreDuplicateCreates: when stubs generates "fake" mutation instructions, in + * some cases it can produce too many "create" instructions. We ignore + * duplicates and treat them as noops. In the case of verifying actual diffing, + * that assert is left on. + * + * @param mutations + * @param ignoreDuplicateCreates + */ +void StubViewTree::mutate( + ShadowViewMutationList const &mutations, + bool ignoreDuplicateCreates) { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Mutating Begin"; }); for (auto const &mutation : mutations) { switch (mutation.type) { case ShadowViewMutation::Create: { STUB_VIEW_ASSERT(mutation.parentShadowView == ShadowView{}); STUB_VIEW_ASSERT(mutation.oldChildShadowView == ShadowView{}); - STUB_VIEW_ASSERT(mutation.newChildShadowView.props); auto stubView = std::make_shared(); - stubView->update(mutation.newChildShadowView); auto tag = mutation.newChildShadowView.tag; STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Create: " << tag; }); - STUB_VIEW_ASSERT(registry.find(tag) == registry.end()); + if (!ignoreDuplicateCreates) { + STUB_VIEW_ASSERT(registry.find(tag) == registry.end()); + } registry[tag] = stubView; break; } @@ -62,9 +73,6 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_ASSERT(mutation.newChildShadowView == ShadowView{}); auto tag = mutation.oldChildShadowView.tag; STUB_VIEW_ASSERT(registry.find(tag) != registry.end()); - auto stubView = registry[tag]; - STUB_VIEW_ASSERT( - (ShadowView)(*stubView) == mutation.oldChildShadowView); registry.erase(tag); break; } @@ -129,15 +137,19 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Update: " << mutation.newChildShadowView.tag; }); - STUB_VIEW_ASSERT(mutation.newChildShadowView.props); + + // We don't have a strict requirement that oldChildShadowView has any + // data. In particular, LayoutAnimations can produce UPDATEs with only a + // new node. STUB_VIEW_ASSERT( - mutation.newChildShadowView.tag == mutation.oldChildShadowView.tag); + mutation.newChildShadowView.tag == + mutation.oldChildShadowView.tag || + mutation.oldChildShadowView.tag == 0); + STUB_VIEW_ASSERT( registry.find(mutation.newChildShadowView.tag) != registry.end()); - auto oldStubView = registry[mutation.newChildShadowView.tag]; - STUB_VIEW_ASSERT( - (ShadowView)(*oldStubView) == mutation.oldChildShadowView); - oldStubView->update(mutation.newChildShadowView); + auto stubView = registry[mutation.newChildShadowView.tag]; + stubView->update(mutation.newChildShadowView); break; } } diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.h b/ReactCommon/react/renderer/mounting/StubViewTree.h index 6ffb00e63ce96a..3dceaba3dc7e97 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.h +++ b/ReactCommon/react/renderer/mounting/StubViewTree.h @@ -21,7 +21,9 @@ class StubViewTree { StubViewTree() = default; StubViewTree(ShadowView const &shadowView); - void mutate(ShadowViewMutationList const &mutations); + void mutate( + ShadowViewMutationList const &mutations, + bool ignoreDuplicateCreates = false); StubView const &getRootStubView() const; diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index 370989a21a8d7a..47ce20e9e2c400 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -54,7 +54,7 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { ShadowNode::emptySharedShadowNodeSharedList()}); auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode)); - stubViewTree.mutate(mutations); + stubViewTree.mutate(mutations, true); return stubViewTree; } From 2798e7172b01b9e2dbe2937d0163f98ab29230cf Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Fri, 13 Nov 2020 09:51:34 -0800 Subject: [PATCH 0058/1810] remove ReactFragmentActivity (#30331) Summary: Remove ReactFragmentActivity class, which was deprecated at least since 0.58. ## Changelog [Android] [Changed] - remove ReactFragmentActivity class. Pull Request resolved: https://github.com/facebook/react-native/pull/30331 Reviewed By: makovkastar Differential Revision: D24914082 Pulled By: fkgozali fbshipit-source-id: 6833b76552a1fc19680f96501d4b8e2ff03c2c39 --- .../com/facebook/react/ReactActivityDelegate.java | 6 +++--- .../com/facebook/react/ReactFragmentActivity.java | 15 --------------- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index 7083f86bfc9cbb..c6766d138f59d4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -20,9 +20,9 @@ import com.facebook.react.modules.core.PermissionListener; /** - * Delegate class for {@link ReactActivity} and {@link ReactFragmentActivity}. You can subclass this - * to provide custom implementations for e.g. {@link #getReactNativeHost()}, if your Application - * class doesn't implement {@link ReactApplication}. + * Delegate class for {@link ReactActivity}. You can subclass this to provide custom implementations + * for e.g. {@link #getReactNativeHost()}, if your Application class doesn't implement {@link + * ReactApplication}. */ public class ReactActivityDelegate { diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java b/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java deleted file mode 100644 index 9a0e1a1c1fea46..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react; - -/** - * @deprecated ReactFragmentActivity will be removed in 0.59 release. Use {@link ReactActivity} - * instead. - */ -@Deprecated -public abstract class ReactFragmentActivity extends ReactActivity {} From 9be3356e02845a3a8194226a34faa4cb6f7295f1 Mon Sep 17 00:00:00 2001 From: Nadiia D Date: Fri, 13 Nov 2020 17:05:09 -0800 Subject: [PATCH 0059/1810] replace defaultProps usage in functional components Summary: Changelog: [General] [Removed] - Replace defaultProps usage in functional components Reviewed By: kacieb Differential Revision: D24907836 fbshipit-source-id: 05c7381b66c7738790eff5fea594791c3ecfa12e --- .../ActivityIndicator/ActivityIndicator.js | 29 ++++++++++--------- .../ActivityIndicator-test.js.snap | 6 ---- .../ProgressBarAndroid.android.js | 26 ++++++++++------- .../ProgressBarAndroid-test.js.snap | 2 -- Libraries/Components/TextInput/TextInput.js | 24 +++++++++------ .../__snapshots__/TextInput-test.js.snap | 16 ++-------- 6 files changed, 48 insertions(+), 55 deletions(-) diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 52cbda4a7312e2..05f125d86698bf 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -62,8 +62,18 @@ type Props = $ReadOnly<{| size?: ?IndicatorSize, |}>; -const ActivityIndicator = (props: Props, forwardedRef?: any) => { - const {onLayout, style, size, ...restProps} = props; +const ActivityIndicator = ( + { + animating = true, + color = Platform.OS === 'ios' ? GRAY : null, + hidesWhenStopped = true, + onLayout, + size = 'small', + style, + ...restProps + }: Props, + forwardedRef?: any, +) => { let sizeStyle; let sizeProp; @@ -77,11 +87,14 @@ const ActivityIndicator = (props: Props, forwardedRef?: any) => { sizeProp = 'large'; break; default: - sizeStyle = {height: props.size, width: props.size}; + sizeStyle = {height: size, width: size}; break; } const nativeProps = { + animating, + color, + hidesWhenStopped, ...restProps, ref: forwardedRef, style: sizeStyle, @@ -178,16 +191,6 @@ const ActivityIndicatorWithRef: React.AbstractComponent< > = React.forwardRef(ActivityIndicator); ActivityIndicatorWithRef.displayName = 'ActivityIndicator'; -/* $FlowFixMe(>=0.89.0 site=react_native_fb) This comment suppresses an error - * found when Flow v0.89 was deployed. To see the error, delete this comment - * and run Flow. */ -ActivityIndicatorWithRef.defaultProps = { - animating: true, - color: Platform.OS === 'ios' ? GRAY : null, - hidesWhenStopped: true, - size: 'small', -}; - const styles = StyleSheet.create({ container: { alignItems: 'center', diff --git a/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap b/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap index d8316e939d13d1..4326d7f8ae20f3 100644 --- a/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap +++ b/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap @@ -2,9 +2,7 @@ exports[` should render as expected: should deep render when mocked (please verify output manually) 1`] = ` `; @@ -35,18 +33,14 @@ exports[` should render as expected: should deep render whe exports[` should render as expected: should shallow render as when mocked 1`] = ` `; exports[` should render as expected: should shallow render as when not mocked 1`] = ` `; diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js index 61663d6ad50b30..b4d1118cf40533 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -81,23 +81,27 @@ export type ProgressBarAndroidProps = $ReadOnly<{| * ``` */ const ProgressBarAndroid = ( - props: ProgressBarAndroidProps, + { + styleAttr = 'Normal', + indeterminate = true, + animating = true, + ...restProps + }: ProgressBarAndroidProps, forwardedRef: ?React.Ref, ) => { - return ; + return ( + + ); }; const ProgressBarAndroidToExport = React.forwardRef(ProgressBarAndroid); -/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an - * error found when Flow v0.89 was deployed. To see the error, delete this - * comment and run Flow. */ -ProgressBarAndroidToExport.defaultProps = { - styleAttr: 'Normal', - indeterminate: true, - animating: true, -}; - /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this * comment and run Flow. */ diff --git a/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap b/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap index 87b8c16da4f277..f1985dfedb660a 100644 --- a/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap +++ b/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap @@ -18,7 +18,6 @@ exports[` should render as expected: should deep render wh exports[` should render as expected: should shallow render as when mocked 1`] = ` @@ -26,7 +25,6 @@ exports[` should render as expected: should shallow render exports[` should render as expected: should shallow render as when not mocked 1`] = ` diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index a46efe02c63e99..03c41c9f9b5b18 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -1164,21 +1164,27 @@ const ExportedForwardRef: React.AbstractComponent< React.ElementConfig, React.ElementRef> & ImperativeMethods, > = React.forwardRef(function TextInput( - props, + { + allowFontScaling = true, + rejectResponderTermination = true, + underlineColorAndroid = 'transparent', + ...restProps + }, forwardedRef: ReactRefSetter< React.ElementRef> & ImperativeMethods, >, ) { - return ; + return ( + + ); }); -// $FlowFixMe -ExportedForwardRef.defaultProps = { - allowFontScaling: true, - rejectResponderTermination: true, - underlineColorAndroid: 'transparent', -}; - // TODO: Deprecate this // $FlowFixMe ExportedForwardRef.propTypes = DeprecatedTextInputPropTypes; diff --git a/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap b/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap index 9ab974ba299412..ea9693e96244c5 100644 --- a/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap +++ b/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap @@ -56,18 +56,6 @@ exports[`TextInput tests should render as expected: should deep render when not /> `; -exports[`TextInput tests should render as expected: should shallow render as when mocked 1`] = ` - -`; +exports[`TextInput tests should render as expected: should shallow render as when mocked 1`] = ``; -exports[`TextInput tests should render as expected: should shallow render as when not mocked 1`] = ` - -`; +exports[`TextInput tests should render as expected: should shallow render as when not mocked 1`] = ``; From 480dabd66547a60522249eda203a3eb1934b02e5 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 13 Nov 2020 18:04:51 -0800 Subject: [PATCH 0060/1810] RN: Remove Android `setTimeout` Warning Summary: Many third-party libraries (especially data management and caching ones) make use of long timeouts. There are currently no plans to change `setTimeout` on Android to support firing when apps are in the background. In the meantime, this warning is not actionable for developers who are using these frameworks. Their workarounds are to 1) deal with the noise in their logs, or 2) suppress the warning. Changelog: [General][Removed] - Removed warning on Android for `setTimeout` with delays greater than 1 minute. Reviewed By: lunaleaps Differential Revision: D24964958 fbshipit-source-id: 1b40c8ba95d554c29dec74477aa63ea3ef8e4768 --- Libraries/Core/Timers/JSTimers.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index 9c5d2a099e3887..504daa5f446193 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -11,7 +11,6 @@ 'use strict'; const BatchedBridge = require('../../BatchedBridge/BatchedBridge'); -const Platform = require('../../Utilities/Platform'); const Systrace = require('../../Performance/Systrace'); const invariant = require('invariant'); @@ -36,14 +35,6 @@ export type JSTimerType = const FRAME_DURATION = 1000 / 60; const IDLE_CALLBACK_FRAME_DEADLINE = 1; -const MAX_TIMER_DURATION_MS = 60 * 1000; -const IS_ANDROID = Platform.OS === 'android'; -const ANDROID_LONG_TIMER_MESSAGE = - 'Setting a timer for a long period of time, i.e. multiple minutes, is a ' + - 'performance and correctness issue on Android as it keeps the timer ' + - 'module awake, and timers can only be called when the app is in the foreground. ' + - 'See https://github.com/facebook/react-native/issues/12981 for more info.'; - // Parallel arrays const callbacks: Array = []; const types: Array = []; @@ -218,15 +209,6 @@ const JSTimers = { * @param {number} duration Number of milliseconds. */ setTimeout: function(func: Function, duration: number, ...args: any): number { - if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) { - console.warn( - ANDROID_LONG_TIMER_MESSAGE + - '\n' + - '(Saw setTimeout with duration ' + - duration + - 'ms)', - ); - } const id = _allocateCallback( () => func.apply(undefined, args), 'setTimeout', @@ -244,15 +226,6 @@ const JSTimers = { duration: number, ...args: any ): number { - if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) { - console.warn( - ANDROID_LONG_TIMER_MESSAGE + - '\n' + - '(Saw setInterval with duration ' + - duration + - 'ms)', - ); - } const id = _allocateCallback( () => func.apply(undefined, args), 'setInterval', From 23def0f8f096607d72fa24fb46f5b4336026f8d2 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 13 Nov 2020 21:51:04 -0800 Subject: [PATCH 0061/1810] Experiment to replace Fabric MountItem lists with concurrent queues Summary: Currently, queuing any sort of MountItem or getting the list of MountItems requires synchronization. Since these can be queued up at any point from the JS thread, there will, in theory, be constant contention between JS and UI thread. To see if this is true, I'm creating an experiment instead of just switching over to concurrent structures. After seeing results, we can hopefully make a decision and delete the non-concurrent stuff or improve on it somehow. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D24942110 fbshipit-source-id: fcbdeda51f91f4bd430a20d7484854fb1e94a832 --- .../react/config/ReactFeatureFlags.java | 3 + .../react/fabric/FabricUIManager.java | 202 ++++++++++++------ 2 files changed, 144 insertions(+), 61 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 5a5cfeee2f78ec..d972c83330ed70 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -88,4 +88,7 @@ public class ReactFeatureFlags { /** Potential bugfix for crashes caused by mutating the view hierarchy during onDraw. */ public static boolean enableDrawMutationFix = true; + + /** Use lock-free data structures for Fabric MountItems. */ + public static boolean enableLockFreeMountInstructions = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index f769f708f43cd0..05ca95c13f2911 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -89,10 +89,12 @@ import com.facebook.systrace.Systrace; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; @SuppressLint("MissingNativeLoadLibrary") @@ -124,19 +126,34 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { new ConcurrentHashMap<>(); @NonNull private final EventBeatManager mEventBeatManager; - @NonNull private final Object mViewCommandMountItemsLock = new Object(); - @NonNull private final Object mMountItemsLock = new Object(); - @NonNull private final Object mPreMountItemsLock = new Object(); private boolean mInDispatch = false; private int mReDispatchCounter = 0; - @GuardedBy("mViewCommandMountItemsLock") @NonNull - private List mViewCommandMountItems = new ArrayList<>(); + private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); + // Concurrent MountItem data-structures, experimental. TODO: T79662803 @NonNull - private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); + private final ConcurrentLinkedQueue mViewCommandMountItemsConcurrent = + new ConcurrentLinkedQueue<>(); + + @NonNull + private final ConcurrentLinkedQueue mMountItemsConcurrent = + new ConcurrentLinkedQueue<>(); + + @NonNull + private final ConcurrentLinkedQueue mPreMountItemsConcurrent = + new ConcurrentLinkedQueue<>(); + + // Non-concurrent MountItem data-structures + @NonNull private final Object mViewCommandMountItemsLock = new Object(); + @NonNull private final Object mMountItemsLock = new Object(); + @NonNull private final Object mPreMountItemsLock = new Object(); + + @GuardedBy("mViewCommandMountItemsLock") + @NonNull + private List mViewCommandMountItems = new ArrayList<>(); @GuardedBy("mMountItemsLock") @NonNull @@ -339,18 +356,15 @@ private void preallocateView( // possible at teardown, but this race should *never* happen at startup. @Nullable ThemedReactContext context = mReactContextForRootTag.get(rootTag); - String component = getFabricComponentName(componentName); - synchronized (mPreMountItemsLock) { - mPreMountItems.add( - new PreAllocateViewMountItem( - context, - rootTag, - reactTag, - component, - props, - (StateWrapper) stateWrapper, - isLayoutable)); - } + addPreAllocateMountItem( + new PreAllocateViewMountItem( + context, + rootTag, + reactTag, + getFabricComponentName(componentName), + props, + (StateWrapper) stateWrapper, + isLayoutable)); } @DoNotStrip @@ -616,9 +630,7 @@ public void execute(@NonNull MountingManager mountingManager) { // If the reactTag exists, we assume that it might at the end of the next // batch of MountItems. Otherwise, we try to execute immediately. if (!mMountingManager.getViewExists(reactTag)) { - synchronized (mMountItemsLock) { - mMountItems.add(synchronousMountItem); - } + addMountItem(synchronousMountItem); return; } @@ -692,9 +704,7 @@ private void scheduleMountItem( } if (shouldSchedule && mountItem != null) { - synchronized (mMountItemsLock) { - mMountItems.add(mountItem); - } + addMountItem(mountItem); if (UiThreadUtil.isOnUiThread()) { // We only read these flags on the UI thread. tryDispatchMountItems(); @@ -777,9 +787,28 @@ private void tryDispatchMountItems() { mLastExecutedMountItemSurfaceId = -1; } + @Nullable + private List drainConcurrentItemQueue(ConcurrentLinkedQueue queue) { + List result = new ArrayList<>(); + while (!queue.isEmpty()) { + E item = queue.poll(); + if (item != null) { + result.add(item); + } + } + if (result.size() == 0) { + return null; + } + return result; + } + @UiThread @ThreadConfined(UI) private List getAndResetViewCommandMountItems() { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + return drainConcurrentItemQueue(mViewCommandMountItemsConcurrent); + } + synchronized (mViewCommandMountItemsLock) { List result = mViewCommandMountItems; if (result.isEmpty()) { @@ -793,6 +822,10 @@ private List getAndResetViewCommandMountItems() { @UiThread @ThreadConfined(UI) private List getAndResetMountItems() { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + return drainConcurrentItemQueue(mMountItemsConcurrent); + } + synchronized (mMountItemsLock) { List result = mMountItems; if (result.isEmpty()) { @@ -803,7 +836,11 @@ private List getAndResetMountItems() { } } - private ArrayDeque getAndResetPreMountItems() { + private Collection getAndResetPreMountItems() { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + return drainConcurrentItemQueue(mPreMountItemsConcurrent); + } + synchronized (mPreMountItemsLock) { ArrayDeque result = mPreMountItems; if (result.isEmpty()) { @@ -926,19 +963,18 @@ private boolean dispatchMountItems() { // If there are MountItems to dispatch, we make sure all the "pre mount items" are executed // first - ArrayDeque mPreMountItemsToDispatch = getAndResetPreMountItems(); + Collection preMountItemsToDispatch = getAndResetPreMountItems(); - if (mPreMountItemsToDispatch != null) { + if (preMountItemsToDispatch != null) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManager::mountViews preMountItems to execute: " - + mPreMountItemsToDispatch.size()); + + preMountItemsToDispatch.size()); - while (!mPreMountItemsToDispatch.isEmpty()) { - PreAllocateViewMountItem mountItem = mPreMountItemsToDispatch.pollFirst(); + for (PreAllocateViewMountItem preMountItem : preMountItemsToDispatch) { if (surfaceActiveForExecution( - mountItem.getRootTag(), "dispatchMountItems PreAllocateViewMountItem")) { - mountItem.execute(mMountingManager); + preMountItem.getRootTag(), "dispatchMountItems PreAllocateViewMountItem")) { + preMountItem.execute(mMountingManager); } } @@ -1016,12 +1052,19 @@ private void dispatchPreMountItems(long frameTimeNanos) { break; } - PreAllocateViewMountItem preMountItemToDispatch; - synchronized (mPreMountItemsLock) { - if (mPreMountItems.isEmpty()) { - break; + PreAllocateViewMountItem preMountItemToDispatch = null; + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + preMountItemToDispatch = mPreMountItemsConcurrent.poll(); + } else { + synchronized (mPreMountItemsLock) { + if (!mPreMountItems.isEmpty()) { + preMountItemToDispatch = mPreMountItems.pollFirst(); + } } - preMountItemToDispatch = mPreMountItems.pollFirst(); + } + // If list is empty, `poll` will return null, or var will never be set + if (preMountItemToDispatch == null) { + break; } if (surfaceActiveForExecution( @@ -1132,18 +1175,14 @@ public void dispatchCommand( @AnyThread @ThreadConfined(ANY) private void dispatchCommandMountItem(DispatchCommandMountItem command) { - synchronized (mViewCommandMountItemsLock) { - mViewCommandMountItems.add(command); - } + addViewCommandMountItem(command); } @Override @AnyThread @ThreadConfined(ANY) public void sendAccessibilityEvent(int reactTag, int eventType) { - synchronized (mMountItemsLock) { - mMountItems.add(new SendAccessibilityEvent(reactTag, eventType)); - } + addMountItem(new SendAccessibilityEvent(reactTag, eventType)); } /** @@ -1156,15 +1195,13 @@ public void sendAccessibilityEvent(int reactTag, int eventType) { @DoNotStrip public void setJSResponder( final int reactTag, final int initialReactTag, final boolean blockNativeResponder) { - synchronized (mMountItemsLock) { - mMountItems.add( - new MountItem() { - @Override - public void execute(MountingManager mountingManager) { - mountingManager.setJSResponder(reactTag, initialReactTag, blockNativeResponder); - } - }); - } + addMountItem( + new MountItem() { + @Override + public void execute(MountingManager mountingManager) { + mountingManager.setJSResponder(reactTag, initialReactTag, blockNativeResponder); + } + }); } /** @@ -1173,15 +1210,13 @@ public void execute(MountingManager mountingManager) { */ @DoNotStrip public void clearJSResponder() { - synchronized (mMountItemsLock) { - mMountItems.add( - new MountItem() { - @Override - public void execute(MountingManager mountingManager) { - mountingManager.clearJSResponder(); - } - }); - } + addMountItem( + new MountItem() { + @Override + public void execute(MountingManager mountingManager) { + mountingManager.clearJSResponder(); + } + }); } @Override @@ -1229,6 +1264,51 @@ public Map getPerformanceCounters() { return performanceCounters; } + /** + * Abstraction between concurrent and non-concurrent MountItem list. + * + * @param mountItem + */ + private void addMountItem(MountItem mountItem) { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + mMountItemsConcurrent.add(mountItem); + } else { + synchronized (mMountItemsLock) { + mMountItems.add(mountItem); + } + } + } + + /** + * Abstraction between concurrent and non-concurrent PreAllocateViewMountItem list. + * + * @param mountItem + */ + private void addPreAllocateMountItem(PreAllocateViewMountItem mountItem) { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + mPreMountItemsConcurrent.add(mountItem); + } else { + synchronized (mPreMountItemsLock) { + mPreMountItemsConcurrent.add(mountItem); + } + } + } + + /** + * Abstraction between concurrent and non-concurrent DispatchCommandMountItem list. + * + * @param mountItem + */ + private void addViewCommandMountItem(DispatchCommandMountItem mountItem) { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + mViewCommandMountItemsConcurrent.add(mountItem); + } else { + synchronized (mViewCommandMountItemsLock) { + mViewCommandMountItems.add(mountItem); + } + } + } + private class DispatchUIFrameCallback extends GuardedFrameCallback { private volatile boolean mIsMountingEnabled = true; From 66e536739e2b863a8f4ec2dac448a4bc7b731484 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 13 Nov 2020 21:51:04 -0800 Subject: [PATCH 0062/1810] Add additional debug logging for startSurface crashes Summary: There are a very, very small number of crashes in production that are hitting this line. I would like to understand what the existing tag ID is (perhaps it's eqal to the ID being set, which would indicate "double-start"). If not, it indicates that fragments are being reused somewhere, or something else odd is going on with lifecycles. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D24953785 fbshipit-source-id: 079c86cdb571749662cca46feeaebdd6cb1281f4 --- .../com/facebook/react/fabric/mounting/MountingManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 74869a0ee45196..811393666c72c4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -103,6 +103,11 @@ private static void logViewHierarchy(ViewGroup parent, boolean recurse) { @ThreadConfined(UI) public void addRootView(int reactRootTag, @NonNull View rootView) { if (rootView.getId() != View.NO_ID) { + FLog.e( + TAG, + "Trying to add RootTag to RootView that already has a tag: existing tag: [%d] new tag: [%d]", + rootView.getId(), + reactRootTag); throw new IllegalViewOperationException( "Trying to add a root view with an explicit id already set. React Native uses " + "the id field to track react tags and will overwrite this field. If that is fine, " From c609952ddbebecba1aca62da1fb3fd143f5d11d1 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 13 Nov 2020 21:51:04 -0800 Subject: [PATCH 0063/1810] Add Systrace sections to UIImplementationProvider Summary: Add Systrace sections to initialization of non-Fabric UIImplementationProvider. This path is sometimes invoked during startup of Fabric so I'd like to gather more information about its impact. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D24959965 fbshipit-source-id: a8555b8db284d00f97c71ca859cb2020409cb110 --- .../uimanager/UIImplementationProvider.java | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java index 65b222408f66ad..dd51fe3a32f318 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java @@ -9,6 +9,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.events.EventDispatcher; +import com.facebook.systrace.Systrace; import java.util.List; /** Provides UIImplementation to use in {@link UIManagerModule}. */ @@ -20,11 +21,17 @@ public UIImplementation createUIImplementation( UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { - return new UIImplementation( - reactContext, - viewManagerResolver, - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); + Systrace.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementationProvider.createUIImplementation[1]"); + try { + return new UIImplementation( + reactContext, + viewManagerResolver, + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } finally { + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + } } public UIImplementation createUIImplementation( @@ -32,8 +39,17 @@ public UIImplementation createUIImplementation( List viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { - return new UIImplementation( - reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); + Systrace.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementationProvider.createUIImplementation[2]"); + try { + return new UIImplementation( + reactContext, + viewManagerList, + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } finally { + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + } } UIImplementation createUIImplementation( @@ -41,10 +57,16 @@ UIImplementation createUIImplementation( ViewManagerRegistry viewManagerRegistry, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { - return new UIImplementation( - reactContext, - viewManagerRegistry, - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); + Systrace.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementationProvider.createUIImplementation[3]"); + try { + return new UIImplementation( + reactContext, + viewManagerRegistry, + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } finally { + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + } } } From 47000756fefdb0c9edca1a1bf890adf7d436493c Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 13 Nov 2020 21:51:04 -0800 Subject: [PATCH 0064/1810] Add more systrace sections to FabricJSIModuleProvider Summary: Adding more Systrace sections to get perf information during critical paths. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D24960195 fbshipit-source-id: 099e9cfac8ac87287e48e9915e6b28fe7a448783 --- .../com/facebook/react/fabric/FabricJSIModuleProvider.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index c079b48231795a..91fe11b20cd55e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -56,6 +56,7 @@ public FabricJSIModuleProvider( @Override public UIManager get() { + Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.get"); final EventBeatManager eventBeatManager = new EventBeatManager(mReactApplicationContext); final FabricUIManager uiManager = createUIManager(eventBeatManager); Systrace.beginSection( @@ -76,7 +77,10 @@ public UIManager get() { jsMessageQueueThread, mComponentFactory, mConfig); + + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + return uiManager; } From d85d5d2e1974b463318e4c86da29a5ccdd60a977 Mon Sep 17 00:00:00 2001 From: Koichi Nagaoka Date: Fri, 13 Nov 2020 23:53:58 -0800 Subject: [PATCH 0065/1810] Fix cannot working Modal's onDismiss. (#29882) Summary: Fixes: https://github.com/facebook/react-native/issues/29455 Modal's onDismiss is not called on iOS. This issue occurred the commit https://github.com/facebook/react-native/commit/bd2b7d6c0366b5f19de56b71cb706a0af4b0be43 and was fixed the commit https://github.com/facebook/react-native/commit/27a3248a3b37410b5ee6dda421ae00fa485b525c. However, the master and stable-0.63 branches do not have this modified commit applied to them. ## Changelog [iOS] [Fixed] - Modal's onDismiss prop will now be called successfully. Pull Request resolved: https://github.com/facebook/react-native/pull/29882 Test Plan: Tested on iOS with this change: 1. Set function Modal's onDismiss prop. 1. Set Modal's visible props is true. (show Modal) 1. Set Modal's visible props is false. (close Modal) 1. The set function in onDismiss is called. Reviewed By: shergin Differential Revision: D24648412 Pulled By: hramos fbshipit-source-id: acf28fef21420117c845d3aed97e47b5dd4e9390 --- Libraries/Modal/Modal.js | 25 ++++++++++- .../Modal/RCTModalHostViewNativeComponent.js | 9 ++++ React/Views/RCTModalHostViewManager.m | 27 ++++-------- React/Views/RCTModalManager.h | 17 ++++++++ React/Views/RCTModalManager.m | 42 +++++++++++++++++++ .../components/rncore/EventEmitters.cpp | 7 ++++ .../components/rncore/EventEmitters.h | 6 +++ 7 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 React/Views/RCTModalManager.h create mode 100644 React/Views/RCTModalManager.m diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index 89523ad5d9bf61..f5d3556453b2c0 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -12,6 +12,9 @@ const AppContainer = require('../ReactNative/AppContainer'); const I18nManager = require('../ReactNative/I18nManager'); +import NativeEventEmitter from '../EventEmitter/NativeEventEmitter'; +import NativeModalManager from './NativeModalManager'; +const Platform = require('../Utilities/Platform'); const React = require('react'); const ScrollView = require('../Components/ScrollView/ScrollView'); const StyleSheet = require('../StyleSheet/StyleSheet'); @@ -26,6 +29,11 @@ import type {DirectEventHandler} from '../Types/CodegenTypes'; import {type EventSubscription} from '../vendor/emitter/EventEmitter'; import RCTModalHostView from './RCTModalHostViewNativeComponent'; +const ModalEventEmitter = + Platform.OS === 'ios' && NativeModalManager != null + ? new NativeEventEmitter(NativeModalManager) + : null; + /** * The Modal component is a simple way to present content above an enclosing view. * @@ -161,9 +169,22 @@ class Modal extends React.Component { this._identifier = uniqueModalIdentifier++; } + componentDidMount() { + if (ModalEventEmitter) { + this._eventSubscription = ModalEventEmitter.addListener( + 'modalDismissed', + event => { + if (event.modalID === this._identifier && this.props.onDismiss) { + this.props.onDismiss(); + } + }, + ); + } + } + componentWillUnmount() { - if (this.props.onDismiss != null) { - this.props.onDismiss(); + if (this._eventSubscription) { + this._eventSubscription.remove(); } } diff --git a/Libraries/Modal/RCTModalHostViewNativeComponent.js b/Libraries/Modal/RCTModalHostViewNativeComponent.js index 62bd8a8daf144a..7d8151eae25df0 100644 --- a/Libraries/Modal/RCTModalHostViewNativeComponent.js +++ b/Libraries/Modal/RCTModalHostViewNativeComponent.js @@ -15,6 +15,7 @@ import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; import type { WithDefault, DirectEventHandler, + BubblingEventHandler, Int32, } from '../Types/CodegenTypes'; @@ -86,6 +87,14 @@ type NativeProps = $ReadOnly<{| */ onShow?: ?DirectEventHandler, + /** + * The `onDismiss` prop allows passing a function that will be called once + * the modal has been dismissed. + * + * See https://reactnative.dev/docs/modal.html#ondismiss + */ + onDismiss?: ?BubblingEventHandler, + /** * Deprecated. Use the `animationType` prop instead. */ diff --git a/React/Views/RCTModalHostViewManager.m b/React/Views/RCTModalHostViewManager.m index 14c220ba5b90e9..91d83aabbdc604 100644 --- a/React/Views/RCTModalHostViewManager.m +++ b/React/Views/RCTModalHostViewManager.m @@ -10,6 +10,7 @@ #import "RCTBridge.h" #import "RCTModalHostView.h" #import "RCTModalHostViewController.h" +#import "RCTModalManager.h" #import "RCTShadowView.h" #import "RCTUtils.h" @@ -46,8 +47,6 @@ - (void)insertReactSubview:(id)subview atIndex:(NSInteger)atIndex @interface RCTModalHostViewManager () -@property (nonatomic, copy) dispatch_block_t dismissWaitingBlock; - @end @implementation RCTModalHostViewManager { @@ -79,16 +78,9 @@ - (void)presentModalHostView:(RCTModalHostView *)modalHostView if (_presentationBlock) { _presentationBlock([modalHostView reactViewController], viewController, animated, completionBlock); } else { - __weak typeof(self) weakself = self; [[modalHostView reactViewController] presentViewController:viewController animated:animated - completion:^{ - !completionBlock ?: completionBlock(); - __strong typeof(weakself) strongself = weakself; - !strongself.dismissWaitingBlock - ?: strongself.dismissWaitingBlock(); - strongself.dismissWaitingBlock = nil; - }]; + completion:completionBlock]; } } @@ -96,16 +88,15 @@ - (void)dismissModalHostView:(RCTModalHostView *)modalHostView withViewController:(RCTModalHostViewController *)viewController animated:(BOOL)animated { + dispatch_block_t completionBlock = ^{ + if (modalHostView.identifier) { + [[self.bridge moduleForClass:[RCTModalManager class]] modalDismissed:modalHostView.identifier]; + } + }; if (_dismissalBlock) { - _dismissalBlock([modalHostView reactViewController], viewController, animated, nil); + _dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock); } else { - self.dismissWaitingBlock = ^{ - [viewController.presentingViewController dismissViewControllerAnimated:animated completion:nil]; - }; - if (viewController.presentingViewController) { - self.dismissWaitingBlock(); - self.dismissWaitingBlock = nil; - } + [viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock]; } } diff --git a/React/Views/RCTModalManager.h b/React/Views/RCTModalManager.h new file mode 100644 index 00000000000000..4fbe6dfbd01e25 --- /dev/null +++ b/React/Views/RCTModalManager.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import + +#import +#import + +@interface RCTModalManager : RCTEventEmitter + +- (void)modalDismissed:(NSNumber *)modalID; + +@end diff --git a/React/Views/RCTModalManager.m b/React/Views/RCTModalManager.m new file mode 100644 index 00000000000000..992b73c62db660 --- /dev/null +++ b/React/Views/RCTModalManager.m @@ -0,0 +1,42 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTModalManager.h" + +@interface RCTModalManager () + +@property BOOL shouldEmit; + +@end + +@implementation RCTModalManager + +RCT_EXPORT_MODULE(); + +- (NSArray *)supportedEvents +{ + return @[ @"modalDismissed" ]; +} + +- (void)startObserving +{ + _shouldEmit = YES; +} + +- (void)stopObserving +{ + _shouldEmit = NO; +} + +- (void)modalDismissed:(NSNumber *)modalID +{ + if (_shouldEmit) { + [self sendEventWithName:@"modalDismissed" body:@{@"modalID" : modalID}]; + } +} + +@end diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp index 68ba41cdd1c633..ee226666fb4fd6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp @@ -129,6 +129,13 @@ void ModalHostViewEventEmitter::onShow(OnShow event) const { return payload; }); } +void ModalHostViewEventEmitter::onDismiss(OnDismiss event) const { + dispatchEvent("dismiss", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + + return payload; + }); +} void ModalHostViewEventEmitter::onOrientationChange(OnOrientationChange event) const { dispatchEvent("orientationChange", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h index 412c956aad8770..16cc009e715739 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h @@ -196,6 +196,10 @@ class ModalHostViewEventEmitter : public ViewEventEmitter { }; + struct OnDismiss { + + }; + enum class OnOrientationChangeOrientation { Portrait, Landscape @@ -216,6 +220,8 @@ class ModalHostViewEventEmitter : public ViewEventEmitter { void onShow(OnShow value) const; + void onDismiss(OnDismiss value) const; + void onOrientationChange(OnOrientationChange value) const; }; From 26787e2260412d9d2fe831e68a8616505d3cab36 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Sat, 14 Nov 2020 08:56:58 -0800 Subject: [PATCH 0066/1810] Back out "Experiment to replace Fabric MountItem lists with concurrent queues" Summary: Changelog: [Internal] Original commit changeset: fcbdeda51f91 Reviewed By: rubennorte Differential Revision: D24973616 fbshipit-source-id: 4d21211d329c77dba50972a26b1daeccfffad912 --- .../react/config/ReactFeatureFlags.java | 3 - .../react/fabric/FabricUIManager.java | 202 ++++++------------ 2 files changed, 61 insertions(+), 144 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index d972c83330ed70..5a5cfeee2f78ec 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -88,7 +88,4 @@ public class ReactFeatureFlags { /** Potential bugfix for crashes caused by mutating the view hierarchy during onDraw. */ public static boolean enableDrawMutationFix = true; - - /** Use lock-free data structures for Fabric MountItems. */ - public static boolean enableLockFreeMountInstructions = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 05ca95c13f2911..f769f708f43cd0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -89,12 +89,10 @@ import com.facebook.systrace.Systrace; import java.util.ArrayDeque; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; @SuppressLint("MissingNativeLoadLibrary") @@ -126,35 +124,20 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { new ConcurrentHashMap<>(); @NonNull private final EventBeatManager mEventBeatManager; - - private boolean mInDispatch = false; - private int mReDispatchCounter = 0; - - @NonNull - private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); - - // Concurrent MountItem data-structures, experimental. TODO: T79662803 - @NonNull - private final ConcurrentLinkedQueue mViewCommandMountItemsConcurrent = - new ConcurrentLinkedQueue<>(); - - @NonNull - private final ConcurrentLinkedQueue mMountItemsConcurrent = - new ConcurrentLinkedQueue<>(); - - @NonNull - private final ConcurrentLinkedQueue mPreMountItemsConcurrent = - new ConcurrentLinkedQueue<>(); - - // Non-concurrent MountItem data-structures @NonNull private final Object mViewCommandMountItemsLock = new Object(); @NonNull private final Object mMountItemsLock = new Object(); @NonNull private final Object mPreMountItemsLock = new Object(); + private boolean mInDispatch = false; + private int mReDispatchCounter = 0; + @GuardedBy("mViewCommandMountItemsLock") @NonNull private List mViewCommandMountItems = new ArrayList<>(); + @NonNull + private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); + @GuardedBy("mMountItemsLock") @NonNull private List mMountItems = new ArrayList<>(); @@ -356,15 +339,18 @@ private void preallocateView( // possible at teardown, but this race should *never* happen at startup. @Nullable ThemedReactContext context = mReactContextForRootTag.get(rootTag); - addPreAllocateMountItem( - new PreAllocateViewMountItem( - context, - rootTag, - reactTag, - getFabricComponentName(componentName), - props, - (StateWrapper) stateWrapper, - isLayoutable)); + String component = getFabricComponentName(componentName); + synchronized (mPreMountItemsLock) { + mPreMountItems.add( + new PreAllocateViewMountItem( + context, + rootTag, + reactTag, + component, + props, + (StateWrapper) stateWrapper, + isLayoutable)); + } } @DoNotStrip @@ -630,7 +616,9 @@ public void execute(@NonNull MountingManager mountingManager) { // If the reactTag exists, we assume that it might at the end of the next // batch of MountItems. Otherwise, we try to execute immediately. if (!mMountingManager.getViewExists(reactTag)) { - addMountItem(synchronousMountItem); + synchronized (mMountItemsLock) { + mMountItems.add(synchronousMountItem); + } return; } @@ -704,7 +692,9 @@ private void scheduleMountItem( } if (shouldSchedule && mountItem != null) { - addMountItem(mountItem); + synchronized (mMountItemsLock) { + mMountItems.add(mountItem); + } if (UiThreadUtil.isOnUiThread()) { // We only read these flags on the UI thread. tryDispatchMountItems(); @@ -787,28 +777,9 @@ private void tryDispatchMountItems() { mLastExecutedMountItemSurfaceId = -1; } - @Nullable - private List drainConcurrentItemQueue(ConcurrentLinkedQueue queue) { - List result = new ArrayList<>(); - while (!queue.isEmpty()) { - E item = queue.poll(); - if (item != null) { - result.add(item); - } - } - if (result.size() == 0) { - return null; - } - return result; - } - @UiThread @ThreadConfined(UI) private List getAndResetViewCommandMountItems() { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - return drainConcurrentItemQueue(mViewCommandMountItemsConcurrent); - } - synchronized (mViewCommandMountItemsLock) { List result = mViewCommandMountItems; if (result.isEmpty()) { @@ -822,10 +793,6 @@ private List getAndResetViewCommandMountItems() { @UiThread @ThreadConfined(UI) private List getAndResetMountItems() { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - return drainConcurrentItemQueue(mMountItemsConcurrent); - } - synchronized (mMountItemsLock) { List result = mMountItems; if (result.isEmpty()) { @@ -836,11 +803,7 @@ private List getAndResetMountItems() { } } - private Collection getAndResetPreMountItems() { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - return drainConcurrentItemQueue(mPreMountItemsConcurrent); - } - + private ArrayDeque getAndResetPreMountItems() { synchronized (mPreMountItemsLock) { ArrayDeque result = mPreMountItems; if (result.isEmpty()) { @@ -963,18 +926,19 @@ private boolean dispatchMountItems() { // If there are MountItems to dispatch, we make sure all the "pre mount items" are executed // first - Collection preMountItemsToDispatch = getAndResetPreMountItems(); + ArrayDeque mPreMountItemsToDispatch = getAndResetPreMountItems(); - if (preMountItemsToDispatch != null) { + if (mPreMountItemsToDispatch != null) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManager::mountViews preMountItems to execute: " - + preMountItemsToDispatch.size()); + + mPreMountItemsToDispatch.size()); - for (PreAllocateViewMountItem preMountItem : preMountItemsToDispatch) { + while (!mPreMountItemsToDispatch.isEmpty()) { + PreAllocateViewMountItem mountItem = mPreMountItemsToDispatch.pollFirst(); if (surfaceActiveForExecution( - preMountItem.getRootTag(), "dispatchMountItems PreAllocateViewMountItem")) { - preMountItem.execute(mMountingManager); + mountItem.getRootTag(), "dispatchMountItems PreAllocateViewMountItem")) { + mountItem.execute(mMountingManager); } } @@ -1052,19 +1016,12 @@ private void dispatchPreMountItems(long frameTimeNanos) { break; } - PreAllocateViewMountItem preMountItemToDispatch = null; - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - preMountItemToDispatch = mPreMountItemsConcurrent.poll(); - } else { - synchronized (mPreMountItemsLock) { - if (!mPreMountItems.isEmpty()) { - preMountItemToDispatch = mPreMountItems.pollFirst(); - } + PreAllocateViewMountItem preMountItemToDispatch; + synchronized (mPreMountItemsLock) { + if (mPreMountItems.isEmpty()) { + break; } - } - // If list is empty, `poll` will return null, or var will never be set - if (preMountItemToDispatch == null) { - break; + preMountItemToDispatch = mPreMountItems.pollFirst(); } if (surfaceActiveForExecution( @@ -1175,14 +1132,18 @@ public void dispatchCommand( @AnyThread @ThreadConfined(ANY) private void dispatchCommandMountItem(DispatchCommandMountItem command) { - addViewCommandMountItem(command); + synchronized (mViewCommandMountItemsLock) { + mViewCommandMountItems.add(command); + } } @Override @AnyThread @ThreadConfined(ANY) public void sendAccessibilityEvent(int reactTag, int eventType) { - addMountItem(new SendAccessibilityEvent(reactTag, eventType)); + synchronized (mMountItemsLock) { + mMountItems.add(new SendAccessibilityEvent(reactTag, eventType)); + } } /** @@ -1195,13 +1156,15 @@ public void sendAccessibilityEvent(int reactTag, int eventType) { @DoNotStrip public void setJSResponder( final int reactTag, final int initialReactTag, final boolean blockNativeResponder) { - addMountItem( - new MountItem() { - @Override - public void execute(MountingManager mountingManager) { - mountingManager.setJSResponder(reactTag, initialReactTag, blockNativeResponder); - } - }); + synchronized (mMountItemsLock) { + mMountItems.add( + new MountItem() { + @Override + public void execute(MountingManager mountingManager) { + mountingManager.setJSResponder(reactTag, initialReactTag, blockNativeResponder); + } + }); + } } /** @@ -1210,13 +1173,15 @@ public void execute(MountingManager mountingManager) { */ @DoNotStrip public void clearJSResponder() { - addMountItem( - new MountItem() { - @Override - public void execute(MountingManager mountingManager) { - mountingManager.clearJSResponder(); - } - }); + synchronized (mMountItemsLock) { + mMountItems.add( + new MountItem() { + @Override + public void execute(MountingManager mountingManager) { + mountingManager.clearJSResponder(); + } + }); + } } @Override @@ -1264,51 +1229,6 @@ public Map getPerformanceCounters() { return performanceCounters; } - /** - * Abstraction between concurrent and non-concurrent MountItem list. - * - * @param mountItem - */ - private void addMountItem(MountItem mountItem) { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - mMountItemsConcurrent.add(mountItem); - } else { - synchronized (mMountItemsLock) { - mMountItems.add(mountItem); - } - } - } - - /** - * Abstraction between concurrent and non-concurrent PreAllocateViewMountItem list. - * - * @param mountItem - */ - private void addPreAllocateMountItem(PreAllocateViewMountItem mountItem) { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - mPreMountItemsConcurrent.add(mountItem); - } else { - synchronized (mPreMountItemsLock) { - mPreMountItemsConcurrent.add(mountItem); - } - } - } - - /** - * Abstraction between concurrent and non-concurrent DispatchCommandMountItem list. - * - * @param mountItem - */ - private void addViewCommandMountItem(DispatchCommandMountItem mountItem) { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - mViewCommandMountItemsConcurrent.add(mountItem); - } else { - synchronized (mViewCommandMountItemsLock) { - mViewCommandMountItems.add(mountItem); - } - } - } - private class DispatchUIFrameCallback extends GuardedFrameCallback { private volatile boolean mIsMountingEnabled = true; From 752e7ab1f9b787090abdc2f1b0debe0113efd04d Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Sat, 14 Nov 2020 12:18:05 -0800 Subject: [PATCH 0067/1810] Experiment to replace Fabric MountItem lists with concurrent queues (re-land) Summary: Currently, queuing any sort of MountItem or getting the list of MountItems requires synchronization. Since these can be queued up at any point from the JS thread, there will, in theory, be constant contention between JS and UI thread. To see if this is true, I'm creating an experiment instead of just switching over to concurrent structures. After seeing results, we can hopefully make a decision and delete the non-concurrent stuff or improve on it somehow. The original was unlanded in D24973616 (https://github.com/facebook/react-native/commit/26787e2260412d9d2fe831e68a8616505d3cab36) due to a typo, which has been fixed now. The typo was that in Blocking Mode, we queued up all PreMountItems to the concurrent PreMountItems queue. Changelog: [Internal] Reviewed By: ShikaSD Differential Revision: D24974851 fbshipit-source-id: d081c081bbd0de445bb92408f0ec822056b905a5 --- .../react/config/ReactFeatureFlags.java | 3 + .../react/fabric/FabricUIManager.java | 202 ++++++++++++------ 2 files changed, 144 insertions(+), 61 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 5a5cfeee2f78ec..d972c83330ed70 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -88,4 +88,7 @@ public class ReactFeatureFlags { /** Potential bugfix for crashes caused by mutating the view hierarchy during onDraw. */ public static boolean enableDrawMutationFix = true; + + /** Use lock-free data structures for Fabric MountItems. */ + public static boolean enableLockFreeMountInstructions = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index f769f708f43cd0..76ab25a54633dc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -89,10 +89,12 @@ import com.facebook.systrace.Systrace; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; @SuppressLint("MissingNativeLoadLibrary") @@ -124,19 +126,34 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { new ConcurrentHashMap<>(); @NonNull private final EventBeatManager mEventBeatManager; - @NonNull private final Object mViewCommandMountItemsLock = new Object(); - @NonNull private final Object mMountItemsLock = new Object(); - @NonNull private final Object mPreMountItemsLock = new Object(); private boolean mInDispatch = false; private int mReDispatchCounter = 0; - @GuardedBy("mViewCommandMountItemsLock") @NonNull - private List mViewCommandMountItems = new ArrayList<>(); + private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); + // Concurrent MountItem data-structures, experimental. TODO: T79662803 @NonNull - private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); + private final ConcurrentLinkedQueue mViewCommandMountItemsConcurrent = + new ConcurrentLinkedQueue<>(); + + @NonNull + private final ConcurrentLinkedQueue mMountItemsConcurrent = + new ConcurrentLinkedQueue<>(); + + @NonNull + private final ConcurrentLinkedQueue mPreMountItemsConcurrent = + new ConcurrentLinkedQueue<>(); + + // Non-concurrent MountItem data-structures + @NonNull private final Object mViewCommandMountItemsLock = new Object(); + @NonNull private final Object mMountItemsLock = new Object(); + @NonNull private final Object mPreMountItemsLock = new Object(); + + @GuardedBy("mViewCommandMountItemsLock") + @NonNull + private List mViewCommandMountItems = new ArrayList<>(); @GuardedBy("mMountItemsLock") @NonNull @@ -339,18 +356,15 @@ private void preallocateView( // possible at teardown, but this race should *never* happen at startup. @Nullable ThemedReactContext context = mReactContextForRootTag.get(rootTag); - String component = getFabricComponentName(componentName); - synchronized (mPreMountItemsLock) { - mPreMountItems.add( - new PreAllocateViewMountItem( - context, - rootTag, - reactTag, - component, - props, - (StateWrapper) stateWrapper, - isLayoutable)); - } + addPreAllocateMountItem( + new PreAllocateViewMountItem( + context, + rootTag, + reactTag, + getFabricComponentName(componentName), + props, + (StateWrapper) stateWrapper, + isLayoutable)); } @DoNotStrip @@ -616,9 +630,7 @@ public void execute(@NonNull MountingManager mountingManager) { // If the reactTag exists, we assume that it might at the end of the next // batch of MountItems. Otherwise, we try to execute immediately. if (!mMountingManager.getViewExists(reactTag)) { - synchronized (mMountItemsLock) { - mMountItems.add(synchronousMountItem); - } + addMountItem(synchronousMountItem); return; } @@ -692,9 +704,7 @@ private void scheduleMountItem( } if (shouldSchedule && mountItem != null) { - synchronized (mMountItemsLock) { - mMountItems.add(mountItem); - } + addMountItem(mountItem); if (UiThreadUtil.isOnUiThread()) { // We only read these flags on the UI thread. tryDispatchMountItems(); @@ -777,9 +787,28 @@ private void tryDispatchMountItems() { mLastExecutedMountItemSurfaceId = -1; } + @Nullable + private List drainConcurrentItemQueue(ConcurrentLinkedQueue queue) { + List result = new ArrayList<>(); + while (!queue.isEmpty()) { + E item = queue.poll(); + if (item != null) { + result.add(item); + } + } + if (result.size() == 0) { + return null; + } + return result; + } + @UiThread @ThreadConfined(UI) private List getAndResetViewCommandMountItems() { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + return drainConcurrentItemQueue(mViewCommandMountItemsConcurrent); + } + synchronized (mViewCommandMountItemsLock) { List result = mViewCommandMountItems; if (result.isEmpty()) { @@ -793,6 +822,10 @@ private List getAndResetViewCommandMountItems() { @UiThread @ThreadConfined(UI) private List getAndResetMountItems() { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + return drainConcurrentItemQueue(mMountItemsConcurrent); + } + synchronized (mMountItemsLock) { List result = mMountItems; if (result.isEmpty()) { @@ -803,7 +836,11 @@ private List getAndResetMountItems() { } } - private ArrayDeque getAndResetPreMountItems() { + private Collection getAndResetPreMountItems() { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + return drainConcurrentItemQueue(mPreMountItemsConcurrent); + } + synchronized (mPreMountItemsLock) { ArrayDeque result = mPreMountItems; if (result.isEmpty()) { @@ -926,19 +963,18 @@ private boolean dispatchMountItems() { // If there are MountItems to dispatch, we make sure all the "pre mount items" are executed // first - ArrayDeque mPreMountItemsToDispatch = getAndResetPreMountItems(); + Collection preMountItemsToDispatch = getAndResetPreMountItems(); - if (mPreMountItemsToDispatch != null) { + if (preMountItemsToDispatch != null) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManager::mountViews preMountItems to execute: " - + mPreMountItemsToDispatch.size()); + + preMountItemsToDispatch.size()); - while (!mPreMountItemsToDispatch.isEmpty()) { - PreAllocateViewMountItem mountItem = mPreMountItemsToDispatch.pollFirst(); + for (PreAllocateViewMountItem preMountItem : preMountItemsToDispatch) { if (surfaceActiveForExecution( - mountItem.getRootTag(), "dispatchMountItems PreAllocateViewMountItem")) { - mountItem.execute(mMountingManager); + preMountItem.getRootTag(), "dispatchMountItems PreAllocateViewMountItem")) { + preMountItem.execute(mMountingManager); } } @@ -1016,12 +1052,19 @@ private void dispatchPreMountItems(long frameTimeNanos) { break; } - PreAllocateViewMountItem preMountItemToDispatch; - synchronized (mPreMountItemsLock) { - if (mPreMountItems.isEmpty()) { - break; + PreAllocateViewMountItem preMountItemToDispatch = null; + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + preMountItemToDispatch = mPreMountItemsConcurrent.poll(); + } else { + synchronized (mPreMountItemsLock) { + if (!mPreMountItems.isEmpty()) { + preMountItemToDispatch = mPreMountItems.pollFirst(); + } } - preMountItemToDispatch = mPreMountItems.pollFirst(); + } + // If list is empty, `poll` will return null, or var will never be set + if (preMountItemToDispatch == null) { + break; } if (surfaceActiveForExecution( @@ -1132,18 +1175,14 @@ public void dispatchCommand( @AnyThread @ThreadConfined(ANY) private void dispatchCommandMountItem(DispatchCommandMountItem command) { - synchronized (mViewCommandMountItemsLock) { - mViewCommandMountItems.add(command); - } + addViewCommandMountItem(command); } @Override @AnyThread @ThreadConfined(ANY) public void sendAccessibilityEvent(int reactTag, int eventType) { - synchronized (mMountItemsLock) { - mMountItems.add(new SendAccessibilityEvent(reactTag, eventType)); - } + addMountItem(new SendAccessibilityEvent(reactTag, eventType)); } /** @@ -1156,15 +1195,13 @@ public void sendAccessibilityEvent(int reactTag, int eventType) { @DoNotStrip public void setJSResponder( final int reactTag, final int initialReactTag, final boolean blockNativeResponder) { - synchronized (mMountItemsLock) { - mMountItems.add( - new MountItem() { - @Override - public void execute(MountingManager mountingManager) { - mountingManager.setJSResponder(reactTag, initialReactTag, blockNativeResponder); - } - }); - } + addMountItem( + new MountItem() { + @Override + public void execute(MountingManager mountingManager) { + mountingManager.setJSResponder(reactTag, initialReactTag, blockNativeResponder); + } + }); } /** @@ -1173,15 +1210,13 @@ public void execute(MountingManager mountingManager) { */ @DoNotStrip public void clearJSResponder() { - synchronized (mMountItemsLock) { - mMountItems.add( - new MountItem() { - @Override - public void execute(MountingManager mountingManager) { - mountingManager.clearJSResponder(); - } - }); - } + addMountItem( + new MountItem() { + @Override + public void execute(MountingManager mountingManager) { + mountingManager.clearJSResponder(); + } + }); } @Override @@ -1229,6 +1264,51 @@ public Map getPerformanceCounters() { return performanceCounters; } + /** + * Abstraction between concurrent and non-concurrent MountItem list. + * + * @param mountItem + */ + private void addMountItem(MountItem mountItem) { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + mMountItemsConcurrent.add(mountItem); + } else { + synchronized (mMountItemsLock) { + mMountItems.add(mountItem); + } + } + } + + /** + * Abstraction between concurrent and non-concurrent PreAllocateViewMountItem list. + * + * @param mountItem + */ + private void addPreAllocateMountItem(PreAllocateViewMountItem mountItem) { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + mPreMountItemsConcurrent.add(mountItem); + } else { + synchronized (mPreMountItemsLock) { + mPreMountItems.add(mountItem); + } + } + } + + /** + * Abstraction between concurrent and non-concurrent DispatchCommandMountItem list. + * + * @param mountItem + */ + private void addViewCommandMountItem(DispatchCommandMountItem mountItem) { + if (ReactFeatureFlags.enableLockFreeMountInstructions) { + mViewCommandMountItemsConcurrent.add(mountItem); + } else { + synchronized (mViewCommandMountItemsLock) { + mViewCommandMountItems.add(mountItem); + } + } + } + private class DispatchUIFrameCallback extends GuardedFrameCallback { private volatile boolean mIsMountingEnabled = true; From f1f716879561e308fe3bc2433ea7498365a1758b Mon Sep 17 00:00:00 2001 From: Marshall Roch Date: Mon, 16 Nov 2020 12:17:09 -0800 Subject: [PATCH 0068/1810] Deploy Flow v0.138.0 Summary: Changelog: [Internal] Reviewed By: dsainati1 Differential Revision: D24993067 fbshipit-source-id: ef2ffb61269be49afa970283a7ccef0b4475898a --- .flowconfig | 2 +- .flowconfig.android | 2 +- package.json | 2 +- repo-config/package.json | 2 +- template/_flowconfig | 2 +- yarn.lock | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.flowconfig b/.flowconfig index 7e5fe8843a4010..5e535932747a97 100644 --- a/.flowconfig +++ b/.flowconfig @@ -70,4 +70,4 @@ untyped-import untyped-type-import [version] -^0.137.0 +^0.138.0 diff --git a/.flowconfig.android b/.flowconfig.android index 6f1179f22aebcf..d3c2296a9e69c6 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -70,4 +70,4 @@ untyped-import untyped-type-import [version] -^0.137.0 +^0.138.0 diff --git a/package.json b/package.json index 53f4cc10e9333e..5106b2bddb4f27 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "ws": "^6.1.4" }, "devDependencies": { - "flow-bin": "^0.137.0", + "flow-bin": "^0.138.0", "react": "17.0.1" }, "detox": { diff --git a/repo-config/package.json b/repo-config/package.json index f1da3a5d82d8a9..a1f4346e3ee58f 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -33,7 +33,7 @@ "eslint-plugin-react-hooks": "^4.0.7", "eslint-plugin-react-native": "3.8.1", "eslint-plugin-relay": "1.8.1", - "flow-bin": "^0.137.0", + "flow-bin": "^0.138.0", "jest": "^26.5.2", "jest-junit": "^10.0.0", "jscodeshift": "^0.11.0", diff --git a/template/_flowconfig b/template/_flowconfig index 315f2747bad5fe..9fb685f67a5972 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -63,4 +63,4 @@ untyped-import untyped-type-import [version] -^0.137.0 +^0.138.0 diff --git a/yarn.lock b/yarn.lock index fb9fe1dbf7717a..49bdff9a976e14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3101,10 +3101,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -flow-bin@^0.137.0: - version "0.137.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.137.0.tgz#322a15b3744195af1e02bf1fec0a716296aee7d5" - integrity sha512-ytwUn68fPKK/VWVpCxJ4KNeNIjCC/uX0Ll6Z1E98sOXfMknB000WtgQjKYDdO6tOR8mvXBE0adzjgCrChVympw== +flow-bin@^0.138.0: + version "0.138.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.138.0.tgz#a0c81a3dd1ed34771b33b7e91078ed260301aa17" + integrity sha512-y3twwNeN0FWEK0vvJo/5SiC/OQVlhubGRyOPIS6p49b2yiiWE/cBFG/aC9kFXFfh7Orewe5O5B2X0+IiEOCYIw== flow-parser@0.*, flow-parser@^0.121.0: version "0.121.0" From 0937f13cc32a87e7db52dbcd1d5d35a53e51e8c2 Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Mon, 16 Nov 2020 12:36:14 -0800 Subject: [PATCH 0069/1810] Do not log image if it fails lifecycle assert in getWillRequestUrlTime Reviewed By: sammy-SC Differential Revision: D24990452 fbshipit-source-id: ce4d5ec9e3cf237c6edbd17368f2dcf3aecbec2b --- .../renderer/imagemanager/ImageTelemetry.cpp | 6 ------ .../react/renderer/imagemanager/ImageTelemetry.h | 15 +++++---------- .../imagemanager/platform/ios/RCTImageManager.mm | 1 - 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp index 43a6134495ecdb..40524e5b0ff0f6 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp +++ b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp @@ -10,17 +10,11 @@ namespace facebook { namespace react { -void ImageTelemetry::willRequestUrl() { - assert(willRequestUrlTime_ == kTelemetryUndefinedTimePoint); - willRequestUrlTime_ = telemetryTimePointNow(); -} - SurfaceId ImageTelemetry::getSurfaceId() const { return surfaceId_; } TelemetryTimePoint ImageTelemetry::getWillRequestUrlTime() const { - assert(willRequestUrlTime_ != kTelemetryUndefinedTimePoint); return willRequestUrlTime_; } diff --git a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h index 3f053dbcf3ea1a..1ffaffd0a4aa0c 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h +++ b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h @@ -15,25 +15,20 @@ namespace react { /* * Represents telemetry data associated with a image request + * where the willRequestUrlTime is the time at ImageTelemetry's creation. */ class ImageTelemetry final { public: - ImageTelemetry(SurfaceId const surfaceId) : surfaceId_(surfaceId) {} + ImageTelemetry(SurfaceId const surfaceId) : surfaceId_(surfaceId) { + willRequestUrlTime_ = telemetryTimePointNow(); + } - /* - * Signaling - */ - void willRequestUrl(); - - /* - * Reading - */ TelemetryTimePoint getWillRequestUrlTime() const; SurfaceId getSurfaceId() const; private: - TelemetryTimePoint willRequestUrlTime_{kTelemetryUndefinedTimePoint}; + TelemetryTimePoint willRequestUrlTime_; const SurfaceId surfaceId_; }; diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm index 3fa8c36b291746..4922b96ef03d3f 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm @@ -44,7 +44,6 @@ - (ImageRequest)requestImage:(ImageSource)imageSource surfaceId:(SurfaceId)surfa std::shared_ptr telemetry; if ([self->_imageLoader shouldEnablePerfLoggingForRequestUrl:request.URL]) { telemetry = std::make_shared(surfaceId); - telemetry->willRequestUrl(); } else { telemetry = nullptr; } From bbd0f03481c23b295797abd1089d5688b0d22bb9 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 16 Nov 2020 12:38:28 -0800 Subject: [PATCH 0070/1810] Removing pre-API 21 code Summary: We don't support pre-API 21/Android <5/pre-Lollipop anymore; delete related code or checks. No need for this to make it to the changelog, this announcement was already made. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D24965249 fbshipit-source-id: e537e62e8eb18878c29afe17b8c7861d095a37b7 --- .../views/text/ReactBaseTextShadowNode.java | 15 ++++++--------- .../react/views/text/TextLayoutManager.java | 10 ++++------ .../react/views/textinput/ReactEditText.java | 18 +++++++----------- .../react/views/view/ReactDrawableHelper.java | 6 +----- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index 6835918b587d54..f685bf567b2455 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -178,15 +178,12 @@ private static void buildSpannedFromShadowNode( new SetSpanOperation( start, end, new ReactBackgroundColorSpan(textShadowNode.mBackgroundColor))); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - float effectiveLetterSpacing = textAttributes.getEffectiveLetterSpacing(); - if (!Float.isNaN(effectiveLetterSpacing) - && (parentTextAttributes == null - || parentTextAttributes.getEffectiveLetterSpacing() != effectiveLetterSpacing)) { - ops.add( - new SetSpanOperation( - start, end, new CustomLetterSpacingSpan(effectiveLetterSpacing))); - } + float effectiveLetterSpacing = textAttributes.getEffectiveLetterSpacing(); + if (!Float.isNaN(effectiveLetterSpacing) + && (parentTextAttributes == null + || parentTextAttributes.getEffectiveLetterSpacing() != effectiveLetterSpacing)) { + ops.add( + new SetSpanOperation(start, end, new CustomLetterSpacingSpan(effectiveLetterSpacing))); } int effectiveFontSize = textAttributes.getEffectiveFontSize(); if ( // `getEffectiveFontSize` always returns a value so don't need to check for anything like diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 3b10c2c7d1c402..a322eaa7ad48ac 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -139,12 +139,10 @@ private static void buildSpannableFromFragment( new SetSpanOperation( start, end, new ReactBackgroundColorSpan(textAttributes.mBackgroundColor))); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (!Float.isNaN(textAttributes.getLetterSpacing())) { - ops.add( - new SetSpanOperation( - start, end, new CustomLetterSpacingSpan(textAttributes.getLetterSpacing()))); - } + if (!Float.isNaN(textAttributes.getLetterSpacing())) { + ops.add( + new SetSpanOperation( + start, end, new CustomLetterSpacingSpan(textAttributes.getLetterSpacing()))); } ops.add( new SetSpanOperation(start, end, new ReactAbsoluteSizeSpan(textAttributes.mFontSize))); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 058e154849dfce..f908681034f679 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -654,12 +654,10 @@ private void addSpansForMeasurement(Spannable spannable) { List ops = new ArrayList<>(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (!Float.isNaN(mTextAttributes.getLetterSpacing())) { - ops.add( - new TextLayoutManager.SetSpanOperation( - start, end, new CustomLetterSpacingSpan(mTextAttributes.getLetterSpacing()))); - } + if (!Float.isNaN(mTextAttributes.getLetterSpacing())) { + ops.add( + new TextLayoutManager.SetSpanOperation( + start, end, new CustomLetterSpacingSpan(mTextAttributes.getLetterSpacing()))); } ops.add( new TextLayoutManager.SetSpanOperation( @@ -947,11 +945,9 @@ protected void applyTextAttributes() { // `Float.NaN`. setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextAttributes.getEffectiveFontSize()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - float effectiveLetterSpacing = mTextAttributes.getEffectiveLetterSpacing(); - if (!Float.isNaN(effectiveLetterSpacing)) { - setLetterSpacing(effectiveLetterSpacing); - } + float effectiveLetterSpacing = mTextAttributes.getEffectiveLetterSpacing(); + if (!Float.isNaN(effectiveLetterSpacing)) { + setLetterSpacing(effectiveLetterSpacing); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java index 8f5f8267330932..b4a3feb9418c86 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java @@ -65,11 +65,7 @@ private static int getAttrId(Context context, String attr) { } private static Drawable getDefaultThemeDrawable(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return context.getResources().getDrawable(sResolveOutValue.resourceId, context.getTheme()); - } else { - return context.getResources().getDrawable(sResolveOutValue.resourceId); - } + return context.getResources().getDrawable(sResolveOutValue.resourceId, context.getTheme()); } private static RippleDrawable getRippleDrawable( From 68a476103a95be77f4fc7c582e52cc94946de1b4 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 16 Nov 2020 13:09:57 -0800 Subject: [PATCH 0071/1810] Name a bunch of anonymous RN contexts Summary: Changelog: [General] [Changed] - Added (DEV-only) `displayName` to some RN contexts to make them more easy to differentiate when debugging. Reviewed By: lunaleaps Differential Revision: D24993068 fbshipit-source-id: 4904259eda50444c2f74700a3540ff4fd02ac322 --- Libraries/Components/ScrollView/ScrollViewContext.js | 4 +++- Libraries/Image/ImageAnalyticsTagContext.js | 4 ++++ Libraries/Lists/VirtualizedListContext.js | 3 +++ Libraries/ReactNative/RootTag.js | 4 ++++ Libraries/Text/TextAncestor.js | 8 +++++++- Libraries/Utilities/PerformanceLoggerContext.js | 3 +++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollViewContext.js b/Libraries/Components/ScrollView/ScrollViewContext.js index f774483912d928..894d7f0a56555d 100644 --- a/Libraries/Components/ScrollView/ScrollViewContext.js +++ b/Libraries/Components/ScrollView/ScrollViewContext.js @@ -15,7 +15,9 @@ import * as React from 'react'; type Value = {horizontal: boolean} | null; const ScrollViewContext: React.Context = React.createContext(null); - +if (__DEV__) { + ScrollViewContext.displayName = 'ScrollViewContext'; +} export default ScrollViewContext; export const HORIZONTAL: Value = Object.freeze({horizontal: true}); diff --git a/Libraries/Image/ImageAnalyticsTagContext.js b/Libraries/Image/ImageAnalyticsTagContext.js index ea458bf0c28043..540ae6c02db72d 100644 --- a/Libraries/Image/ImageAnalyticsTagContext.js +++ b/Libraries/Image/ImageAnalyticsTagContext.js @@ -18,4 +18,8 @@ const Context: React.Context = React.createContext( null, ); +if (__DEV__) { + Context.displayName = 'ImageAnalyticsTagContext'; +} + export default Context; diff --git a/Libraries/Lists/VirtualizedListContext.js b/Libraries/Lists/VirtualizedListContext.js index 130315a1b08d57..eddb578ed714c1 100644 --- a/Libraries/Lists/VirtualizedListContext.js +++ b/Libraries/Lists/VirtualizedListContext.js @@ -69,6 +69,9 @@ type Context = $ReadOnly<{ export const VirtualizedListContext: React.Context = React.createContext( null, ); +if (__DEV__) { + VirtualizedListContext.displayName = 'VirtualizedListContext'; +} /** * Resets the context. Intended for use by portal-like components (e.g. Modal). diff --git a/Libraries/ReactNative/RootTag.js b/Libraries/ReactNative/RootTag.js index 24b151544d43b2..e36cafd5744e33 100644 --- a/Libraries/ReactNative/RootTag.js +++ b/Libraries/ReactNative/RootTag.js @@ -19,6 +19,10 @@ export const RootTagContext: React$Context = React.createContext element. */ -module.exports = (React.createContext(false): React$Context<$FlowFixMe>); +const TextAncestorContext = (React.createContext( + false, +): React$Context<$FlowFixMe>); +if (__DEV__) { + TextAncestorContext.displayName = 'TextAncestorContext'; +} +module.exports = TextAncestorContext; diff --git a/Libraries/Utilities/PerformanceLoggerContext.js b/Libraries/Utilities/PerformanceLoggerContext.js index 5bc3560f0fe1b9..e32f6c249e731b 100644 --- a/Libraries/Utilities/PerformanceLoggerContext.js +++ b/Libraries/Utilities/PerformanceLoggerContext.js @@ -23,4 +23,7 @@ import type {IPerformanceLogger} from './createPerformanceLogger'; const PerformanceLoggerContext: React.Context = React.createContext( GlobalPerformanceLogger, ); +if (__DEV__) { + PerformanceLoggerContext.displayName = 'PerformanceLoggerContext'; +} module.exports = PerformanceLoggerContext; From 27cf82074daa8f1f8e0584cc0492dddeaf7b85aa Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 17 Nov 2020 00:32:01 -0800 Subject: [PATCH 0072/1810] Guard against initializer interruptions in {Catalyst,Work,RNTester}TurboModuleManagerDelegate Summary: Migrate over to [how we load so libraries in Fb4aTurboModuleManagerDelegate](https://fburl.com/diffusion/wu0mcr8o). ## Motivation When we migrated Twilight over to TurboModules, we used the CatalystTurboModuleManager as a template. This led to a production crash (T70918829) because we weren't loading so's this way. The fix: D24894071. I'm updating these two TMMDelegates so that people don't fall into the same trap when migrating other Standalone apps. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D24992931 fbshipit-source-id: 3ac3b8c30a67e24f79021f915abf5ae980d5b5d3 --- .../RNTesterTurboModuleManagerDelegate.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterTurboModuleManagerDelegate.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterTurboModuleManagerDelegate.java index 0baf04bc1d7da5..95c2b6b93fc616 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterTurboModuleManagerDelegate.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterTurboModuleManagerDelegate.java @@ -17,9 +17,7 @@ /** This class is responsible for creating all the TurboModules for the RNTester app. */ public class RNTesterTurboModuleManagerDelegate extends ReactPackageTurboModuleManagerDelegate { - static { - SoLoader.loadLibrary("rntester_appmodules"); - } + private static volatile boolean sIsSoLibraryLoaded; protected native HybridData initHybrid(); @@ -30,4 +28,17 @@ public RNTesterTurboModuleManagerDelegate( ReactApplicationContext context, List packages) { super(context, packages); } + + @Override + protected void maybeLoadOtherSoLibraries() { + maybeLoadSoLibraries(); + } + + // Prevents issues with initializer interruptions. + private static synchronized void maybeLoadSoLibraries() { + if (!sIsSoLibraryLoaded) { + SoLoader.loadLibrary("rntester_appmodules"); + sIsSoLibraryLoaded = true; + } + } } From 2669118fc87ee3dd1b109cccec9944b3e67ed61c Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 17 Nov 2020 04:19:13 -0800 Subject: [PATCH 0073/1810] Make event coalescing more aggressive Summary: Changelog: [internal] Previous implementation of coalescing would only look at the last element in `eventQueue_` and if it was the same type and target, it would coalesce the two together. This was problem when user would scroll in UIScrollView, this triggers onTouchMove and onScroll events at high rates and prevents coalescing of them. This changes changes the behaviour to search the `eventQueue_` backwards for an event of the same type and target. If one if found, it is moved into its place. If even of another type is found before for the same target, the event is pushed back onto the queue. Reviewed By: JoshuaGross Differential Revision: D24992941 fbshipit-source-id: fc1eae4ecd100af6202346674778b0634ed7a15b --- .../react/renderer/core/BatchedEventQueue.cpp | 50 +++++++++++++++---- .../react/renderer/core/BatchedEventQueue.h | 13 +++-- .../react/renderer/core/EventDispatcher.cpp | 9 ++-- .../react/renderer/core/EventDispatcher.h | 3 +- .../react/renderer/scheduler/Scheduler.cpp | 3 +- 5 files changed, 61 insertions(+), 17 deletions(-) diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp index d8acdd6112b4c1..055e9c59ec41f5 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp @@ -6,29 +6,61 @@ */ #include "BatchedEventQueue.h" -#include namespace facebook { namespace react { +BatchedEventQueue::BatchedEventQueue( + EventPipe eventPipe, + StatePipe statePipe, + std::unique_ptr eventBeat, + bool enableV2EventCoalescing) + : EventQueue(eventPipe, statePipe, std::move(eventBeat)), + enableV2EventCoalescing_(enableV2EventCoalescing) {} + void BatchedEventQueue::onEnqueue() const { EventQueue::onEnqueue(); eventBeat_->request(); } -void BatchedEventQueue::enqueueUniqueEvent(const RawEvent &rawEvent) const { +void BatchedEventQueue::enqueueUniqueEvent(RawEvent const &rawEvent) const { { std::lock_guard lock(queueMutex_); - if (!eventQueue_.empty()) { - auto const position = eventQueue_.back(); - if (position.type == rawEvent.type && - position.eventTarget == rawEvent.eventTarget) { - eventQueue_.pop_back(); + + if (enableV2EventCoalescing_) { + auto repeatedEvent = eventQueue_.rend(); + + for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) { + if (it->type == rawEvent.type && + it->eventTarget == rawEvent.eventTarget) { + repeatedEvent = it; + break; + } else if (it->eventTarget == rawEvent.eventTarget) { + // It is necessary to maintain order of different event types + // for the same target. If the same target has event types A1, B1 + // in the event queue and event A2 occurs. A1 has to stay in the + // queue. + break; + } } - } - eventQueue_.push_back(rawEvent); + if (repeatedEvent == eventQueue_.rend()) { + eventQueue_.push_back(rawEvent); + } else { + *repeatedEvent = std::move(rawEvent); + } + } else { + if (!eventQueue_.empty()) { + auto const position = eventQueue_.back(); + if (position.type == rawEvent.type && + position.eventTarget == rawEvent.eventTarget) { + eventQueue_.pop_back(); + } + } + + eventQueue_.push_back(rawEvent); + } } onEnqueue(); diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.h b/ReactCommon/react/renderer/core/BatchedEventQueue.h index 2acabd8600b746..85f7c8bca45951 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.h +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.h @@ -18,16 +18,23 @@ namespace react { */ class BatchedEventQueue final : public EventQueue { public: - using EventQueue::EventQueue; + BatchedEventQueue( + EventPipe eventPipe, + StatePipe statePipe, + std::unique_ptr eventBeat, + bool enableV2EventCoalescing); void onEnqueue() const override; /* - * Enqueues and (probably later) dispatch a given event. - * Deletes last RawEvent from the queu if it has the same type and target. + * Enqueues and (probably later) dispatches a given event. + * Deletes last RawEvent from the queue if it has the same type and target. * Can be called on any thread. */ void enqueueUniqueEvent(const RawEvent &rawEvent) const; + + private: + bool const enableV2EventCoalescing_; }; } // namespace react diff --git a/ReactCommon/react/renderer/core/EventDispatcher.cpp b/ReactCommon/react/renderer/core/EventDispatcher.cpp index 8ece2ab3a07aff..75d04608287142 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -21,7 +21,8 @@ EventDispatcher::EventDispatcher( StatePipe const &statePipe, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, - EventBeat::SharedOwnerBox const &ownerBox) + EventBeat::SharedOwnerBox const &ownerBox, + bool enableV2EventCoalescing) : synchronousUnbatchedQueue_(std::make_unique( eventPipe, statePipe, @@ -29,7 +30,8 @@ EventDispatcher::EventDispatcher( synchronousBatchedQueue_(std::make_unique( eventPipe, statePipe, - synchonousEventBeatFactory(ownerBox))), + synchonousEventBeatFactory(ownerBox), + enableV2EventCoalescing)), asynchronousUnbatchedQueue_(std::make_unique( eventPipe, statePipe, @@ -37,7 +39,8 @@ EventDispatcher::EventDispatcher( asynchronousBatchedQueue_(std::make_unique( eventPipe, statePipe, - asynchonousEventBeatFactory(ownerBox))) {} + asynchonousEventBeatFactory(ownerBox), + enableV2EventCoalescing)) {} void EventDispatcher::dispatchEvent( RawEvent const &rawEvent, diff --git a/ReactCommon/react/renderer/core/EventDispatcher.h b/ReactCommon/react/renderer/core/EventDispatcher.h index d3fb37c132754f..eb0abf52eba76b 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/ReactCommon/react/renderer/core/EventDispatcher.h @@ -37,7 +37,8 @@ class EventDispatcher { StatePipe const &statePipe, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, - EventBeat::SharedOwnerBox const &ownerBox); + EventBeat::SharedOwnerBox const &ownerBox, + bool enableV2EventCoalescing); /* * Dispatches a raw event with given priority using event-delivery pipe. diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 1f0c617ef8d58a..1e8ab5f50c5b11 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -67,7 +67,8 @@ Scheduler::Scheduler( statePipe, schedulerToolbox.synchronousEventBeatFactory, schedulerToolbox.asynchronousEventBeatFactory, - eventOwnerBox); + eventOwnerBox, + reactNativeConfig_->getBool("react_fabric:enable_v2_event_coalescing")); // Casting to `std::shared_ptr`. auto eventDispatcher = From 3a0ed2e5510ec14a695195d9e8b7d9736c3417d6 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 17 Nov 2020 11:14:20 -0800 Subject: [PATCH 0074/1810] Implement zoom in ScrollView Summary: changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D24991161 fbshipit-source-id: 6f36cc21b89554006a744da8d32349ff21ccd68f --- .../ScrollView/RCTScrollViewComponentView.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index d958209607f6a2..dd0f4ce94e61a0 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -452,7 +452,12 @@ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UI [self _updateStateWithContentOffset]; } -#pragma mark - UIScrollViewDelegate +- (UIView *)viewForZoomingInScrollView:(__unused UIScrollView *)scrollView +{ + return _containerView; +} + +#pragma mark - - (void)_forceDispatchNextScrollEvent { From 53858ceaa3beab02726b1bd6e125e506477d445e Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Tue, 17 Nov 2020 14:47:55 -0800 Subject: [PATCH 0075/1810] Add reset method to RCTFabricSurface [2/N] Summary: This method allows a surface to re-render from scratch, without having to delete and reinstantiate the surface. Changelog: [iOS] Added reset method to RCTFabricSurface to help with reloads Reviewed By: RSNara Differential Revision: D25000509 fbshipit-source-id: f74170aa78cc84491ad2679f130ed3c8965bbe34 --- React/Fabric/Surface/RCTFabricSurface.h | 7 +++++++ React/Fabric/Surface/RCTFabricSurface.mm | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/React/Fabric/Surface/RCTFabricSurface.h b/React/Fabric/Surface/RCTFabricSurface.h index d4dd93c91197a5..1c3e4af43f71dd 100644 --- a/React/Fabric/Surface/RCTFabricSurface.h +++ b/React/Fabric/Surface/RCTFabricSurface.h @@ -70,6 +70,13 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)start; - (BOOL)stop; +/** + * EXPERIMENTAL + * Reset's the Surface to it's initial stage. + * It uses the passed in surface presenter, and whatever else was passed in init. + */ +- (void)resetWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter; + #pragma mark - Layout: Setting the size constrains /** diff --git a/React/Fabric/Surface/RCTFabricSurface.mm b/React/Fabric/Surface/RCTFabricSurface.mm index 35368dada39056..993985c4846392 100644 --- a/React/Fabric/Surface/RCTFabricSurface.mm +++ b/React/Fabric/Surface/RCTFabricSurface.mm @@ -64,6 +64,13 @@ - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter return self; } +- (void)resetWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter +{ + _surfacePresenter = surfacePresenter; + _stage = RCTSurfaceStageSurfaceDidInitialize; + _view = nil; +} + - (BOOL)start { if (![self _setStage:RCTSurfaceStageStarted]) { From b841ee6fb8df3a91c877e96fe3f653553b619533 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 17 Nov 2020 18:26:00 -0800 Subject: [PATCH 0076/1810] Fix :ReactAndroid:androidJavadoc task (#30417) Summary: Fixes https://github.com/facebook/react-native/issues/30415 This is a quick and dirty fix to unblock publish, of excluding a class from Javadoc generation that is importing a class current build logic cannot handle. This is not a long-term fix for the issue. ## Changelog [Internal] [Fixed] - Fix :ReactAndroid:androidJavadoc task Pull Request resolved: https://github.com/facebook/react-native/pull/30417 Test Plan: Tested that the task now completes locally. Reviewed By: lunaleaps Differential Revision: D25041282 Pulled By: fkgozali fbshipit-source-id: f774ab30a09db473178e2a51c77860e4985dd8e3 --- ReactAndroid/release.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/release.gradle b/ReactAndroid/release.gradle index bf3db45264580c..8650a2088cec33 100644 --- a/ReactAndroid/release.gradle +++ b/ReactAndroid/release.gradle @@ -73,12 +73,12 @@ if (JavaVersion.current().isJava8Compatible()) { afterEvaluate { project -> - task androidJavadoc(type: Javadoc) { + task androidJavadoc(type: Javadoc, dependsOn: generateReleaseBuildConfig) { source = android.sourceSets.main.java.srcDirs classpath += files(android.bootClasspath) classpath += files(project.getConfigurations().getByName("compile").asList()) + classpath += files("$buildDir/generated/source/buildConfig/release") include("**/*.java") - exclude("**/ReactBuildConfig.java") } task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { From 9eb23e741fe6eac41120353ff7d699a62b239020 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Tue, 17 Nov 2020 18:26:00 -0800 Subject: [PATCH 0077/1810] Android OSS: Solve some Javadoc warning due to missing dependencies Summary: A bunch of deps were missing when generating Javadoc, producing warnings. One issue was: ``` project.getConfigurations().getByName("compile").asList() ``` Seems to be deprecated (?), so this list is always empty. The mitigation is to create a new configuration that just inherits from `api()` dependencies, so that we can add them in Javadoc task. The other problem (not solved in this commit), is that some deps are .aar files, which require some manual unpacking before they can be processed: https://stackoverflow.com/questions/35853906/how-to-generate-javadoc-for-android-library-when-it-has-dependencies-which-are-a Note that this is separate fix from https://github.com/facebook/react-native/pull/30417 Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25041164 fbshipit-source-id: 2ee8b268c2d38e3ecbf622c05c3c56123b7a15a6 --- ReactAndroid/build.gradle | 3 +++ ReactAndroid/release.gradle | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index daa5a0c75d3e18..e651b5be40fd87 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -437,6 +437,7 @@ android { configurations { extractHeaders extractJNI + javadocDeps.extendsFrom api } } @@ -457,6 +458,8 @@ dependencies { extractHeaders("com.facebook.fbjni:fbjni:0.0.2:headers") extractJNI("com.facebook.fbjni:fbjni:0.0.2") + javadocDeps("com.squareup:javapoet:1.13.0") + testImplementation("junit:junit:${JUNIT_VERSION}") testImplementation("org.powermock:powermock-api-mockito2:${POWERMOCK_VERSION}") testImplementation("org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}") diff --git a/ReactAndroid/release.gradle b/ReactAndroid/release.gradle index 8650a2088cec33..13727752d19690 100644 --- a/ReactAndroid/release.gradle +++ b/ReactAndroid/release.gradle @@ -76,8 +76,9 @@ afterEvaluate { project -> task androidJavadoc(type: Javadoc, dependsOn: generateReleaseBuildConfig) { source = android.sourceSets.main.java.srcDirs classpath += files(android.bootClasspath) - classpath += files(project.getConfigurations().getByName("compile").asList()) classpath += files("$buildDir/generated/source/buildConfig/release") + // Note: this doesn't handle .aar files, only .jar. + classpath += configurations.javadocDeps include("**/*.java") } From 8cc44678ceed9d7383f73a5533e99a7b4c1bc267 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 17 Nov 2020 20:03:03 -0800 Subject: [PATCH 0078/1810] switch Readme version badge source to shields.io (#30411) Summary: Lately there are some loading issues for the `fury.io` badges service which results in missing image and alt text visible in the Readme. This PR fixes that issue by switching to `shields.io` version badge - badge service that has been used for few other badges already. ## Changelog [Internal] [Changed] - change Readme npm version badge to `shields.io` Pull Request resolved: https://github.com/facebook/react-native/pull/30411 Test Plan: All badges will appear in the Readme file. {emoji:1f642} Reviewed By: cpojer Differential Revision: D25040061 Pulled By: hramos fbshipit-source-id: 2ef6b94ff39ec21573b7e58318aba653fd716037 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af9316f2e2acb0..a45e1deef040e3 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Current CircleCI build status. - Current npm package version. + Current npm package version. PRs welcome! From 312226362d88142ece8d906dc3fc49355fee353d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 18 Nov 2020 06:54:47 -0800 Subject: [PATCH 0079/1810] Add const annotations to LayoutAnimationKeyFrameManager Summary: Changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25023706 fbshipit-source-id: 678377e2c471386670d1eab9c5adbe8aa6473a3c --- .../LayoutAnimationKeyFrameManager.cpp | 16 ++++++++-------- .../animations/LayoutAnimationKeyFrameManager.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 394a78c5d05aef..fa74d7a7178144 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -631,12 +631,12 @@ void LayoutAnimationKeyFrameManager::adjustDelayedMutationIndicesForMutation( std::vector> LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( SurfaceId surfaceId, - ShadowViewMutationList &mutations, + ShadowViewMutationList const &mutations, bool deletesOnly) const { std::vector> conflictingAnimations{}; - for (auto &mutation : mutations) { + for (auto const &mutation : mutations) { if (deletesOnly && mutation.type != ShadowViewMutation::Type::Delete) { continue; } @@ -785,7 +785,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( LOG(ERROR) << "BEGINNING DISPLAYING ONGOING inflightAnimations_!"; int i = 0; int j = 0; - for (auto &inflightAnimation : inflightAnimations_) { + for (auto const &inflightAnimation : inflightAnimations_) { i++; j = 0; if (inflightAnimation.completed) { @@ -885,7 +885,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( std::vector keyFramesToAnimate; std::vector movesToAnimate; auto const layoutAnimationConfig = animation.layoutAnimationConfig; - for (auto &mutation : mutations) { + for (auto const &mutation : mutations) { ShadowView baselineShadowView = (mutation.type == ShadowViewMutation::Type::Delete || mutation.type == ShadowViewMutation::Type::Remove @@ -1182,7 +1182,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( #endif auto finalConflictingMutations = ShadowViewMutationList{}; - for (auto &conflictingKeyframeTuple : conflictingAnimations) { + for (auto const &conflictingKeyframeTuple : conflictingAnimations) { auto &keyFrame = std::get<0>(conflictingKeyframeTuple); if (keyFrame.finalMutationForKeyFrame.hasValue()) { auto &mutation = *keyFrame.finalMutationForKeyFrame; @@ -1359,7 +1359,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( LOG(ERROR) << "No Animation: Queue up final conflicting animations"; #endif ShadowViewMutationList finalMutationsForConflictingAnimations{}; - for (auto &conflictingKeyframeTuple : conflictingAnimations) { + for (auto const &conflictingKeyframeTuple : conflictingAnimations) { auto &keyFrame = std::get<0>(conflictingKeyframeTuple); if (keyFrame.finalMutationForKeyFrame.hasValue()) { PrintMutationInstruction( @@ -1399,7 +1399,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( LOG(ERROR) << "No Animation: Adjust delayed mutations based on all finalMutationsForConflictingAnimations"; #endif - for (auto &mutation : finalMutationsForConflictingAnimations) { + for (auto const &mutation : finalMutationsForConflictingAnimations) { if (mutation.type == ShadowViewMutation::Type::Remove || mutation.type == ShadowViewMutation::Type::Insert) { adjustDelayedMutationIndicesForMutation(surfaceId, mutation); @@ -1463,7 +1463,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( LOG(ERROR) << "FINISHING DISPLAYING ONGOING inflightAnimations_!"; int i = 0; int j = 0; - for (auto &inflightAnimation : inflightAnimations_) { + for (auto const &inflightAnimation : inflightAnimations_) { i++; j = 0; if (inflightAnimation.completed) { diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 9015aa1b61a95f..5d69cec5688fb0 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -223,7 +223,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, std::vector> getAndEraseConflictingAnimations( SurfaceId surfaceId, - ShadowViewMutationList &mutations, + ShadowViewMutationList const &mutations, bool deletesOnly = false) const; mutable std::mutex surfaceIdsToStopMutex_; From 3c8d0112b37f1583644d33d9c0fa0623d31acdda Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 18 Nov 2020 06:54:47 -0800 Subject: [PATCH 0080/1810] Use variable instead of reference Summary: Changelog: [internal] Reference here is incorrect, we need a container for `ShadowViewMutation`. Reviewed By: JoshuaGross Differential Revision: D25024080 fbshipit-source-id: f59a18d859ad391bc168c8990d40b25d18003f74 --- .../animations/LayoutAnimationKeyFrameManager.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index fa74d7a7178144..7ed615bef2edb4 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1187,12 +1187,11 @@ LayoutAnimationKeyFrameManager::pullTransaction( if (keyFrame.finalMutationForKeyFrame.hasValue()) { auto &mutation = *keyFrame.finalMutationForKeyFrame; if (mutation.type == ShadowViewMutation::Type::Update) { - const auto &mutationInstruction = - ShadowViewMutation::UpdateMutation( - mutation.parentShadowView, - {}, - mutation.newChildShadowView, - mutation.index); + auto mutationInstruction = ShadowViewMutation::UpdateMutation( + mutation.parentShadowView, + {}, + mutation.newChildShadowView, + mutation.index); PrintMutationInstruction( "Queueing up final mutation instruction - update:", mutationInstruction); From a6b785553b11d8706604305cb1d10541af545490 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 18 Nov 2020 09:37:44 -0800 Subject: [PATCH 0081/1810] Check error code returned from vImageBoxConvolve_ARGB8888 Summary: Changelog: [internal] If value returned from `vImageBoxConvolve_ARGB8888` is negative, an error occurred. Converting a negative number to `unsigned long` produces a large positive number (larger than memory). Trying to allocate that much memory fails, malloc returns NULL, and abort triggered inside `RCTBlurredImageWithRadius`. To fix this we need to check for return value from `vImageBoxConvolve_ARGB8888`. Documentation: https://developer.apple.com/documentation/accelerate/1515945-vimageboxconvolve_argb8888?language=objc Reviewed By: JoshuaGross Differential Revision: D25055827 fbshipit-source-id: 2c46ae6eea5cfcc95c2b552c7cd2bc60125fd24a --- Libraries/Image/RCTImageBlurUtils.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Libraries/Image/RCTImageBlurUtils.m b/Libraries/Image/RCTImageBlurUtils.m index 72e60af696214b..592f0239ed60fc 100644 --- a/Libraries/Image/RCTImageBlurUtils.m +++ b/Libraries/Image/RCTImageBlurUtils.m @@ -49,8 +49,14 @@ boxSize |= 1; // Ensure boxSize is odd //create temp buffer - void *tempBuffer = malloc((size_t)vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, NULL, 0, 0, boxSize, boxSize, - NULL, kvImageEdgeExtend + kvImageGetTempBufferSize)); + vImage_Error tempBufferSize = vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, NULL, 0, 0, boxSize, boxSize, + NULL, kvImageGetTempBufferSize | kvImageEdgeExtend); + if (tempBufferSize < 0) { + free(buffer1.data); + free(buffer2.data); + return inputImage; + } + void *tempBuffer = malloc(tempBufferSize); if (!tempBuffer) { // CWE - 391 : Unchecked error condition // https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html From cf97c1f3bd2c1c0877926bae1bfd0ae0a07eca26 Mon Sep 17 00:00:00 2001 From: inokawa <48897392+inokawa@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:10:59 -0800 Subject: [PATCH 0082/1810] Fix typo (#30330) Summary: Fix typo in comment ## Changelog [CATEGORY] [TYPE] - Message Pull Request resolved: https://github.com/facebook/react-native/pull/30330 Reviewed By: fkgozali Differential Revision: D25062086 Pulled By: PeteTheHeat fbshipit-source-id: 251bf1d4f4986f77ae72f7654796ae1d49c1863d --- react.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react.gradle b/react.gradle index 5995ad5fbb328a..5a3bf6ba9cb982 100644 --- a/react.gradle +++ b/react.gradle @@ -315,7 +315,7 @@ afterEvaluate { // Delete the VM related libraries that this build doesn't need. // The application can manage this manually by setting 'enableVmCleanup: false' // - // This should really be done by packaging all Hermes releated libs into + // This should really be done by packaging all Hermes related libs into // two separate HermesDebug and HermesRelease AARs, but until then we'll // kludge it by deleting the .so files out of the /transforms/ directory. def isRelease = targetName.toLowerCase().contains("release") From 19d4cc2d49e3c7f15e030e240041bf4f0525d6ca Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 18 Nov 2020 15:29:44 -0800 Subject: [PATCH 0083/1810] Implement ScrollView.zoomToRect Summary: Changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D24991008 fbshipit-source-id: 6048246a784b94a321281547d966379badd8f6fd --- .../ScrollView/RCTScrollViewComponentView.mm | 2 +- .../scrollview/RCTComponentViewHelpers.h | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index dd0f4ce94e61a0..453312d85cde08 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -627,7 +627,7 @@ - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated { - // Not implemented. + [_scrollView zoomToRect:rect animated:animated]; } - (void)addScrollListener:(NSObject *)scrollListener diff --git a/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h b/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h index ce4303c2c94afd..0fab3ae8160e68 100644 --- a/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h +++ b/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h @@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)flashScrollIndicators; - (void)scrollTo:(double)x y:(double)y animated:(BOOL)animated; - (void)scrollToEnd:(BOOL)animated; +- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated; @end RCT_EXTERN inline void @@ -90,6 +91,43 @@ RCTScrollViewHandleCommand(id componentView, NSString con [componentView scrollToEnd:animated]; return; } + + if ([commandName isEqualToString:@"zoomToRect"]) { +#if RCT_DEBUG + if ([args count] != 2) { + RCTLogError( + @"%@ command %@ received %d arguments, expected %d.", @"ScrollView", commandName, (int)[args count], 2); + return; + } +#endif + + NSObject *arg0 = args[0]; + +#if RCT_DEBUG + if (!RCTValidateTypeOfViewCommandArgument( + arg0, [NSDictionary class], @"dictionary", @"ScrollView", commandName, @"1st")) { + return; + } +#endif + + NSDictionary *rectDict = (NSDictionary *)arg0; + NSNumber *x = rectDict[@"x"]; + NSNumber *y = rectDict[@"y"]; + NSNumber *width = rectDict[@"width"]; + NSNumber *height = rectDict[@"height"]; + CGRect rect = CGRectMake(x.doubleValue, y.doubleValue, width.doubleValue, height.doubleValue); + + NSObject *arg1 = args[1]; +#if RCT_DEBUG + if (!RCTValidateTypeOfViewCommandArgument(arg1, [NSNumber class], @"boolean", @"ScrollView", commandName, @"2nd")) { + return; + } +#endif + + BOOL animated = [(NSNumber *)arg1 boolValue]; + [componentView zoomToRect:rect animated:animated]; + return; + } } NS_ASSUME_NONNULL_END From bea3495fd06c822c2f747be05e1882c5131403d4 Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Wed, 18 Nov 2020 19:32:03 -0800 Subject: [PATCH 0084/1810] Fix crash in RCTLegacyViewManagerInteropCoordinator Summary: Like the task mentions `strongSelf->_eventInterceptors` was crashing, probably because the coordinator was cleaned up before this block ran. Check to make sure self is still valid before attempting to access any instance variables. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25073812 fbshipit-source-id: cdf666f2ac028b5523097f15ff51fbae9f9ffbd8 --- .../RCTLegacyViewManagerInteropCoordinator.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm index 3e962334bf9c7f..cab75ac3882009 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm @@ -40,9 +40,11 @@ - (instancetype)initWithComponentData:(RCTComponentData *)componentData bridge:( __weak __typeof(self) weakSelf = self; _componentData.eventInterceptor = ^(NSString *eventName, NSDictionary *event, NSNumber *reactTag) { __typeof(self) strongSelf = weakSelf; - InterceptorBlock block = [strongSelf->_eventInterceptors objectForKey:reactTag]; - if (block) { - block(std::string([RCTNormalizeInputEventName(eventName) UTF8String]), convertIdToFollyDynamic(event ?: @{})); + if (strongSelf) { + InterceptorBlock block = [strongSelf->_eventInterceptors objectForKey:reactTag]; + if (block) { + block(std::string([RCTNormalizeInputEventName(eventName) UTF8String]), convertIdToFollyDynamic(event ?: @{})); + } } }; } From 130618fd8509c09df2b1a93535e57af006079879 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Wed, 18 Nov 2020 20:57:13 -0800 Subject: [PATCH 0085/1810] RN: Suppress RCTVirtualText Warning in Bridgeless Summary: The `DummyUIManager` module warns whenever `RCTVirtualText` is initialized. This stops that. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25073194 fbshipit-source-id: 8b9052d1cbb9a4defa5efbd110e1a91cd8884c48 --- Libraries/Text/TextNativeComponent.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Text/TextNativeComponent.js b/Libraries/Text/TextNativeComponent.js index eafc7ddf8d1483..b98dca5a5b3541 100644 --- a/Libraries/Text/TextNativeComponent.js +++ b/Libraries/Text/TextNativeComponent.js @@ -56,6 +56,7 @@ export const NativeText: HostComponent = (createReactNativeComp ): any); export const NativeVirtualText: HostComponent = + !global.RN$Bridgeless && UIManager.getViewManagerConfig('RCTVirtualText') == null ? NativeText : (createReactNativeComponentClass('RCTVirtualText', () => ({ From a7c1c5aff24671bba609caeb82092a8de3d3b232 Mon Sep 17 00:00:00 2001 From: Luke Walczak Date: Wed, 18 Nov 2020 21:09:39 -0800 Subject: [PATCH 0086/1810] Add possibility to disable buttons in action sheet ios (#28979) Summary: _**Fixed**_ version of [the previous PR](https://github.com/facebook/react-native/pull/28792) after reverting [changes](https://github.com/facebook/react-native/commit/c8d678abcf93fd3f6daf4bebfdf25937995c1fdf#commitcomment-39299254) ---- I've noticed that currently there is no option to disable button within the `ActionSheetIOS`. It can be really useful and decided to extend the API to support that functionality. I added a new option called `disabledButtonsIndices` to `ActionSheetIOS` which is an array of button indices which should be disabled. `ActionSheetIOS` documentation - PR https://github.com/facebook/react-native-website/pull/1898 ## Changelog [iOS] [Added] - Add disableButtonsIndices option to ActionSheetIOS component Pull Request resolved: https://github.com/facebook/react-native/pull/28979 Test Plan: 1. Run the `RNTester` 2. Choose `ActionSheetIOS` 3. Check the fourth example `Show Action Sheet with disabled buttons` 4. `Option 1` and `Option 2` should be disabled screenshot | gif --- | --- Screenshot 2020-04-30 at 15 16 22 | Reviewed By: sammy-SC Differential Revision: D21727497 Pulled By: PeteTheHeat fbshipit-source-id: 749b6c623eb8a44fe2bd96829ce89be5310e2368 --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 2 + .../NativeActionSheetManager.js | 1 + React/CoreModules/RCTActionSheetManager.mm | 18 +++++++++ .../ActionSheetIOS/ActionSheetIOSExample.js | 38 +++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index bc3a935dee298b..1fc86a0fd8872c 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -33,6 +33,7 @@ const ActionSheetIOS = { * - `destructiveButtonIndex` (int or array of ints) - index or indices of destructive buttons in `options` * - `title` (string) - a title to show above the action sheet * - `message` (string) - a message to show below the title + * - `disabledButtonIndices` (array of numbers) - a list of button indices which should be disabled * * The 'callback' function takes one parameter, the zero-based index * of the selected item. @@ -49,6 +50,7 @@ const ActionSheetIOS = { +anchor?: ?number, +tintColor?: ColorValue | ProcessedColorValue, +userInterfaceStyle?: string, + +disabledButtonIndices?: Array, |}, callback: (buttonIndex: number) => void, ) { diff --git a/Libraries/ActionSheetIOS/NativeActionSheetManager.js b/Libraries/ActionSheetIOS/NativeActionSheetManager.js index 063d9147e1d69b..6d86200d9accd6 100644 --- a/Libraries/ActionSheetIOS/NativeActionSheetManager.js +++ b/Libraries/ActionSheetIOS/NativeActionSheetManager.js @@ -25,6 +25,7 @@ export interface Spec extends TurboModule { +anchor?: ?number, +tintColor?: ?number, +userInterfaceStyle?: ?string, + +disabledButtonIndices?: Array, |}, callback: (buttonIndex: number) => void, ) => void; diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index 754e461157349d..c2eae7c9fe8808 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -73,9 +73,15 @@ - (void)presentViewController:(UIViewController *)alertController NSArray *buttons = RCTConvertOptionalVecToArray(options.options(), ^id(NSString *element) { return element; }); + NSArray *disabledButtonIndices; NSInteger cancelButtonIndex = options.cancelButtonIndex() ? [RCTConvert NSInteger:@(*options.cancelButtonIndex())] : -1; NSArray *destructiveButtonIndices; + if (options.disabledButtonIndices()) { + disabledButtonIndices = RCTConvertVecToArray(*options.disabledButtonIndices(), ^id(double element) { + return @(element); + }); + } if (options.destructiveButtonIndices()) { destructiveButtonIndices = RCTConvertVecToArray(*options.destructiveButtonIndices(), ^id(double element) { return @(element); @@ -98,6 +104,7 @@ - (void)presentViewController:(UIViewController *)alertController @"destructiveButtonIndices" : destructiveButtonIndices, @"anchor" : anchor, @"tintColor" : tintColor, + @"disabledButtonIndices" : disabledButtonIndices, }); return; } @@ -132,6 +139,17 @@ - (void)presentViewController:(UIViewController *)alertController index++; } + if (disabledButtonIndices) { + for (NSNumber *disabledButtonIndex in disabledButtonIndices) { + if ([disabledButtonIndex integerValue] < buttons.count) { + [alertController.actions[[disabledButtonIndex integerValue]] setEnabled:false]; + } else { + RCTLogError(@"Index %@ from `disabledButtonIndices` is out of bounds. Maximum index value is %@.", @([disabledButtonIndex integerValue]), @(buttons.count - 1)); + return; + } + } + } + alertController.view.tintColor = tintColor; #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 diff --git a/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js b/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js index 786811a725d53f..917cba05c0ce09 100644 --- a/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js +++ b/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js @@ -25,6 +25,7 @@ const ScreenshotManager = NativeModules.ScreenshotManager; const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel']; const DESTRUCTIVE_INDEX = 3; const CANCEL_INDEX = 4; +const DISABLED_BUTTON_INDICES = [1, 2]; type Props = $ReadOnly<{||}>; type State = {|clicked: string|}; @@ -138,6 +139,37 @@ class ActionSheetAnchorExample extends React.Component< }; } +class ActionSheetDisabledExample extends React.Component { + state = { + clicked: 'none', + }; + + render() { + return ( + + + Click to show the ActionSheet + + Clicked button: {this.state.clicked} + + ); + } + + showActionSheet = () => { + ActionSheetIOS.showActionSheetWithOptions( + { + options: BUTTONS, + cancelButtonIndex: CANCEL_INDEX, + destructiveButtonIndex: DESTRUCTIVE_INDEX, + disabledButtonIndices: DISABLED_BUTTON_INDICES, + }, + buttonIndex => { + this.setState({clicked: BUTTONS[buttonIndex]}); + }, + ); + }; +} + class ShareActionSheetExample extends React.Component< $FlowFixMeProps, $FlowFixMeState, @@ -316,6 +348,12 @@ exports.examples = [ return ; }, }, + { + title: 'Show Action Sheet with disabled buttons', + render(): React.Element { + return ; + }, + }, { title: 'Show Share Action Sheet', render(): React.Element { From 9611a7b43e16b095d9cc02f77c14b19ddc9b2145 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Wed, 18 Nov 2020 21:16:22 -0800 Subject: [PATCH 0087/1810] RN: Move RN$Bridgeless Check to Registration Summary: Moves the `RN$Bridgeless` check as part of moving more logic out of the verification function. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D25072601 fbshipit-source-id: 929230c02a6eaa1b724f7fd2e1a691a7c20c4b11 --- .../Utilities/registerGeneratedViewConfig.js | 4 +- .../verifyComponentAttributeEquivalence.js | 39 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Libraries/Utilities/registerGeneratedViewConfig.js b/Libraries/Utilities/registerGeneratedViewConfig.js index 947b3b06642b72..0814da85e89278 100644 --- a/Libraries/Utilities/registerGeneratedViewConfig.js +++ b/Libraries/Utilities/registerGeneratedViewConfig.js @@ -74,7 +74,9 @@ function registerGeneratedViewConfig( }; ReactNativeViewConfigRegistry.register(componentName, () => { - verifyComponentAttributeEquivalence(componentName, mergedViewConfig); + if (!global.RN$Bridgeless) { + verifyComponentAttributeEquivalence(componentName, mergedViewConfig); + } return mergedViewConfig; }); diff --git a/Libraries/Utilities/verifyComponentAttributeEquivalence.js b/Libraries/Utilities/verifyComponentAttributeEquivalence.js index 10dbe98dd0b4a1..0bd13ab6744d1f 100644 --- a/Libraries/Utilities/verifyComponentAttributeEquivalence.js +++ b/Libraries/Utilities/verifyComponentAttributeEquivalence.js @@ -16,6 +16,7 @@ import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewCon import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes'; const IGNORED_KEYS = ['transform', 'hitSlop']; + /** * The purpose of this function is to validate that the view config that * native exposes for a given view manager is the same as the view config @@ -39,29 +40,27 @@ const IGNORED_KEYS = ['transform', 'hitSlop']; * single source of truth. I wonder if this message will still be here two * years from now... */ -function verifyComponentAttributeEquivalence( +export default function verifyComponentAttributeEquivalence( componentName: string, config: ReactNativeBaseComponentViewConfig<>, ) { - if (!global.RN$Bridgeless) { - const nativeAttributes = getNativeComponentAttributes(componentName); - - ['validAttributes', 'bubblingEventTypes', 'directEventTypes'].forEach( - prop => { - const diffKeys = Object.keys( - lefthandObjectDiff(nativeAttributes[prop], config[prop]), + const nativeAttributes = getNativeComponentAttributes(componentName); + + ['validAttributes', 'bubblingEventTypes', 'directEventTypes'].forEach( + prop => { + const diffKeys = Object.keys( + lefthandObjectDiff(nativeAttributes[prop], config[prop]), + ); + + if (diffKeys.length) { + console.error( + `${componentName} generated view config for ${prop} does not match native, missing: ${diffKeys.join( + ' ', + )}`, ); - - if (diffKeys.length) { - console.error( - `${componentName} generated view config for ${prop} does not match native, missing: ${diffKeys.join( - ' ', - )}`, - ); - } - }, - ); - } + } + }, + ); } export function lefthandObjectDiff(leftObj: Object, rightObj: Object): Object { @@ -130,5 +129,3 @@ export function stringifyViewConfig(viewConfig: any): string { 2, ); } - -export default verifyComponentAttributeEquivalence; From 69b4611049e3211b7a64ffcf49dcb87128163218 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Wed, 18 Nov 2020 21:16:22 -0800 Subject: [PATCH 0088/1810] RN: Hoist Reflection from Verification Summary: Hoists the call to `getNativeComponentAttributes` out of the verification function so that it's easier to keep track of when this function is and is not called. The purpose of this will become clearer in a future refactor. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D25072600 fbshipit-source-id: bc42461baae3476fa7ecb6186c4256dd23921ed5 --- ...erifyComponentAttributeEquivalence-test.js | 78 ++++++++++--------- .../Utilities/registerGeneratedViewConfig.js | 13 ++-- .../verifyComponentAttributeEquivalence.js | 39 +++++----- 3 files changed, 67 insertions(+), 63 deletions(-) diff --git a/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js b/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js index 58acd17758cab8..43a507335d39cb 100644 --- a/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js +++ b/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js @@ -10,12 +10,13 @@ 'use strict'; -const getNativeComponentAttributes = require('../../ReactNative/getNativeComponentAttributes'); +jest.dontMock('../verifyComponentAttributeEquivalence'); + const verifyComponentAttributeEquivalence = require('../verifyComponentAttributeEquivalence') .default; -jest.dontMock('../verifyComponentAttributeEquivalence'); -jest.mock('../../ReactNative/getNativeComponentAttributes', () => () => ({ +const TestComponentNativeViewConfig = { + uiViewClassName: 'TestComponent', NativeProps: { value: 'BOOL', }, @@ -40,62 +41,63 @@ jest.mock('../../ReactNative/getNativeComponentAttributes', () => () => ({ }, transform: 'CATransform3D', }, -})); - -beforeEach(() => { - global.__DEV__ = true; - console.error = jest.fn(); - jest.resetModules(); -}); +}; describe('verifyComponentAttributeEquivalence', () => { - test('should not verify in prod', () => { - global.__DEV__ = false; - verifyComponentAttributeEquivalence('TestComponent', {}); + beforeEach(() => { + global.__DEV__ = true; + console.error = jest.fn(); + jest.resetModules(); }); - test('should not error with native config that is a subset of the given config', () => { - const configWithAdditionalProperties = getNativeComponentAttributes( - 'TestComponent', - ); + it('should not verify in prod', () => { + global.__DEV__ = false; + verifyComponentAttributeEquivalence(TestComponentNativeViewConfig, {}); + }); - configWithAdditionalProperties.bubblingEventTypes.topFocus = { - phasedRegistrationNames: { - bubbled: 'onFocus', - captured: 'onFocusCapture', + it('should not error with native config that is a subset of the given config', () => { + const configWithAdditionalProperties = { + ...TestComponentNativeViewConfig, + bubblingEventTypes: { + ...TestComponentNativeViewConfig.bubblingEventTypes, + topFocus: { + phasedRegistrationNames: { + bubbled: 'onFocus', + captured: 'onFocusCapture', + }, + }, + }, + directEventTypes: { + ...TestComponentNativeViewConfig.directEventTypes, + topSlidingComplete: { + registrationName: 'onSlidingComplete', + }, + }, + validAttributes: { + ...TestComponentNativeViewConfig.validAttributes, + active: true, }, }; - - configWithAdditionalProperties.directEventTypes.topSlidingComplete = { - registrationName: 'onSlidingComplete', - }; - - configWithAdditionalProperties.validAttributes.active = true; - - verifyComponentAttributeEquivalence( - 'TestComponent', - configWithAdditionalProperties, - ); verifyComponentAttributeEquivalence( - 'TestComponent', + TestComponentNativeViewConfig, configWithAdditionalProperties, ); expect(console.error).not.toBeCalled(); }); - test('should error if given config is missing native config properties', () => { - verifyComponentAttributeEquivalence('TestComponent', {}); + it('should error if given config is missing native config properties', () => { + verifyComponentAttributeEquivalence(TestComponentNativeViewConfig, {}); expect(console.error).toBeCalledTimes(3); expect(console.error).toBeCalledWith( - 'TestComponent generated view config for directEventTypes does not match native, missing: topAccessibilityAction', + "'TestComponent' has a view config that does not match native. 'validAttributes' is missing: borderColor, style", ); expect(console.error).toBeCalledWith( - 'TestComponent generated view config for bubblingEventTypes does not match native, missing: topChange', + "'TestComponent' has a view config that does not match native. 'bubblingEventTypes' is missing: topChange", ); expect(console.error).toBeCalledWith( - 'TestComponent generated view config for validAttributes does not match native, missing: borderColor style', + "'TestComponent' has a view config that does not match native. 'directEventTypes' is missing: topAccessibilityAction", ); }); }); diff --git a/Libraries/Utilities/registerGeneratedViewConfig.js b/Libraries/Utilities/registerGeneratedViewConfig.js index 0814da85e89278..aabcb4989bf2e7 100644 --- a/Libraries/Utilities/registerGeneratedViewConfig.js +++ b/Libraries/Utilities/registerGeneratedViewConfig.js @@ -10,8 +10,9 @@ 'use strict'; -const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry'); -const ReactNativeViewViewConfig = require('../Components/View/ReactNativeViewViewConfig'); +import ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConfigRegistry'; +import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; +import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes'; import verifyComponentAttributeEquivalence from './verifyComponentAttributeEquivalence'; export type GeneratedViewConfig = { @@ -47,7 +48,7 @@ function registerGeneratedViewConfig( componentName: string, viewConfig: GeneratedViewConfig, ) { - const mergedViewConfig = { + const staticViewConfig = { uiViewClassName: componentName, Commands: {}, /* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an @@ -75,10 +76,12 @@ function registerGeneratedViewConfig( ReactNativeViewConfigRegistry.register(componentName, () => { if (!global.RN$Bridgeless) { - verifyComponentAttributeEquivalence(componentName, mergedViewConfig); + const nativeViewConfig = getNativeComponentAttributes(componentName); + + verifyComponentAttributeEquivalence(nativeViewConfig, staticViewConfig); } - return mergedViewConfig; + return staticViewConfig; }); } diff --git a/Libraries/Utilities/verifyComponentAttributeEquivalence.js b/Libraries/Utilities/verifyComponentAttributeEquivalence.js index 0bd13ab6744d1f..bb3e235111674e 100644 --- a/Libraries/Utilities/verifyComponentAttributeEquivalence.js +++ b/Libraries/Utilities/verifyComponentAttributeEquivalence.js @@ -10,8 +10,6 @@ 'use strict'; -const getNativeComponentAttributes = require('../ReactNative/getNativeComponentAttributes'); - import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes'; @@ -41,26 +39,27 @@ const IGNORED_KEYS = ['transform', 'hitSlop']; * years from now... */ export default function verifyComponentAttributeEquivalence( - componentName: string, - config: ReactNativeBaseComponentViewConfig<>, + nativeViewConfig: ReactNativeBaseComponentViewConfig<>, + staticViewConfig: ReactNativeBaseComponentViewConfig<>, ) { - const nativeAttributes = getNativeComponentAttributes(componentName); - - ['validAttributes', 'bubblingEventTypes', 'directEventTypes'].forEach( - prop => { - const diffKeys = Object.keys( - lefthandObjectDiff(nativeAttributes[prop], config[prop]), + for (const prop of [ + 'validAttributes', + 'bubblingEventTypes', + 'directEventTypes', + ]) { + const diff = Object.keys( + lefthandObjectDiff(nativeViewConfig[prop], staticViewConfig[prop]), + ); + + if (diff.length > 0) { + const name = + staticViewConfig.uiViewClassName ?? nativeViewConfig.uiViewClassName; + console.error( + `'${name}' has a view config that does not match native. ` + + `'${prop}' is missing: ${diff.join(', ')}`, ); - - if (diffKeys.length) { - console.error( - `${componentName} generated view config for ${prop} does not match native, missing: ${diffKeys.join( - ' ', - )}`, - ); - } - }, - ); + } + } } export function lefthandObjectDiff(leftObj: Object, rightObj: Object): Object { From e136aa3fc4d3d05ff55fe8af9cd151ffc0436408 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Wed, 18 Nov 2020 21:16:22 -0800 Subject: [PATCH 0089/1810] RN: Cleanup ViewConfig Types Summary: Cleans up the Flow types for React Native ViewConfig. After this diff, we will have two new canonical types: - `ViewConfig` which is what we get from native and what is registered in the `ReactNativeViewConfigRegistry`. - `PartialViewConfig` which is what we generate statically and augment at runtime before registering with the `ReactNativeViewConfigRegistry`. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25075299 fbshipit-source-id: 4b53927b2db437b615447b711e83db355d0cfa55 --- .../Picker/AndroidDialogPickerViewConfig.js | 4 +- .../Components/Picker/RCTPickerViewConfig.js | 4 +- .../ScrollView/ScrollViewViewConfig.js | 4 +- .../TextInput/AndroidTextInputViewConfig.js | 4 +- .../RCTSinglelineTextInputViewConfig.js | 4 +- Libraries/Image/ImageViewViewConfig.js | 4 +- Libraries/Renderer/shims/ReactNativeTypes.js | 42 ++++++++++--------- .../shims/ReactNativeViewConfigRegistry.js | 18 +++----- .../shims/createReactNativeComponentClass.js | 5 +-- .../Utilities/registerGeneratedViewConfig.js | 32 +------------- .../verifyComponentAttributeEquivalence.js | 8 ++-- 11 files changed, 47 insertions(+), 82 deletions(-) diff --git a/Libraries/Components/Picker/AndroidDialogPickerViewConfig.js b/Libraries/Components/Picker/AndroidDialogPickerViewConfig.js index 1108b8105e37e1..440006163698c2 100644 --- a/Libraries/Components/Picker/AndroidDialogPickerViewConfig.js +++ b/Libraries/Components/Picker/AndroidDialogPickerViewConfig.js @@ -10,7 +10,7 @@ 'use strict'; -import type {GeneratedViewConfig} from '../../Utilities/registerGeneratedViewConfig'; +import type {PartialViewConfig} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; const AndroidDialogPickerViewConfig = { uiViewClassName: 'AndroidDialogPicker', @@ -27,4 +27,4 @@ const AndroidDialogPickerViewConfig = { }, }; -module.exports = (AndroidDialogPickerViewConfig: GeneratedViewConfig); +module.exports = (AndroidDialogPickerViewConfig: PartialViewConfig); diff --git a/Libraries/Components/Picker/RCTPickerViewConfig.js b/Libraries/Components/Picker/RCTPickerViewConfig.js index 448bc2a2b8e5cf..9a5ec9d612dd1b 100644 --- a/Libraries/Components/Picker/RCTPickerViewConfig.js +++ b/Libraries/Components/Picker/RCTPickerViewConfig.js @@ -11,7 +11,7 @@ 'use strict'; import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig'; -import type {ReactNativeBaseComponentViewConfig} from '../../Renderer/shims/ReactNativeTypes'; +import {type ViewConfig} from '../../Renderer/shims/ReactNativeTypes'; const RCTPickerViewConfig = { uiViewClassName: 'RCTPicker', @@ -38,4 +38,4 @@ const RCTPickerViewConfig = { }, }; -module.exports = (RCTPickerViewConfig: ReactNativeBaseComponentViewConfig<>); +module.exports = (RCTPickerViewConfig: ViewConfig); diff --git a/Libraries/Components/ScrollView/ScrollViewViewConfig.js b/Libraries/Components/ScrollView/ScrollViewViewConfig.js index b2a3a9246b343b..c9603784a855a6 100644 --- a/Libraries/Components/ScrollView/ScrollViewViewConfig.js +++ b/Libraries/Components/ScrollView/ScrollViewViewConfig.js @@ -10,7 +10,7 @@ 'use strict'; -import type {GeneratedViewConfig} from '../../Utilities/registerGeneratedViewConfig'; +import type {PartialViewConfig} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; const ScrollViewViewConfig = { uiViewClassName: 'RCTScrollView', @@ -72,4 +72,4 @@ const ScrollViewViewConfig = { }, }; -module.exports = (ScrollViewViewConfig: GeneratedViewConfig); +module.exports = (ScrollViewViewConfig: PartialViewConfig); diff --git a/Libraries/Components/TextInput/AndroidTextInputViewConfig.js b/Libraries/Components/TextInput/AndroidTextInputViewConfig.js index 0853b60a75dc65..170a81526dcf07 100644 --- a/Libraries/Components/TextInput/AndroidTextInputViewConfig.js +++ b/Libraries/Components/TextInput/AndroidTextInputViewConfig.js @@ -11,7 +11,7 @@ 'use strict'; import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig'; -import type {ReactNativeBaseComponentViewConfig} from '../../Renderer/shims/ReactNativeTypes'; +import {type ViewConfig} from '../../Renderer/shims/ReactNativeTypes'; const AndroidTextInputViewConfig = { uiViewClassName: 'AndroidTextInput', @@ -111,4 +111,4 @@ const AndroidTextInputViewConfig = { }, }; -module.exports = (AndroidTextInputViewConfig: ReactNativeBaseComponentViewConfig<>); +module.exports = (AndroidTextInputViewConfig: ViewConfig); diff --git a/Libraries/Components/TextInput/RCTSinglelineTextInputViewConfig.js b/Libraries/Components/TextInput/RCTSinglelineTextInputViewConfig.js index 4836323d1a3615..990bcbb1c271ce 100644 --- a/Libraries/Components/TextInput/RCTSinglelineTextInputViewConfig.js +++ b/Libraries/Components/TextInput/RCTSinglelineTextInputViewConfig.js @@ -11,7 +11,7 @@ 'use strict'; import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig'; -import type {ReactNativeBaseComponentViewConfig} from '../../Renderer/shims/ReactNativeTypes'; +import {type ViewConfig} from '../../Renderer/shims/ReactNativeTypes'; const RCTSinglelineTextInputViewConfig = { uiViewClassName: 'RCTSinglelineTextInputView', @@ -131,4 +131,4 @@ const RCTSinglelineTextInputViewConfig = { }, }; -module.exports = (RCTSinglelineTextInputViewConfig: ReactNativeBaseComponentViewConfig<>); +module.exports = (RCTSinglelineTextInputViewConfig: ViewConfig); diff --git a/Libraries/Image/ImageViewViewConfig.js b/Libraries/Image/ImageViewViewConfig.js index 5870038e97d584..4f974c463c2991 100644 --- a/Libraries/Image/ImageViewViewConfig.js +++ b/Libraries/Image/ImageViewViewConfig.js @@ -11,7 +11,7 @@ 'use strict'; import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; -import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes'; +import {type ViewConfig} from '../Renderer/shims/ReactNativeTypes'; const ImageViewViewConfig = { uiViewClassName: 'RCTImageView', @@ -65,4 +65,4 @@ const ImageViewViewConfig = { }, }; -module.exports = (ImageViewViewConfig: ReactNativeBaseComponentViewConfig<>); +module.exports = (ImageViewViewConfig: ViewConfig); diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 2f9876384b8357..992c762beb13ee 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -33,10 +33,10 @@ export type MeasureLayoutOnSuccessCallback = ( height: number, ) => void; -type AttributeType = +type AttributeType = | true | $ReadOnly<{| - diff?: (arg1: T, arg2: T) => boolean, + diff?: (arg1: T, arg2: T) => boolean, process?: (arg1: any) => any, |}>; @@ -44,38 +44,40 @@ export type AttributeConfiguration< TProps = string, TStyleProps = string, > = $ReadOnly<{ - [propName: TProps]: AttributeType, - style: $ReadOnly<{[propName: TStyleProps]: AttributeType, ...}>, + [propName: TProps]: AttributeType, + style: $ReadOnly<{[propName: TStyleProps]: AttributeType, ...}>, ... }>; -export type ReactNativeBaseComponentViewConfig< - TProps = string, - TStyleProps = string, -> = $ReadOnly<{| +export type ViewConfig = $ReadOnly<{ + Commands?: $ReadOnly<{[commandName: string]: number, ...}>, + NativeProps?: $ReadOnly<{[propName: string]: string, ...}>, baseModuleName?: string, bubblingEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{| - phasedRegistrationNames: $ReadOnly<{| + [eventName: string]: $ReadOnly<{ + phasedRegistrationNames: $ReadOnly<{ captured: string, bubbled: string, - |}>, - |}>, + }>, + }>, ..., }>, - Commands?: $ReadOnly<{[commandName: string]: number, ...}>, directEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{| + [eventName: string]: $ReadOnly<{ registrationName: string, - |}>, + }>, ..., }>, - NativeProps?: $ReadOnly<{[propName: string]: string, ...}>, uiViewClassName: string, - validAttributes: AttributeConfiguration, -|}>; + validAttributes: AttributeConfiguration, +}>; -export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig<>; +export type PartialViewConfig = $ReadOnly<{ + bubblingEventTypes?: $PropertyType, + directEventTypes?: $PropertyType, + uiViewClassName: string, + validAttributes?: $ReadOnly<{[propName: string]: AttributeType}>, +}>; export type NativeMethods = { blur(): void, @@ -182,7 +184,7 @@ export type ReactNativeEventTarget = { node: Object, canonical: { _nativeTag: number, - viewConfig: ReactNativeBaseComponentViewConfig<>, + viewConfig: ViewConfig, currentProps: Object, _internalInstanceHandle: Object, ... diff --git a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js index 2c09ddf3caab10..194a91e31ae624 100644 --- a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +++ b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js @@ -8,16 +8,10 @@ * @flow strict-local */ -/* eslint-disable react-internal/invariant-args */ - 'use strict'; -import type { - ReactNativeBaseComponentViewConfig, - ViewConfigGetter, -} from './ReactNativeTypes'; - -const invariant = require('invariant'); +import {type ViewConfig} from './ReactNativeTypes'; +import invariant from 'invariant'; // Event configs const customBubblingEventTypes: { @@ -42,9 +36,7 @@ exports.customDirectEventTypes = customDirectEventTypes; const viewConfigCallbacks = new Map(); const viewConfigs = new Map(); -function processEventTypes( - viewConfig: ReactNativeBaseComponentViewConfig<>, -): void { +function processEventTypes(viewConfig: ViewConfig): void { const {bubblingEventTypes, directEventTypes} = viewConfig; if (__DEV__) { @@ -82,7 +74,7 @@ function processEventTypes( * A callback is provided to load the view config from UIManager. * The callback is deferred until the view is actually rendered. */ -exports.register = function(name: string, callback: ViewConfigGetter): string { +exports.register = function(name: string, callback: () => ViewConfig): string { invariant( !viewConfigCallbacks.has(name), 'Tried to register two views with the same name %s', @@ -103,7 +95,7 @@ exports.register = function(name: string, callback: ViewConfigGetter): string { * If this is the first time the view has been used, * This configuration will be lazy-loaded from UIManager. */ -exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> { +exports.get = function(name: string): ViewConfig { let viewConfig; if (!viewConfigs.has(name)) { const callback = viewConfigCallbacks.get(name); diff --git a/Libraries/Renderer/shims/createReactNativeComponentClass.js b/Libraries/Renderer/shims/createReactNativeComponentClass.js index 86a758d918b483..f8f4c9284e4c32 100644 --- a/Libraries/Renderer/shims/createReactNativeComponentClass.js +++ b/Libraries/Renderer/shims/createReactNativeComponentClass.js @@ -11,8 +11,7 @@ 'use strict'; import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; - -import type {ViewConfigGetter} from './ReactNativeTypes'; +import {type ViewConfig} from './ReactNativeTypes'; const {register} = ReactNativeViewConfigRegistry; @@ -26,7 +25,7 @@ const {register} = ReactNativeViewConfigRegistry; */ const createReactNativeComponentClass = function( name: string, - callback: ViewConfigGetter, + callback: () => ViewConfig, ): string { return register(name, callback); }; diff --git a/Libraries/Utilities/registerGeneratedViewConfig.js b/Libraries/Utilities/registerGeneratedViewConfig.js index aabcb4989bf2e7..ea25a644421d44 100644 --- a/Libraries/Utilities/registerGeneratedViewConfig.js +++ b/Libraries/Utilities/registerGeneratedViewConfig.js @@ -10,43 +10,15 @@ 'use strict'; +import {type PartialViewConfig} from '../Renderer/shims/ReactNativeTypes'; import ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConfigRegistry'; import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes'; import verifyComponentAttributeEquivalence from './verifyComponentAttributeEquivalence'; -export type GeneratedViewConfig = { - uiViewClassName: string, - bubblingEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{| - phasedRegistrationNames: $ReadOnly<{| - captured: string, - bubbled: string, - |}>, - |}>, - ..., - }>, - directEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{| - registrationName: string, - |}>, - ..., - }>, - validAttributes?: { - [propName: string]: - | true - | $ReadOnly<{| - diff?: (arg1: any, arg2: any) => boolean, - process?: (arg1: any) => any, - |}>, - ..., - }, - ... -}; - function registerGeneratedViewConfig( componentName: string, - viewConfig: GeneratedViewConfig, + viewConfig: PartialViewConfig, ) { const staticViewConfig = { uiViewClassName: componentName, diff --git a/Libraries/Utilities/verifyComponentAttributeEquivalence.js b/Libraries/Utilities/verifyComponentAttributeEquivalence.js index bb3e235111674e..acd459c1e12650 100644 --- a/Libraries/Utilities/verifyComponentAttributeEquivalence.js +++ b/Libraries/Utilities/verifyComponentAttributeEquivalence.js @@ -11,7 +11,7 @@ 'use strict'; import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; -import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes'; +import {type ViewConfig} from '../Renderer/shims/ReactNativeTypes'; const IGNORED_KEYS = ['transform', 'hitSlop']; @@ -39,8 +39,8 @@ const IGNORED_KEYS = ['transform', 'hitSlop']; * years from now... */ export default function verifyComponentAttributeEquivalence( - nativeViewConfig: ReactNativeBaseComponentViewConfig<>, - staticViewConfig: ReactNativeBaseComponentViewConfig<>, + nativeViewConfig: ViewConfig, + staticViewConfig: ViewConfig, ) { for (const prop of [ 'validAttributes', @@ -101,7 +101,7 @@ export function lefthandObjectDiff(leftObj: Object, rightObj: Object): Object { } export function getConfigWithoutViewProps( - viewConfig: ReactNativeBaseComponentViewConfig<>, + viewConfig: ViewConfig, propName: string, ): {...} { if (!viewConfig[propName]) { From 5b527fefcbd98be8dccc6e47f4f726f5fec6ebcf Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Wed, 18 Nov 2020 21:16:22 -0800 Subject: [PATCH 0090/1810] RN: Fix `registerGeneratedViewConfig` Types Summary: Fixes types in `registerGeneratedViewConfig` and also removes some unnecessary hacks for the `ReactNativeViewViewConfig` type. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25076608 fbshipit-source-id: 5cb2060e11db598b42fbb7f2f8aecfd7f4b262ef --- .../View/ReactNativeViewViewConfig.js | 24 +++++++++++-------- Libraries/Renderer/shims/ReactNativeTypes.js | 4 +++- .../Utilities/registerGeneratedViewConfig.js | 24 +++++++++---------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Libraries/Components/View/ReactNativeViewViewConfig.js b/Libraries/Components/View/ReactNativeViewViewConfig.js index 4d6f0dd0a6ce10..95cfa81733b6a8 100644 --- a/Libraries/Components/View/ReactNativeViewViewConfig.js +++ b/Libraries/Components/View/ReactNativeViewViewConfig.js @@ -9,15 +9,17 @@ */ 'use strict'; + +import {type ViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid'; import {Platform} from 'react-native'; -const ReactNativeViewConfig = { +const ReactNativeViewConfig: ViewConfig = { uiViewClassName: 'RCTView', baseModuleName: null, Manager: 'ViewManager', - Commands: ({}: {...}), - Constants: ({}: {...}), + Commands: {}, + Constants: {}, bubblingEventTypes: { ...ReactNativeViewViewConfigAndroid.bubblingEventTypes, topBlur: { @@ -171,7 +173,7 @@ const ReactNativeViewConfig = { flexShrink: true, flexWrap: true, height: true, - hitSlop: {diff: (require('../../Utilities/differ/insetsDiffer'): any)}, + hitSlop: {diff: require('../../Utilities/differ/insetsDiffer')}, importantForAccessibility: true, justifyContent: true, left: true, @@ -322,9 +324,10 @@ const ReactNativeViewConfig = { textTransform: true, tintColor: {process: require('../../StyleSheet/processColor')}, top: true, - transform: ((Platform.OS === 'ios' - ? {diff: require('../../Utilities/differ/matricesDiffer')} - : {process: require('../../StyleSheet/processTransform')}): any), + transform: + Platform.OS === 'ios' + ? {diff: require('../../Utilities/differ/matricesDiffer')} + : {process: require('../../StyleSheet/processTransform')}, transformMatrix: true, translateX: true, translateY: true, @@ -334,9 +337,10 @@ const ReactNativeViewConfig = { }, testID: true, top: true, - transform: ((Platform.OS === 'ios' - ? {diff: require('../../Utilities/differ/matricesDiffer')} - : {process: require('../../StyleSheet/processTransform')}): any), + transform: + Platform.OS === 'ios' + ? {diff: require('../../Utilities/differ/matricesDiffer')} + : {process: require('../../StyleSheet/processTransform')}, translateX: true, translateY: true, width: true, diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 992c762beb13ee..922585d4c5c302 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -51,8 +51,10 @@ export type AttributeConfiguration< export type ViewConfig = $ReadOnly<{ Commands?: $ReadOnly<{[commandName: string]: number, ...}>, + Constants?: $ReadOnly<{[name: string]: mixed, ...}>, + Manager?: string, NativeProps?: $ReadOnly<{[propName: string]: string, ...}>, - baseModuleName?: string, + baseModuleName?: ?string, bubblingEventTypes?: $ReadOnly<{ [eventName: string]: $ReadOnly<{ phasedRegistrationNames: $ReadOnly<{ diff --git a/Libraries/Utilities/registerGeneratedViewConfig.js b/Libraries/Utilities/registerGeneratedViewConfig.js index ea25a644421d44..b8acdb716c4a0a 100644 --- a/Libraries/Utilities/registerGeneratedViewConfig.js +++ b/Libraries/Utilities/registerGeneratedViewConfig.js @@ -23,26 +23,26 @@ function registerGeneratedViewConfig( const staticViewConfig = { uiViewClassName: componentName, Commands: {}, - /* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.122.0 was deployed. To see the error, delete - * this comment and run Flow. */ + // $FlowFixMe[cannot-spread-indexer] Properties can be overridden. bubblingEventTypes: { ...ReactNativeViewViewConfig.bubblingEventTypes, - ...(viewConfig.bubblingEventTypes || {}), + ...(viewConfig.bubblingEventTypes ?? {}: $NonMaybeType< + $PropertyType, + >), }, - /* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.122.0 was deployed. To see the error, delete - * this comment and run Flow. */ + // $FlowFixMe[cannot-spread-indexer] Properties can be overridden. directEventTypes: { ...ReactNativeViewViewConfig.directEventTypes, - ...(viewConfig.directEventTypes || {}), + ...(viewConfig.directEventTypes ?? {}: $NonMaybeType< + $PropertyType, + >), }, - /* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.122.0 was deployed. To see the error, delete - * this comment and run Flow. */ + // $FlowFixMe[cannot-spread-indexer] Properties can be overridden. validAttributes: { ...ReactNativeViewViewConfig.validAttributes, - ...(viewConfig.validAttributes || {}), + ...(viewConfig.validAttributes ?? {}: $NonMaybeType< + $PropertyType, + >), }, }; From 003d72d80b6da71759bd39f3802da8eb9fb1c38d Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Wed, 18 Nov 2020 21:24:07 -0800 Subject: [PATCH 0091/1810] Provide default device scale Summary: Changelog: [Internal][Fixed] - Provide a default device scale Reviewed By: kacieb Differential Revision: D24975788 fbshipit-source-id: 5f2158d7b704713b6a759734943e52228c9cafbc --- Libraries/Image/AssetSourceResolver.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Image/AssetSourceResolver.js b/Libraries/Image/AssetSourceResolver.js index 5ebd97a3d0298f..6c97f008e1bb21 100644 --- a/Libraries/Image/AssetSourceResolver.js +++ b/Libraries/Image/AssetSourceResolver.js @@ -158,7 +158,10 @@ class AssetSourceResolver { }; } - static pickScale(scales: Array, deviceScale: number): number { + static pickScale(scales: Array, deviceScale?: number): number { + if (deviceScale == null) { + deviceScale = PixelRatio.get(); + } // Packager guarantees that `scales` array is sorted for (let i = 0; i < scales.length; i++) { if (scales[i] >= deviceScale) { From de92e7405d48700ab2f1bf34f80a794b497f8c7b Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 02:49:06 -0800 Subject: [PATCH 0092/1810] RN: Refactor `ViewConfig` Inflation Summary: Refactors the conversion of a `PartialViewConfig` into a `ViewConfig` to a separate function so that it can be reused. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25084469 fbshipit-source-id: 8a7f53ff2c68860697c791c37a6abbfd3213a0f9 --- Libraries/NativeComponent/ViewConfig.js | 50 +++++++++++++++++++ Libraries/Renderer/shims/ReactNativeTypes.js | 19 ++++--- .../Utilities/registerGeneratedViewConfig.js | 30 ++--------- 3 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 Libraries/NativeComponent/ViewConfig.js diff --git a/Libraries/NativeComponent/ViewConfig.js b/Libraries/NativeComponent/ViewConfig.js new file mode 100644 index 00000000000000..d04535a4096736 --- /dev/null +++ b/Libraries/NativeComponent/ViewConfig.js @@ -0,0 +1,50 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; +import type { + PartialViewConfig, + ViewConfig, +} from '../Renderer/shims/ReactNativeTypes'; + +/** + * Creates a complete `ViewConfig` from a `PartialViewConfig`. + */ +export function createViewConfig( + partialViewConfig: PartialViewConfig, +): ViewConfig { + return { + uiViewClassName: partialViewConfig.uiViewClassName, + Commands: {}, + bubblingEventTypes: composeIndexers( + ReactNativeViewViewConfig.bubblingEventTypes, + partialViewConfig.bubblingEventTypes, + ), + directEventTypes: composeIndexers( + ReactNativeViewViewConfig.directEventTypes, + partialViewConfig.directEventTypes, + ), + validAttributes: composeIndexers( + // $FlowFixMe[incompatible-call] `style` property confuses Flow. + ReactNativeViewViewConfig.validAttributes, + // $FlowFixMe[incompatible-call] `style` property confuses Flow. + partialViewConfig.validAttributes, + ), + }; +} + +function composeIndexers( + maybeA: ?{+[string]: T}, + maybeB: ?{+[string]: T}, +): {+[string]: T} { + return maybeA == null || maybeB == null + ? maybeA ?? maybeB ?? {} + : {...maybeA, ...maybeB}; +} diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 922585d4c5c302..86cb8908473859 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -40,12 +40,15 @@ type AttributeType = process?: (arg1: any) => any, |}>; -export type AttributeConfiguration< - TProps = string, - TStyleProps = string, -> = $ReadOnly<{ - [propName: TProps]: AttributeType, - style: $ReadOnly<{[propName: TStyleProps]: AttributeType, ...}>, +type AttributeConfiguration = $ReadOnly<{ + [propName: string]: AttributeType, + style: $ReadOnly<{[propName: string]: AttributeType, ...}>, + ... +}>; + +type PartialAttributeConfiguration = $ReadOnly<{ + [propName: string]: AttributeType, + style?: $ReadOnly<{[propName: string]: AttributeType, ...}>, ... }>; @@ -71,14 +74,14 @@ export type ViewConfig = $ReadOnly<{ ..., }>, uiViewClassName: string, - validAttributes: AttributeConfiguration, + validAttributes: AttributeConfiguration, }>; export type PartialViewConfig = $ReadOnly<{ bubblingEventTypes?: $PropertyType, directEventTypes?: $PropertyType, uiViewClassName: string, - validAttributes?: $ReadOnly<{[propName: string]: AttributeType}>, + validAttributes?: PartialAttributeConfiguration, }>; export type NativeMethods = { diff --git a/Libraries/Utilities/registerGeneratedViewConfig.js b/Libraries/Utilities/registerGeneratedViewConfig.js index b8acdb716c4a0a..cb8449590a46d8 100644 --- a/Libraries/Utilities/registerGeneratedViewConfig.js +++ b/Libraries/Utilities/registerGeneratedViewConfig.js @@ -10,41 +10,17 @@ 'use strict'; +import {createViewConfig} from '../NativeComponent/ViewConfig'; import {type PartialViewConfig} from '../Renderer/shims/ReactNativeTypes'; import ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConfigRegistry'; -import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes'; import verifyComponentAttributeEquivalence from './verifyComponentAttributeEquivalence'; function registerGeneratedViewConfig( componentName: string, - viewConfig: PartialViewConfig, + partialViewConfig: PartialViewConfig, ) { - const staticViewConfig = { - uiViewClassName: componentName, - Commands: {}, - // $FlowFixMe[cannot-spread-indexer] Properties can be overridden. - bubblingEventTypes: { - ...ReactNativeViewViewConfig.bubblingEventTypes, - ...(viewConfig.bubblingEventTypes ?? {}: $NonMaybeType< - $PropertyType, - >), - }, - // $FlowFixMe[cannot-spread-indexer] Properties can be overridden. - directEventTypes: { - ...ReactNativeViewViewConfig.directEventTypes, - ...(viewConfig.directEventTypes ?? {}: $NonMaybeType< - $PropertyType, - >), - }, - // $FlowFixMe[cannot-spread-indexer] Properties can be overridden. - validAttributes: { - ...ReactNativeViewViewConfig.validAttributes, - ...(viewConfig.validAttributes ?? {}: $NonMaybeType< - $PropertyType, - >), - }, - }; + const staticViewConfig = createViewConfig(partialViewConfig); ReactNativeViewConfigRegistry.register(componentName, () => { if (!global.RN$Bridgeless) { From f6b8736b090185da936eb979621fac5d2a03e525 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 02:49:06 -0800 Subject: [PATCH 0093/1810] RN: Update ViewConfig for ScrollView Summary: Updates `ReactScrollViewManager` and the `ViewConfig` for `ScrollView` so that they are equivalent. - `inverted` was missing. - `contentOffset` was missing differ on Android. (However, there does not seem to be any perceivable behavior difference besides the native `ViewConfig` being different.) Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25084470 fbshipit-source-id: 8bea3b7a692c1038819a4147b174583a4faa71e9 --- .../Components/ScrollView/ScrollViewViewConfig.js | 15 +++++++++++---- .../ReactNative/getNativeComponentAttributes.js | 3 ++- .../views/scroll/ReactScrollViewManager.java | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollViewViewConfig.js b/Libraries/Components/ScrollView/ScrollViewViewConfig.js index c9603784a855a6..19818e0fae8440 100644 --- a/Libraries/Components/ScrollView/ScrollViewViewConfig.js +++ b/Libraries/Components/ScrollView/ScrollViewViewConfig.js @@ -10,7 +10,7 @@ 'use strict'; -import type {PartialViewConfig} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; const ScrollViewViewConfig = { uiViewClassName: 'RCTScrollView', @@ -28,15 +28,22 @@ const ScrollViewViewConfig = { bouncesZoom: true, canCancelContentTouches: true, centerContent: true, - contentInset: {diff: require('../../Utilities/differ/pointsDiffer')}, - contentOffset: {diff: require('../../Utilities/differ/pointsDiffer')}, + contentInset: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, + contentOffset: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, contentInsetAdjustmentBehavior: true, decelerationRate: true, directionalLockEnabled: true, disableIntervalMomentum: true, - endFillColor: {process: require('../../StyleSheet/processColor')}, + endFillColor: { + process: require('../../StyleSheet/processColor'), + }, fadingEdgeLength: true, indicatorStyle: true, + inverted: true, keyboardDismissMode: true, maintainVisibleContentPosition: true, maximumZoomScale: true, diff --git a/Libraries/ReactNative/getNativeComponentAttributes.js b/Libraries/ReactNative/getNativeComponentAttributes.js index b31603098a5dbf..732e9b6745cfe7 100644 --- a/Libraries/ReactNative/getNativeComponentAttributes.js +++ b/Libraries/ReactNative/getNativeComponentAttributes.js @@ -154,7 +154,8 @@ function getDifferForType( case 'UIEdgeInsets': return insetsDiffer; // Android Types - // (not yet implemented) + case 'Point': + return pointsDiffer; } return null; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index 23ad78a5a880a8..c9733b096970ac 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -305,7 +305,7 @@ public void setFadingEdgeLength(ReactScrollView view, int value) { } } - @ReactProp(name = "contentOffset") + @ReactProp(name = "contentOffset", customType = "Point") public void setContentOffset(ReactScrollView view, ReadableMap value) { if (value != null) { double x = value.hasKey("x") ? value.getDouble("x") : 0; From c797fcf5aa674ea8752923eca3f8a8f0d84419f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 19 Nov 2020 04:48:07 -0800 Subject: [PATCH 0094/1810] chore: Bump CLI to ^5.0.1-alpha.0 (#30420) Summary: Upgrading CLI to latest. This diff is intended to be cherry-picked to 0.64. cc grabbou kelset alloy ## Changelog [Internal] [Changed] - Bump CLI to ^5.0.1-alpha.0 Pull Request resolved: https://github.com/facebook/react-native/pull/30420 Test Plan: None Reviewed By: MichaReiser Differential Revision: D25063261 Pulled By: cpojer fbshipit-source-id: e1788fd40db2b00daaf888e7b2afaf708ade5451 --- package.json | 6 +- yarn.lock | 944 ++++++++++++++++----------------------------------- 2 files changed, 287 insertions(+), 663 deletions(-) diff --git a/package.json b/package.json index 5106b2bddb4f27..51e8ae3b019b3b 100644 --- a/package.json +++ b/package.json @@ -87,9 +87,9 @@ }, "dependencies": { "@jest/create-cache-key-function": "^26.5.0", - "@react-native-community/cli": "^4.13.0", - "@react-native-community/cli-platform-android": "^4.13.0", - "@react-native-community/cli-platform-ios": "^4.13.0", + "@react-native-community/cli": "^5.0.1-alpha.0", + "@react-native-community/cli-platform-android": "^5.0.1-alpha.0", + "@react-native-community/cli-platform-ios": "^5.0.1-alpha.0", "@react-native/assets": "1.0.0", "@react-native/normalize-color": "1.0.0", "@react-native/polyfills": "1.0.0", diff --git a/yarn.lock b/yarn.lock index 49bdff9a976e14..eb210874e90c0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -250,13 +250,6 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.5.tgz#b4af32ddd473c0bfa643bd7ff0728b8e71b81ea0" integrity sha512-FVM6RZQ0mn2KCf1VUED7KepYeUWoVShczewOCfm3nzoBybaih51h+sYVVGthW9M6lPByEPTQf+xm27PBdlpwmQ== -"@babel/plugin-external-helpers@^7.0.0": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-external-helpers/-/plugin-external-helpers-7.12.1.tgz#df474775860b3b8bdfeaedd45596cd2c7f36a2be" - integrity sha512-5VBqan0daXhDSRjrq2miABuELRwWJWFdM42Jvs/CDuhp+Es+fW+ISA5l+co8d+9oN3WLz/N3VvzyeseL3AvjxA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.1.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de" @@ -752,42 +745,17 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@hapi/address@2.x.x": - version "2.0.0" - resolved "https://registry.npmjs.org/@hapi/address/-/address-2.0.0.tgz#9f05469c88cb2fd3dcd624776b54ee95c312126a" - integrity sha512-mV6T0IYqb0xL1UALPFplXYQmR0twnXG0M6jUswpquqT2sD12BOiCiLy3EvMp/Fy7s3DZElC4/aPjEjo2jeZpvw== - -"@hapi/hoek@6.x.x": - version "6.2.4" - resolved "https://registry.npmjs.org/@hapi/hoek/-/hoek-6.2.4.tgz#4b95fbaccbfba90185690890bdf1a2fbbda10595" - integrity sha512-HOJ20Kc93DkDVvjwHyHawPwPkX44sIrbXazAUDiUXaY2R9JwQGo2PhFfnQtdrsIe4igjG2fPgMra7NYw7qhy0A== - -"@hapi/hoek@8.x.x": - version "8.0.2" - resolved "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.0.2.tgz#f63a5ff00e891a4e7aa98f11119f9515c6672032" - integrity sha512-O6o6mrV4P65vVccxymuruucb+GhP2zl9NLCG8OdoFRS8BEGw3vwpPp20wpAtpbQQxz1CEUtmxJGgWhjq1XA3qw== - -"@hapi/joi@^15.0.3": - version "15.1.0" - resolved "https://registry.npmjs.org/@hapi/joi/-/joi-15.1.0.tgz#940cb749b5c55c26ab3b34ce362e82b6162c8e7a" - integrity sha512-n6kaRQO8S+kepUTbXL9O/UOL788Odqs38/VOfoCrATDtTvyfiO3fgjlSRaNkHabpTLgM7qru9ifqXlXbXk8SeQ== - dependencies: - "@hapi/address" "2.x.x" - "@hapi/hoek" "6.x.x" - "@hapi/marker" "1.x.x" - "@hapi/topo" "3.x.x" - -"@hapi/marker@1.x.x": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@hapi/marker/-/marker-1.0.0.tgz#65b0b2b01d1be06304886ce9b4b77b1bfb21a769" - integrity sha512-JOfdekTXnJexfE8PyhZFyHvHjt81rBFSAbTIRAhF2vv/2Y1JzoKsGqxH/GpZJoF7aEfYok8JVcAHmSz1gkBieA== +"@hapi/hoek@^9.0.0": + version "9.1.0" + resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6" + integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw== -"@hapi/topo@3.x.x": - version "3.1.2" - resolved "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.2.tgz#57cc1317be1a8c5f47c124f9b0e3c49cd78424d2" - integrity sha512-r+aumOqJ5QbD6aLPJWqVjMAPsx5pZKz+F5yPqXZ/WWG9JTtHbQqlzrJoknJ0iJxLj9vlXtmpSdjlkszseeG8OA== +"@hapi/topo@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" + integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== dependencies: - "@hapi/hoek" "8.x.x" + "@hapi/hoek" "^9.0.0" "@istanbuljs/load-nyc-config@^1.0.0": version "1.0.0" @@ -804,15 +772,6 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd" integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw== -"@jest/console@^24.7.1": - version "24.7.1" - resolved "https://registry.yarnpkg.com/@jest/console/-/console-24.7.1.tgz#32a9e42535a97aedfe037e725bd67e954b459545" - integrity sha512-iNhtIy2M8bXlAOULWVTUxmnelTLFneTNEkHCgPmgd+zNwy9zVddJ6oS5rZ9iwoscNdT5mMwUd0C51v/fSlzItg== - dependencies: - "@jest/source-map" "^24.3.0" - chalk "^2.0.1" - slash "^2.0.0" - "@jest/console@^26.5.2": version "26.5.2" resolved "https://registry.yarnpkg.com/@jest/console/-/console-26.5.2.tgz#94fc4865b1abed7c352b5e21e6c57be4b95604a6" @@ -874,15 +833,6 @@ "@types/node" "*" jest-mock "^26.5.2" -"@jest/fake-timers@^24.8.0": - version "24.8.0" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-24.8.0.tgz#2e5b80a4f78f284bcb4bd5714b8e10dd36a8d3d1" - integrity sha512-2M4d5MufVXwi6VzZhJ9f5S/wU4ud2ck0kxPof1Iz3zWx6Y+V2eJrES9jEktB6O3o/oEyk+il/uNu9PvASjWXQw== - dependencies: - "@jest/types" "^24.8.0" - jest-message-util "^24.8.0" - jest-mock "^24.8.0" - "@jest/fake-timers@^26.5.2": version "26.5.2" resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-26.5.2.tgz#1291ac81680ceb0dc7daa1f92c059307eea6400a" @@ -936,15 +886,6 @@ optionalDependencies: node-notifier "^8.0.0" -"@jest/source-map@^24.3.0": - version "24.3.0" - resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-24.3.0.tgz#563be3aa4d224caf65ff77edc95cd1ca4da67f28" - integrity sha512-zALZt1t2ou8le/crCeeiRYzvdnTzaIlpOWaet45lNSqNJUnXbppUUFR4ZUAlzgDmKee4Q5P/tKXypI1RiHwgag== - dependencies: - callsites "^3.0.0" - graceful-fs "^4.1.15" - source-map "^0.6.0" - "@jest/source-map@^26.5.0": version "26.5.0" resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-26.5.0.tgz#98792457c85bdd902365cd2847b58fff05d96367" @@ -954,15 +895,6 @@ graceful-fs "^4.2.4" source-map "^0.6.0" -"@jest/test-result@^24.8.0": - version "24.8.0" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-24.8.0.tgz#7675d0aaf9d2484caa65e048d9b467d160f8e9d3" - integrity sha512-+YdLlxwizlfqkFDh7Mc7ONPQAhA4YylU1s529vVM1rsf67vGZH/2GGm5uO8QzPeVyaVMobCQ7FTxl38QrKRlng== - dependencies: - "@jest/console" "^24.7.1" - "@jest/types" "^24.8.0" - "@types/istanbul-lib-coverage" "^2.0.0" - "@jest/test-result@^26.5.2": version "26.5.2" resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-26.5.2.tgz#cc1a44cfd4db2ecee3fb0bc4e9fe087aa54b5230" @@ -1005,7 +937,7 @@ source-map "^0.6.1" write-file-atomic "^3.0.0" -"@jest/types@^24.8.0", "@jest/types@^24.9.0": +"@jest/types@^24.9.0": version "24.9.0" resolved "https://registry.yarnpkg.com/@jest/types/-/types-24.9.0.tgz#63cb26cb7500d069e5a389441a7c6ab5e909fc59" integrity sha512-XKK7ze1apu5JWQ5eZjHITP66AX+QsLlbaJRBGYr8pNzwcAE2JVkwnf0yqjHTsDRcjR0mujy/NmZMXw5kl+kGBw== @@ -1014,16 +946,6 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@jest/types@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-25.5.0.tgz#4d6a4793f7b9599fc3680877b856a97dbccf2a9d" - integrity sha512-OXD0RgQ86Tu3MazKo8bnrkDRaDXXMGUqd+kTtLtK1Zb7CRzQcaSRPPPV37SvYTdevXEBVxe0HXylEjs8ibkmCw== - dependencies: - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^1.1.1" - "@types/yargs" "^15.0.0" - chalk "^3.0.0" - "@jest/types@^26.5.2": version "26.5.2" resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.5.2.tgz#44c24f30c8ee6c7f492ead9ec3f3c62a5289756d" @@ -1035,30 +957,41 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@react-native-community/cli-debugger-ui@^4.9.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-4.9.0.tgz#4177764ba69243c97aa26829d59d9501acb2bd71" - integrity sha512-fBFGamHm4VUrDqkBGnsrwQL8OC6Om7K6EBQb4xj0nWekpXt1HSa3ScylYHTTWwYcpRf9htGMRGiv4dQDY/odAw== +"@jest/types@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" + integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^15.0.0" + chalk "^4.0.0" + +"@react-native-community/cli-debugger-ui@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-5.0.1-alpha.0.tgz#9e47a8d62e7e2409627e1bbbf56afea71477bd3c" + integrity sha512-ZXEi3RdehQJGS9MOA60X/QnOkAIStDRL+goviBFBn9u/EeE6Ea3jxDsFnG91SAlT16ZpuH9hxDiKi8hgEbxDuQ== dependencies: serve-static "^1.13.1" -"@react-native-community/cli-hermes@^4.13.0": - version "4.13.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-4.13.0.tgz#6243ed9c709dad5e523f1ccd7d21066b32f2899d" - integrity sha512-oG+w0Uby6rSGsUkJGLvMQctZ5eVRLLfhf84lLyz942OEDxFRa9U19YJxOe9FmgCKtotbYiM3P/XhK+SVCuerPQ== +"@react-native-community/cli-hermes@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-5.0.1-alpha.0.tgz#f3d36fa36e7783d45f36560063faa59f8f279251" + integrity sha512-2fSk8X3YdjAQOa0tZizSxe2e4onqUpsfLFW1SByym+dYTXvM8hoCIkQJa5/OBvlknrWEiepLB8Ux2O5rW/1Rkw== dependencies: - "@react-native-community/cli-platform-android" "^4.13.0" - "@react-native-community/cli-tools" "^4.13.0" + "@react-native-community/cli-platform-android" "^5.0.1-alpha.0" + "@react-native-community/cli-tools" "^5.0.1-alpha.0" chalk "^3.0.0" hermes-profile-transformer "^0.0.6" ip "^1.1.5" -"@react-native-community/cli-platform-android@^4.13.0": - version "4.13.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-4.13.0.tgz#922681ec82ee1aadd993598b814df1152118be02" - integrity sha512-3i8sX8GklEytUZwPnojuoFbCjIRzMugCdzDIdZ9UNmi/OhD4/8mLGO0dgXfT4sMWjZwu3qjy45sFfk2zOAgHbA== +"@react-native-community/cli-platform-android@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-5.0.1-alpha.0.tgz#812b646ce5a690479aa9adc530edea288b6b8fd6" + integrity sha512-AQaBV3A5f6sYjfWTkvEbOOPoIj2e9cy//CVQxq+lIgiNXIl1E+48czYr2qoHY7U407H318jmdrUn6mgSHMVQEQ== dependencies: - "@react-native-community/cli-tools" "^4.13.0" + "@react-native-community/cli-tools" "^5.0.1-alpha.0" chalk "^3.0.0" execa "^1.0.0" fs-extra "^8.1.0" @@ -1069,12 +1002,12 @@ slash "^3.0.0" xmldoc "^1.1.2" -"@react-native-community/cli-platform-ios@^4.13.0": - version "4.13.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-4.13.0.tgz#a738915c68cac86df54e578b59a1311ea62b1aef" - integrity sha512-6THlTu8zp62efkzimfGr3VIuQJ2514o+vScZERJCV1xgEi8XtV7mb/ZKt9o6Y9WGxKKkc0E0b/aVAtgy+L27CA== +"@react-native-community/cli-platform-ios@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-5.0.1-alpha.0.tgz#a1c37f2c630819d2d1520621e0f7665ec6a751ba" + integrity sha512-gcWpxB2k5X3Gl+DhrKDe7eegzeJvIOW/tM4p4zX4OO19/osM7glSlLNj+X5WVVB+XkFqm9W99NrasVfqGyFcdg== dependencies: - "@react-native-community/cli-tools" "^4.13.0" + "@react-native-community/cli-tools" "^5.0.1-alpha.0" chalk "^3.0.0" glob "^7.1.3" js-yaml "^3.13.1" @@ -1082,24 +1015,25 @@ plist "^3.0.1" xcode "^2.0.0" -"@react-native-community/cli-server-api@^4.13.0": - version "4.13.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-4.13.0.tgz#ef0e53fe0edc7356d62bca725ca47cb368f748a5" - integrity sha512-ER138ChLc1YYX7j9yE6fDm4DdNdsHThr+pla/B6iZoKje1r7TwymDdKaUvOsYalG7sWG9glW3bofcCq+Yh0Dvw== +"@react-native-community/cli-server-api@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-5.0.1-alpha.0.tgz#b46cc0a0d626e72682fbf9451e9d3fc2ceb3a4be" + integrity sha512-bK7DUUKzWglsCaIvTko8kBPC/El6vRDTayEGTcFf9O1VcfYJqykLhgI3seJDqOFAC+PGooyTvKisEotmtTk3tA== dependencies: - "@react-native-community/cli-debugger-ui" "^4.9.0" - "@react-native-community/cli-tools" "^4.13.0" + "@react-native-community/cli-debugger-ui" "^5.0.1-alpha.0" + "@react-native-community/cli-tools" "^5.0.1-alpha.0" compression "^1.7.1" connect "^3.6.5" errorhandler "^1.5.0" - pretty-format "^25.1.0" + nocache "^2.1.0" + pretty-format "^26.6.2" serve-static "^1.13.1" ws "^1.1.0" -"@react-native-community/cli-tools@^4.13.0": - version "4.13.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-4.13.0.tgz#b406463d33af16cedc4305a9a9257ed32845cf1b" - integrity sha512-s4f489h5+EJksn4CfheLgv5PGOM0CDmK1UEBLw2t/ncWs3cW2VI7vXzndcd/WJHTv3GntJhXDcJMuL+Z2IAOgg== +"@react-native-community/cli-tools@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-5.0.1-alpha.0.tgz#e88c3ff6a2f33a39b6943323c29315372ebf0c57" + integrity sha512-rsX9c3XxBvsOqVhEGxibLesWbOORnBBU2UVDUYRcGqkj2Err5ltcl4/98PvbCeQhTnh5h2e7nsm/SCEfbaYUtg== dependencies: chalk "^3.0.0" lodash "^4.17.15" @@ -1108,22 +1042,23 @@ open "^6.2.0" shell-quote "1.6.1" -"@react-native-community/cli-types@^4.10.1": - version "4.10.1" - resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-4.10.1.tgz#d68a2dcd1649d3b3774823c64e5e9ce55bfbe1c9" - integrity sha512-ael2f1onoPF3vF7YqHGWy7NnafzGu+yp88BbFbP0ydoCP2xGSUzmZVw0zakPTC040Id+JQ9WeFczujMkDy6jYQ== - -"@react-native-community/cli@^4.13.0": - version "4.13.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-4.13.0.tgz#04d5032f9b2b423c61ceef6be83b1bcc8a37db75" - integrity sha512-R+1VehIQ6VTLf+e7YOwzJk0F9tstfeSC4xy7oT6GSgB3FnXbTJGHFUp4siyO68Ae/gzGqt8SiUO145teWkP+ZA== - dependencies: - "@hapi/joi" "^15.0.3" - "@react-native-community/cli-debugger-ui" "^4.9.0" - "@react-native-community/cli-hermes" "^4.13.0" - "@react-native-community/cli-server-api" "^4.13.0" - "@react-native-community/cli-tools" "^4.13.0" - "@react-native-community/cli-types" "^4.10.1" +"@react-native-community/cli-types@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-5.0.1-alpha.0.tgz#962e6e61d259b10282703718a32740758540ee5b" + integrity sha512-asx1AhZSx1w8slT1K0RwcSz/+Q5/bYRIYfa8eVCZlQqsGCeELajPIgayLmSNlnQT8JUWTB1caR3XX5vD3ab/mg== + dependencies: + ora "^3.4.0" + +"@react-native-community/cli@^5.0.1-alpha.0": + version "5.0.1-alpha.0" + resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-5.0.1-alpha.0.tgz#c05652b66760aff0948e490a06bdac06ab60f12f" + integrity sha512-WmKGtiKDpMB5vbH2CQ03TBiMrvRTq6JWZ8IqqSijKQ8DHoB6XFc+96yWRRu7aMCymy1kHhbVd214r4n+AjH2fg== + dependencies: + "@react-native-community/cli-debugger-ui" "^5.0.1-alpha.0" + "@react-native-community/cli-hermes" "^5.0.1-alpha.0" + "@react-native-community/cli-server-api" "^5.0.1-alpha.0" + "@react-native-community/cli-tools" "^5.0.1-alpha.0" + "@react-native-community/cli-types" "^5.0.1-alpha.0" chalk "^3.0.0" command-exists "^1.2.8" commander "^2.19.0" @@ -1136,18 +1071,20 @@ glob "^7.1.3" graceful-fs "^4.1.3" inquirer "^3.0.6" + joi "^17.2.1" leven "^3.1.0" lodash "^4.17.15" - metro "^0.58.0" - metro-config "^0.58.0" - metro-core "^0.58.0" - metro-react-native-babel-transformer "^0.58.0" - metro-resolver "^0.58.0" + metro "^0.64.0" + metro-config "^0.64.0" + metro-core "^0.64.0" + metro-react-native-babel-transformer "^0.64.0" + metro-resolver "^0.64.0" + metro-runtime "^0.64.0" minimist "^1.2.0" mkdirp "^0.5.1" node-stream-zip "^1.9.1" ora "^3.4.0" - pretty-format "^25.2.0" + pretty-format "^26.6.2" semver "^6.3.0" serve-static "^1.13.1" strip-ansi "^5.2.0" @@ -1158,6 +1095,23 @@ version "2.0.2" resolved "https://registry.yarnpkg.com/@reactions/component/-/component-2.0.2.tgz#40f8c1c2c37baabe57a0c944edb9310dc1ec6642" +"@sideway/address@^4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.0.tgz#0b301ada10ac4e0e3fa525c90615e0b61a72b78d" + integrity sha512-wAH/JYRXeIFQRsxerIuLjgUu2Xszam+O5xKeatJ4oudShOOirfmsQ1D6LL54XOU2tizpCYku+s1wmU0SYdpoSA== + dependencies: + "@hapi/hoek" "^9.0.0" + +"@sideway/formula@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c" + integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg== + +"@sideway/pinpoint@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" + integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== + "@sinonjs/commons@^1.7.0": version "1.7.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.2.tgz#505f55c74e0272b43f6c52d81946bed7058fc0e2" @@ -1259,11 +1213,6 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.0.tgz#dc85454b953178cc6043df5208b9e949b54a3bc4" integrity sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q== -"@types/stack-utils@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" - integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== - "@types/stack-utils@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff" @@ -1305,6 +1254,14 @@ absolute-path@^0.0.0: resolved "https://registry.yarnpkg.com/absolute-path/-/absolute-path-0.0.0.tgz#a78762fbdadfb5297be99b15d35a785b2f095bf7" integrity sha1-p4di+9rftSl76ZsV01p4Wy8JW/c= +accepts@^1.3.7: + version "1.3.7" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" + integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== + dependencies: + mime-types "~2.1.24" + negotiator "0.6.2" + accepts@~1.3.3, accepts@~1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" @@ -1511,7 +1468,7 @@ array.prototype.flatmap@^1.2.3: es-abstract "^1.17.0-next.1" function-bind "^1.1.1" -asap@~2.0.3, asap@~2.0.6: +asap@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= @@ -1751,13 +1708,6 @@ big-integer@^1.6.7: resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.36.tgz#78631076265d4ae3555c04f85e7d9d2f3a071a36" integrity sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg== -bindings@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" - integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== - dependencies: - file-uri-to-path "1.0.0" - bluebird@^3.5.4: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" @@ -1820,11 +1770,6 @@ bser@^2.0.0: dependencies: node-int64 "^0.4.0" -buffer-crc32@^0.2.13: - version "0.2.13" - resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" - integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1914,7 +1859,7 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -2008,15 +1953,6 @@ cliui@^4.0.0: strip-ansi "^4.0.0" wrap-ansi "^2.0.0" -cliui@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" - integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== - dependencies: - string-width "^3.1.0" - strip-ansi "^5.2.0" - wrap-ansi "^5.1.0" - cliui@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" @@ -2145,16 +2081,6 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@^1.6.0: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== - dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - connect@^3.6.5: version "3.6.6" resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" @@ -2177,11 +2103,6 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= -core-js@^2.2.2, core-js@^2.4.1: - version "2.5.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" - integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw== - core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -2488,13 +2409,6 @@ encodeurl@~1.0.1, encodeurl@~1.0.2: resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= -encoding@^0.1.11: - version "0.1.12" - resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" - integrity sha1-U4tm8+5izRq1HsMjgp0flIDHS+s= - dependencies: - iconv-lite "~0.4.13" - end-of-stream@^1.1.0: version "1.4.1" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" @@ -2521,6 +2435,13 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" +error-stack-parser@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.6.tgz#5a99a707bd7a4c58a797902d48d82803ede6aad8" + integrity sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ== + dependencies: + stackframe "^1.1.1" + errorhandler@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/errorhandler/-/errorhandler-1.5.0.tgz#eaba64ca5d542a311ac945f582defc336165d9f4" @@ -2845,11 +2766,6 @@ event-target-shim@^5.0.0, event-target-shim@^5.0.1: resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== -eventemitter3@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163" - integrity sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA== - exception-formatter@^1.0.4: version "1.0.7" resolved "https://registry.yarnpkg.com/exception-formatter/-/exception-formatter-1.0.7.tgz#3291616b86fceabefa97aee6a4708032c6e3b96d" @@ -2995,25 +2911,6 @@ fb-watchman@^2.0.0: dependencies: bser "^2.0.0" -fbjs-css-vars@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fbjs-css-vars/-/fbjs-css-vars-1.0.1.tgz#836d876e887d702f45610f5ebd2fbeef649527fc" - integrity sha512-IM+v/C40MNZWqsLErc32e0TyIk/NhkkQZL0QmjBh6zi1eXv0/GeVKmKmueQX7nn9SXQBQbTUcB8zuexIF3/88w== - -fbjs@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-1.0.0.tgz#52c215e0883a3c86af2a7a776ed51525ae8e0a5a" - integrity sha512-MUgcMEJaFhCaF1QtWGnmq9ZDRAzECTCRAF7O6UZIlAlkTs1SasiX9aP0Iw7wfD2mJ7wDTNfg2w7u5fSCwJk1OA== - dependencies: - core-js "^2.4.1" - fbjs-css-vars "^1.0.0" - isomorphic-fetch "^2.1.1" - loose-envify "^1.0.0" - object-assign "^4.1.0" - promise "^7.1.1" - setimmediate "^1.0.5" - ua-parser-js "^0.7.18" - figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" @@ -3028,11 +2925,6 @@ file-entry-cache@^5.0.1: dependencies: flat-cache "^2.0.1" -file-uri-to-path@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== - fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -3174,14 +3066,6 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= -fsevents@^1.2.7: - version "1.2.13" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.13.tgz#f325cb0455592428bcf11b383370ef70e3bfcc38" - integrity sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw== - dependencies: - bindings "^1.5.0" - nan "^2.12.1" - fsevents@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805" @@ -3292,7 +3176,7 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== @@ -3431,7 +3315,7 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.17: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -3498,7 +3382,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.3: +inherits@2, inherits@2.0.3, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= @@ -3736,7 +3620,7 @@ is-regex@^1.1.1: dependencies: has-symbols "^1.0.1" -is-stream@^1.0.1, is-stream@^1.1.0: +is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= @@ -3802,14 +3686,6 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= -isomorphic-fetch@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" - integrity sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk= - dependencies: - node-fetch "^1.0.1" - whatwg-fetch ">=0.10.0" - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -3976,25 +3852,6 @@ jest-get-type@^26.3.0: resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0" integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig== -jest-haste-map@^24.7.1: - version "24.8.1" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-24.8.1.tgz#f39cc1d2b1d907e014165b4bd5a957afcb992982" - integrity sha512-SwaxMGVdAZk3ernAx2Uv2sorA7jm3Kx+lR0grp6rMmnY06Kn/urtKx1LPN2mGTea4fCT38impYT28FfcLUhX0g== - dependencies: - "@jest/types" "^24.8.0" - anymatch "^2.0.0" - fb-watchman "^2.0.0" - graceful-fs "^4.1.15" - invariant "^2.2.4" - jest-serializer "^24.4.0" - jest-util "^24.8.0" - jest-worker "^24.6.0" - micromatch "^3.1.10" - sane "^4.0.3" - walker "^1.0.7" - optionalDependencies: - fsevents "^1.2.7" - jest-haste-map@^26.5.2: version "26.5.2" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.5.2.tgz#a15008abfc502c18aa56e4919ed8c96304ceb23d" @@ -4069,20 +3926,6 @@ jest-matcher-utils@^26.5.2: jest-get-type "^26.3.0" pretty-format "^26.5.2" -jest-message-util@^24.8.0: - version "24.8.0" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-24.8.0.tgz#0d6891e72a4beacc0292b638685df42e28d6218b" - integrity sha512-p2k71rf/b6ns8btdB0uVdljWo9h0ovpnEe05ZKWceQGfXYr4KkzgKo3PBi8wdnd9OtNh46VpNIJynUn/3MKm1g== - dependencies: - "@babel/code-frame" "^7.0.0" - "@jest/test-result" "^24.8.0" - "@jest/types" "^24.8.0" - "@types/stack-utils" "^1.0.1" - chalk "^2.0.1" - micromatch "^3.1.10" - slash "^2.0.0" - stack-utils "^1.0.1" - jest-message-util@^26.5.2: version "26.5.2" resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-26.5.2.tgz#6c4c4c46dcfbabb47cd1ba2f6351559729bc11bb" @@ -4097,13 +3940,6 @@ jest-message-util@^26.5.2: slash "^3.0.0" stack-utils "^2.0.2" -jest-mock@^24.8.0: - version "24.8.0" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-24.8.0.tgz#2f9d14d37699e863f1febf4e4d5a33b7fdbbde56" - integrity sha512-6kWugwjGjJw+ZkK4mDa0Df3sDlUTsV47MSrT0nGQ0RBWJbpODDQ8MHDVtGtUYBne3IwZUhtB7elxHspU79WH3A== - dependencies: - "@jest/types" "^24.8.0" - jest-mock@^26.5.2: version "26.5.2" resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-26.5.2.tgz#c9302e8ef807f2bfc749ee52e65ad11166a1b6a1" @@ -4203,11 +4039,6 @@ jest-runtime@^26.5.2: strip-bom "^4.0.0" yargs "^15.4.1" -jest-serializer@^24.4.0: - version "24.4.0" - resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.4.0.tgz#f70c5918c8ea9235ccb1276d232e459080588db3" - integrity sha512-k//0DtglVstc1fv+GY/VHDIjrtNjdYvYjMlbLUed4kxrE92sIUewOi5Hj3vrpB8CXfkJntRPDRjCrCvUhBdL8Q== - jest-serializer@^26.5.0: version "26.5.0" resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-26.5.0.tgz#f5425cc4c5f6b4b355f854b5f0f23ec6b962bc13" @@ -4238,24 +4069,6 @@ jest-snapshot@^26.5.2: pretty-format "^26.5.2" semver "^7.3.2" -jest-util@^24.8.0: - version "24.8.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-24.8.0.tgz#41f0e945da11df44cc76d64ffb915d0716f46cd1" - integrity sha512-DYZeE+XyAnbNt0BG1OQqKy/4GVLPtzwGx5tsnDrFcax36rVE3lTA5fbvgmbVPUZf9w77AJ8otqR4VBbfFJkUZA== - dependencies: - "@jest/console" "^24.7.1" - "@jest/fake-timers" "^24.8.0" - "@jest/source-map" "^24.3.0" - "@jest/test-result" "^24.8.0" - "@jest/types" "^24.8.0" - callsites "^3.0.0" - chalk "^2.0.1" - graceful-fs "^4.1.15" - is-ci "^2.0.0" - mkdirp "^0.5.1" - slash "^2.0.0" - source-map "^0.6.0" - jest-util@^26.5.2: version "26.5.2" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.5.2.tgz#8403f75677902cc52a1b2140f568e91f8ed4f4d7" @@ -4268,7 +4081,7 @@ jest-util@^26.5.2: is-ci "^2.0.0" micromatch "^4.0.2" -jest-validate@^24.7.0, jest-validate@^24.9.0: +jest-validate@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-24.9.0.tgz#0775c55360d173cd854e40180756d4ff52def8ab" integrity sha512-HPIt6C5ACwiqSiwi+OfSSHbK8sG7akG8eATl+IPKaeIjtPOeBUd/g3J7DghugzxrGjI93qS/+RPKe1H6PqvhRQ== @@ -4305,13 +4118,14 @@ jest-watcher@^26.5.2: jest-util "^26.5.2" string-length "^4.0.1" -jest-worker@^24.6.0: - version "24.6.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.6.0.tgz#7f81ceae34b7cde0c9827a6980c35b7cdc0161b3" - integrity sha512-jDwgW5W9qGNvpI1tNnvajh0a5IE/PuGLFmHk6aR/BZFz8tSgGw17GsDPXAJ6p91IvYDjOw8GpFbvvZGAK+DPQQ== +jest-worker@^26.0.0: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" + integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== dependencies: - merge-stream "^1.0.1" - supports-color "^6.1.0" + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^7.0.0" jest-worker@^26.5.0: version "26.5.0" @@ -4336,6 +4150,17 @@ jetifier@^1.6.2: resolved "https://registry.yarnpkg.com/jetifier/-/jetifier-1.6.4.tgz#6159db8e275d97980d26162897a0648b6d4a3222" integrity sha512-+f/4OLeqY8RAmXnonI1ffeY1DR8kMNJPhv5WMFehchf7U71cjMQVKkOz1n6asz6kfVoAqKNWJz1A/18i18AcXA== +joi@^17.2.1: + version "17.3.0" + resolved "https://registry.yarnpkg.com/joi/-/joi-17.3.0.tgz#f1be4a6ce29bc1716665819ac361dfa139fff5d2" + integrity sha512-Qh5gdU6niuYbUIUV5ejbsMiiFmBdw8Kcp8Buj2JntszCkCfxJ9Cz76OtHxOZMPXrt5810iDIXs+n1nNVoquHgg== + dependencies: + "@hapi/hoek" "^9.0.0" + "@hapi/topo" "^5.0.0" + "@sideway/address" "^4.1.0" + "@sideway/formula" "^3.0.0" + "@sideway/pinpoint" "^2.0.0" + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -4446,13 +4271,6 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= -json-stable-stringify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" - integrity sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8= - dependencies: - jsonify "~0.0.0" - json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" @@ -4704,36 +4522,11 @@ mem@^4.0.0: mimic-fn "^1.0.0" p-is-promise "^1.1.0" -merge-stream@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1" - integrity sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE= - dependencies: - readable-stream "^2.0.1" - merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -metro-babel-register@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-babel-register/-/metro-babel-register-0.58.0.tgz#5c44786d49a044048df56cf476a2263491d4f53a" - integrity sha512-P5+G3ufhSYL6cA3a7xkbSJzzFBvtivj/PhWvGXFXnuFssDlMAX1CTktff+0gpka5Cd6B6QLt0UAMWulUAAE4Eg== - dependencies: - "@babel/core" "^7.0.0" - "@babel/plugin-proposal-class-properties" "^7.0.0" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.0.0" - "@babel/plugin-proposal-object-rest-spread" "^7.0.0" - "@babel/plugin-proposal-optional-catch-binding" "^7.0.0" - "@babel/plugin-proposal-optional-chaining" "^7.0.0" - "@babel/plugin-transform-async-to-generator" "^7.0.0" - "@babel/plugin-transform-flow-strip-types" "^7.0.0" - "@babel/plugin-transform-modules-commonjs" "^7.0.0" - "@babel/register" "^7.0.0" - core-js "^2.2.2" - escape-string-regexp "^1.0.5" - metro-babel-register@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-babel-register/-/metro-babel-register-0.64.0.tgz#1a2d23f68da8b8ee42e78dca37ad21a5f4d3647d" @@ -4748,14 +4541,6 @@ metro-babel-register@0.64.0: "@babel/register" "^7.0.0" escape-string-regexp "^1.0.5" -metro-babel-transformer@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-babel-transformer/-/metro-babel-transformer-0.58.0.tgz#317c83b863cceb0573943815f1711fbcbe69b106" - integrity sha512-yBX3BkRhw2TCNPhe+pmLSgsAEA3huMvnX08UwjFqSXXI1aiqzRQobn92uKd1U5MM1Vx8EtXVomlJb95ZHNAv6A== - dependencies: - "@babel/core" "^7.0.0" - metro-source-map "0.58.0" - metro-babel-transformer@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-babel-transformer/-/metro-babel-transformer-0.64.0.tgz#a21f8a989a5ea60c1109456e21bd4d9374194ea0" @@ -4765,97 +4550,63 @@ metro-babel-transformer@0.64.0: metro-source-map "0.64.0" nullthrows "^1.1.1" -metro-cache@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-cache/-/metro-cache-0.58.0.tgz#630ea0a4626dfb9591c71fdb85dce14b5e9a04ec" - integrity sha512-jjW9zCTKxhgKcVkyQ6LHyna9Zdf4TK/45vvT1fPyyTk1RY82ZYjU1qs+84ycKEd08Ka4YcK9xcUew9SIDJYI8Q== +metro-cache-key@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-cache-key/-/metro-cache-key-0.64.0.tgz#98d0a94332453c4c52b74f72c07cc62a5c264c4f" + integrity sha512-O9B65G8L/fopck45ZhdRosyVZdMtUQuX5mBWEC1NRj02iWBIUPLmYMjrunqIe8vHipCMp3DtTCm/65IlBmO8jg== + +metro-cache@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-cache/-/metro-cache-0.64.0.tgz#a769503e12521d9e9d95ce5840ffb2efdb4e8703" + integrity sha512-QvGfxe/1QQYM9XOlR8W1xqE9eHDw/AgJIgYGn/TxZxBu9Zga+Rgs1omeSZju45D8w5VWgMr83ma5kACgzvOecg== dependencies: - jest-serializer "^24.4.0" - metro-core "0.58.0" + metro-core "0.64.0" mkdirp "^0.5.1" rimraf "^2.5.4" -metro-config@0.58.0, metro-config@^0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-config/-/metro-config-0.58.0.tgz#1e24b43a5a00971d75662b1a0d3c04a13d4a1746" - integrity sha512-4vgBliXwL56vjUlYplvGMVSNrJJpkHuLcD+O20trV3FvPxKg4ZsvuOcNSxqDSMU26FCtIEJ15ojcuCbRL7KY0w== +metro-config@0.64.0, metro-config@^0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-config/-/metro-config-0.64.0.tgz#b634fa05cffd06b1e50e4339c200f90a42924afb" + integrity sha512-QhM4asnX5KhlRWaugwVGNNXhX0Z85u5nK0UQ/A90bBb4xWyXqUe20e788VtdA75rkQiiI6wXTCIHWT0afbnjwQ== dependencies: cosmiconfig "^5.0.5" - jest-validate "^24.7.0" - metro "0.58.0" - metro-cache "0.58.0" - metro-core "0.58.0" - pretty-format "^24.7.0" - -metro-core@0.58.0, metro-core@^0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-core/-/metro-core-0.58.0.tgz#ad9f6645a2b439a3fbce7ce4e19b01b00375768a" - integrity sha512-RzXUjGFmCLOyzUqcKDvr91AldGtIOxnzNZrWUIiG8uC3kerVLo0mQp4YH3+XVm6fMNiLMg6iER7HLqD+MbpUjQ== - dependencies: - jest-haste-map "^24.7.1" + jest-validate "^26.5.2" + metro "0.64.0" + metro-cache "0.64.0" + metro-core "0.64.0" + metro-runtime "0.64.0" + +metro-core@0.64.0, metro-core@^0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-core/-/metro-core-0.64.0.tgz#7616b27acfe7baa476f6cd6bd9e70ae64fa62541" + integrity sha512-v8ZQ5j72EaUwamQ8pLfHlOHTyp7SbdazvHPzFGDpHnwIQqIT0Bw3Syg8R4regTlVG3ngpeSEAi005UITljmMcQ== + dependencies: + jest-haste-map "^26.5.2" lodash.throttle "^4.1.1" - metro-resolver "0.58.0" - wordwrap "^1.0.0" + metro-resolver "0.64.0" + +metro-hermes-compiler@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-hermes-compiler/-/metro-hermes-compiler-0.64.0.tgz#e6043d7aa924e5b2be99bd3f602e693685d15386" + integrity sha512-CLAjVDWGAoGhbi2ZyPHnH5YDdfrDIx6+tzFWfHGIMTZkYBXsYta9IfYXBV8lFb6BIbrXLjlXZAOoosknetMPOA== -metro-inspector-proxy@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-inspector-proxy/-/metro-inspector-proxy-0.58.0.tgz#6fefb0cdf25655919d56c82ebe09cd26eb00e636" - integrity sha512-oFqTyNTJdCdvcw1Ha6SKE7ITbSaoTbO4xpYownIoJR+WZ0ZfxbWpp225JkHuBJm9UcBAnG9c0CME924m3uBbaw== +metro-inspector-proxy@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-inspector-proxy/-/metro-inspector-proxy-0.64.0.tgz#9a481b3f49773d5418e028178efec68f861bec88" + integrity sha512-KywbH3GNSz9Iqw4UH3smgaV2dBHHYMISeN7ORntDL/G+xfgPc6vt13d+zFb907YpUcXj5N0vdoiAHI5V/0y8IA== dependencies: connect "^3.6.5" debug "^2.2.0" - rxjs "^5.4.3" ws "^1.1.5" - yargs "^14.2.0" + yargs "^15.3.1" -metro-minify-uglify@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-minify-uglify/-/metro-minify-uglify-0.58.0.tgz#7e1066954bfd4f767ba6aca7feef676ca44c68b8" - integrity sha512-vRHsA7bCi7eCn3LXLm20EfY2NoWDyYOnmWaq/N8LB0OxL2L5DXRqMYAQK+prWGJ5S1yvVnDuuNVP+peQ9851TA== +metro-minify-uglify@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-minify-uglify/-/metro-minify-uglify-0.64.0.tgz#da6ab4dda030e3211f5924e7f41ed308d466068f" + integrity sha512-DRwRstqXR5qfte9Nuwoov5dRXxL7fJeVlO5fGyOajWeO3+AgPjvjXh/UcLJqftkMWTPGUFuzAD5/7JC5v5FLWw== dependencies: uglify-es "^3.1.9" -metro-react-native-babel-preset@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.58.0.tgz#18f48d33fe124280ffabc000ab8b42c488d762a2" - integrity sha512-MRriNW+fF6jxABsgPphocUY6mIhmCm8idcrQZ58fT3Iti2vCdtkaK32TyCGUNUptzhUe2/cbE57j4aC+eaodAA== - dependencies: - "@babel/plugin-proposal-class-properties" "^7.0.0" - "@babel/plugin-proposal-export-default-from" "^7.0.0" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.0.0" - "@babel/plugin-proposal-object-rest-spread" "^7.0.0" - "@babel/plugin-proposal-optional-catch-binding" "^7.0.0" - "@babel/plugin-proposal-optional-chaining" "^7.0.0" - "@babel/plugin-syntax-dynamic-import" "^7.0.0" - "@babel/plugin-syntax-export-default-from" "^7.0.0" - "@babel/plugin-syntax-flow" "^7.2.0" - "@babel/plugin-transform-arrow-functions" "^7.0.0" - "@babel/plugin-transform-block-scoping" "^7.0.0" - "@babel/plugin-transform-classes" "^7.0.0" - "@babel/plugin-transform-computed-properties" "^7.0.0" - "@babel/plugin-transform-destructuring" "^7.0.0" - "@babel/plugin-transform-exponentiation-operator" "^7.0.0" - "@babel/plugin-transform-flow-strip-types" "^7.0.0" - "@babel/plugin-transform-for-of" "^7.0.0" - "@babel/plugin-transform-function-name" "^7.0.0" - "@babel/plugin-transform-literals" "^7.0.0" - "@babel/plugin-transform-modules-commonjs" "^7.0.0" - "@babel/plugin-transform-object-assign" "^7.0.0" - "@babel/plugin-transform-parameters" "^7.0.0" - "@babel/plugin-transform-react-display-name" "^7.0.0" - "@babel/plugin-transform-react-jsx" "^7.0.0" - "@babel/plugin-transform-react-jsx-source" "^7.0.0" - "@babel/plugin-transform-regenerator" "^7.0.0" - "@babel/plugin-transform-runtime" "^7.0.0" - "@babel/plugin-transform-shorthand-properties" "^7.0.0" - "@babel/plugin-transform-spread" "^7.0.0" - "@babel/plugin-transform-sticky-regex" "^7.0.0" - "@babel/plugin-transform-template-literals" "^7.0.0" - "@babel/plugin-transform-typescript" "^7.5.0" - "@babel/plugin-transform-unicode-regex" "^7.0.0" - "@babel/template" "^7.0.0" - react-refresh "^0.4.0" - metro-react-native-babel-preset@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.64.0.tgz#76861408681dfda3c1d962eb31a8994918c976f8" @@ -4901,7 +4652,7 @@ metro-react-native-babel-preset@0.64.0: "@babel/template" "^7.0.0" react-refresh "^0.4.0" -metro-react-native-babel-transformer@0.64.0: +metro-react-native-babel-transformer@0.64.0, metro-react-native-babel-transformer@^0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-react-native-babel-transformer/-/metro-react-native-babel-transformer-0.64.0.tgz#eafef756972f20efdc51bd5361d55f8598355623" integrity sha512-K1sHO3ODBFCr7uEiCQ4RvVr+cQg0EHQF8ChVPnecGh/WDD8udrTq9ECwB0dRfMjAvlsHtRUlJm6ZSI8UPgum2w== @@ -4913,42 +4664,18 @@ metro-react-native-babel-transformer@0.64.0: metro-source-map "0.64.0" nullthrows "^1.1.1" -metro-react-native-babel-transformer@^0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-react-native-babel-transformer/-/metro-react-native-babel-transformer-0.58.0.tgz#5da0e5a1b83c01d11626905fa59f34fda53a21a5" - integrity sha512-3A73+cRq1eUPQ8g+hPNGgMUMCGmtQjwqHfoG1DwinAoJ/kr4WOXWWbGZo0xHJNBe/zdHGl0uHcDCp2knPglTdQ== - dependencies: - "@babel/core" "^7.0.0" - babel-preset-fbjs "^3.3.0" - metro-babel-transformer "0.58.0" - metro-react-native-babel-preset "0.58.0" - metro-source-map "0.58.0" - -metro-resolver@0.58.0, metro-resolver@^0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.58.0.tgz#4d03edc52e2e25d45f16688adf3b3f268ea60df9" - integrity sha512-XFbAKvCHN2iWqKeiRARzEXn69eTDdJVJC7lu16S4dPQJ+Dy82dZBr5Es12iN+NmbJuFgrAuIHbpWrdnA9tOf6Q== +metro-resolver@0.64.0, metro-resolver@^0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.64.0.tgz#21126b44f31346ac2ce0b06b77ef65e8c9e2294a" + integrity sha512-cJ26Id8Zf+HmS/1vFwu71K3u7ep/+HeXXAJIeVDYf+niE7AWB9FijyMtAlQgbD8elWqv1leJCnQ/xHRFBfGKYA== dependencies: absolute-path "^0.0.0" -metro-runtime@0.64.0: +metro-runtime@0.64.0, metro-runtime@^0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-runtime/-/metro-runtime-0.64.0.tgz#cdaa1121d91041bf6345f2a69eb7c2fb289eff7b" integrity sha512-m7XbWOaIOeFX7YcxUhmnOi6Pg8EaeL89xyZ+quZyZVF1aNoTr4w8FfbKxvijpjsytKHIZtd+43m2Wt5JrqyQmQ== -metro-source-map@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-source-map/-/metro-source-map-0.58.0.tgz#e951b99f4c653239ce9323bb08339c6f1978a112" - integrity sha512-yvN1YPmejmgiiS7T1aKBiiUTHPw2Vcm3r2TZ+DY92z/9PR4alysIywrCs/fTHs8rbDcKM5VfPCKGLpkBrbKeOw== - dependencies: - "@babel/traverse" "^7.0.0" - "@babel/types" "^7.0.0" - invariant "^2.2.4" - metro-symbolicate "0.58.0" - ob1 "0.58.0" - source-map "^0.5.6" - vlq "^1.0.0" - metro-source-map@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-source-map/-/metro-source-map-0.64.0.tgz#4310e17c3d4539c6369688022494ad66fa4d39a1" @@ -4963,17 +4690,6 @@ metro-source-map@0.64.0: source-map "^0.5.6" vlq "^1.0.0" -metro-symbolicate@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro-symbolicate/-/metro-symbolicate-0.58.0.tgz#ba9fd52549c41fc1b656adaad7c8875726dd5abe" - integrity sha512-uIVxUQC1E26qOMj13dKROhwAa2FmZk5eR0NcBqej/aXmQhpr8LjJg2sondkoLKUp827Tf/Fm9+pS4icb5XiqCw== - dependencies: - invariant "^2.2.4" - metro-source-map "0.58.0" - source-map "^0.5.6" - through2 "^2.0.1" - vlq "^1.0.0" - metro-symbolicate@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-symbolicate/-/metro-symbolicate-0.64.0.tgz#405c21438ab553c29f6841da52ca76ee87bb06ac" @@ -4986,67 +4702,92 @@ metro-symbolicate@0.64.0: through2 "^2.0.1" vlq "^1.0.0" -metro@0.58.0, metro@^0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/metro/-/metro-0.58.0.tgz#c037318c112f80dc96199780c8b401ab72cfd142" - integrity sha512-yi/REXX+/s4r7RjzXht+E+qE6nzvFIrEXO5Q61h+70Q7RODMU8EnlpXx04JYk7DevHuMhFaX+NWhCtRINzR4zA== +metro-transform-plugins@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-transform-plugins/-/metro-transform-plugins-0.64.0.tgz#41d3dce0f2966bbd79fea1ecff61bcc8a00e4665" + integrity sha512-iTIRBD/wBI98plfxj8jAoNUUXfXLNlyvcjPtshhpGvdwu9pzQilGfnDnOaaK+vbITcOk9w5oQectXyJwAqTr1A== + dependencies: + "@babel/core" "^7.0.0" + "@babel/generator" "^7.5.0" + "@babel/template" "^7.0.0" + "@babel/traverse" "^7.0.0" + nullthrows "^1.1.1" + +metro-transform-worker@0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro-transform-worker/-/metro-transform-worker-0.64.0.tgz#f94429b2c42b13cb1c93be4c2e25e97f2d27ca60" + integrity sha512-wegRtK8GyLF6IPZRBJp+zsORgA4iX0h1DRpknyAMDCtSbJ4VU2xV/AojteOgAsDvY3ucAGsvfuZLNDJHUdUNHQ== + dependencies: + "@babel/core" "^7.0.0" + "@babel/generator" "^7.5.0" + "@babel/parser" "^7.0.0" + "@babel/types" "^7.0.0" + babel-preset-fbjs "^3.3.0" + metro "0.64.0" + metro-babel-transformer "0.64.0" + metro-cache "0.64.0" + metro-cache-key "0.64.0" + metro-hermes-compiler "0.64.0" + metro-source-map "0.64.0" + metro-transform-plugins "0.64.0" + nullthrows "^1.1.1" + +metro@0.64.0, metro@^0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/metro/-/metro-0.64.0.tgz#0091a856cfbcc94dd576da563eee466e96186195" + integrity sha512-G2OC08Rzfs0kqnSEuKo2yZxR+/eNUpA93Ru45c60uN0Dw3HPrDi+ZBipgFftC6iLE0l+6hu8roFFIofotWxybw== dependencies: "@babel/code-frame" "^7.0.0" "@babel/core" "^7.0.0" "@babel/generator" "^7.5.0" "@babel/parser" "^7.0.0" - "@babel/plugin-external-helpers" "^7.0.0" "@babel/template" "^7.0.0" "@babel/traverse" "^7.0.0" "@babel/types" "^7.0.0" absolute-path "^0.0.0" + accepts "^1.3.7" async "^2.4.0" - babel-preset-fbjs "^3.3.0" - buffer-crc32 "^0.2.13" - chalk "^2.4.1" + chalk "^4.0.0" ci-info "^2.0.0" - concat-stream "^1.6.0" connect "^3.6.5" debug "^2.2.0" denodeify "^1.2.1" - eventemitter3 "^3.0.0" - fbjs "^1.0.0" + error-stack-parser "^2.0.6" fs-extra "^1.0.0" graceful-fs "^4.1.3" image-size "^0.6.0" invariant "^2.2.4" - jest-haste-map "^24.7.1" - jest-worker "^24.6.0" - json-stable-stringify "^1.0.1" + jest-haste-map "^26.5.2" + jest-worker "^26.0.0" lodash.throttle "^4.1.1" - merge-stream "^1.0.1" - metro-babel-register "0.58.0" - metro-babel-transformer "0.58.0" - metro-cache "0.58.0" - metro-config "0.58.0" - metro-core "0.58.0" - metro-inspector-proxy "0.58.0" - metro-minify-uglify "0.58.0" - metro-react-native-babel-preset "0.58.0" - metro-resolver "0.58.0" - metro-source-map "0.58.0" - metro-symbolicate "0.58.0" - mime-types "2.1.11" + metro-babel-register "0.64.0" + metro-babel-transformer "0.64.0" + metro-cache "0.64.0" + metro-cache-key "0.64.0" + metro-config "0.64.0" + metro-core "0.64.0" + metro-hermes-compiler "0.64.0" + metro-inspector-proxy "0.64.0" + metro-minify-uglify "0.64.0" + metro-react-native-babel-preset "0.64.0" + metro-resolver "0.64.0" + metro-runtime "0.64.0" + metro-source-map "0.64.0" + metro-symbolicate "0.64.0" + metro-transform-plugins "0.64.0" + metro-transform-worker "0.64.0" + mime-types "^2.1.27" mkdirp "^0.5.1" node-fetch "^2.2.0" nullthrows "^1.1.1" - resolve "^1.5.0" rimraf "^2.5.4" serialize-error "^2.1.0" source-map "^0.5.6" - strip-ansi "^4.0.0" + strip-ansi "^6.0.0" temp "0.8.3" - throat "^4.1.0" - wordwrap "^1.0.0" - write-file-atomic "^1.2.0" + throat "^5.0.0" ws "^1.1.5" - xpipe "^1.0.5" - yargs "^14.2.0" + yargs "^15.3.1" micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" @@ -5075,23 +4816,16 @@ micromatch@^4.0.2: braces "^3.0.1" picomatch "^2.0.5" +mime-db@1.44.0: + version "1.44.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" + integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== + "mime-db@>= 1.36.0 < 2", mime-db@~1.36.0: version "1.36.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.36.0.tgz#5020478db3c7fe93aad7bbcc4dcf869c43363397" integrity sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw== -mime-db@~1.23.0: - version "1.23.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.23.0.tgz#a31b4070adaea27d732ea333740a64d0ec9a6659" - integrity sha1-oxtAcK2uon1zLqMzdApk0OyaZlk= - -mime-types@2.1.11: - version "2.1.11" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.11.tgz#c259c471bda808a85d6cd193b430a5fae4473b3c" - integrity sha1-wlnEcb2oCKhdbNGTtDCl+uRHOzw= - dependencies: - mime-db "~1.23.0" - mime-types@^2.1.12, mime-types@~2.1.18, mime-types@~2.1.19: version "2.1.20" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.20.tgz#930cb719d571e903738520f8470911548ca2cc19" @@ -5099,6 +4833,13 @@ mime-types@^2.1.12, mime-types@~2.1.18, mime-types@~2.1.19: dependencies: mime-db "~1.36.0" +mime-types@^2.1.27, mime-types@~2.1.24: + version "2.1.27" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" + integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== + dependencies: + mime-db "1.44.0" + mime@1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" @@ -5185,11 +4926,6 @@ nan@^2.10.0: resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA== -nan@^2.12.1: - version "2.14.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" - integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ== - nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -5222,6 +4958,11 @@ negotiator@0.6.1: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= +negotiator@0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" + integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== + neo-async@^2.5.0: version "2.6.0" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.0.tgz#b9d15e4d71c6762908654b5183ed38b753340835" @@ -5232,6 +4973,11 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +nocache@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f" + integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q== + node-dir@^0.1.17: version "0.1.17" resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.17.tgz#5f5665d93351335caabef8f1c554516cf5f1e4e5" @@ -5239,14 +4985,6 @@ node-dir@^0.1.17: dependencies: minimatch "^3.0.2" -node-fetch@^1.0.1: - version "1.7.3" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" - integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ== - dependencies: - encoding "^0.1.11" - is-stream "^1.0.1" - node-fetch@^2.2.0, node-fetch@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" @@ -5340,17 +5078,12 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -ob1@0.58.0: - version "0.58.0" - resolved "https://registry.yarnpkg.com/ob1/-/ob1-0.58.0.tgz#484a1e9a63a8b79d9ea6f3a83b2a42110faac973" - integrity sha512-uZP44cbowAfHafP1k4skpWItk5iHCoRevMfrnUvYCfyNNPPJd3rfDCyj0exklWi2gDXvjlj2ObsfiqP/bs/J7Q== - ob1@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/ob1/-/ob1-0.64.0.tgz#f254a55a53ca395c4f9090e28a85483eac5eba19" integrity sha512-CO1N+5dhvy+MoAwxz8+fymEUcwsT4a+wHhrHFb02LppcJdHxgcBWviwEhUwKOD2kLMQ7ijrrzybOqpGcqEtvpQ== -object-assign@^4.1.0, object-assign@^4.1.1: +object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= @@ -5715,7 +5448,7 @@ prettier@1.19.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== -pretty-format@^24.7.0, pretty-format@^24.9.0: +pretty-format@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA== @@ -5725,16 +5458,6 @@ pretty-format@^24.7.0, pretty-format@^24.9.0: ansi-styles "^3.2.0" react-is "^16.8.4" -pretty-format@^25.1.0, pretty-format@^25.2.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a" - integrity sha512-kbo/kq2LQ/A/is0PQwsEHM7Ca6//bGPPvU6UnsdDRSKTWxT/ru/xb88v4BJf6a69H+uTytOEsTusT9ksd/1iWQ== - dependencies: - "@jest/types" "^25.5.0" - ansi-regex "^5.0.0" - ansi-styles "^4.0.0" - react-is "^16.12.0" - pretty-format@^26.5.2: version "26.5.2" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.5.2.tgz#5d896acfdaa09210683d34b6dc0e6e21423cd3e1" @@ -5745,6 +5468,16 @@ pretty-format@^26.5.2: ansi-styles "^4.0.0" react-is "^16.12.0" +pretty-format@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" + integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg== + dependencies: + "@jest/types" "^26.6.2" + ansi-regex "^5.0.0" + ansi-styles "^4.0.0" + react-is "^17.0.1" + private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -5765,13 +5498,6 @@ promise-polyfill@^6.0.1: resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-6.1.0.tgz#dfa96943ea9c121fca4de9b5868cb39d3472e057" integrity sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc= -promise@^7.1.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" - integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg== - dependencies: - asap "~2.0.3" - promise@^8.0.3: version "8.0.3" resolved "https://registry.yarnpkg.com/promise/-/promise-8.0.3.tgz#f592e099c6cddc000d538ee7283bb190452b0bf6" @@ -5905,7 +5631,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.1, readable-stream@^2.2.2, readable-stream@~2.3.6: +readable-stream@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== @@ -6100,7 +5826,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.8.1: version "1.18.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.18.1.tgz#018fcb2c5b207d2a6424aee361c5a266da8f4130" integrity sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA== @@ -6174,13 +5900,6 @@ rx-lite@*, rx-lite@^4.0.8: resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" integrity sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ= -rxjs@^5.4.3: - version "5.5.12" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.12.tgz#6fa61b8a77c3d793dbaf270bee2f43f652d741cc" - integrity sha512-xx2itnL5sBbqeeiVgNPVuQQ1nC8Jp2WfNJhXWHmElW9YmrpS9UVnNzhP3EH3HFqexO5Tlp8GhYY+WEcqcVMvGw== - dependencies: - symbol-observable "1.0.1" - safe-buffer@5.1.2, safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -6319,11 +6038,6 @@ set-value@^2.0.0: is-plain-object "^2.0.3" split-string "^3.0.1" -setimmediate@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - setprototypeof@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" @@ -6416,11 +6130,6 @@ sisteransi@^1.0.0: resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.0.tgz#77d9622ff909080f1c19e5f4a1df0c1b0a27b88c" integrity sha512-N+z4pHB4AmUv0SjveWRd6q1Nj5w62m5jodv+GD8lvmbY/83T/rpbJGZOnK5T149OldDj4Db07BSv9xY4K6NTPQ== -slash@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" - integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== - slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -6435,11 +6144,6 @@ slice-ansi@^2.0.0, slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -slide@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" - integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -6569,11 +6273,6 @@ sshpk@^1.7.0: safer-buffer "^2.0.2" tweetnacl "~0.14.0" -stack-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620" - integrity sha1-1PM6tU6OOHeLDKXP07OvsS22hiA= - stack-utils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.2.tgz#5cf48b4557becb4638d0bc4f21d23f5d19586593" @@ -6581,6 +6280,11 @@ stack-utils@^2.0.2: dependencies: escape-string-regexp "^2.0.0" +stackframe@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.2.0.tgz#52429492d63c62eb989804c11552e3d22e779303" + integrity sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA== + stacktrace-parser@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.4.tgz#01397922e5f62ecf30845522c95c4fe1d25e7d4e" @@ -6644,7 +6348,7 @@ string-width@^2.1.0, string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^3.0.0, string-width@^3.1.0: +string-width@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== @@ -6757,13 +6461,6 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -supports-color@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" - integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== - dependencies: - has-flag "^3.0.0" - supports-color@^7.0.0, supports-color@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" @@ -6779,11 +6476,6 @@ supports-hyperlinks@^2.0.0: has-flag "^4.0.0" supports-color "^7.0.0" -symbol-observable@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" - integrity sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ= - symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" @@ -6854,11 +6546,6 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -throat@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" - integrity sha1-iQN8vJLFarGJJua6TLsgDhVnKmo= - throat@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" @@ -7015,16 +6702,6 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= - -ua-parser-js@^0.7.18: - version "0.7.18" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed" - integrity sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA== - uglify-es@^3.1.9: version "3.3.9" resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677" @@ -7227,7 +6904,7 @@ whatwg-encoding@^1.0.5: dependencies: iconv-lite "0.4.24" -whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0: +whatwg-fetch@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q== @@ -7270,11 +6947,6 @@ word-wrap@^1.2.3, word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== -wordwrap@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= - wrap-ansi@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" @@ -7283,15 +6955,6 @@ wrap-ansi@^2.0.0: string-width "^1.0.1" strip-ansi "^3.0.1" -wrap-ansi@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" - integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== - dependencies: - ansi-styles "^3.2.0" - string-width "^3.0.0" - strip-ansi "^5.0.0" - wrap-ansi@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" @@ -7306,15 +6969,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -write-file-atomic@^1.2.0: - version "1.3.4" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" - integrity sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8= - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - slide "^1.1.5" - write-file-atomic@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" @@ -7410,11 +7064,6 @@ xmldom@0.1.x: resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9" integrity sha1-1QH5ezvbQDr4757MIFcxh6rawOk= -xpipe@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/xpipe/-/xpipe-1.0.5.tgz#8dd8bf45fc3f7f55f0e054b878f43a62614dafdf" - integrity sha1-jdi/Rfw/f1Xw4FS4ePQ6YmFNr98= - xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" @@ -7438,14 +7087,6 @@ yargs-parser@^13.0.0: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^15.0.0: - version "15.0.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.0.tgz#cdd7a97490ec836195f59f3f4dbe5ea9e8f75f08" - integrity sha512-xLTUnCMc4JhxrPEPUYD5IBR1mWCK/aT6+RJ/K29JY2y1vD+FhtgKK0AXRWvI262q3QSffAQuTouFIKUuHX89wQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - yargs-parser@^18.1.2: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" @@ -7471,23 +7112,6 @@ yargs@^13.0.0: y18n "^4.0.0" yargs-parser "^13.0.0" -yargs@^14.2.0: - version "14.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.0.tgz#f116a9242c4ed8668790b40759b4906c276e76c3" - integrity sha512-/is78VKbKs70bVZH7w4YaZea6xcJWOAwkhbR0CFuZBmYtfTYF0xjGJF43AYd8g2Uii1yJwmS5GR2vBmrc32sbg== - dependencies: - cliui "^5.0.0" - decamelize "^1.2.0" - find-up "^3.0.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^3.0.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^15.0.0" - yargs@^15.1.0, yargs@^15.3.1, yargs@^15.4.1: version "15.4.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" From 6a547c6c573b5fe9c457c3fc01aa19e0ebdacad3 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 10:53:49 -0800 Subject: [PATCH 0095/1810] RN: Create `NativeComponentRegistry` Summary: Creates `NativeComponentRegistry` which makes native component initialization more declarative and configurable through an optionally configurable provider. The next diff converts `ScrollView` to use this new abstraction as a demonstration. The plan would be to use this to replace all current manual call sites of `registerGeneratedViewConfig`, and then the ones generated via the Babel plugin. Migrating to this will not change any production behavior, but it will enable verification of `ViewConfig` in development. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25084468 fbshipit-source-id: 9c758ddc279bf937a401a868a066907a94098f37 --- .../NativeComponentRegistry.js | 78 +++++++++++++++++++ jest/mockNativeComponent.js | 36 +++++++++ jest/setup.js | 34 +++----- 3 files changed, 123 insertions(+), 25 deletions(-) create mode 100644 Libraries/NativeComponent/NativeComponentRegistry.js create mode 100644 jest/mockNativeComponent.js diff --git a/Libraries/NativeComponent/NativeComponentRegistry.js b/Libraries/NativeComponent/NativeComponentRegistry.js new file mode 100644 index 00000000000000..76dd24a883e156 --- /dev/null +++ b/Libraries/NativeComponent/NativeComponentRegistry.js @@ -0,0 +1,78 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import {createViewConfig} from './ViewConfig'; +import type { + HostComponent, + PartialViewConfig, +} from '../Renderer/shims/ReactNativeTypes'; +import ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConfigRegistry'; +import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes'; +import verifyComponentAttributeEquivalence from '../Utilities/verifyComponentAttributeEquivalence'; +import invariant from 'invariant'; + +let getRuntimeConfig; + +/** + * Configures a function that is called to determine whether a given component + * should be registered using reflection of the native component at runtime. + */ +export function setRuntimeConfigProvider( + runtimeConfigProvider: (name: string) => {native: boolean, verify: boolean}, +): void { + invariant( + getRuntimeConfig == null, + 'NativeComponentRegistry.setRuntimeConfigProvider() called more than once.', + ); + getRuntimeConfig = runtimeConfigProvider; +} + +/** + * Gets a `NativeComponent` that can be rendered by React Native. + * + * The supplied `viewConfigProvider` may or may not be invoked and utilized, + * depending on how `setRuntimeConfigProvider` is configured. + */ +export function get( + name: string, + viewConfigProvider: () => PartialViewConfig, +): HostComponent { + ReactNativeViewConfigRegistry.register(name, () => { + const {native, verify} = getRuntimeConfig?.(name) ?? { + native: true, + verify: false, + }; + + const viewConfig = native + ? getNativeComponentAttributes(name) + : createViewConfig(viewConfigProvider()); + + if (verify) { + if (native) { + verifyComponentAttributeEquivalence( + viewConfig, + createViewConfig(viewConfigProvider()), + ); + } else { + verifyComponentAttributeEquivalence( + getNativeComponentAttributes(name), + viewConfig, + ); + } + } + + return viewConfig; + }); + + // $FlowFixMe[incompatible-return] `NativeComponent` is actually string! + return name; +} diff --git a/jest/mockNativeComponent.js b/jest/mockNativeComponent.js new file mode 100644 index 00000000000000..e6080b7d1498e7 --- /dev/null +++ b/jest/mockNativeComponent.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +const React = require('react'); + +module.exports = viewName => { + const Component = class extends React.Component { + render() { + return React.createElement(viewName, this.props, this.props.children); + } + + // The methods that exist on host components + blur = jest.fn(); + focus = jest.fn(); + measure = jest.fn(); + measureInWindow = jest.fn(); + measureLayout = jest.fn(); + setNativeProps = jest.fn(); + }; + + if (viewName === 'RCTView') { + Component.displayName = 'View'; + } else { + Component.displayName = viewName; + } + + return Component; +}; diff --git a/jest/setup.js b/jest/setup.js index bc27b00e23abf0..eefca60e23be6e 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -325,33 +325,17 @@ jest }), }, })) - .mock('../Libraries/ReactNative/requireNativeComponent', () => { - const React = require('react'); - - return viewName => { - const Component = class extends React.Component { - render() { - return React.createElement(viewName, this.props, this.props.children); - } - - // The methods that exist on host components - blur = jest.fn(); - focus = jest.fn(); - measure = jest.fn(); - measureInWindow = jest.fn(); - measureLayout = jest.fn(); - setNativeProps = jest.fn(); - }; - - if (viewName === 'RCTView') { - Component.displayName = 'View'; - } else { - Component.displayName = viewName; - } - - return Component; + .mock('../Libraries/NativeComponent/NativeComponentRegistry', () => { + return { + get: jest.fn((name, viewConfigProvider) => { + return jest.requireActual('./mockNativeComponent')(name); + }), + setRuntimeConfigProvider: jest.fn(), }; }) + .mock('../Libraries/ReactNative/requireNativeComponent', () => { + return jest.requireActual('./mockNativeComponent'); + }) .mock( '../Libraries/Utilities/verifyComponentAttributeEquivalence', () => function() {}, From 5af6a44de3890873881937f8fb0fe9914b744937 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 19 Nov 2020 11:55:22 -0800 Subject: [PATCH 0096/1810] Back out "Back out "[RN] Fabric: Strengthening StubView mutating validation"" Summary: Changelog: [internal] Original commit changeset: b6109a45f153 Reviewed By: JoshuaGross Differential Revision: D25020497 fbshipit-source-id: c52d5ad03dd1049ac66ecb2d82b5018a05bb4f19 --- .../react/renderer/mounting/StubView.cpp | 12 ++++++ .../react/renderer/mounting/StubView.h | 2 + .../react/renderer/mounting/StubViewTree.cpp | 38 +++++++------------ .../react/renderer/mounting/StubViewTree.h | 4 +- ReactCommon/react/renderer/mounting/stubs.cpp | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/StubView.cpp b/ReactCommon/react/renderer/mounting/StubView.cpp index f476de31184899..4d6b140da20a04 100644 --- a/ReactCommon/react/renderer/mounting/StubView.cpp +++ b/ReactCommon/react/renderer/mounting/StubView.cpp @@ -10,6 +10,18 @@ namespace facebook { namespace react { +StubView::operator ShadowView() const { + auto shadowView = ShadowView{}; + shadowView.componentName = componentName; + shadowView.componentHandle = componentHandle; + shadowView.tag = tag; + shadowView.props = props; + shadowView.eventEmitter = eventEmitter; + shadowView.layoutMetrics = layoutMetrics; + shadowView.state = state; + return shadowView; +} + void StubView::update(ShadowView const &shadowView) { componentName = shadowView.componentName; componentHandle = shadowView.componentHandle; diff --git a/ReactCommon/react/renderer/mounting/StubView.h b/ReactCommon/react/renderer/mounting/StubView.h index 8546baa157aee5..3c95f68f5be24f 100644 --- a/ReactCommon/react/renderer/mounting/StubView.h +++ b/ReactCommon/react/renderer/mounting/StubView.h @@ -25,6 +25,8 @@ class StubView final { StubView() = default; StubView(StubView const &stubView) = default; + operator ShadowView() const; + void update(ShadowView const &shadowView); ComponentName componentName; diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index 0c9dedee025294..c2e3e3d62c5f76 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -38,30 +38,19 @@ StubView const &StubViewTree::getRootStubView() const { return *registry.at(rootTag); } -/** - * ignoreDuplicateCreates: when stubs generates "fake" mutation instructions, in - * some cases it can produce too many "create" instructions. We ignore - * duplicates and treat them as noops. In the case of verifying actual diffing, - * that assert is left on. - * - * @param mutations - * @param ignoreDuplicateCreates - */ -void StubViewTree::mutate( - ShadowViewMutationList const &mutations, - bool ignoreDuplicateCreates) { +void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Mutating Begin"; }); for (auto const &mutation : mutations) { switch (mutation.type) { case ShadowViewMutation::Create: { STUB_VIEW_ASSERT(mutation.parentShadowView == ShadowView{}); STUB_VIEW_ASSERT(mutation.oldChildShadowView == ShadowView{}); + STUB_VIEW_ASSERT(mutation.newChildShadowView.props); auto stubView = std::make_shared(); + stubView->update(mutation.newChildShadowView); auto tag = mutation.newChildShadowView.tag; STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Create: " << tag; }); - if (!ignoreDuplicateCreates) { - STUB_VIEW_ASSERT(registry.find(tag) == registry.end()); - } + STUB_VIEW_ASSERT(registry.find(tag) == registry.end()); registry[tag] = stubView; break; } @@ -73,6 +62,9 @@ void StubViewTree::mutate( STUB_VIEW_ASSERT(mutation.newChildShadowView == ShadowView{}); auto tag = mutation.oldChildShadowView.tag; STUB_VIEW_ASSERT(registry.find(tag) != registry.end()); + auto stubView = registry[tag]; + STUB_VIEW_ASSERT( + (ShadowView)(*stubView) == mutation.oldChildShadowView); registry.erase(tag); break; } @@ -137,19 +129,15 @@ void StubViewTree::mutate( STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Update: " << mutation.newChildShadowView.tag; }); - - // We don't have a strict requirement that oldChildShadowView has any - // data. In particular, LayoutAnimations can produce UPDATEs with only a - // new node. + STUB_VIEW_ASSERT(mutation.newChildShadowView.props); STUB_VIEW_ASSERT( - mutation.newChildShadowView.tag == - mutation.oldChildShadowView.tag || - mutation.oldChildShadowView.tag == 0); - + mutation.newChildShadowView.tag == mutation.oldChildShadowView.tag); STUB_VIEW_ASSERT( registry.find(mutation.newChildShadowView.tag) != registry.end()); - auto stubView = registry[mutation.newChildShadowView.tag]; - stubView->update(mutation.newChildShadowView); + auto oldStubView = registry[mutation.newChildShadowView.tag]; + STUB_VIEW_ASSERT( + (ShadowView)(*oldStubView) == mutation.oldChildShadowView); + oldStubView->update(mutation.newChildShadowView); break; } } diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.h b/ReactCommon/react/renderer/mounting/StubViewTree.h index 3dceaba3dc7e97..6ffb00e63ce96a 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.h +++ b/ReactCommon/react/renderer/mounting/StubViewTree.h @@ -21,9 +21,7 @@ class StubViewTree { StubViewTree() = default; StubViewTree(ShadowView const &shadowView); - void mutate( - ShadowViewMutationList const &mutations, - bool ignoreDuplicateCreates = false); + void mutate(ShadowViewMutationList const &mutations); StubView const &getRootStubView() const; diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index 47ce20e9e2c400..370989a21a8d7a 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -54,7 +54,7 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { ShadowNode::emptySharedShadowNodeSharedList()}); auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode)); - stubViewTree.mutate(mutations, true); + stubViewTree.mutate(mutations); return stubViewTree; } From eaab64764e13033599d9af83726f4d1e86c15cf6 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 19 Nov 2020 11:55:22 -0800 Subject: [PATCH 0097/1810] Do not remove oldChildShadowView from mutation Summary: Changelog: [internal] This diff reverts some changes in D23886519 (https://github.com/facebook/react-native/commit/9f00752a97db3fe0b03cb412c5357eeebc3e2b16), I was not able to repro the issues that D23886519 (https://github.com/facebook/react-native/commit/9f00752a97db3fe0b03cb412c5357eeebc3e2b16) is fixing. `oldChildShadowView` must be defined for update mutation. Reviewed By: JoshuaGross Differential Revision: D25088008 fbshipit-source-id: 956d0cc536e35376ce0e1cc09f7c5b66cb89fc77 --- .../react/renderer/animations/LayoutAnimationDriver.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 4c382f3ead5fd5..085cdff84b1d7d 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -200,15 +200,10 @@ void LayoutAnimationDriver::animationMutationsForFrame( // Copy so that if something else mutates the inflight animations, it // won't change this mutation after this point. - ShadowView oldShadowView{}; - if (finalMutationForKeyFrame.type != - ShadowViewMutation::Type::Update) { - oldShadowView = finalMutationForKeyFrame.oldChildShadowView; - } mutationsList.push_back( ShadowViewMutation{finalMutationForKeyFrame.type, finalMutationForKeyFrame.parentShadowView, - oldShadowView, + finalMutationForKeyFrame.oldChildShadowView, finalMutationForKeyFrame.newChildShadowView, finalMutationForKeyFrame.index}); } else { From 6d2a5279841886a9a14f82057202bf8950c3f917 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 19 Nov 2020 13:10:13 -0800 Subject: [PATCH 0098/1810] Avoid eating clicks/taps into ScrollView when using physical keyboard (#30374) Summary: This is an extension of https://github.com/facebook/react-native/issues/29798 which was reverted due to cases where the soft keyboard could not be dismissed. ## Changelog [General] [Fixed] - Avoid eating clicks/taps into ScrollView when using physical keyboard Pull Request resolved: https://github.com/facebook/react-native/pull/30374 Test Plan: Validated with iOS simulator that taps on default ScrollView will dismiss soft keyboard and be eaten if open, but taps are not eaten when emulating a connected physical keyboard. Reviewed By: kacieb Differential Revision: D24935077 Pulled By: lyahdav fbshipit-source-id: 19d9cf64547e40a35f9363896e3abbdccb95b546 --- Libraries/Components/ScrollResponder.js | 32 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 7aef247b62c869..c6b0794e2f4b7a 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -186,7 +186,7 @@ const ScrollResponderMixin = { if ( this.props.keyboardShouldPersistTaps === 'handled' && - currentlyFocusedInput != null && + this.scrollResponderKeyboardIsDismissible() && e.target !== currentlyFocusedInput ) { return true; @@ -223,7 +223,6 @@ const ScrollResponderMixin = { // and a new touch starts with a non-textinput target (in which case the // first tap should be sent to the scroll view and dismiss the keyboard, // then the second tap goes to the actual interior view) - const currentlyFocusedTextInput = TextInputState.currentlyFocusedInput(); const {keyboardShouldPersistTaps} = this.props; const keyboardNeverPersistTaps = !keyboardShouldPersistTaps || keyboardShouldPersistTaps === 'never'; @@ -240,7 +239,7 @@ const ScrollResponderMixin = { if ( keyboardNeverPersistTaps && - currentlyFocusedTextInput != null && + this.scrollResponderKeyboardIsDismissible() && e.target != null && !TextInputState.isTextInput(e.target) ) { @@ -250,6 +249,31 @@ const ScrollResponderMixin = { return false; }, + /** + * Do we consider there to be a dismissible soft-keyboard open? + */ + scrollResponderKeyboardIsDismissible: function(): boolean { + const currentlyFocusedInput = TextInputState.currentlyFocusedInput(); + + // We cannot dismiss the keyboard without an input to blur, even if a soft + // keyboard is open (e.g. when keyboard is open due to a native component + // not participating in TextInputState). It's also possible that the + // currently focused input isn't a TextInput (such as by calling ref.focus + // on a non-TextInput). + const hasFocusedTextInput = + currentlyFocusedInput != null && + TextInputState.isTextInput(currentlyFocusedInput); + + // Even if an input is focused, we may not have a keyboard to dismiss. E.g + // when using a physical keyboard. Ensure we have an event for an opened + // keyboard, except on Android where setting windowSoftInputMode to + // adjustNone leads to missing keyboard events. + const softKeyboardMayBeOpen = + this.keyboardWillOpenTo != null || Platform.OS === 'android'; + + return hasFocusedTextInput && softKeyboardMayBeOpen; + }, + /** * Invoke this from an `onResponderReject` event. * @@ -324,7 +348,7 @@ const ScrollResponderMixin = { if ( this.props.keyboardShouldPersistTaps !== true && this.props.keyboardShouldPersistTaps !== 'always' && - currentlyFocusedTextInput != null && + this.scrollResponderKeyboardIsDismissible() && e.target !== currentlyFocusedTextInput && !this.state.observedScrollSinceBecomingResponder && !this.state.becameResponderWhileAnimating From 5bd5fcdd381acb65abfc5d1b50a2d342f220cd92 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 19 Nov 2020 14:50:25 -0800 Subject: [PATCH 0099/1810] LayoutAnimations: ensure that all mutations retain the correct "old" node Summary: The current implementation of LayoutAnimations assumed that the "previous/old" ShadowView passed into the diff mutation didn't matter except for purposes of diffing. As it turns out, iOS components could possibly use the "old" version of props, state, etc - so we should try to keep track of the current value in the tree as much as possible. This diff accomplishes that by keeping track of the "previous" view, which the AnimationDriver will update over time. This also allows us to simplify logic around conflicting animations. I'm also adding a few additional asserts to assist in debugging. This doesn't totally eliminate all asserts hit on iOS, yet, but it does reduce the number of times the asserts are hit in StubViewTree. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25048644 fbshipit-source-id: d00aeece5af04624d8193063be453c7ce4a6e565 --- .../animations/LayoutAnimationDriver.cpp | 129 ++++-------------- .../animations/LayoutAnimationDriver.h | 4 - .../LayoutAnimationKeyFrameManager.cpp | 111 +++++++-------- .../LayoutAnimationKeyFrameManager.h | 8 +- .../react/renderer/mounting/StubViewTree.cpp | 3 + 5 files changed, 84 insertions(+), 171 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 085cdff84b1d7d..4c68ae3f45ac83 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -29,96 +29,6 @@ namespace facebook { namespace react { -static double -getProgressFromValues(double start, double end, double currentValue) { - auto opacityMinmax = std::minmax({start, end}); - auto min = opacityMinmax.first; - auto max = opacityMinmax.second; - return ( - currentValue < min - ? 0 - : (currentValue > max ? 0 : ((max - currentValue) / (max - min)))); -} - -/** - * Given an animation and a ShadowView with properties set on it, detect how - * far through the animation the ShadowView has progressed. - * - * @param mutationsList - * @param now - */ -double LayoutAnimationDriver::getProgressThroughAnimation( - AnimationKeyFrame const &keyFrame, - LayoutAnimation const *layoutAnimation, - ShadowView const &animationStateView) const { - auto layoutAnimationConfig = layoutAnimation->layoutAnimationConfig; - auto const mutationConfig = - *(keyFrame.type == AnimationConfigurationType::Delete - ? layoutAnimationConfig.deleteConfig - : (keyFrame.type == AnimationConfigurationType::Create - ? layoutAnimationConfig.createConfig - : layoutAnimationConfig.updateConfig)); - - auto initialProps = keyFrame.viewStart.props; - auto finalProps = keyFrame.viewEnd.props; - - if (mutationConfig.animationProperty == AnimationProperty::Opacity) { - // Detect progress through opacity animation. - const auto &oldViewProps = - dynamic_cast(initialProps.get()); - const auto &newViewProps = - dynamic_cast(finalProps.get()); - const auto &animationStateViewProps = - dynamic_cast(animationStateView.props.get()); - if (oldViewProps != nullptr && newViewProps != nullptr && - animationStateViewProps != nullptr) { - return getProgressFromValues( - oldViewProps->opacity, - newViewProps->opacity, - animationStateViewProps->opacity); - } - } else if ( - mutationConfig.animationProperty != AnimationProperty::NotApplicable) { - // Detect progress through layout animation. - LayoutMetrics const &finalLayoutMetrics = keyFrame.viewEnd.layoutMetrics; - LayoutMetrics const &baselineLayoutMetrics = - keyFrame.viewStart.layoutMetrics; - LayoutMetrics const &animationStateLayoutMetrics = - animationStateView.layoutMetrics; - - if (baselineLayoutMetrics.frame.size.height != - finalLayoutMetrics.frame.size.height) { - return getProgressFromValues( - baselineLayoutMetrics.frame.size.height, - finalLayoutMetrics.frame.size.height, - animationStateLayoutMetrics.frame.size.height); - } - if (baselineLayoutMetrics.frame.size.width != - finalLayoutMetrics.frame.size.width) { - return getProgressFromValues( - baselineLayoutMetrics.frame.size.width, - finalLayoutMetrics.frame.size.width, - animationStateLayoutMetrics.frame.size.width); - } - if (baselineLayoutMetrics.frame.origin.x != - finalLayoutMetrics.frame.origin.x) { - return getProgressFromValues( - baselineLayoutMetrics.frame.origin.x, - finalLayoutMetrics.frame.origin.x, - animationStateLayoutMetrics.frame.origin.x); - } - if (baselineLayoutMetrics.frame.origin.y != - finalLayoutMetrics.frame.origin.y) { - return getProgressFromValues( - baselineLayoutMetrics.frame.origin.y, - finalLayoutMetrics.frame.origin.y, - animationStateLayoutMetrics.frame.origin.y); - } - } - - return 0; -} - void LayoutAnimationDriver::animationMutationsForFrame( SurfaceId surfaceId, ShadowViewMutation::List &mutationsList, @@ -132,7 +42,7 @@ void LayoutAnimationDriver::animationMutationsForFrame( } int incompleteAnimations = 0; - for (const auto &keyframe : animation.keyFrames) { + for (auto &keyframe : animation.keyFrames) { if (keyframe.type == AnimationConfigurationType::Noop) { continue; } @@ -164,10 +74,19 @@ void LayoutAnimationDriver::animationMutationsForFrame( // Create the mutation instruction auto updateMutation = ShadowViewMutation::UpdateMutation( - keyframe.parentView, baselineShadowView, mutatedShadowView, -1); + keyframe.parentView, keyframe.viewPrev, mutatedShadowView, -1); + + // All generated Update mutations must have an "old" and "new" + // ShadowView. Checking for nonzero tag doesn't guarantee that the views + // are valid/correct, just that something is there. + assert(updateMutation.oldChildShadowView.tag != 0); + assert(updateMutation.newChildShadowView.tag != 0); + mutationsList.push_back(updateMutation); PrintMutationInstruction("Animation Progress:", updateMutation); + keyframe.viewPrev = mutatedShadowView; + if (animationTimeProgressLinear < 1) { incompleteAnimations++; } @@ -200,23 +119,31 @@ void LayoutAnimationDriver::animationMutationsForFrame( // Copy so that if something else mutates the inflight animations, it // won't change this mutation after this point. - mutationsList.push_back( + auto mutation = ShadowViewMutation{finalMutationForKeyFrame.type, finalMutationForKeyFrame.parentShadowView, - finalMutationForKeyFrame.oldChildShadowView, + keyframe.viewPrev, finalMutationForKeyFrame.newChildShadowView, - finalMutationForKeyFrame.index}); + finalMutationForKeyFrame.index}; + assert(mutation.oldChildShadowView.tag != 0); + assert( + mutation.newChildShadowView.tag != 0 || + finalMutationForKeyFrame.type == ShadowViewMutation::Remove || + finalMutationForKeyFrame.type == ShadowViewMutation::Delete); + mutationsList.push_back(mutation); } else { // Issue a final UPDATE so that the final props object sent to the // mounting layer is the same as the one on the ShadowTree. This is // mostly to make the MountingCoordinator StubViewTree assertions // pass. - mutationsList.push_back( - ShadowViewMutation{ShadowViewMutation::Type::Update, - keyframe.parentView, - {}, - keyframe.viewEnd, - -1}); + auto mutation = ShadowViewMutation{ShadowViewMutation::Type::Update, + keyframe.parentView, + keyframe.viewPrev, + keyframe.viewEnd, + -1}; + assert(mutation.oldChildShadowView.tag != 0); + assert(mutation.newChildShadowView.tag != 0); + mutationsList.push_back(mutation); } } diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h index 59033afca14463..b0d0dabab851a6 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h @@ -35,10 +35,6 @@ class LayoutAnimationDriver : public LayoutAnimationKeyFrameManager { SurfaceId surfaceId, ShadowViewMutation::List &mutationsList, uint64_t now) const override; - virtual double getProgressThroughAnimation( - AnimationKeyFrame const &keyFrame, - LayoutAnimation const *layoutAnimation, - ShadowView const &animationStateView) const override; }; } // namespace react diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 7ed615bef2edb4..248092f1ee0853 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -667,9 +667,7 @@ LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( bool conflicting = animatedKeyFrame.tag == baselineShadowView.tag || ((mutation.type == ShadowViewMutation::Type::Delete || mutation.type == ShadowViewMutation::Type::Create) && - animatedKeyFrame.parentView.tag == baselineShadowView.tag) /* || - finalMutationTag == baselineShadowView.tag*/ - ; + animatedKeyFrame.parentView.tag == baselineShadowView.tag); // Conflicting animation detected: if we're mutating a tag under // animation, or deleting the parent of a tag under animation, or @@ -888,7 +886,8 @@ LayoutAnimationKeyFrameManager::pullTransaction( for (auto const &mutation : mutations) { ShadowView baselineShadowView = (mutation.type == ShadowViewMutation::Type::Delete || - mutation.type == ShadowViewMutation::Type::Remove + mutation.type == ShadowViewMutation::Type::Remove || + mutation.type == ShadowViewMutation::Type::Update ? mutation.oldChildShadowView : mutation.newChildShadowView); bool haveComponentDescriptor = @@ -949,7 +948,9 @@ LayoutAnimationKeyFrameManager::pullTransaction( mutation.newChildShadowView.tag, mutation.parentShadowView, movedIt->second.oldChildShadowView, - mutation.newChildShadowView}); + mutation.newChildShadowView, + movedIt->second.oldChildShadowView, + 0}); } } @@ -1017,6 +1018,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( parent, viewStart, viewFinal, + baselineShadowView, 0}; } else if (mutation.type == ShadowViewMutation::Type::Delete) { if (mutationConfig->animationProperty == @@ -1058,6 +1060,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( parent, viewStart, viewFinal, + baselineShadowView, 0}; } else if (mutation.type == ShadowViewMutation::Type::Update) { viewFinal = ShadowView(mutation.newChildShadowView); @@ -1069,6 +1072,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( parent, viewStart, viewFinal, + baselineShadowView, 0}; } else { // This should just be "Remove" instructions that are not animated @@ -1092,8 +1096,9 @@ LayoutAnimationKeyFrameManager::pullTransaction( AnimationConfigurationType::Noop, tag, parent, - {}, - {}, + mutation.oldChildShadowView, + mutation.oldChildShadowView, + mutation.oldChildShadowView, 0}; } else { PrintMutationInstruction( @@ -1112,30 +1117,13 @@ LayoutAnimationKeyFrameManager::pullTransaction( // We've found a conflict. if (conflictingMutationBaselineShadowView.tag == tag) { - // What's the progress of this ongoing animation? - double conflictingAnimationProgress = - calculateAnimationProgress( - now, - *std::get<2>(conflictingKeyframeTuple), - std::get<1>(conflictingKeyframeTuple)) - .first; - - // Get a baseline ShadowView at the current progress of the - // inflight animation. TODO: handle multiple properties being - // animated separately? - auto interpolatedInflightShadowView = - createInterpolatedShadowView( - conflictingAnimationProgress, - conflictingKeyFrame.viewStart, - conflictingKeyFrame.viewEnd); - // Pick a Prop or layout property, depending on the current // animation configuration. Figure out how much progress we've // already made in the current animation, and start the animation // from this point. - keyFrame.viewStart = interpolatedInflightShadowView; - keyFrame.initialProgress = getProgressThroughAnimation( - keyFrame, &animation, interpolatedInflightShadowView); + keyFrame.viewStart = conflictingKeyFrame.viewPrev; + assert(keyFrame.viewStart.tag != 0); + keyFrame.initialProgress = 0; // We're guaranteed that a tag only has one animation associated // with it, so we can break here. If we support multiple @@ -1145,6 +1133,9 @@ LayoutAnimationKeyFrameManager::pullTransaction( } } + assert(keyFrame.viewStart.tag != 0); + assert(keyFrame.viewEnd.tag != 0); + assert(keyFrame.viewPrev.tag != 0); keyFramesToAnimate.push_back(keyFrame); } @@ -1185,36 +1176,32 @@ LayoutAnimationKeyFrameManager::pullTransaction( for (auto const &conflictingKeyframeTuple : conflictingAnimations) { auto &keyFrame = std::get<0>(conflictingKeyframeTuple); if (keyFrame.finalMutationForKeyFrame.hasValue()) { - auto &mutation = *keyFrame.finalMutationForKeyFrame; - if (mutation.type == ShadowViewMutation::Type::Update) { - auto mutationInstruction = ShadowViewMutation::UpdateMutation( - mutation.parentShadowView, - {}, - mutation.newChildShadowView, - mutation.index); - PrintMutationInstruction( - "Queueing up final mutation instruction - update:", - mutationInstruction); - finalConflictingMutations.push_back(std::move(mutationInstruction)); - } else { - PrintMutationInstruction( - "Queueing up final mutation instruction - non-update", - mutation); - finalConflictingMutations.push_back(mutation); - } + auto &finalMutation = *keyFrame.finalMutationForKeyFrame; + auto mutationInstruction = + ShadowViewMutation{finalMutation.type, + finalMutation.parentShadowView, + keyFrame.viewPrev, + finalMutation.newChildShadowView, + finalMutation.index}; + PrintMutationInstruction( + "Queueing up final mutation instruction - update:", + mutationInstruction); + assert(mutationInstruction.oldChildShadowView.tag != 0); + assert( + mutationInstruction.newChildShadowView.tag != 0 || + mutationInstruction.type == ShadowViewMutation::Delete || + mutationInstruction.type == ShadowViewMutation::Remove); + finalConflictingMutations.push_back(mutationInstruction); } else { // If there's no final mutation associated, create a mutation that // corresponds to the animation being 100% complete. This is important // for, for example, INSERT mutations being animated from opacity 0 // to 1. If the animation is interrupted we must force the View to be // at opacity 1. - auto mutatedShadowView = createInterpolatedShadowView( - 1, keyFrame.viewStart, keyFrame.viewEnd); auto generatedMutation = ShadowViewMutation::UpdateMutation( - keyFrame.parentView, - keyFrame.viewStart, - std::move(mutatedShadowView), - -1); + keyFrame.parentView, keyFrame.viewPrev, keyFrame.viewEnd, -1); + assert(generatedMutation.oldChildShadowView.tag != 0); + assert(generatedMutation.newChildShadowView.tag != 0); PrintMutationInstruction( "Queueing up final mutation instruction - synthetic", generatedMutation); @@ -1361,28 +1348,30 @@ LayoutAnimationKeyFrameManager::pullTransaction( for (auto const &conflictingKeyframeTuple : conflictingAnimations) { auto &keyFrame = std::get<0>(conflictingKeyframeTuple); if (keyFrame.finalMutationForKeyFrame.hasValue()) { + auto &finalMutation = (*keyFrame.finalMutationForKeyFrame); + auto mutation = ShadowViewMutation{finalMutation.type, + finalMutation.parentShadowView, + keyFrame.viewPrev, + finalMutation.newChildShadowView, + finalMutation.index}; PrintMutationInstruction( - "No Animation: Queueing final mutation instruction", - *keyFrame.finalMutationForKeyFrame); - finalMutationsForConflictingAnimations.push_back( - *keyFrame.finalMutationForKeyFrame); + "No Animation: Queueing up final conflicting mutation instruction", + mutation); + finalMutationsForConflictingAnimations.push_back(mutation); } else { // If there's no final mutation associated, create a mutation that // corresponds to the animation being 100% complete. This is important // for, for example, INSERT mutations being animated from opacity 0 // to 1. If the animation is interrupted we must force the View to be // at opacity 1. - auto mutatedShadowView = createInterpolatedShadowView( - 1, keyFrame.viewStart, keyFrame.viewEnd); auto generatedMutation = ShadowViewMutation::UpdateMutation( - keyFrame.parentView, - keyFrame.viewStart, - std::move(mutatedShadowView), - -1); + keyFrame.parentView, keyFrame.viewPrev, keyFrame.viewEnd, -1); + assert(generatedMutation.oldChildShadowView.tag != 0); + assert(generatedMutation.newChildShadowView.tag != 0); PrintMutationInstruction( "Queueing up final mutation instruction - synthetic", generatedMutation); - // Create the mutation instruction + // Create the mutation instructions finalMutationsForConflictingAnimations.push_back(generatedMutation); } } diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 5d69cec5688fb0..6cb5176001a0c0 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -103,6 +103,9 @@ struct AnimationKeyFrame { ShadowView viewStart; ShadowView viewEnd; + // ShadowView representing the previous frame of the animation. + ShadowView viewPrev; + // If an animation interrupts an existing one, the starting state may actually // be halfway through the intended transition. double initialProgress; @@ -252,11 +255,6 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, ShadowViewMutation::List &mutationsList, uint64_t now) const = 0; - virtual double getProgressThroughAnimation( - AnimationKeyFrame const &keyFrame, - LayoutAnimation const *layoutAnimation, - ShadowView const &animationStateView) const = 0; - SharedComponentDescriptorRegistry componentDescriptorRegistry_; mutable better::optional currentAnimation_{}; mutable std::mutex currentAnimationMutex_; diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index c2e3e3d62c5f76..4268b35e166c5f 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -129,12 +129,15 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Update: " << mutation.newChildShadowView.tag; }); + STUB_VIEW_ASSERT(mutation.oldChildShadowView.tag != 0); + STUB_VIEW_ASSERT(mutation.newChildShadowView.tag != 0); STUB_VIEW_ASSERT(mutation.newChildShadowView.props); STUB_VIEW_ASSERT( mutation.newChildShadowView.tag == mutation.oldChildShadowView.tag); STUB_VIEW_ASSERT( registry.find(mutation.newChildShadowView.tag) != registry.end()); auto oldStubView = registry[mutation.newChildShadowView.tag]; + STUB_VIEW_ASSERT(oldStubView->tag != 0); STUB_VIEW_ASSERT( (ShadowView)(*oldStubView) == mutation.oldChildShadowView); oldStubView->update(mutation.newChildShadowView); From a45c9213961cec3f955f1d07223b8ff9b14a4162 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 19 Nov 2020 14:50:25 -0800 Subject: [PATCH 0100/1810] Keep "previous" ShadowView for animations consistent with MOVE sequences (UPDATE/REMOVE/INSERT) Summary: See comments, hopefully they explain this situation. This fixes the last remaining case that I have repro'd where StubViewTree asserts fire. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25062135 fbshipit-source-id: a28afba21f4094200aa0502b1e085dcbc10f9835 --- .../LayoutAnimationKeyFrameManager.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 248092f1ee0853..2e7258f3721295 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -961,6 +961,32 @@ LayoutAnimationKeyFrameManager::pullTransaction( mutation.type == ShadowViewMutation::Type::Create || mutation.type == ShadowViewMutation::Type::Insert) { executeMutationImmediately = true; + + // It is possible, especially in the case of "moves", that we have a + // sequence of operations like: + // UPDATE X + // REMOVE X + // INSERT X + // In these cases, we will have queued up an animation for the UPDATE + // and delayed its execution; the REMOVE and INSERT will be executed + // first; and then the UPDATE will be animating to/from ShadowViews + // that are out-of-sync with what's on the mounting layer. Thus, for + // any UPDATE animations already queued up for this tag, we adjust the + // "previous" ShadowView. + if (mutation.type == ShadowViewMutation::Type::Insert) { + for (auto &keyframe : keyFramesToAnimate) { + if (keyframe.tag == baselineShadowView.tag) { + // If there's already an animation queued up, followed by this + // Insert, it *must* be an Update mutation animation. Other + // sequences should not be possible. + assert(keyframe.type == AnimationConfigurationType::Update); + + keyframe.viewPrev = mutation.newChildShadowView.tag != 0 + ? mutation.newChildShadowView + : mutation.oldChildShadowView; + } + } + } } // Deletes, non-move inserts, updates get animated @@ -1140,6 +1166,8 @@ LayoutAnimationKeyFrameManager::pullTransaction( } if (executeMutationImmediately) { + PrintMutationInstruction( + "Queue Up Animation For Immediate Execution", mutation); immediateMutations.push_back(mutation); } } From 0423eab4ee867af958e7a219354e137f7f6959f8 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 19 Nov 2020 14:50:25 -0800 Subject: [PATCH 0101/1810] LayoutAnimations: remove noisy, non-useful log Summary: This is noisy when enabled, and not very useful. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25071584 fbshipit-source-id: 7205b5fa39622feccaf315ccebb181dbdac4281d --- .../react/renderer/animations/LayoutAnimationKeyFrameManager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 2e7258f3721295..dc64a7d13aba00 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -640,7 +640,6 @@ LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( if (deletesOnly && mutation.type != ShadowViewMutation::Type::Delete) { continue; } - PrintMutationInstruction("getAndEraseConflictingAnimations of: ", mutation); auto const &baselineShadowView = (mutation.type == ShadowViewMutation::Type::Insert || From b3865a914334570fd88fa47d74286b4aa881fac5 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 19 Nov 2020 14:50:25 -0800 Subject: [PATCH 0102/1810] LayoutAnimations: attempt to re-queue animations if an UPDATE conflicts with a REMOVE+INSERT (move) without a corresponding Update Summary: Imagine the scenario in which there's an ongoing UPDATE animation; a REMOVE+INSERT (move) is queued up for the same tag, but there's no new corresponding UPDATE - so maybe the indices of the view have changed, but the layout stays the same. Under the old model, the previous animation would be canceled and the node would jump to the final position. In theory, if there's no new UPDATE, we should continue animating the node to its final position. I'm much happier with this - conflicting animations transition into each other super seamlessly now, and I think the logic is more straightforward as well. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25071664 fbshipit-source-id: fcefc4619dc34cdafdc4d8e8e730b935e5528290 --- .../LayoutAnimationKeyFrameManager.cpp | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index dc64a7d13aba00..7e00c3bd3cdc4d 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1200,8 +1200,46 @@ LayoutAnimationKeyFrameManager::pullTransaction( #endif auto finalConflictingMutations = ShadowViewMutationList{}; - for (auto const &conflictingKeyframeTuple : conflictingAnimations) { + for (auto &conflictingKeyframeTuple : conflictingAnimations) { auto &keyFrame = std::get<0>(conflictingKeyframeTuple); + + // Special-case: if we have some (1) ongoing UPDATE animation, + // (2) it conflicted with a new MOVE operation (REMOVE+INSERT) + // without another corresponding UPDATE, we should re-queue the + // keyframe so that its position/props don't suddenly "jump". + if (keyFrame.type == AnimationConfigurationType::Update) { + auto movedIt = movedTags.find(keyFrame.tag); + if (movedIt != movedTags.end()) { + auto newKeyFrameForUpdate = std::find_if( + keyFramesToAnimate.begin(), + keyFramesToAnimate.end(), + [&](auto const &newKeyFrame) { + return newKeyFrame.type == + AnimationConfigurationType::Update && + newKeyFrame.tag == keyFrame.tag; + }); + if (newKeyFrameForUpdate == keyFramesToAnimate.end()) { + keyFrame.invalidated = false; + + // The animation will continue from the current position - we + // restart viewStart to make sure there are no sudden jumps + keyFrame.viewStart = keyFrame.viewPrev; + + // Find the insert mutation that conflicted with this update + for (auto &mutation : immediateMutations) { + if (mutation.newChildShadowView.tag == keyFrame.tag && + (mutation.type == ShadowViewMutation::Insert || + mutation.type == ShadowViewMutation::Create)) { + keyFrame.viewPrev = mutation.newChildShadowView; + keyFrame.viewEnd = mutation.newChildShadowView; + } + } + keyFramesToAnimate.push_back(keyFrame); + continue; + } + } + } + if (keyFrame.finalMutationForKeyFrame.hasValue()) { auto &finalMutation = *keyFrame.finalMutationForKeyFrame; auto mutationInstruction = From 7e7527e7db9068390f28de8264289c8c50053831 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 15:52:24 -0800 Subject: [PATCH 0103/1810] RN: Preserve Style Type in `flattenStyle` Summary: Refactors `flattenStyle` so that it preserves the style type of the argument. This lets us avoid using `DangerouslyImpreciseStyleProp` where we can. Changelog: [Internal] Reviewed By: JoshuaGross, nadiia, kacieb Differential Revision: D25097227 fbshipit-source-id: df6af6fefab25dbb62e3c81897c3cef98619a9c7 --- .../ReactPrivate/ReactNativePrivateInterface.js | 3 ++- Libraries/StyleSheet/StyleSheetTypes.js | 5 +++++ Libraries/StyleSheet/flattenStyle.js | 12 +++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Libraries/ReactPrivate/ReactNativePrivateInterface.js b/Libraries/ReactPrivate/ReactNativePrivateInterface.js index d67720d28fe1a7..603912af5ba2ae 100644 --- a/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ b/Libraries/ReactPrivate/ReactNativePrivateInterface.js @@ -18,6 +18,7 @@ import typeof UIManager from '../ReactNative/UIManager'; import typeof deepDiffer from '../Utilities/differ/deepDiffer'; import typeof deepFreezeAndThrowOnMutationInDev from '../Utilities/deepFreezeAndThrowOnMutationInDev'; import typeof flattenStyle from '../StyleSheet/flattenStyle'; +import {type DangerouslyImpreciseStyleProp} from '../StyleSheet/StyleSheet'; import typeof ReactFiberErrorDialog from '../Core/ReactFiberErrorDialog'; // flowlint unsafe-getters-setters:off @@ -52,7 +53,7 @@ module.exports = { > { return require('../Utilities/deepFreezeAndThrowOnMutationInDev'); }, - get flattenStyle(): flattenStyle { + get flattenStyle(): flattenStyle { return require('../StyleSheet/flattenStyle'); }, get ReactFiberErrorDialog(): ReactFiberErrorDialog { diff --git a/Libraries/StyleSheet/StyleSheetTypes.js b/Libraries/StyleSheet/StyleSheetTypes.js index 95ed2b8a2cced7..5a32873e345643 100644 --- a/Libraries/StyleSheet/StyleSheetTypes.js +++ b/Libraries/StyleSheet/StyleSheetTypes.js @@ -675,3 +675,8 @@ export type ____Styles_Internal = { +[key: string]: $Shape<____DangerouslyImpreciseStyle_Internal>, ..., }; + +export type ____FlattenStyleProp_Internal<+TStyleProp> = $Call< + (GenericStyleProp) => T, + TStyleProp, +>; diff --git a/Libraries/StyleSheet/flattenStyle.js b/Libraries/StyleSheet/flattenStyle.js index 679e39b3af6643..488ef19d061336 100644 --- a/Libraries/StyleSheet/flattenStyle.js +++ b/Libraries/StyleSheet/flattenStyle.js @@ -10,14 +10,12 @@ 'use strict'; -import type { - DangerouslyImpreciseStyle, - DangerouslyImpreciseStyleProp, -} from './StyleSheet'; +import type {DangerouslyImpreciseStyleProp} from './StyleSheet'; +import type {____FlattenStyleProp_Internal} from './StyleSheetTypes'; -function flattenStyle( - style: ?DangerouslyImpreciseStyleProp, -): ?DangerouslyImpreciseStyle { +function flattenStyle<+TStyleProp: DangerouslyImpreciseStyleProp>( + style: ?TStyleProp, +): ?____FlattenStyleProp_Internal { if (style === null || typeof style !== 'object') { return undefined; } From 54a067e61ea5d5c149ed137e51aacc59fbaef2e4 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 15:52:24 -0800 Subject: [PATCH 0104/1810] RN: Refactor `ScrollView` Style Splitting Summary: Rewrites `splitLayoutProps`, which is only used by `ScrollView`. - Improve type safety by avoiding `DangerouslyImpreciseStyle`. - Avoid allocating objects when it is not necessary. - Avoid allocating a object enumeratig layout props by using a switch statement. Changelog: [Internal] Reviewed By: JoshuaGross, kacieb Differential Revision: D25097226 fbshipit-source-id: 2050c03b681024212c06a48b7eb05f28c14415f9 --- Libraries/Components/ScrollView/ScrollView.js | 6 +- .../__snapshots__/ScrollView-test.js.snap | 15 ++- .../__tests__/splitLayoutProps-test.js | 8 +- Libraries/StyleSheet/splitLayoutProps.js | 96 ++++++++++--------- 4 files changed, 66 insertions(+), 59 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index a069a24c733b87..0015a9daabfde1 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1138,7 +1138,7 @@ class ScrollView extends React.Component { ...this.props, alwaysBounceHorizontal, alwaysBounceVertical, - style: [baseStyle, this.props.style], + style: StyleSheet.compose(baseStyle, this.props.style), // Override the onContentSizeChange from props, since this event can // bubble up from TextInputs onContentSizeChange: null, @@ -1224,10 +1224,10 @@ class ScrollView extends React.Component { const {outer, inner} = splitLayoutProps(flattenStyle(props.style)); return React.cloneElement( refreshControl, - {style: [baseStyle, outer]}, + {style: StyleSheet.compose(baseStyle, outer)}, {contentContainer} , diff --git a/Libraries/Components/ScrollView/__tests__/__snapshots__/ScrollView-test.js.snap b/Libraries/Components/ScrollView/__tests__/__snapshots__/ScrollView-test.js.snap index 1afba0ee035cd2..de40fd6e028016 100644 --- a/Libraries/Components/ScrollView/__tests__/__snapshots__/ScrollView-test.js.snap +++ b/Libraries/Components/ScrollView/__tests__/__snapshots__/ScrollView-test.js.snap @@ -40,15 +40,12 @@ exports[` should render as expected: should deep render when not m snapToEnd={true} snapToStart={true} style={ - Array [ - Object { - "flexDirection": "column", - "flexGrow": 1, - "flexShrink": 1, - "overflow": "scroll", - }, - undefined, - ] + Object { + "flexDirection": "column", + "flexGrow": 1, + "flexShrink": 1, + "overflow": "scroll", + } } > { const style = {width: 10, margin: 20, padding: 30, transform: {scaleY: -1}}; @@ -45,3 +45,9 @@ test('does not copy values to both returned objects', () => { } `); }); + +test('returns null values if argument is null', () => { + const {outer, inner} = splitLayoutProps(null); + expect(outer).toBe(null); + expect(inner).toBe(null); +}); diff --git a/Libraries/StyleSheet/splitLayoutProps.js b/Libraries/StyleSheet/splitLayoutProps.js index 2c6fd33f87eca1..03bb726001e1ac 100644 --- a/Libraries/StyleSheet/splitLayoutProps.js +++ b/Libraries/StyleSheet/splitLayoutProps.js @@ -4,61 +4,65 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format * @flow strict-local + * @format */ 'use strict'; -import type {DangerouslyImpreciseStyle} from './StyleSheet'; +import type {____ViewStyle_Internal} from './StyleSheetTypes'; -const OUTER_PROPS = Object.assign(Object.create(null), { - margin: true, - marginHorizontal: true, - marginVertical: true, - marginBottom: true, - marginTop: true, - marginLeft: true, - marginRight: true, - flex: true, - flexGrow: true, - flexShrink: true, - flexBasis: true, - alignSelf: true, - height: true, - minHeight: true, - maxHeight: true, - width: true, - minWidth: true, - maxWidth: true, - position: true, - left: true, - right: true, - bottom: true, - top: true, - transform: true, -}); - -function splitLayoutProps( - props: ?DangerouslyImpreciseStyle, +export default function splitLayoutProps( + props: ?____ViewStyle_Internal, ): { - outer: DangerouslyImpreciseStyle, - inner: DangerouslyImpreciseStyle, - ... + outer: ?____ViewStyle_Internal, + inner: ?____ViewStyle_Internal, } { - const inner = {}; - const outer = {}; - if (props) { - Object.keys(props).forEach((k: string) => { - const value = props[k]; - if (OUTER_PROPS[k]) { - outer[k] = value; - } else { - inner[k] = value; + let outer: ?____ViewStyle_Internal = null; + let inner: ?____ViewStyle_Internal = null; + + if (props != null) { + // $FlowIgnore[incompatible-exact] Will contain a subset of keys from `props`. + // $FlowIgnore[incompatible-type] Values are preserved within a key. + outer = {}; + // $FlowIgnore[incompatible-exact] Will contain a subset of keys from `props`. + // $FlowIgnore[incompatible-type] Values are preserved within a key. + inner = {}; + + for (const prop of Object.keys(props)) { + switch (prop) { + case 'margin': + case 'marginHorizontal': + case 'marginVertical': + case 'marginBottom': + case 'marginTop': + case 'marginLeft': + case 'marginRight': + case 'flex': + case 'flexGrow': + case 'flexShrink': + case 'flexBasis': + case 'alignSelf': + case 'height': + case 'minHeight': + case 'maxHeight': + case 'width': + case 'minWidth': + case 'maxWidth': + case 'position': + case 'left': + case 'right': + case 'bottom': + case 'top': + case 'transform': + outer[prop] = props[prop]; + break; + default: + inner[prop] = props[prop]; + break; } - }); + } } + return {outer, inner}; } - -module.exports = splitLayoutProps; From d4e29ecdaaaa0c44aff8e8b598e3411339042e5e Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 15:52:24 -0800 Subject: [PATCH 0105/1810] RN: Fix `ScrollView` Type Errors Summary: Fixes some of the type errors in `ScrollView` that were previously being suppressed by comments. This also slightly simplifies the implementation of `ScrollView`. Changelog: [Internal] Reviewed By: kacieb Differential Revision: D25097225 fbshipit-source-id: a444db8179c91e264671d8f32431b93c4da8dfc4 --- Libraries/Components/ScrollView/ScrollView.js | 95 ++++++++----------- .../ScrollViewNativeComponentType.js | 13 +-- 2 files changed, 41 insertions(+), 67 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 0015a9daabfde1..0492c76bf6e60a 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -48,20 +48,25 @@ import ScrollContentViewNativeComponent from './ScrollContentViewNativeComponent import AndroidHorizontalScrollViewNativeComponent from './AndroidHorizontalScrollViewNativeComponent'; import AndroidHorizontalScrollContentViewNativeComponent from './AndroidHorizontalScrollContentViewNativeComponent'; -let AndroidScrollView; -let AndroidHorizontalScrollContentView; -let AndroidHorizontalScrollView; -let RCTScrollView; -let RCTScrollContentView; - -if (Platform.OS === 'android') { - AndroidScrollView = ScrollViewNativeComponent; - AndroidHorizontalScrollView = AndroidHorizontalScrollViewNativeComponent; - AndroidHorizontalScrollContentView = AndroidHorizontalScrollContentViewNativeComponent; -} else { - RCTScrollView = ScrollViewNativeComponent; - RCTScrollContentView = ScrollContentViewNativeComponent; -} +const {NativeHorizontalScrollViewTuple, NativeVerticalScrollViewTuple} = + Platform.OS === 'android' + ? { + NativeHorizontalScrollViewTuple: [ + AndroidHorizontalScrollViewNativeComponent, + AndroidHorizontalScrollContentViewNativeComponent, + ], + NativeVerticalScrollViewTuple: [ScrollViewNativeComponent, View], + } + : { + NativeHorizontalScrollViewTuple: [ + ScrollViewNativeComponent, + ScrollContentViewNativeComponent, + ], + NativeVerticalScrollViewTuple: [ + ScrollViewNativeComponent, + ScrollContentViewNativeComponent, + ], + }; // Public methods for ScrollView export type ScrollViewImperativeMethods = $ReadOnly<{| @@ -1008,30 +1013,10 @@ class ScrollView extends React.Component { }); render(): React.Node | React.Element { - let ScrollViewClass; - let ScrollContentContainerViewClass; - if (Platform.OS === 'android') { - if (this.props.horizontal === true) { - ScrollViewClass = AndroidHorizontalScrollView; - ScrollContentContainerViewClass = AndroidHorizontalScrollContentView; - } else { - ScrollViewClass = AndroidScrollView; - ScrollContentContainerViewClass = View; - } - } else { - ScrollViewClass = RCTScrollView; - ScrollContentContainerViewClass = RCTScrollContentView; - } - - invariant( - ScrollViewClass !== undefined, - 'ScrollViewClass must not be undefined', - ); - - invariant( - ScrollContentContainerViewClass !== undefined, - 'ScrollContentContainerViewClass must not be undefined', - ); + const [NativeDirectionalScrollView, NativeDirectionalScrollContentView] = + this.props.horizontal === true + ? NativeHorizontalScrollViewTuple + : NativeVerticalScrollViewTuple; const contentContainerStyle = [ this.props.horizontal === true && styles.contentContainerHorizontal, @@ -1050,12 +1035,12 @@ class ScrollView extends React.Component { ); } - let contentSizeChangeProps = {}; - if (this.props.onContentSizeChange) { - contentSizeChangeProps = { - onLayout: this._handleContentOnLayout, - }; - } + const contentSizeChangeProps = + this.props.onContentSizeChange == null + ? null + : { + onLayout: this._handleContentOnLayout, + }; const {stickyHeaderIndices} = this.props; let children = this.props.children; @@ -1101,10 +1086,7 @@ class ScrollView extends React.Component { Array.isArray(stickyHeaderIndices) && stickyHeaderIndices.length > 0; const contentContainer = ( - /* $FlowFixMe(>=0.112.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.112 was deployed. To see the error, delete - * this comment and run Flow. */ - { } collapsable={false}> {children} - + ); const alwaysBounceHorizontal = @@ -1207,13 +1189,10 @@ class ScrollView extends React.Component { if (Platform.OS === 'ios') { // On iOS the RefreshControl is a child of the ScrollView. return ( - /* $FlowFixMe(>=0.117.0 site=react_native_fb) This comment suppresses - * an error found when Flow v0.117 was deployed. To see the error, - * delete this comment and run Flow. */ - + {refreshControl} {contentContainer} - + ); } else if (Platform.OS === 'android') { // On Android wrap the ScrollView with a AndroidSwipeRefreshLayout. @@ -1225,19 +1204,19 @@ class ScrollView extends React.Component { return React.cloneElement( refreshControl, {style: StyleSheet.compose(baseStyle, outer)}, - {contentContainer} - , + , ); } } return ( - + {contentContainer} - + ); } } diff --git a/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js b/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js index a6366e8b62b347..13af2ed6146c83 100644 --- a/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +++ b/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js @@ -4,18 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow strict-local * @format - * @flow */ 'use strict'; import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {ViewProps} from '../View/ViewPropTypes'; -import type { - ViewStyleProp, - DangerouslyImpreciseStyle, -} from '../../StyleSheet/StyleSheet'; import type {ColorValue} from '../../StyleSheet/StyleSheet'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; import type {ScrollEvent} from '../../Types/CoreEventTypes'; @@ -45,10 +41,10 @@ export type ScrollViewNativeProps = $ReadOnly<{ fadingEdgeLength?: ?number, indicatorStyle?: ?('default' | 'black' | 'white'), keyboardDismissMode?: ?('none' | 'on-drag' | 'interactive'), - maintainVisibleContentPosition?: ?$ReadOnly<{| + maintainVisibleContentPosition?: ?$ReadOnly<{ minIndexForVisible: number, autoscrollToTopThreshold?: ?number, - |}>, + }>, maximumZoomScale?: ?number, minimumZoomScale?: ?number, nestedScrollEnabled?: ?boolean, @@ -78,8 +74,7 @@ export type ScrollViewNativeProps = $ReadOnly<{ snapToStart?: ?boolean, zoomScale?: ?number, // Overrides - style?: {...ViewStyleProp, ...} | DangerouslyImpreciseStyle, - onResponderGrant?: ?(e: any) => void | boolean, + onResponderGrant?: ?(e: $FlowFixMe) => void | boolean, ... }>; From 00e623ddbb61c1af4c6384f5f3d4e07429b53953 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 19 Nov 2020 15:52:24 -0800 Subject: [PATCH 0106/1810] RN: Migrate `ScrollView` to NativeComponentRegistry Summary: Migrates `ScrollView` (and its related native components) to use `NativeComponentRegistry`. This will enable it to be configured using experiments to conditionally use the native `ViewConfig` or verify the static `ViewConfig`. This also cleans up a bunch of the modules and types related to defining the native `ScrollView` component. This also proposes adopting the same module naming protocol was has been adopted for TurboModules (i.e. `NativeScrollView` instead of `ScrollViewNativeComponent`). Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25098530 fbshipit-source-id: ff1394bfac023daf58e85d5f9068e4f8da3538be --- ...izontalScrollContentViewNativeComponent.js | 40 --------- ...roidHorizontalScrollViewNativeComponent.js | 57 ------------ ...ativeAndroidHorizontalScrollContentView.js | 27 ++++++ .../NativeAndroidHorizontalScrollView.js | 45 ++++++++++ ...omponent.js => NativeScrollContentView.js} | 0 .../Components/ScrollView/NativeScrollView.js | 87 +++++++++++++++++++ Libraries/Components/ScrollView/ScrollView.js | 27 +++--- .../ScrollView/ScrollViewNativeComponent.js | 32 ------- .../ScrollViewNativeComponentType.js | 3 - Libraries/Lists/FlatList.js | 4 +- 10 files changed, 174 insertions(+), 148 deletions(-) delete mode 100644 Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js delete mode 100644 Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js create mode 100644 Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js create mode 100644 Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js rename Libraries/Components/ScrollView/{ScrollContentViewNativeComponent.js => NativeScrollContentView.js} (100%) create mode 100644 Libraries/Components/ScrollView/NativeScrollView.js delete mode 100644 Libraries/Components/ScrollView/ScrollViewNativeComponent.js diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js deleted file mode 100644 index fa0a173a4fdcc5..00000000000000 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -import registerGeneratedViewConfig from '../../Utilities/registerGeneratedViewConfig'; -import requireNativeComponent from '../../ReactNative/requireNativeComponent'; - -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; -import type {ViewProps} from '../View/ViewPropTypes'; - -const AndroidHorizontalScrollContentViewViewConfig = { - uiViewClassName: 'AndroidHorizontalScrollContentView', - bubblingEventTypes: {}, - directEventTypes: {}, - validAttributes: {}, -}; - -let AndroidHorizontalScrollContentViewNativeComponent; -if (global.RN$Bridgeless) { - registerGeneratedViewConfig( - 'AndroidHorizontalScrollContentView', - AndroidHorizontalScrollContentViewViewConfig, - ); - AndroidHorizontalScrollContentViewNativeComponent = - 'AndroidHorizontalScrollContentView'; -} else { - AndroidHorizontalScrollContentViewNativeComponent = requireNativeComponent( - 'AndroidHorizontalScrollContentView', - ); -} - -export default ((AndroidHorizontalScrollContentViewNativeComponent: any): HostComponent); diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js deleted file mode 100644 index a4a0d4e6bb8dba..00000000000000 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -import registerGeneratedViewConfig from '../../Utilities/registerGeneratedViewConfig'; -import requireNativeComponent from '../../ReactNative/requireNativeComponent'; - -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; -import type {ScrollViewNativeProps} from './ScrollViewNativeComponentType'; - -const AndroidHorizontalScrollViewViewConfig = { - uiViewClassName: 'AndroidHorizontalScrollView', - bubblingEventTypes: {}, - directEventTypes: {}, - validAttributes: { - decelerationRate: true, - disableIntervalMomentum: true, - endFillColor: {process: require('../../StyleSheet/processColor')}, - fadingEdgeLength: true, - nestedScrollEnabled: true, - overScrollMode: true, - pagingEnabled: true, - persistentScrollbar: true, - scrollEnabled: true, - scrollPerfTag: true, - sendMomentumEvents: true, - showsHorizontalScrollIndicator: true, - snapToEnd: true, - snapToInterval: true, - snapToStart: true, - snapToOffsets: true, - contentOffset: true, - }, -}; - -let AndroidHorizontalScrollViewNativeComponent; -if (global.RN$Bridgeless) { - registerGeneratedViewConfig( - 'AndroidHorizontalScrollView', - AndroidHorizontalScrollViewViewConfig, - ); - AndroidHorizontalScrollViewNativeComponent = 'AndroidHorizontalScrollView'; -} else { - AndroidHorizontalScrollViewNativeComponent = requireNativeComponent( - 'AndroidHorizontalScrollView', - ); -} - -export default ((AndroidHorizontalScrollViewNativeComponent: any): HostComponent); diff --git a/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js b/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js new file mode 100644 index 00000000000000..1fbb695accc01c --- /dev/null +++ b/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; +import {type ViewProps as Props} from '../View/ViewPropTypes'; + +const NativeAndroidHorizontalScrollContentView: HostComponent = NativeComponentRegistry.get( + 'AndroidHorizontalScrollContentView', + () => ({ + uiViewClassName: 'AndroidHorizontalScrollContentView', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: {}, + }), +); + +export default NativeAndroidHorizontalScrollContentView; diff --git a/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js b/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js new file mode 100644 index 00000000000000..328b2f6683299f --- /dev/null +++ b/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js @@ -0,0 +1,45 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import {type ScrollViewNativeProps as Props} from './ScrollViewNativeComponentType'; +import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; + +const NativeAndroidHorizontalScrollView: HostComponent = NativeComponentRegistry.get( + 'AndroidHorizontalScrollView', + () => ({ + uiViewClassName: 'AndroidHorizontalScrollView', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: { + decelerationRate: true, + disableIntervalMomentum: true, + endFillColor: {process: require('../../StyleSheet/processColor')}, + fadingEdgeLength: true, + nestedScrollEnabled: true, + overScrollMode: true, + pagingEnabled: true, + persistentScrollbar: true, + scrollEnabled: true, + scrollPerfTag: true, + sendMomentumEvents: true, + showsHorizontalScrollIndicator: true, + snapToEnd: true, + snapToInterval: true, + snapToStart: true, + snapToOffsets: true, + contentOffset: true, + }, + }), +); + +export default NativeAndroidHorizontalScrollView; diff --git a/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/NativeScrollContentView.js similarity index 100% rename from Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js rename to Libraries/Components/ScrollView/NativeScrollContentView.js diff --git a/Libraries/Components/ScrollView/NativeScrollView.js b/Libraries/Components/ScrollView/NativeScrollView.js new file mode 100644 index 00000000000000..a0439bd066146d --- /dev/null +++ b/Libraries/Components/ScrollView/NativeScrollView.js @@ -0,0 +1,87 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import {type ScrollViewNativeProps as Props} from './ScrollViewNativeComponentType'; +import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; + +const NativeScrollView: HostComponent = NativeComponentRegistry.get( + 'RCTScrollView', + () => ({ + uiViewClassName: 'RCTScrollView', + bubblingEventTypes: {}, + directEventTypes: { + topScrollToTop: { + registrationName: 'onScrollToTop', + }, + }, + validAttributes: { + alwaysBounceHorizontal: true, + alwaysBounceVertical: true, + automaticallyAdjustContentInsets: true, + bounces: true, + bouncesZoom: true, + canCancelContentTouches: true, + centerContent: true, + contentInset: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, + contentOffset: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, + contentInsetAdjustmentBehavior: true, + decelerationRate: true, + directionalLockEnabled: true, + disableIntervalMomentum: true, + endFillColor: { + process: require('../../StyleSheet/processColor'), + }, + fadingEdgeLength: true, + indicatorStyle: true, + inverted: true, + keyboardDismissMode: true, + maintainVisibleContentPosition: true, + maximumZoomScale: true, + minimumZoomScale: true, + nestedScrollEnabled: true, + onMomentumScrollBegin: true, + onMomentumScrollEnd: true, + onScroll: true, + onScrollBeginDrag: true, + onScrollEndDrag: true, + onScrollToTop: true, + overScrollMode: true, + pagingEnabled: true, + persistentScrollbar: true, + pinchGestureEnabled: true, + scrollEnabled: true, + scrollEventThrottle: true, + scrollIndicatorInsets: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, + scrollPerfTag: true, + scrollToOverflowEnabled: true, + scrollsToTop: true, + sendMomentumEvents: true, + showsHorizontalScrollIndicator: true, + showsVerticalScrollIndicator: true, + snapToAlignment: true, + snapToEnd: true, + snapToInterval: true, + snapToOffsets: true, + snapToStart: true, + zoomScale: true, + }, + }), +); + +export default NativeScrollView; diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 0492c76bf6e60a..dcb204d6c281d8 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -40,31 +40,30 @@ import type { import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {State as ScrollResponderState} from '../ScrollResponder'; import type {ViewProps} from '../View/ViewPropTypes'; -import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader'; - +import NativeAndroidHorizontalScrollContentView from './NativeAndroidHorizontalScrollContentView'; +import NativeAndroidHorizontalScrollView from './NativeAndroidHorizontalScrollView'; +import NativeScrollContentView from './NativeScrollContentView'; +import NativeScrollView from './NativeScrollView'; import ScrollViewContext, {HORIZONTAL, VERTICAL} from './ScrollViewContext'; -import ScrollViewNativeComponent from './ScrollViewNativeComponent'; -import ScrollContentViewNativeComponent from './ScrollContentViewNativeComponent'; -import AndroidHorizontalScrollViewNativeComponent from './AndroidHorizontalScrollViewNativeComponent'; -import AndroidHorizontalScrollContentViewNativeComponent from './AndroidHorizontalScrollContentViewNativeComponent'; +import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader'; const {NativeHorizontalScrollViewTuple, NativeVerticalScrollViewTuple} = Platform.OS === 'android' ? { NativeHorizontalScrollViewTuple: [ - AndroidHorizontalScrollViewNativeComponent, - AndroidHorizontalScrollContentViewNativeComponent, + NativeAndroidHorizontalScrollView, + NativeAndroidHorizontalScrollContentView, ], - NativeVerticalScrollViewTuple: [ScrollViewNativeComponent, View], + NativeVerticalScrollViewTuple: [NativeScrollView, View], } : { NativeHorizontalScrollViewTuple: [ - ScrollViewNativeComponent, - ScrollContentViewNativeComponent, + NativeScrollView, + NativeScrollContentView, ], NativeVerticalScrollViewTuple: [ - ScrollViewNativeComponent, - ScrollContentViewNativeComponent, + NativeScrollView, + NativeScrollContentView, ], }; @@ -593,7 +592,7 @@ export type Props = $ReadOnly<{| * measure, measureLayout, etc. */ scrollViewRef?: React.Ref< - typeof ScrollViewNativeComponent & ScrollViewImperativeMethods, + typeof NativeScrollView & ScrollViewImperativeMethods, >, |}>; diff --git a/Libraries/Components/ScrollView/ScrollViewNativeComponent.js b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js deleted file mode 100644 index 1e1100f0cc3165..00000000000000 --- a/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -import registerGeneratedViewConfig from '../../Utilities/registerGeneratedViewConfig'; -import requireNativeComponent from '../../ReactNative/requireNativeComponent'; -import ScrollViewViewConfig from './ScrollViewViewConfig'; - -import type { - ScrollViewNativeProps, - ScrollViewNativeComponentType, -} from './ScrollViewNativeComponentType'; - -let ScrollViewNativeComponent; -if (global.RN$Bridgeless) { - registerGeneratedViewConfig('RCTScrollView', ScrollViewViewConfig); - ScrollViewNativeComponent = 'RCTScrollView'; -} else { - ScrollViewNativeComponent = requireNativeComponent( - 'RCTScrollView', - ); -} - -export default ((ScrollViewNativeComponent: any): ScrollViewNativeComponentType); diff --git a/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js b/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js index 13af2ed6146c83..405667d1f38059 100644 --- a/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +++ b/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js @@ -10,7 +10,6 @@ 'use strict'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {ViewProps} from '../View/ViewPropTypes'; import type {ColorValue} from '../../StyleSheet/StyleSheet'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; @@ -77,5 +76,3 @@ export type ScrollViewNativeProps = $ReadOnly<{ onResponderGrant?: ?(e: $FlowFixMe) => void | boolean, ... }>; - -export type ScrollViewNativeComponentType = HostComponent; diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index d72228d33ceaa2..77c19489f003df 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -19,8 +19,8 @@ const StyleSheet = require('../StyleSheet/StyleSheet'); const invariant = require('invariant'); +import typeof NativeScrollView from '../Components/ScrollView/NativeScrollView'; import {type ScrollResponderType} from '../Components/ScrollView/ScrollView'; -import type {ScrollViewNativeComponentType} from '../Components/ScrollView/ScrollViewNativeComponentType.js'; import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; import type { ViewToken, @@ -373,7 +373,7 @@ class FlatList extends React.PureComponent, void> { */ getNativeScrollRef(): | ?React.ElementRef - | ?React.ElementRef { + | ?React.ElementRef { if (this._listRef) { return this._listRef.getScrollRef(); } From 4421a64ac1ea9df3827fb99194c8576a0750beab Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Thu, 19 Nov 2020 20:32:14 -0800 Subject: [PATCH 0107/1810] chore: updated url of deprecated modules (#30422) Summary: Part of https://github.com/react-native-community/releases/issues/207 Migrate warnings in index.js to point to new lean core repos NOTE: some npm modules has been transferred to new nom namespace, such as `react-native-picker/picker` `react-native-async-storage/async-storage` `react-native-masked-view/masked-view`. Some lean core repo has been transferred to new repo, but its npm namespace remains the same. ex: clipboard module exists in react-native-clipboard/clipboard repo, but npm package name is still `react-native-community/clipboard` (they're planned to be migrated in the future) ## Changelog [General] [Changed] - Migrate warnings in index.js to point to new lean core repos Pull Request resolved: https://github.com/facebook/react-native/pull/30422 Test Plan: - Updated repo URL can be accessed - Updated npm package can be installed Reviewed By: rickhanlonii Differential Revision: D25077750 Pulled By: cpojer fbshipit-source-id: b736ea449835bdf3d2a2f85e5c86e5253b90db78 --- index.js | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/index.js b/index.js index 1a53b10a837ead..65ee685b46f0f6 100644 --- a/index.js +++ b/index.js @@ -131,7 +131,7 @@ module.exports = { 'DatePickerIOS-merged', 'DatePickerIOS has been merged with DatePickerAndroid and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/datetimepicker' instead of 'react-native'. " + - 'See https://github.com/react-native-community/datetimepicker', + 'See https://github.com/react-native-datetimepicker/datetimepicker', ); return require('./Libraries/Components/DatePicker/DatePickerIOS'); }, @@ -158,8 +158,8 @@ module.exports = { warnOnce( 'maskedviewios-moved', 'MaskedViewIOS has been extracted from react-native core and will be removed in a future release. ' + - "It can now be installed and imported from '@react-native-community/masked-view' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-masked-view', + "It can now be installed and imported from '@react-native-masked-view/masked-view' instead of 'react-native'. " + + 'See https://github.com/react-native-masked-view/react-native-masked-view', ); return require('./Libraries/Components/MaskedView/MaskedViewIOS'); }, @@ -170,8 +170,8 @@ module.exports = { warnOnce( 'picker-moved', 'Picker has been extracted from react-native core and will be removed in a future release. ' + - "It can now be installed and imported from '@react-native-community/picker' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-picker', + "It can now be installed and imported from '@react-native-picker/picker' instead of 'react-native'. " + + 'See https://github.com/react-native-picker/react-native-picker', ); return require('./Libraries/Components/Picker/Picker'); }, @@ -180,8 +180,8 @@ module.exports = { warnOnce( 'pickerios-moved', 'PickerIOS has been extracted from react-native core and will be removed in a future release. ' + - "It can now be installed and imported from '@react-native-community/picker' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-picker', + "It can now be installed and imported from '@react-native-picker/picker' instead of 'react-native'. " + + 'See https://github.com/react-native-picker/react-native-picker', ); return require('./Libraries/Components/Picker/PickerIOS'); }, @@ -194,7 +194,7 @@ module.exports = { 'progress-bar-android-moved', 'ProgressBarAndroid has been extracted from react-native core and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/progress-bar-android' instead of 'react-native'. " + - 'See https://github.com/react-native-community/progress-bar-android', + 'See https://github.com/react-native-progress-view/progress-bar-android', ); return require('./Libraries/Components/ProgressBarAndroid/ProgressBarAndroid'); }, @@ -204,7 +204,7 @@ module.exports = { 'progress-view-ios-moved', 'ProgressViewIOS has been extracted from react-native core and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/progress-view' instead of 'react-native'. " + - 'See https://github.com/react-native-community/progress-view', + 'See https://github.com/react-native-progress-view/progress-view', ); return require('./Libraries/Components/ProgressViewIOS/ProgressViewIOS'); }, @@ -226,7 +226,7 @@ module.exports = { 'segmented-control-ios-moved', 'SegmentedControlIOS has been extracted from react-native core and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/segmented-control' instead of 'react-native'. " + - 'See https://github.com/react-native-community/segmented-control', + 'See https://github.com/react-native-segmented-control/segmented-control', ); return require('./Libraries/Components/SegmentedControlIOS/SegmentedControlIOS'); }, @@ -235,7 +235,7 @@ module.exports = { 'slider-moved', 'Slider has been extracted from react-native core and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/slider' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-slider', + 'See https://github.com/callstack/react-native-slider', ); return require('./Libraries/Components/Slider/Slider'); }, @@ -300,8 +300,8 @@ module.exports = { warnOnce( 'async-storage-moved', 'AsyncStorage has been extracted from react-native core and will be removed in a future release. ' + - "It can now be installed and imported from '@react-native-community/async-storage' instead of 'react-native'. " + - 'See https://github.com/react-native-community/async-storage', + "It can now be installed and imported from '@react-native-async-storage/async-storage' instead of 'react-native'. " + + 'See https://github.com/react-native-async-storage/async-storage', ); return require('./Libraries/Storage/AsyncStorage'); }, @@ -313,7 +313,7 @@ module.exports = { 'clipboard-moved', 'Clipboard has been extracted from react-native core and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/clipboard' instead of 'react-native'. " + - 'See https://github.com/react-native-community/clipboard', + 'See https://github.com/react-native-clipboard/clipboard', ); return require('./Libraries/Components/Clipboard/Clipboard'); }, @@ -322,7 +322,7 @@ module.exports = { 'DatePickerAndroid-merged', 'DatePickerAndroid has been merged with DatePickerIOS and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/datetimepicker' instead of 'react-native'. " + - 'See https://github.com/react-native-community/datetimepicker', + 'See https://github.com/react-native-datetimepicker/datetimepicker', ); return require('./Libraries/Components/DatePickerAndroid/DatePickerAndroid'); }, @@ -350,7 +350,7 @@ module.exports = { 'ImagePickerIOS has been extracted from react-native core and will be removed in a future release. ' + "Please upgrade to use either '@react-native-community/react-native-image-picker' or 'expo-image-picker'. " + "If you cannot upgrade to a different library, please install the deprecated '@react-native-community/image-picker-ios' package. " + - 'See https://github.com/react-native-community/react-native-image-picker-ios', + 'See https://github.com/rnc-archive/react-native-image-picker-ios', ); return require('./Libraries/Image/ImagePickerIOS'); }, @@ -393,7 +393,7 @@ module.exports = { 'pushNotificationIOS-moved', 'PushNotificationIOS has been extracted from react-native core and will be removed in a future release. ' + "It can now be installed and imported from '@react-native-community/push-notification-ios' instead of 'react-native'. " + - 'See https://github.com/react-native-community/push-notification-ios', + 'See https://github.com/react-native-push-notification-ios/push-notification-ios', ); return require('./Libraries/PushNotificationIOS/PushNotificationIOS'); }, @@ -512,7 +512,7 @@ if (__DEV__) { false, 'ART has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/art' instead of 'react-native'. " + - 'See https://github.com/react-native-community/art', + 'See https://github.com/react-native-art/art', ); }, }); @@ -551,7 +551,7 @@ if (__DEV__) { false, 'WebView has been removed from React Native. ' + "It can now be installed and imported from 'react-native-webview' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-webview', + 'See https://github.com/react-native-webview/react-native-webview', ); }, }); @@ -564,7 +564,7 @@ if (__DEV__) { false, 'NetInfo has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/netinfo' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-netinfo', + 'See https://github.com/react-native-netinfo/react-native-netinfo', ); }, }); @@ -577,7 +577,7 @@ if (__DEV__) { false, 'CameraRoll has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/cameraroll' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-cameraroll', + 'See https://github.com/react-native-cameraroll/react-native-cameraroll', ); }, }); @@ -604,7 +604,7 @@ if (__DEV__) { false, 'ImageEditor has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/image-editor' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-image-editor', + 'See https://github.com/callstack/react-native-image-editor', ); }, }); @@ -617,7 +617,7 @@ if (__DEV__) { false, 'TimePickerAndroid has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/datetimepicker' instead of 'react-native'. " + - 'See https://github.com/react-native-community/datetimepicker', + 'See https://github.com/react-native-datetimepicker/datetimepicker', ); }, }); @@ -630,7 +630,7 @@ if (__DEV__) { false, 'ToolbarAndroid has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/toolbar-android' instead of 'react-native'. " + - 'See https://github.com/react-native-community/toolbar-android', + 'See https://github.com/react-native-toolbar-android/toolbar-android', ); }, }); @@ -643,7 +643,7 @@ if (__DEV__) { false, 'ViewPagerAndroid has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/viewpager' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-viewpager', + 'See https://github.com/callstack/react-native-viewpager', ); }, }); @@ -656,7 +656,7 @@ if (__DEV__) { false, 'CheckBox has been removed from React Native. ' + "It can now be installed and imported from '@react-native-community/checkbox' instead of 'react-native'. " + - 'See https://github.com/react-native-community/react-native-checkbox', + 'See https://github.com/react-native-checkbox/react-native-checkbox', ); }, }); From 7f53bb95f7a4dd9a64a5c28ea9e03232d7b5497d Mon Sep 17 00:00:00 2001 From: Mike Vitousek Date: Fri, 20 Nov 2020 00:47:54 -0800 Subject: [PATCH 0108/1810] Suppress errors and switch to new-generics in xplat Summary: The Flow team has been building a new implementation of the system that typechecks the body of generic functions and classes. This system is more sound than the previous approach and detects errors that were uncaught previously. This diff turns on the new generic system by setting generate_tests=false in the .flowconfig, and suppresses newly discovered errors. This diff modifies and re-signs some generated modules, because syncing from www pulled in a ton of other changes that have runtime differences, and I'm not equipped to verify that the changes are safe to land. Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D24801184 fbshipit-source-id: bb31fe4c5a4107d183649b436a548df5ff42e217 --- .flowconfig | 1 + .flowconfig.android | 1 + Libraries/Lists/FlatList.js | 10 +++++++--- Libraries/TurboModule/TurboModuleRegistry.js | 2 ++ Libraries/Utilities/Platform.android.js | 9 ++++++--- Libraries/Utilities/Platform.ios.js | 1 + template/_flowconfig | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.flowconfig b/.flowconfig index 5e535932747a97..d5aa492cf7e282 100644 --- a/.flowconfig +++ b/.flowconfig @@ -48,6 +48,7 @@ suppress_type=$FlowFixMeState suppress_type=$FlowFixMeEmpty experimental.abstract_locations=true +generate_tests=false [lints] sketchy-null-number=warn diff --git a/.flowconfig.android b/.flowconfig.android index d3c2296a9e69c6..9c087d9436dfb1 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -48,6 +48,7 @@ suppress_type=$FlowFixMeState suppress_type=$FlowFixMeEmpty experimental.abstract_locations=true +generate_tests=false [lints] sketchy-null-number=warn diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 77c19489f003df..ff87a2bdb996f6 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -511,9 +511,12 @@ class FlatList extends React.PureComponent, void> { 'array with 1-%s columns; instead, received a single item.', numColumns, ); - return items - .map((it, kk) => keyExtractor(it, index * numColumns + kk)) - .join(':'); + return ( + items + // $FlowFixMe[incompatible-call] + .map((it, kk) => keyExtractor(it, index * numColumns + kk)) + .join(':') + ); } else { // $FlowFixMe Can't call keyExtractor with an array return keyExtractor(items, index); @@ -575,6 +578,7 @@ class FlatList extends React.PureComponent, void> { // $FlowFixMe Component isn't valid return ; } else if (renderItem) { + // $FlowFixMe[incompatible-call] return renderItem(props); } else { return null; diff --git a/Libraries/TurboModule/TurboModuleRegistry.js b/Libraries/TurboModule/TurboModuleRegistry.js index 0e70e6b4610616..b292623d95ff55 100644 --- a/Libraries/TurboModule/TurboModuleRegistry.js +++ b/Libraries/TurboModule/TurboModuleRegistry.js @@ -46,6 +46,7 @@ export function get(name: string): ?T { * TurboModule object. */ const schema = arguments.length === 2 ? arguments[1] : undefined; + // $FlowFixMe[incompatible-call] return requireModule(name, schema); } @@ -60,6 +61,7 @@ export function getEnforcing(name: string): T { * TurboModule object. */ const schema = arguments.length === 2 ? arguments[1] : undefined; + // $FlowFixMe[incompatible-call] const module = requireModule(name, schema); invariant( module != null, diff --git a/Libraries/Utilities/Platform.android.js b/Libraries/Utilities/Platform.android.js index ab3bc9b345c5b2..0ed8a36eaff97b 100644 --- a/Libraries/Utilities/Platform.android.js +++ b/Libraries/Utilities/Platform.android.js @@ -63,10 +63,13 @@ const Platform = { }, select: (spec: PlatformSelectSpec): A | N | D => 'android' in spec - ? spec.android + ? // $FlowFixMe[incompatible-return] + spec.android : 'native' in spec - ? spec.native - : spec.default, + ? // $FlowFixMe[incompatible-return] + spec.native + : // $FlowFixMe[incompatible-return] + spec.default, }; module.exports = Platform; diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js index afb39c5aad8b06..fef93470ae1e08 100644 --- a/Libraries/Utilities/Platform.ios.js +++ b/Libraries/Utilities/Platform.ios.js @@ -68,6 +68,7 @@ const Platform = { return false; }, select: (spec: PlatformSelectSpec): D | N | I => + // $FlowFixMe[incompatible-return] 'ios' in spec ? spec.ios : 'native' in spec ? spec.native : spec.default, }; diff --git a/template/_flowconfig b/template/_flowconfig index 9fb685f67a5972..cd04a9ecbec161 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -27,6 +27,7 @@ esproposal.optional_chaining=enable esproposal.nullish_coalescing=enable exact_by_default=true +generate_tests=false module.file_ext=.js module.file_ext=.json From 246ddc72bed181042b6af47106f98ac5ed701237 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 20 Nov 2020 06:38:03 -0800 Subject: [PATCH 0109/1810] Reset imageSource in ImageRequest's move constructor Summary: Changelog: [Internal] General improvements. Behaviour should be exactly the same. Reviewed By: JoshuaGross Differential Revision: D25092505 fbshipit-source-id: 584640ece3e02d468f6bcb84577d7a6c899cc253 --- .../react/renderer/components/image/ImageShadowNode.cpp | 2 +- ReactCommon/react/renderer/imagemanager/ImageRequest.h | 4 +--- .../renderer/imagemanager/platform/ios/ImageRequest.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp b/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp index fe20bc78845db6..99535cf047fe08 100644 --- a/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp +++ b/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp @@ -25,7 +25,7 @@ void ImageShadowNode::setImageManager(const SharedImageManager &imageManager) { void ImageShadowNode::updateStateIfNeeded() { ensureUnsealed(); - auto const &imageSource = getImageSource(); + auto imageSource = getImageSource(); auto const ¤tState = getStateData(); bool hasSameRadius = getConcreteProps().blurRadius == currentState.getBlurRadius(); diff --git a/ReactCommon/react/renderer/imagemanager/ImageRequest.h b/ReactCommon/react/renderer/imagemanager/ImageRequest.h index 48da2253099a11..2c181d3b9b28f5 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageRequest.h +++ b/ReactCommon/react/renderer/imagemanager/ImageRequest.h @@ -52,9 +52,7 @@ class ImageRequest final { /* * Returns the Image Source associated with the request. */ - const ImageSource getImageSource() const { - return imageSource_; - } + const ImageSource &getImageSource() const; /* * Returns stored observer coordinator as a shared pointer. diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp b/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp index e9ce8dcb9a02b8..ac01f5b1c1903f 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp @@ -11,7 +11,7 @@ namespace facebook { namespace react { ImageRequest::ImageRequest( - const ImageSource &imageSource, + ImageSource const &imageSource, std::shared_ptr telemetry) : imageSource_(imageSource), telemetry_(telemetry) { coordinator_ = std::make_shared(); @@ -24,6 +24,7 @@ ImageRequest::ImageRequest(ImageRequest &&other) noexcept other.coordinator_ = nullptr; other.cancelRequest_ = nullptr; other.telemetry_ = nullptr; + other.imageSource_ = {}; } ImageRequest::~ImageRequest() { @@ -37,6 +38,10 @@ void ImageRequest::setCancelationFunction( cancelRequest_ = cancelationFunction; } +const ImageSource &ImageRequest::getImageSource() const { + return imageSource_; +} + const std::shared_ptr &ImageRequest::getSharedTelemetry() const { return telemetry_; From a023ff0bd443a0dd6b172638f075bfc3560903db Mon Sep 17 00:00:00 2001 From: generatedunixname89002005325676 Date: Fri, 20 Nov 2020 06:39:49 -0800 Subject: [PATCH 0110/1810] Daily `arc lint --take CLANGFORMAT` Reviewed By: zertosh Differential Revision: D25117167 fbshipit-source-id: 1eb415aa139a9be92676202ffdc1a901043122b9 --- React/CoreModules/RCTActionSheetManager.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index c2eae7c9fe8808..3c01cefa35c8bc 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -144,7 +144,10 @@ - (void)presentViewController:(UIViewController *)alertController if ([disabledButtonIndex integerValue] < buttons.count) { [alertController.actions[[disabledButtonIndex integerValue]] setEnabled:false]; } else { - RCTLogError(@"Index %@ from `disabledButtonIndices` is out of bounds. Maximum index value is %@.", @([disabledButtonIndex integerValue]), @(buttons.count - 1)); + RCTLogError( + @"Index %@ from `disabledButtonIndices` is out of bounds. Maximum index value is %@.", + @([disabledButtonIndex integerValue]), + @(buttons.count - 1)); return; } } From 8aae407b6f423ce96b0a1a9242ad6dce69030934 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 20 Nov 2020 09:52:12 -0800 Subject: [PATCH 0111/1810] Fix race condition in LayoutAnimationCallbackWrapper Summary: Changelog: [Internal] Contents of `callComplete_` are accessed from JavaScript thread and main thread and there is possible race condition. This diff changes `bool` to `atomic_bool` to prevent the race. Reviewed By: JoshuaGross Differential Revision: D25094907 fbshipit-source-id: 6a2c6e33ab5ba0c6ab728e175f2e5c11fdd0a579 --- .../renderer/animations/LayoutAnimationKeyFrameManager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 6cb5176001a0c0..f76fecd31f5c9b 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -118,7 +118,6 @@ class LayoutAnimationCallbackWrapper { LayoutAnimationCallbackWrapper(jsi::Function &&callback) : callback_(std::make_shared(std::move(callback))) {} LayoutAnimationCallbackWrapper() : callback_(nullptr) {} - ~LayoutAnimationCallbackWrapper() {} // Copy and assignment-copy constructors should copy callback_, and not // std::move it. Copying is desirable, otherwise the shared_ptr and @@ -134,7 +133,7 @@ class LayoutAnimationCallbackWrapper { } std::weak_ptr callable = callback_; - std::shared_ptr callComplete = callComplete_; + std::shared_ptr callComplete = callComplete_; runtimeExecutor( [=, callComplete = std::move(callComplete)](jsi::Runtime &runtime) { @@ -150,7 +149,8 @@ class LayoutAnimationCallbackWrapper { } private: - std::shared_ptr callComplete_ = std::make_shared(false); + std::shared_ptr callComplete_ = + std::make_shared(false); std::shared_ptr callback_; }; From f6fb1d0936ba58172a7200090ff5c125f18c1bed Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 20 Nov 2020 13:03:19 -0800 Subject: [PATCH 0112/1810] Use auto and implicit type conversion to improve readability in LayoutAnimationKeyFrameManager Summary: Changelog: [internal] Readability improvements. Reviewed By: JoshuaGross Differential Revision: D25121829 fbshipit-source-id: f2937150ca078cc07befd873e91779cb960529a2 --- .../LayoutAnimationKeyFrameManager.cpp | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 7e00c3bd3cdc4d..ea541cc373e5e5 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -73,22 +73,22 @@ void PrintMutationInstructionRelative( static better::optional parseAnimationType(std::string param) { if (param == "spring") { - return better::optional(AnimationType::Spring); + return AnimationType::Spring; } if (param == "linear") { - return better::optional(AnimationType::Linear); + return AnimationType::Linear; } if (param == "easeInEaseOut") { - return better::optional(AnimationType::EaseInEaseOut); + return AnimationType::EaseInEaseOut; } if (param == "easeIn") { - return better::optional(AnimationType::EaseIn); + return AnimationType::EaseIn; } if (param == "easeOut") { - return better::optional(AnimationType::EaseOut); + return AnimationType::EaseOut; } if (param == "keyboard") { - return better::optional(AnimationType::Keyboard); + return AnimationType::Keyboard; } LOG(ERROR) << "Error parsing animation type: " << param; @@ -98,16 +98,16 @@ static better::optional parseAnimationType(std::string param) { static better::optional parseAnimationProperty( std::string param) { if (param == "opacity") { - return better::optional(AnimationProperty::Opacity); + return AnimationProperty::Opacity; } if (param == "scaleX") { - return better::optional(AnimationProperty::ScaleX); + return AnimationProperty::ScaleX; } if (param == "scaleY") { - return better::optional(AnimationProperty::ScaleY); + return AnimationProperty::ScaleY; } if (param == "scaleXY") { - return better::optional(AnimationProperty::ScaleXY); + return AnimationProperty::ScaleXY; } LOG(ERROR) << "Error parsing animation property: " << param; @@ -119,13 +119,12 @@ static better::optional parseAnimationConfig( double defaultDuration, bool parsePropertyType) { if (config.empty() || !config.isObject()) { - return better::optional( - AnimationConfig{AnimationType::Linear, - AnimationProperty::NotApplicable, - defaultDuration, - 0, - 0, - 0}); + return AnimationConfig{AnimationType::Linear, + AnimationProperty::NotApplicable, + defaultDuration, + 0, + 0, + 0}; } auto const typeIt = config.find("type"); @@ -820,10 +819,8 @@ LayoutAnimationKeyFrameManager::pullTransaction( // current mutations then these deleted mutations will serve as the baseline // for the next animation. If not, the current mutations are executed // immediately without issues. - std::vector< - std::tuple> - conflictingAnimations = - getAndEraseConflictingAnimations(surfaceId, mutations); + auto conflictingAnimations = + getAndEraseConflictingAnimations(surfaceId, mutations); // Are we animating this list of mutations? better::optional currentAnimation{}; From 29bbeaf8ac8cdab9f386b21d3b51c00b2112249e Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 20 Nov 2020 13:20:43 -0800 Subject: [PATCH 0113/1810] Fix race condition in LayoutAnimationKeyFrameManager::currentAnimation_ Summary: Changelog: [internal] `currentAnimation_` is accessed on multiple threads and has dedicated mutex, but it was not acquiring the mutex in `LayoutAnimationKeyFrameManager::shouldAnimateFrame` Reviewed By: JoshuaGross Differential Revision: D25121654 fbshipit-source-id: 38b1c82eaabab283beab18dc210ea21379edbe93 --- .../renderer/animations/LayoutAnimationKeyFrameManager.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index ea541cc373e5e5..8f9c487b218ee0 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -323,9 +323,7 @@ void LayoutAnimationKeyFrameManager::stopSurface(SurfaceId surfaceId) { } bool LayoutAnimationKeyFrameManager::shouldAnimateFrame() const { - // There is potentially a race here between getting and setting - // `currentMutation_`. We don't want to lock around this because then we're - // creating contention between pullTransaction and the JS thread. + std::lock_guard lock(currentAnimationMutex_); return currentAnimation_ || !inflightAnimations_.empty(); } From c0a2998387d1730d38a28cbe296520400a645b25 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Fri, 20 Nov 2020 14:31:03 -0800 Subject: [PATCH 0114/1810] Move TurboModuleManager to use RuntimeExecutor instead of jsContext (#30416) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/30416 This diff changes the constructor param for TurboModuleManager from jsContext (a long representing the `jsi::Runtime` pointer) to a RuntimeExecutor. It also updates callsites to use the new RuntimeExecutor created by CatalystInstance. This is only used for installing the TurboModule JSI binding; it's not currently used for JS invocation in TurboModules, which is handled separately by JSCallInvoker. Ultimately we may be able to implement JSCallInvoker *with* the provided RuntimeExecutor, but there's some additional logic in JSCallInvoker that we don't have here yet. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D21338930 fbshipit-source-id: 1480c328f1a1776ddf22752510c0f3b35168a489 --- .../turbomodule/core/TurboModuleManager.java | 8 +- .../react/turbomodule/core/jni/Android.mk | 4 +- .../facebook/react/turbomodule/core/jni/BUCK | 1 + .../jni/ReactCommon/TurboModuleManager.cpp | 170 +++++++++--------- .../core/jni/ReactCommon/TurboModuleManager.h | 8 +- .../react/uiapp/RNTesterApplication.java | 2 +- 6 files changed, 98 insertions(+), 95 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index 8cd4c67037022c..000770aec1d5c2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -15,8 +15,8 @@ import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.CxxModuleWrapper; import com.facebook.react.bridge.JSIModule; -import com.facebook.react.bridge.JavaScriptContextHolder; import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.RuntimeExecutor; import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; import com.facebook.react.turbomodule.core.interfaces.TurboModule; @@ -50,14 +50,14 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry { private final HybridData mHybridData; public TurboModuleManager( - JavaScriptContextHolder jsContext, + RuntimeExecutor runtimeExecutor, @Nullable final TurboModuleManagerDelegate delegate, CallInvokerHolder jsCallInvokerHolder, CallInvokerHolder nativeCallInvokerHolder) { maybeLoadSoLibrary(); mHybridData = initHybrid( - jsContext.get(), + runtimeExecutor, (CallInvokerHolderImpl) jsCallInvokerHolder, (CallInvokerHolderImpl) nativeCallInvokerHolder, delegate, @@ -291,7 +291,7 @@ public boolean hasModule(String moduleName) { } private native HybridData initHybrid( - long jsContext, + RuntimeExecutor runtimeExecutor, CallInvokerHolderImpl jsCallInvokerHolder, CallInvokerHolderImpl nativeCallInvokerHolder, TurboModuleManagerDelegate tmmDelegate, diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk index 955cc86a8b10de..401429a13ac546 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk @@ -19,9 +19,9 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall -LOCAL_SHARED_LIBRARIES = libfb libfbjni +LOCAL_SHARED_LIBRARIES = libfb libfbjni libreactnativeutilsjni -LOCAL_STATIC_LIBRARIES = libcallinvoker libreactperfloggerjni +LOCAL_STATIC_LIBRARIES = libcallinvoker libreactperfloggerjni libruntimeexecutor # Name of this module. LOCAL_MODULE := callinvokerholder diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK index b0db877eea667d..c7f3ec528b1238 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK @@ -35,6 +35,7 @@ rn_xplat_cxx_library( ":callinvokerholder", react_native_xplat_shared_library_target("jsi:jsi"), react_native_xplat_target("react/nativemodule/core:core"), + react_native_xplat_target("runtimeexecutor:runtimeexecutor"), react_native_target("java/com/facebook/react/reactperflogger/jni:jni"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp index 81c17fabb955d5..a6d90b615d8427 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp @@ -24,13 +24,13 @@ namespace react { TurboModuleManager::TurboModuleManager( jni::alias_ref jThis, - jsi::Runtime *rt, + RuntimeExecutor runtimeExecutor, std::shared_ptr jsCallInvoker, std::shared_ptr nativeCallInvoker, jni::alias_ref delegate, bool enableJSCodegen) : javaPart_(jni::make_global(jThis)), - runtime_(rt), + runtimeExecutor_(runtimeExecutor), jsCallInvoker_(jsCallInvoker), nativeCallInvoker_(nativeCallInvoker), delegate_(jni::make_global(delegate)), @@ -39,7 +39,7 @@ TurboModuleManager::TurboModuleManager( jni::local_ref TurboModuleManager::initHybrid( jni::alias_ref jThis, - jlong jsContext, + jni::alias_ref runtimeExecutor, jni::alias_ref jsCallInvokerHolder, jni::alias_ref nativeCallInvokerHolder, jni::alias_ref delegate, @@ -52,7 +52,7 @@ jni::local_ref TurboModuleManager::initHybrid( return makeCxxInstance( jThis, - (jsi::Runtime *)jsContext, + runtimeExecutor->cthis()->get(), jsCallInvoker, nativeCallInvoker, delegate, @@ -68,100 +68,100 @@ void TurboModuleManager::registerNatives() { } void TurboModuleManager::installJSIBindings() { - if (!runtime_ || !jsCallInvoker_) { + if (!jsCallInvoker_) { return; // Runtime doesn't exist when attached to Chrome debugger. } - auto turboModuleProvider = - [turboModuleCache_ = std::weak_ptr(turboModuleCache_), - jsCallInvoker_ = std::weak_ptr(jsCallInvoker_), - nativeCallInvoker_ = std::weak_ptr(nativeCallInvoker_), - delegate_ = jni::make_weak(delegate_), - javaPart_ = jni::make_weak(javaPart_), - runtime_ = runtime_]( - const std::string &name, - const jsi::Value *schema) -> std::shared_ptr { - auto turboModuleCache = turboModuleCache_.lock(); - auto jsCallInvoker = jsCallInvoker_.lock(); - auto nativeCallInvoker = nativeCallInvoker_.lock(); - auto delegate = delegate_.lockLocal(); - auto javaPart = javaPart_.lockLocal(); - - if (!turboModuleCache || !jsCallInvoker || !nativeCallInvoker || - !delegate || !javaPart) { - return nullptr; - } + runtimeExecutor_([this](jsi::Runtime &runtime) { + auto turboModuleProvider = + [turboModuleCache_ = std::weak_ptr(turboModuleCache_), + jsCallInvoker_ = std::weak_ptr(jsCallInvoker_), + nativeCallInvoker_ = std::weak_ptr(nativeCallInvoker_), + delegate_ = jni::make_weak(delegate_), + javaPart_ = jni::make_weak(javaPart_), + &runtime]( + const std::string &name, + const jsi::Value *schema) -> std::shared_ptr { + auto turboModuleCache = turboModuleCache_.lock(); + auto jsCallInvoker = jsCallInvoker_.lock(); + auto nativeCallInvoker = nativeCallInvoker_.lock(); + auto delegate = delegate_.lockLocal(); + auto javaPart = javaPart_.lockLocal(); + + if (!turboModuleCache || !jsCallInvoker || !nativeCallInvoker || + !delegate || !javaPart) { + return nullptr; + } - const char *moduleName = name.c_str(); + const char *moduleName = name.c_str(); - TurboModulePerfLogger::moduleJSRequireBeginningStart(moduleName); + TurboModulePerfLogger::moduleJSRequireBeginningStart(moduleName); + + auto turboModuleLookup = turboModuleCache->find(name); + if (turboModuleLookup != turboModuleCache->end()) { + TurboModulePerfLogger::moduleJSRequireBeginningCacheHit(moduleName); + TurboModulePerfLogger::moduleJSRequireBeginningEnd(moduleName); + return turboModuleLookup->second; + } - auto turboModuleLookup = turboModuleCache->find(name); - if (turboModuleLookup != turboModuleCache->end()) { - TurboModulePerfLogger::moduleJSRequireBeginningCacheHit(moduleName); TurboModulePerfLogger::moduleJSRequireBeginningEnd(moduleName); - return turboModuleLookup->second; - } - - TurboModulePerfLogger::moduleJSRequireBeginningEnd(moduleName); - - auto cxxModule = delegate->cthis()->getTurboModule(name, jsCallInvoker); - if (cxxModule) { - turboModuleCache->insert({name, cxxModule}); - return cxxModule; - } - - static auto getLegacyCxxModule = - javaPart->getClass() - ->getMethod( - const std::string &)>("getLegacyCxxModule"); - auto legacyCxxModule = getLegacyCxxModule(javaPart.get(), name); - - if (legacyCxxModule) { - TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName); - - auto turboModule = std::make_shared( - legacyCxxModule->cthis()->getModule(), jsCallInvoker); - turboModuleCache->insert({name, turboModule}); - - TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); - return turboModule; - } - - static auto getJavaModule = - javaPart->getClass() - ->getMethod(const std::string &)>( - "getJavaModule"); - auto moduleInstance = getJavaModule(javaPart.get(), name); - - if (moduleInstance) { - TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName); - JavaTurboModule::InitParams params = {.moduleName = name, - .instance = moduleInstance, - .jsInvoker = jsCallInvoker, - .nativeInvoker = nativeCallInvoker}; - - if (schema->isObject() && !schema->isNull()) { - auto turboModule = std::make_shared( - params, TurboModuleSchema::parse(*runtime_, name, *schema)); + + auto cxxModule = delegate->cthis()->getTurboModule(name, jsCallInvoker); + if (cxxModule) { + turboModuleCache->insert({name, cxxModule}); + return cxxModule; + } + + static auto getLegacyCxxModule = + javaPart->getClass() + ->getMethod( + const std::string &)>("getLegacyCxxModule"); + auto legacyCxxModule = getLegacyCxxModule(javaPart.get(), name); + + if (legacyCxxModule) { + TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName); + + auto turboModule = std::make_shared( + legacyCxxModule->cthis()->getModule(), jsCallInvoker); + turboModuleCache->insert({name, turboModule}); + TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); return turboModule; } - auto turboModule = delegate->cthis()->getTurboModule(name, params); - turboModuleCache->insert({name, turboModule}); - TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); - return turboModule; - } + static auto getJavaModule = + javaPart->getClass() + ->getMethod(const std::string &)>( + "getJavaModule"); + auto moduleInstance = getJavaModule(javaPart.get(), name); + + if (moduleInstance) { + TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName); + JavaTurboModule::InitParams params = { + .moduleName = name, + .instance = moduleInstance, + .jsInvoker = jsCallInvoker, + .nativeInvoker = nativeCallInvoker}; + + if (schema->isObject() && !schema->isNull()) { + auto turboModule = std::make_shared( + params, TurboModuleSchema::parse(runtime, name, *schema)); + TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); + return turboModule; + } + + auto turboModule = delegate->cthis()->getTurboModule(name, params); + turboModuleCache->insert({name, turboModule}); + TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); + return turboModule; + } - return nullptr; - }; + return nullptr; + }; - jsCallInvoker_->invokeAsync( - [this, turboModuleProvider = std::move(turboModuleProvider)]() -> void { - TurboModuleBinding::install( - *runtime_, std::move(turboModuleProvider), enableJSCodegen_); - }); + TurboModuleBinding::install( + runtime, std::move(turboModuleProvider), enableJSCodegen_); + }); } } // namespace react diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h index 2a6a95aed2dc56..92716800d24e20 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h @@ -9,12 +9,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -27,7 +29,7 @@ class TurboModuleManager : public jni::HybridClass { "Lcom/facebook/react/turbomodule/core/TurboModuleManager;"; static jni::local_ref initHybrid( jni::alias_ref jThis, - jlong jsContext, + jni::alias_ref runtimeExecutor, jni::alias_ref jsCallInvokerHolder, jni::alias_ref nativeCallInvokerHolder, jni::alias_ref delegate, @@ -38,7 +40,7 @@ class TurboModuleManager : public jni::HybridClass { private: friend HybridBase; jni::global_ref javaPart_; - jsi::Runtime *runtime_; + RuntimeExecutor runtimeExecutor_; std::shared_ptr jsCallInvoker_; std::shared_ptr nativeCallInvoker_; jni::global_ref delegate_; @@ -58,7 +60,7 @@ class TurboModuleManager : public jni::HybridClass { void installJSIBindings(); explicit TurboModuleManager( jni::alias_ref jThis, - jsi::Runtime *rt, + RuntimeExecutor runtimeExecutor, std::shared_ptr jsCallInvoker, std::shared_ptr nativeCallInvoker, jni::alias_ref delegate, diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index 0c2e08f91c3b76..14700729103f98 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -140,7 +140,7 @@ public JSIModule get() { final List packages = reactInstanceManager.getPackages(); return new TurboModuleManager( - jsContext, + reactApplicationContext.getCatalystInstance().getRuntimeExecutor(), new RNTesterTurboModuleManagerDelegate( reactApplicationContext, packages), reactApplicationContext From f9a4cafa2068a4c5e7480e2c389f0bee784ad357 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 20 Nov 2020 17:27:53 -0800 Subject: [PATCH 0115/1810] LayoutAnimations: Remove unnecessary optionals in config Summary: These configs are never actually empty, so they shouldn't be optionals. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25129254 fbshipit-source-id: 626119fefad0440732541c680286ebbbfab6aeba --- .../animations/LayoutAnimationDriver.cpp | 4 +- .../LayoutAnimationKeyFrameManager.cpp | 79 +++++++++---------- .../LayoutAnimationKeyFrameManager.h | 6 +- 3 files changed, 43 insertions(+), 46 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 4c68ae3f45ac83..5386b237a0eaa6 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -56,7 +56,7 @@ void LayoutAnimationDriver::animationMutationsForFrame( // The contract with the "keyframes generation" phase is that any animated // node will have a valid configuration. auto const layoutAnimationConfig = animation.layoutAnimationConfig; - auto const mutationConfig = + auto const &mutationConfig = (keyframe.type == AnimationConfigurationType::Delete ? layoutAnimationConfig.deleteConfig : (keyframe.type == AnimationConfigurationType::Create @@ -65,7 +65,7 @@ void LayoutAnimationDriver::animationMutationsForFrame( // Interpolate std::pair progress = - calculateAnimationProgress(now, animation, *mutationConfig); + calculateAnimationProgress(now, animation, mutationConfig); double animationTimeProgressLinear = progress.first; double animationInterpolationFactor = progress.second; diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 8f9c487b218ee0..d9dd34033a5618 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -672,7 +672,7 @@ LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( auto const layoutAnimationConfig = inflightAnimation.layoutAnimationConfig; - auto const mutationConfig = + auto const &mutationConfig = (animatedKeyFrame.type == AnimationConfigurationType::Delete ? layoutAnimationConfig.deleteConfig : (animatedKeyFrame.type == @@ -690,7 +690,7 @@ LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( mutatedViewIsVirtual( *animatedKeyFrame.finalMutationForKeyFrame))) { conflictingAnimations.push_back(std::make_tuple( - animatedKeyFrame, *mutationConfig, &inflightAnimation)); + animatedKeyFrame, mutationConfig, &inflightAnimation)); } #ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING @@ -889,13 +889,6 @@ LayoutAnimationKeyFrameManager::pullTransaction( bool executeMutationImmediately = false; - auto mutationConfig = - (mutation.type == ShadowViewMutation::Type::Delete - ? layoutAnimationConfig.deleteConfig - : (mutation.type == ShadowViewMutation::Type::Insert - ? layoutAnimationConfig.createConfig - : layoutAnimationConfig.updateConfig)); - bool isRemoveReinserted = mutation.type == ShadowViewMutation::Type::Remove && std::find( @@ -920,7 +913,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( // Inserts that follow a "remove" of the same tag should be treated as // an update (move) animation. bool wasInsertedTagRemoved = false; - bool haveConfiguration = mutationConfig.has_value(); + auto movedIt = movedTags.end(); if (mutation.type == ShadowViewMutation::Type::Insert) { // If this is a move, we actually don't want to copy this insert // instruction to animated instructions - we want to @@ -928,24 +921,28 @@ LayoutAnimationKeyFrameManager::pullTransaction( // the layout. // The corresponding Remove and Insert instructions will instead // be treated as "immediate" instructions. - auto movedIt = movedTags.find(mutation.newChildShadowView.tag); + movedIt = movedTags.find(mutation.newChildShadowView.tag); wasInsertedTagRemoved = movedIt != movedTags.end(); - if (wasInsertedTagRemoved) { - mutationConfig = layoutAnimationConfig.updateConfig; - } - haveConfiguration = mutationConfig.has_value(); - - if (wasInsertedTagRemoved && haveConfiguration) { - movesToAnimate.push_back( - AnimationKeyFrame{{}, - AnimationConfigurationType::Update, - mutation.newChildShadowView.tag, - mutation.parentShadowView, - movedIt->second.oldChildShadowView, - mutation.newChildShadowView, - movedIt->second.oldChildShadowView, - 0}); - } + } + + auto const &mutationConfig = + (mutation.type == ShadowViewMutation::Type::Delete + ? layoutAnimationConfig.deleteConfig + : (mutation.type == ShadowViewMutation::Type::Insert && + !wasInsertedTagRemoved + ? layoutAnimationConfig.createConfig + : layoutAnimationConfig.updateConfig)); + bool haveConfiguration = + mutationConfig.animationType != AnimationType::None; + + if (wasInsertedTagRemoved && haveConfiguration) { + movesToAnimate.push_back( + AnimationKeyFrame{{}, + AnimationConfigurationType::Update, + mutation.newChildShadowView.tag, + mutation.parentShadowView, + movedIt->second.oldChildShadowView, + mutation.newChildShadowView}); } // Creates and inserts should also be executed immediately. @@ -1000,7 +997,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( AnimationKeyFrame keyFrame{}; if (mutation.type == ShadowViewMutation::Type::Insert) { - if (mutationConfig->animationProperty == + if (mutationConfig.animationProperty == AnimationProperty::Opacity && haveComponentDescriptor) { auto props = @@ -1013,12 +1010,12 @@ LayoutAnimationKeyFrameManager::pullTransaction( } viewStart.props = props; } - bool isScaleX = mutationConfig->animationProperty == - AnimationProperty::ScaleX || - mutationConfig->animationProperty == AnimationProperty::ScaleXY; - bool isScaleY = mutationConfig->animationProperty == - AnimationProperty::ScaleY || - mutationConfig->animationProperty == AnimationProperty::ScaleXY; + bool isScaleX = + mutationConfig.animationProperty == AnimationProperty::ScaleX || + mutationConfig.animationProperty == AnimationProperty::ScaleXY; + bool isScaleY = + mutationConfig.animationProperty == AnimationProperty::ScaleY || + mutationConfig.animationProperty == AnimationProperty::ScaleXY; if ((isScaleX || isScaleY) && haveComponentDescriptor) { auto props = getComponentDescriptorForShadowView(baselineShadowView) @@ -1041,7 +1038,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( baselineShadowView, 0}; } else if (mutation.type == ShadowViewMutation::Type::Delete) { - if (mutationConfig->animationProperty == + if (mutationConfig.animationProperty == AnimationProperty::Opacity && haveComponentDescriptor) { auto props = @@ -1054,12 +1051,12 @@ LayoutAnimationKeyFrameManager::pullTransaction( } viewFinal.props = props; } - bool isScaleX = mutationConfig->animationProperty == - AnimationProperty::ScaleX || - mutationConfig->animationProperty == AnimationProperty::ScaleXY; - bool isScaleY = mutationConfig->animationProperty == - AnimationProperty::ScaleY || - mutationConfig->animationProperty == AnimationProperty::ScaleXY; + bool isScaleX = + mutationConfig.animationProperty == AnimationProperty::ScaleX || + mutationConfig.animationProperty == AnimationProperty::ScaleXY; + bool isScaleY = + mutationConfig.animationProperty == AnimationProperty::ScaleY || + mutationConfig.animationProperty == AnimationProperty::ScaleXY; if ((isScaleX || isScaleY) && haveComponentDescriptor) { auto props = getComponentDescriptorForShadowView(baselineShadowView) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index f76fecd31f5c9b..0c57bb01c153a2 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -81,9 +81,9 @@ struct AnimationConfig { // This corresponds exactly with JS. struct LayoutAnimationConfig { double duration; // ms - better::optional createConfig; - better::optional updateConfig; - better::optional deleteConfig; + AnimationConfig createConfig; + AnimationConfig updateConfig; + AnimationConfig deleteConfig; }; struct AnimationKeyFrame { From 9dfefa8da0b320839b1468b816b4066e4f51436b Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 20 Nov 2020 18:50:49 -0800 Subject: [PATCH 0116/1810] RN: Rename to `ScrollViewNativeComponent` Summary: There may be assumptions that `Native*.js` contains TurboModule. In order to avoid introducing unplanned breaking changes (especially right before the holidays), roll this back for now. In doing so, I also realized that I forgot to migrate over `ScrollContentViewNativeComponent`. This does that, too. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D25129324 fbshipit-source-id: 343c4b800969dab91f7cd9f2bf253788c94d38e6 --- ...zontalScrollContentViewNativeComponent.js} | 4 +- ...oidHorizontalScrollViewNativeComponent.js} | 4 +- .../ScrollView/NativeScrollContentView.js | 39 ------------------- .../ScrollContentViewNativeComponent.js | 27 +++++++++++++ Libraries/Components/ScrollView/ScrollView.js | 25 ++++++------ ...llView.js => ScrollViewNativeComponent.js} | 4 +- Libraries/Lists/FlatList.js | 4 +- 7 files changed, 48 insertions(+), 59 deletions(-) rename Libraries/Components/ScrollView/{NativeAndroidHorizontalScrollContentView.js => AndroidHorizontalScrollContentViewNativeComponent.js} (78%) rename Libraries/Components/ScrollView/{NativeAndroidHorizontalScrollView.js => AndroidHorizontalScrollViewNativeComponent.js} (88%) delete mode 100644 Libraries/Components/ScrollView/NativeScrollContentView.js create mode 100644 Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js rename Libraries/Components/ScrollView/{NativeScrollView.js => ScrollViewNativeComponent.js} (94%) diff --git a/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js similarity index 78% rename from Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js rename to Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js index 1fbb695accc01c..dc222eda3a1aca 100644 --- a/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollContentView.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js @@ -14,7 +14,7 @@ import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; import {type ViewProps as Props} from '../View/ViewPropTypes'; -const NativeAndroidHorizontalScrollContentView: HostComponent = NativeComponentRegistry.get( +const AndroidHorizontalScrollContentViewNativeComponent: HostComponent = NativeComponentRegistry.get( 'AndroidHorizontalScrollContentView', () => ({ uiViewClassName: 'AndroidHorizontalScrollContentView', @@ -24,4 +24,4 @@ const NativeAndroidHorizontalScrollContentView: HostComponent = NativeCom }), ); -export default NativeAndroidHorizontalScrollContentView; +export default AndroidHorizontalScrollContentViewNativeComponent; diff --git a/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js similarity index 88% rename from Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js rename to Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js index 328b2f6683299f..cd424858d048cc 100644 --- a/Libraries/Components/ScrollView/NativeAndroidHorizontalScrollView.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js @@ -14,7 +14,7 @@ import {type ScrollViewNativeProps as Props} from './ScrollViewNativeComponentTy import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; -const NativeAndroidHorizontalScrollView: HostComponent = NativeComponentRegistry.get( +const AndroidHorizontalScrollViewNativeComponent: HostComponent = NativeComponentRegistry.get( 'AndroidHorizontalScrollView', () => ({ uiViewClassName: 'AndroidHorizontalScrollView', @@ -42,4 +42,4 @@ const NativeAndroidHorizontalScrollView: HostComponent = NativeComponentR }), ); -export default NativeAndroidHorizontalScrollView; +export default AndroidHorizontalScrollViewNativeComponent; diff --git a/Libraries/Components/ScrollView/NativeScrollContentView.js b/Libraries/Components/ScrollView/NativeScrollContentView.js deleted file mode 100644 index 6a94a30a72dae7..00000000000000 --- a/Libraries/Components/ScrollView/NativeScrollContentView.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -import registerGeneratedViewConfig from '../../Utilities/registerGeneratedViewConfig'; -import requireNativeComponent from '../../ReactNative/requireNativeComponent'; - -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; -import type {ViewProps} from '../View/ViewPropTypes'; - -const ScrollContentViewViewConfig = { - uiViewClassName: 'RCTScrollContentView', - bubblingEventTypes: {}, - directEventTypes: {}, - validAttributes: {}, -}; - -let ScrollContentViewNativeComponent; -if (global.RN$Bridgeless) { - registerGeneratedViewConfig( - 'RCTScrollContentView', - ScrollContentViewViewConfig, - ); - ScrollContentViewNativeComponent = 'RCTScrollContentView'; -} else { - ScrollContentViewNativeComponent = requireNativeComponent( - 'RCTScrollContentView', - ); -} - -export default ((ScrollContentViewNativeComponent: any): HostComponent); diff --git a/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js new file mode 100644 index 00000000000000..ad184c19dd1956 --- /dev/null +++ b/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; +import {type ViewProps as Props} from '../View/ViewPropTypes'; + +const ScrollContentViewNativeComponent: HostComponent = NativeComponentRegistry.get( + 'RCTScrollContentView', + () => ({ + uiViewClassName: 'RCTScrollContentView', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: {}, + }), +); + +export default ScrollContentViewNativeComponent; diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index dcb204d6c281d8..99407340c50cc1 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -40,30 +40,31 @@ import type { import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {State as ScrollResponderState} from '../ScrollResponder'; import type {ViewProps} from '../View/ViewPropTypes'; -import NativeAndroidHorizontalScrollContentView from './NativeAndroidHorizontalScrollContentView'; -import NativeAndroidHorizontalScrollView from './NativeAndroidHorizontalScrollView'; -import NativeScrollContentView from './NativeScrollContentView'; -import NativeScrollView from './NativeScrollView'; import ScrollViewContext, {HORIZONTAL, VERTICAL} from './ScrollViewContext'; import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader'; +import AndroidHorizontalScrollContentViewNativeComponent from './AndroidHorizontalScrollContentViewNativeComponent'; +import AndroidHorizontalScrollViewNativeComponent from './AndroidHorizontalScrollViewNativeComponent'; +import ScrollContentViewNativeComponent from './ScrollContentViewNativeComponent'; +import ScrollViewNativeComponent from './ScrollViewNativeComponent'; + const {NativeHorizontalScrollViewTuple, NativeVerticalScrollViewTuple} = Platform.OS === 'android' ? { NativeHorizontalScrollViewTuple: [ - NativeAndroidHorizontalScrollView, - NativeAndroidHorizontalScrollContentView, + AndroidHorizontalScrollViewNativeComponent, + AndroidHorizontalScrollContentViewNativeComponent, ], - NativeVerticalScrollViewTuple: [NativeScrollView, View], + NativeVerticalScrollViewTuple: [ScrollViewNativeComponent, View], } : { NativeHorizontalScrollViewTuple: [ - NativeScrollView, - NativeScrollContentView, + ScrollViewNativeComponent, + ScrollContentViewNativeComponent, ], NativeVerticalScrollViewTuple: [ - NativeScrollView, - NativeScrollContentView, + ScrollViewNativeComponent, + ScrollContentViewNativeComponent, ], }; @@ -592,7 +593,7 @@ export type Props = $ReadOnly<{| * measure, measureLayout, etc. */ scrollViewRef?: React.Ref< - typeof NativeScrollView & ScrollViewImperativeMethods, + typeof ScrollViewNativeComponent & ScrollViewImperativeMethods, >, |}>; diff --git a/Libraries/Components/ScrollView/NativeScrollView.js b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js similarity index 94% rename from Libraries/Components/ScrollView/NativeScrollView.js rename to Libraries/Components/ScrollView/ScrollViewNativeComponent.js index a0439bd066146d..29585037ef40cb 100644 --- a/Libraries/Components/ScrollView/NativeScrollView.js +++ b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js @@ -14,7 +14,7 @@ import {type ScrollViewNativeProps as Props} from './ScrollViewNativeComponentTy import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; -const NativeScrollView: HostComponent = NativeComponentRegistry.get( +const ScrollViewNativeComponent: HostComponent = NativeComponentRegistry.get( 'RCTScrollView', () => ({ uiViewClassName: 'RCTScrollView', @@ -84,4 +84,4 @@ const NativeScrollView: HostComponent = NativeComponentRegistry.get extends React.PureComponent, void> { */ getNativeScrollRef(): | ?React.ElementRef - | ?React.ElementRef { + | ?React.ElementRef { if (this._listRef) { return this._listRef.getScrollRef(); } From a865bd89d7affe9c3ada87f56a61a0771c3e9257 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 20 Nov 2020 18:50:49 -0800 Subject: [PATCH 0117/1810] RN: Migrate `ImageView` to NativeComponentRegistry Summary: Migrates `ImageView` to use `NativeComponentRegistry`, which enables configuring it to avoid reflection by using a static `ViewConfig`. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25104446 fbshipit-source-id: dd01bf01ead94ca6632b2653b45becf408953bcf --- Libraries/Image/ImageViewNativeComponent.js | 98 +++++++++++++++------ Libraries/Image/ImageViewViewConfig.js | 68 -------------- 2 files changed, 71 insertions(+), 95 deletions(-) delete mode 100644 Libraries/Image/ImageViewViewConfig.js diff --git a/Libraries/Image/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index 8a6c0b25aab2e4..360491d5e9fbd0 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -4,26 +4,24 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format * @flow strict-local + * @format */ 'use strict'; -const requireNativeComponent = require('../ReactNative/requireNativeComponent'); - -import type {DangerouslyImpreciseStyle} from '../StyleSheet/StyleSheet'; import type {ResolvedAssetSource} from './AssetSourceResolver'; -import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; import type {ImageProps} from './ImageProps'; import type {ViewProps} from '../Components/View/ViewPropTypes'; -import type {ImageStyleProp} from '../StyleSheet/StyleSheet'; -import type {ColorValue} from '../StyleSheet/StyleSheet'; - -import ImageViewViewConfig from './ImageViewViewConfig'; -const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry'); +import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry'; +import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; +import type { + ColorValue, + DangerouslyImpreciseStyle, + ImageStyleProp, +} from '../StyleSheet/StyleSheet'; -type NativeProps = $ReadOnly<{| +type Props = $ReadOnly<{ ...ImageProps, ...ViewProps, @@ -38,19 +36,65 @@ type NativeProps = $ReadOnly<{| headers?: ?string, defaultSrc?: ?string, loadingIndicatorSrc?: ?string, -|}>; - -let ImageViewNativeComponent; -if (global.RN$Bridgeless) { - ReactNativeViewConfigRegistry.register('RCTImageView', () => { - return ImageViewViewConfig; - }); - ImageViewNativeComponent = 'RCTImageView'; -} else { - ImageViewNativeComponent = requireNativeComponent( - 'RCTImageView', - ); -} - -// flowlint-next-line unclear-type:off -export default ((ImageViewNativeComponent: any): HostComponent); +}>; + +const ImageViewNativeComponent: HostComponent = NativeComponentRegistry.get( + 'RCTImageView', + () => ({ + uiViewClassName: 'RCTImageView', + bubblingEventTypes: {}, + directEventTypes: { + topLoadStart: { + registrationName: 'onLoadStart', + }, + topProgress: { + registrationName: 'onProgress', + }, + topError: { + registrationName: 'onError', + }, + topPartialLoad: { + registrationName: 'onPartialLoad', + }, + topLoad: { + registrationName: 'onLoad', + }, + topLoadEnd: { + registrationName: 'onLoadEnd', + }, + }, + validAttributes: { + blurRadius: true, + capInsets: { + diff: require('../Utilities/differ/insetsDiffer'), + }, + defaultSource: { + process: require('./resolveAssetSource'), + }, + defaultSrc: true, + fadeDuration: true, + headers: true, + loadingIndicatorSrc: true, + onError: true, + onLoad: true, + onLoadEnd: true, + onLoadStart: true, + onPartialLoad: true, + onProgress: true, + overlayColor: { + process: require('../StyleSheet/processColor'), + }, + progressiveRenderingEnabled: true, + resizeMethod: true, + resizeMode: true, + shouldNotifyLoadEvents: true, + source: true, + src: true, + tintColor: { + process: require('../StyleSheet/processColor'), + }, + }, + }), +); + +export default ImageViewNativeComponent; diff --git a/Libraries/Image/ImageViewViewConfig.js b/Libraries/Image/ImageViewViewConfig.js deleted file mode 100644 index 4f974c463c2991..00000000000000 --- a/Libraries/Image/ImageViewViewConfig.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -'use strict'; - -import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; -import {type ViewConfig} from '../Renderer/shims/ReactNativeTypes'; - -const ImageViewViewConfig = { - uiViewClassName: 'RCTImageView', - bubblingEventTypes: {}, - directEventTypes: { - topLoadStart: { - registrationName: 'onLoadStart', - }, - topProgress: { - registrationName: 'onProgress', - }, - topError: { - registrationName: 'onError', - }, - topPartialLoad: { - registrationName: 'onPartialLoad', - }, - topLoad: { - registrationName: 'onLoad', - }, - topLoadEnd: { - registrationName: 'onLoadEnd', - }, - }, - validAttributes: { - ...ReactNativeViewViewConfig.validAttributes, - blurRadius: true, - // flowlint-next-line unclear-type:off - capInsets: {diff: (require('../Utilities/differ/insetsDiffer'): any)}, - defaultSource: { - process: require('./resolveAssetSource'), - }, - defaultSrc: true, - fadeDuration: true, - headers: true, - loadingIndicatorSrc: true, - onError: true, - onLoad: true, - onLoadEnd: true, - onLoadStart: true, - onPartialLoad: true, - onProgress: true, - overlayColor: {process: require('../StyleSheet/processColor')}, - progressiveRenderingEnabled: true, - resizeMethod: true, - resizeMode: true, - shouldNotifyLoadEvents: true, - source: true, - src: true, - tintColor: {process: require('../StyleSheet/processColor')}, - }, -}; - -module.exports = (ImageViewViewConfig: ViewConfig); From f638aff434760aafc2bb9622c0c18d81485a82e2 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 20 Nov 2020 18:50:49 -0800 Subject: [PATCH 0118/1810] RN: Add `NativeComponentRegistry.getWithFallback_DEPRECATED` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Creates `NativeComponentRegistry.getWithFallback_DEPRECATED`. This is deprecated from inception because it exists only to support a pattern that should not be necessary. For any given `NativeX` component, the JavaScript module that calls `NativeComponentRegistry.get('NativeX', …)` should only exist in the JavaScript bundle if the native binary actually supports that native component. But in today's transitional state of the world, there are JavaScript modules that use `UIManager.getViewManagerConfig('NativeX')` as a means of feature detection. The purpose of `NativeComponentRegistry.getWithFallback_DEPRECATED` is to bridge this transitional gap. Component should migrate toward initializing the `NativeComponentRegistry` with a runtime configuration provider that enumerates all supported native components. If the native component is not supported, it should return null. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25109988 fbshipit-source-id: 76f7077904594ca63495d8338905c43712ea02e0 --- .../NativeComponentRegistry.js | 49 ++++++++++++++++++- jest/setup.js | 3 ++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Libraries/NativeComponent/NativeComponentRegistry.js b/Libraries/NativeComponent/NativeComponentRegistry.js index 76dd24a883e156..242cee6ddbdba6 100644 --- a/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/Libraries/NativeComponent/NativeComponentRegistry.js @@ -11,6 +11,7 @@ 'use strict'; import {createViewConfig} from './ViewConfig'; +import UIManager from '../ReactNative/UIManager'; import type { HostComponent, PartialViewConfig, @@ -19,15 +20,24 @@ import ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConf import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes'; import verifyComponentAttributeEquivalence from '../Utilities/verifyComponentAttributeEquivalence'; import invariant from 'invariant'; +import * as React from 'react'; let getRuntimeConfig; /** * Configures a function that is called to determine whether a given component * should be registered using reflection of the native component at runtime. + * + * The provider should return null if the native component is unavailable in + * the current environment. */ export function setRuntimeConfigProvider( - runtimeConfigProvider: (name: string) => {native: boolean, verify: boolean}, + runtimeConfigProvider: ( + name: string, + ) => ?{ + native: boolean, + verify: boolean, + }, ): void { invariant( getRuntimeConfig == null, @@ -76,3 +86,40 @@ export function get( // $FlowFixMe[incompatible-return] `NativeComponent` is actually string! return name; } + +/** + * Same as `NativeComponentRegistry.get(...)`, except this will check either + * the `setRuntimeConfigProvider` configuration or use native reflection (slow) + * to determine whether this native component is available. + * + * If the native component is not available, a stub component is returned. Note + * that the return value of this is not `HostComponent` because the returned + * component instance is not guaranteed to have native methods. + */ +export function getWithFallback_DEPRECATED( + name: string, + viewConfigProvider: () => PartialViewConfig, +): React.AbstractComponent { + if (getRuntimeConfig == null) { + // If `setRuntimeConfigProvider` is not configured, use native reflection. + if (hasNativeViewConfig(name)) { + return get(name, viewConfigProvider); + } + } else { + // If there is no runtime config, then the native component is unavailable. + if (getRuntimeConfig(name) != null) { + return get(name, viewConfigProvider); + } + } + + const FallbackNativeComponent = function(props: Config): React.Node { + return null; + }; + FallbackNativeComponent.displayName = `Fallback(${name})`; + return FallbackNativeComponent; +} + +function hasNativeViewConfig(name: string): boolean { + invariant(getRuntimeConfig == null, 'Unexpected invocation!'); + return UIManager.getViewManagerConfig(name) != null; +} diff --git a/jest/setup.js b/jest/setup.js index eefca60e23be6e..514e76c5242b7a 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -330,6 +330,9 @@ jest get: jest.fn((name, viewConfigProvider) => { return jest.requireActual('./mockNativeComponent')(name); }), + getWithFallback_DEPRECATED: jest.fn((name, viewConfigProvider) => { + return jest.requireActual('./mockNativeComponent')(name); + }), setRuntimeConfigProvider: jest.fn(), }; }) From e99b8bbb404f8cd1f11b6c7998083be530d7b8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Fri, 20 Nov 2020 20:09:37 -0800 Subject: [PATCH 0119/1810] Use react-native-codegen@0.0.6 in new app template Summary: Use pre-built react-native-codegen library from npm in the iOS app template. Built react-native-codegen from source when used with RNTester. Published react-native-codegen@0.0.6. Changelog: [iOS][Added] - Use react-native-codegen in iOS app template [Internal] - Bump react-native-codegen: 0.0.6 Reviewed By: fkgozali Differential Revision: D25128036 fbshipit-source-id: f294c23b9b911aae6f404edc01b62426fb578477 --- package.json | 1 - packages/react-native-codegen/package.json | 2 +- packages/react-native-codegen/scripts/oss/build.sh | 8 +++++++- packages/rn-tester/Podfile | 4 +++- packages/rn-tester/Podfile.lock | 2 +- scripts/react_native_pods.rb | 10 +++++++--- template/package.json | 1 + 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 51e8ae3b019b3b..0326e84134dbcb 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "Libraries", "LICENSE", "local-cli", - "packages/react-native-codegen", "React-Core.podspec", "react-native.config.js", "react.gradle", diff --git a/packages/react-native-codegen/package.json b/packages/react-native-codegen/package.json index 871da36b95f0a9..2ab4e05ad21a78 100644 --- a/packages/react-native-codegen/package.json +++ b/packages/react-native-codegen/package.json @@ -1,6 +1,6 @@ { "name": "react-native-codegen", - "version": "0.0.5", + "version": "0.0.6", "description": "⚛️ Code generation tools for React Native", "homepage": "https://github.com/facebook/react-native/tree/master/packages/react-native-codegen", "repository": { diff --git a/packages/react-native-codegen/scripts/oss/build.sh b/packages/react-native-codegen/scripts/oss/build.sh index 28fe87693b4454..7e22d6bbd6040a 100755 --- a/packages/react-native-codegen/scripts/oss/build.sh +++ b/packages/react-native-codegen/scripts/oss/build.sh @@ -15,7 +15,13 @@ CODEGEN_DIR="$THIS_DIR/../.." rm -rf "${CODEGEN_DIR:?}/lib" "${CODEGEN_DIR:?}/node_modules" -YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" +# Fallback to npm if yarn is not available +if [ -x "$(command -v yarn)" ]; then + YARN_OR_NPM=$(command -v yarn) +else + YARN_OR_NPM=$(command -v npm) +fi +YARN_BINARY="${YARN_BINARY:-$YARN_OR_NPM}" if [[ ${FBSOURCE_ENV:-0} -eq 1 ]]; then # Custom FB-specific setup diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 021f13970c392d..e939c4f2f0b7a8 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -64,7 +64,9 @@ pre_install do |installer| frameworks_pre_install(installer) if ENV['USE_FRAMEWORKS'] == '1' if ENV['USE_CODEGEN'] != '0' prefix_path = "../.." - codegen_pre_install(installer, {path:prefix_path}) + codegen_path = "../../packages/react-native-codegen" + system("./#{codegen_path}/scripts/oss/build.sh") or raise "Could not build react-native-codegen package" + codegen_pre_install(installer, {path:prefix_path, codegen_path:codegen_path}) end end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 4034f23bda4545..6ba9855fd1872b 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -528,6 +528,6 @@ SPEC CHECKSUMS: Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 961e081223f82b7e9208869de4d73534d949ae9e +PODFILE CHECKSUM: cd671238f92c51cd349a1c778fd089994174b101 COCOAPODS: 1.10.0 diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index f184a5c8784177..14d6166f3da6c1 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -111,14 +111,18 @@ def flipper_post_install(installer) # Pre Install processing for Native Modules def codegen_pre_install(installer, options={}) + # Path to React Native prefix = options[:path] ||= "../node_modules/react-native" - system("./#{prefix}/packages/react-native-codegen/scripts/oss/build.sh") + # Path to react-native-codegen + codegen_path = options[:codegen_path] ||= "#{prefix}/../react-native-codegen" + + # Handle Core Modules Dir.mktmpdir do |dir| native_module_spec_name = "FBReactNativeSpec" schema_file = dir + "/schema-#{native_module_spec_name}.json" srcs_dir = "#{prefix}/Libraries" - schema_generated = system("node #{prefix}/packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}") - specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}") + schema_generated = system("node #{codegen_path}/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}") or raise "Could not generate Native Module schema" + specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}") or raise "Could not generate code for #{native_module_spec_name}" end end diff --git a/template/package.json b/template/package.json index 2c481b9ec10034..6c1d3a08ebbd67 100644 --- a/template/package.json +++ b/template/package.json @@ -21,6 +21,7 @@ "eslint": "7.12.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.64.0", + "react-native-codegen": "^0.0.6", "react-test-renderer": "17.0.1" }, "jest": { From baa824826dce30cc69767503291860ad63eb063c Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sun, 22 Nov 2020 01:29:37 -0800 Subject: [PATCH 0120/1810] RN: Call `NativeComponentRegistry` in Codegen Summary: Changes `react-native/babel-plugin-codegen` to generate calls to `NativeComponentRegistry` instead of `registerGeneratedViewConfig`. The only notable changes in behavior from this will be: 1. In bridgeless mode, all components using `codegenNativeComponent` will no longer access `UIManager`. 2. In bridge mode, all components using `codegenNativeComponent` will no longer verify equivalence in production. Only in `__DEV__`. (This may improve performance slightly.) This also changes the `ViewConfig` to be lazily allocated and drops support for `__INTERNAL_VIEW_CONFIG`, which we no longer need. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25135881 fbshipit-source-id: ca2191872c02622ab2279b808102eeb1f664d207 --- .../__snapshots__/index-test.js.snap | 22 +- packages/babel-plugin-codegen/package.json | 2 +- .../components/GenerateViewConfigJs.js | 14 +- .../GenerateViewConfigJs-test.js.snap | 460 ++++++------------ 4 files changed, 156 insertions(+), 342 deletions(-) diff --git a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap index 6ce4b2b73c6b1c..df33cdacef093e 100644 --- a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap @@ -22,13 +22,14 @@ interface NativeCommands { +scrollTo: (viewRef: React.ElementRef, y: Int32, animated: boolean) => void, } -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); const { dispatchCommand } = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\"); -const ModuleViewConfig = { +let nativeComponentName = 'RCTModule'; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'RCTModule', bubblingEventTypes: { topBubblingEventDefinedInlineNull: { @@ -48,11 +49,7 @@ const ModuleViewConfig = { onDirectEventDefinedInlineNull: true, onBubblingEventDefinedInlineNull: true } -}; -let nativeComponentName = 'RCTModule'; -registerGeneratedViewConfig(nativeComponentName, ModuleViewConfig); -export const __INTERNAL_VIEW_CONFIG = ModuleViewConfig; -export default nativeComponentName; +})); export const Commands = { hotspotUpdate(ref, x, y) { dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]); @@ -87,13 +84,14 @@ interface NativeCommands { +scrollTo: (viewRef: React.ElementRef, y: Int32, animated: boolean) => void, } -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); const { dispatchCommand } = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\"); -const ModuleViewConfig = { +let nativeComponentName = 'RCTModule'; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'RCTModule', bubblingEventTypes: { topBubblingEventDefinedInlineNull: { @@ -113,11 +111,7 @@ const ModuleViewConfig = { onDirectEventDefinedInlineNull: true, onBubblingEventDefinedInlineNull: true } -}; -let nativeComponentName = 'RCTModule'; -registerGeneratedViewConfig(nativeComponentName, ModuleViewConfig); -export const __INTERNAL_VIEW_CONFIG = ModuleViewConfig; -export default nativeComponentName; +})); export const Commands = { hotspotUpdate(ref, x, y) { dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]); diff --git a/packages/babel-plugin-codegen/package.json b/packages/babel-plugin-codegen/package.json index 5360b6829c8a31..e5176600ae0476 100644 --- a/packages/babel-plugin-codegen/package.json +++ b/packages/babel-plugin-codegen/package.json @@ -1,5 +1,5 @@ { - "version": "0.0.5", + "version": "0.0.6", "name": "@react-native/babel-plugin-codegen", "description": "Babel plugin to generate native module and view manager code for React Native.", "repository": { diff --git a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js index 63f6dc7892cd16..a95cce35fe0c90 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js +++ b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js @@ -94,24 +94,18 @@ function getReactDiffProcessValue(typeAnnotation) { } const componentTemplate = ` -const ::_COMPONENT_NAME_::ViewConfig = VIEW_CONFIG; - let nativeComponentName = '::_COMPONENT_NAME_WITH_COMPAT_SUPPORT_::'; ::_DEPRECATION_CHECK_:: -registerGeneratedViewConfig(nativeComponentName, ::_COMPONENT_NAME_::ViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ::_COMPONENT_NAME_::ViewConfig; - -export default nativeComponentName; +export default NativeComponentRegistry.get(nativeComponentName, () => VIEW_CONFIG); `.trim(); const deprecatedComponentTemplate = ` if (UIManager.getViewManagerConfig('::_COMPONENT_NAME_::')) { nativeComponentName = '::_COMPONENT_NAME_::'; -} else if (UIManager.getViewManagerConfig('::_COMPONENT_NAME_DEPRECATED_::')){ +} else if (UIManager.getViewManagerConfig('::_COMPONENT_NAME_DEPRECATED_::')) { nativeComponentName = '::_COMPONENT_NAME_DEPRECATED_::'; } else { - throw new Error('Failed to find native component for either "::_COMPONENT_NAME_::" or "::_COMPONENT_NAME_DEPRECATED_::"') + throw new Error('Failed to find native component for either "::_COMPONENT_NAME_::" or "::_COMPONENT_NAME_DEPRECATED_::"'); } `.trim(); @@ -183,7 +177,7 @@ function buildViewConfig( switch (extendProps.knownTypeName) { case 'ReactNativeCoreViewProps': imports.add( - "const registerGeneratedViewConfig = require('registerGeneratedViewConfig');", + "const NativeComponentRegistry = require('NativeComponentRegistry');", ); return; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index 27bf707c6a83ff..099c42e270fb58 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -16,9 +16,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const ArrayPropsNativeComponentViewConfig = { +let nativeComponentName = 'ArrayPropsNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'ArrayPropsNativeComponent', validAttributes: { @@ -38,15 +40,7 @@ const ArrayPropsNativeComponentViewConfig = { array: true, arrayOfArrayOfObject: true, }, -}; - -let nativeComponentName = 'ArrayPropsNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, ArrayPropsNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ArrayPropsNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -67,23 +61,17 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const ArrayPropsNativeComponentViewConfig = { +let nativeComponentName = 'ArrayPropsNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'ArrayPropsNativeComponent', validAttributes: { nativePrimitives: true, }, -}; - -let nativeComponentName = 'ArrayPropsNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, ArrayPropsNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ArrayPropsNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -104,23 +92,17 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'BooleanPropNativeComponent'; -const BooleanPropNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'BooleanPropNativeComponent', validAttributes: { disabled: true, }, -}; - -let nativeComponentName = 'BooleanPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, BooleanPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = BooleanPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -141,9 +123,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'ColorPropNativeComponent'; -const ColorPropNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'ColorPropNativeComponent', validAttributes: { @@ -151,15 +135,7 @@ const ColorPropNativeComponentViewConfig = { process: require('processColor'), }, }, -}; - -let nativeComponentName = 'ColorPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, ColorPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ColorPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -180,21 +156,15 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\"); -const CommandNativeComponentViewConfig = { - uiViewClassName: 'CommandNativeComponent', - validAttributes: {}, -}; - let nativeComponentName = 'CommandNativeComponent'; -registerGeneratedViewConfig(nativeComponentName, CommandNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = CommandNativeComponentViewConfig; - -export default nativeComponentName; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ + uiViewClassName: 'CommandNativeComponent', + validAttributes: {}, +})); export const Commands = { flashScrollIndicators(ref) { @@ -225,24 +195,18 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\"); -const CommandNativeComponentViewConfig = { +let nativeComponentName = 'CommandNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'CommandNativeComponent', validAttributes: { accessibilityHint: true, }, -}; - -let nativeComponentName = 'CommandNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, CommandNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = CommandNativeComponentViewConfig; - -export default nativeComponentName; +})); export const Commands = { handleRootTag(ref, rootTag) { @@ -273,9 +237,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'DoublePropNativeComponent'; -const DoublePropNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'DoublePropNativeComponent', validAttributes: { @@ -286,15 +252,7 @@ const DoublePropNativeComponentViewConfig = { blurRadius5: true, blurRadius6: true, }, -}; - -let nativeComponentName = 'DoublePropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, DoublePropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = DoublePropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -315,9 +273,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'EventsNestedObjectNativeComponent'; -const EventsNestedObjectNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'EventsNestedObjectNativeComponent', bubblingEventTypes: { @@ -333,15 +293,7 @@ const EventsNestedObjectNativeComponentViewConfig = { disabled: true, onChange: true, }, -}; - -let nativeComponentName = 'EventsNestedObjectNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, EventsNestedObjectNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = EventsNestedObjectNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -362,9 +314,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const EventsNativeComponentViewConfig = { +let nativeComponentName = 'EventsNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'EventsNativeComponent', bubblingEventTypes: { @@ -400,15 +354,7 @@ const EventsNativeComponentViewConfig = { onOrientationChange: true, onEnd: true, }, -}; - -let nativeComponentName = 'EventsNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, EventsNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = EventsNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -429,9 +375,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const InterfaceOnlyComponentViewConfig = { +let nativeComponentName = 'RCTInterfaceOnlyComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'RCTInterfaceOnlyComponent', bubblingEventTypes: { @@ -464,15 +412,7 @@ const InterfaceOnlyComponentViewConfig = { onChange: true, onDire tChange: true, }, -}; - -let nativeComponentName = 'RCTInterfaceOnlyComponent'; - -registerGeneratedViewConfig(nativeComponentName, InterfaceOnlyComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = InterfaceOnlyComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -493,20 +433,14 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); - -const ExcludedAndroidComponentViewConfig = { - uiViewClassName: 'ExcludedAndroidComponent', - validAttributes: {}, -}; +const NativeComponentRegistry = require('NativeComponentRegistry'); let nativeComponentName = 'ExcludedAndroidComponent'; -registerGeneratedViewConfig(nativeComponentName, ExcludedAndroidComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ExcludedAndroidComponentViewConfig; - -export default nativeComponentName; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ + uiViewClassName: 'ExcludedAndroidComponent', + validAttributes: {}, +})); ", } `; @@ -527,20 +461,14 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); - -const ExcludedAndroidIosComponentViewConfig = { - uiViewClassName: 'ExcludedAndroidIosComponent', - validAttributes: {}, -}; +const NativeComponentRegistry = require('NativeComponentRegistry'); let nativeComponentName = 'ExcludedAndroidIosComponent'; -registerGeneratedViewConfig(nativeComponentName, ExcludedAndroidIosComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ExcludedAndroidIosComponentViewConfig; - -export default nativeComponentName; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ + uiViewClassName: 'ExcludedAndroidIosComponent', + validAttributes: {}, +})); ", } `; @@ -561,9 +489,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const FloatPropNativeComponentViewConfig = { +let nativeComponentName = 'FloatPropNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'FloatPropNativeComponent', validAttributes: { @@ -574,15 +504,7 @@ const FloatPropNativeComponentViewConfig = { blurRadius5: true, blurRadius6: true, }, -}; - -let nativeComponentName = 'FloatPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, FloatPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = FloatPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -603,9 +525,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const ImagePropNativeComponentViewConfig = { +let nativeComponentName = 'ImagePropNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'ImagePropNativeComponent', validAttributes: { @@ -613,15 +537,7 @@ const ImagePropNativeComponentViewConfig = { process: require('resolveAssetSource'), }, }, -}; - -let nativeComponentName = 'ImagePropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, ImagePropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ImagePropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -642,9 +558,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'InsetsPropNativeComponent'; -const InsetsPropNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'InsetsPropNativeComponent', validAttributes: { @@ -652,15 +570,7 @@ const InsetsPropNativeComponentViewConfig = { diff: require('insetsDiffer'), }, }, -}; - -let nativeComponentName = 'InsetsPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, InsetsPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = InsetsPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -681,23 +591,17 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'Int32EnumPropsNativeComponent'; -const Int32EnumPropsNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'Int32EnumPropsNativeComponent', validAttributes: { maxInterval: true, }, -}; - -let nativeComponentName = 'Int32EnumPropsNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, Int32EnumPropsNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = Int32EnumPropsNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -718,9 +622,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const IntegerPropNativeComponentViewConfig = { +let nativeComponentName = 'IntegerPropNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'IntegerPropNativeComponent', validAttributes: { @@ -728,15 +634,7 @@ const IntegerPropNativeComponentViewConfig = { progress2: true, progress3: true, }, -}; - -let nativeComponentName = 'IntegerPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, IntegerPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = IntegerPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -757,9 +655,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const InterfaceOnlyComponentViewConfig = { +let nativeComponentName = 'RCTInterfaceOnlyComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'RCTInterfaceOnlyComponent', bubblingEventTypes: { @@ -775,15 +675,7 @@ const InterfaceOnlyComponentViewConfig = { accessibilityHint: true, onChange: true, }, -}; - -let nativeComponentName = 'RCTInterfaceOnlyComponent'; - -registerGeneratedViewConfig(nativeComponentName, InterfaceOnlyComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = InterfaceOnlyComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -804,9 +696,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'ImageColorPropNativeComponent'; -const ImageColorPropNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'ImageColorPropNativeComponent', validAttributes: { @@ -826,15 +720,7 @@ const ImageColorPropNativeComponentViewConfig = { diff: require('pointsDiffer'), }, }, -}; - -let nativeComponentName = 'ImageColorPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, ImageColorPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ImageColorPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -855,20 +741,14 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); - -const NoPropsNoEventsComponentViewConfig = { - uiViewClassName: 'NoPropsNoEventsComponent', - validAttributes: {}, -}; +const NativeComponentRegistry = require('NativeComponentRegistry'); let nativeComponentName = 'NoPropsNoEventsComponent'; -registerGeneratedViewConfig(nativeComponentName, NoPropsNoEventsComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = NoPropsNoEventsComponentViewConfig; - -export default nativeComponentName; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ + uiViewClassName: 'NoPropsNoEventsComponent', + validAttributes: {}, +})); ", } `; @@ -889,23 +769,17 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const ObjectPropsViewConfig = { +let nativeComponentName = 'ObjectProps'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'ObjectProps', validAttributes: { objectProp: true, }, -}; - -let nativeComponentName = 'ObjectProps'; - -registerGeneratedViewConfig(nativeComponentName, ObjectPropsViewConfig); - -export const __INTERNAL_VIEW_CONFIG = ObjectPropsViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -926,9 +800,11 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); -const PointPropNativeComponentViewConfig = { +let nativeComponentName = 'PointPropNativeComponent'; + +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'PointPropNativeComponent', validAttributes: { @@ -936,15 +812,7 @@ const PointPropNativeComponentViewConfig = { diff: require('pointsDiffer'), }, }, -}; - -let nativeComponentName = 'PointPropNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, PointPropNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = PointPropNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -965,23 +833,17 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'StringEnumPropsNativeComponent'; -const StringEnumPropsNativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'StringEnumPropsNativeComponent', validAttributes: { alignment: true, }, -}; - -let nativeComponentName = 'StringEnumPropsNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, StringEnumPropsNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = StringEnumPropsNativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -1002,24 +864,18 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'StringPropComponent'; -const StringPropComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'StringPropComponent', validAttributes: { accessibilityHint: true, accessibilityRole: true, }, -}; - -let nativeComponentName = 'StringPropComponent'; - -registerGeneratedViewConfig(nativeComponentName, StringPropComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = StringPropComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -1040,39 +896,27 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'MultiFile1NativeComponent'; -const MultiFile1NativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'MultiFile1NativeComponent', validAttributes: { disabled: true, }, -}; - -let nativeComponentName = 'MultiFile1NativeComponent'; +})); -registerGeneratedViewConfig(nativeComponentName, MultiFile1NativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = MultiFile1NativeComponentViewConfig; - -export default nativeComponentName; +let nativeComponentName = 'MultiFile2NativeComponent'; -const MultiFile2NativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'MultiFile2NativeComponent', validAttributes: { disabled: true, }, -}; - -let nativeComponentName = 'MultiFile2NativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, MultiFile2NativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = MultiFile2NativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -1093,39 +937,27 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); + +let nativeComponentName = 'MultiComponent1NativeComponent'; -const MultiComponent1NativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'MultiComponent1NativeComponent', validAttributes: { disabled: true, }, -}; - -let nativeComponentName = 'MultiComponent1NativeComponent'; +})); -registerGeneratedViewConfig(nativeComponentName, MultiComponent1NativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = MultiComponent1NativeComponentViewConfig; - -export default nativeComponentName; +let nativeComponentName = 'MultiComponent2NativeComponent'; -const MultiComponent2NativeComponentViewConfig = { +export default NativeComponentRegistry.get(nativeComponentName, () => ({ uiViewClassName: 'MultiComponent2NativeComponent', validAttributes: { disabled: true, }, -}; - -let nativeComponentName = 'MultiComponent2NativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, MultiComponent2NativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = MultiComponent2NativeComponentViewConfig; - -export default nativeComponentName; +})); ", } `; @@ -1146,27 +978,21 @@ Map { 'use strict'; -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); +const NativeComponentRegistry = require('NativeComponentRegistry'); const {UIManager} = require(\\"react-native\\") -const NativeComponentNameViewConfig = { - uiViewClassName: 'NativeComponentName', - validAttributes: {}, -}; - let nativeComponentName = 'NativeComponentName'; if (UIManager.getViewManagerConfig('NativeComponentName')) { nativeComponentName = 'NativeComponentName'; -} else if (UIManager.getViewManagerConfig('DeprecatedNativeComponentName')){ +} else if (UIManager.getViewManagerConfig('DeprecatedNativeComponentName')) { nativeComponentName = 'DeprecatedNativeComponentName'; } else { - throw new Error('Failed to find native component for either \\"NativeComponentName\\" or \\"DeprecatedNativeComponentName\\"') + throw new Error('Failed to find native component for either \\"NativeComponentName\\" or \\"DeprecatedNativeComponentName\\"'); } -registerGeneratedViewConfig(nativeComponentName, NativeComponentNameViewConfig); - -export const __INTERNAL_VIEW_CONFIG = NativeComponentNameViewConfig; - -export default nativeComponentName; +export default NativeComponentRegistry.get(nativeComponentName, () => ({ + uiViewClassName: 'NativeComponentName', + validAttributes: {}, +})); ", } `; From 0675beee11a51a346281f92cee56dbe2320c084f Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Tue, 24 Nov 2020 04:24:05 -0800 Subject: [PATCH 0121/1810] include android in npm package (#30451) Summary: RN app expects **android** folder with maven artifacts in NPM package, and *test-manual-e2e.sh* fails on **0.64-stable** because it couldn't find **android** folder, therefore looks into remote repos and finds 0.20.1 version on bintray. See https://github.com/facebook/react-native/blob/e99b8bbb404f8cd1f11b6c7998083be530d7b8a4/template/android/build.gradle#L27 This PR will change npm pack to include **android** folder with maven artifacts in NPM package, thus RN android apps can find RN in node_modules. ## Changelog [Internal] [Changed] - include *android* in npm package Pull Request resolved: https://github.com/facebook/react-native/pull/30451 Test Plan: With this change *test-manual-e2e.sh* will run successfully, previous it was failing due to duplicate classes error. Reviewed By: MichaReiser Differential Revision: D25157286 Pulled By: cpojer fbshipit-source-id: 42fcd09d417560ebd9d3fc8fc52e1e291fca152e --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0326e84134dbcb..2a1a84cfd1d77c 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "!template/node_modules", "!template/package-lock.json", "!template/yarn.lock", + "android", "cli.js", "flow", "flow-typed", From 9528ef27b9376c7e3bf7868856c420356bd954b7 Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Thu, 26 Nov 2020 04:04:30 -0800 Subject: [PATCH 0122/1810] Avoid accessing `self.component` on background thread Summary: Changelog: [Internal] `self.component` is main thread affined so we need to dispatch to main queue before using it. Reviewed By: shergin Differential Revision: D25163182 fbshipit-source-id: a7da0324982354215e0ccb47615f7f121200f12a --- .../RCTSurfaceHostingComponentController.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm b/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm index cd69fb32b3e129..d56974f5152de0 100644 --- a/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm +++ b/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm @@ -130,12 +130,18 @@ - (void)unmountSurfaceView - (void)surface:(RCTSurface *)surface didChangeIntrinsicSize:(CGSize)intrinsicSize { - [self setIntrinsicSize:intrinsicSize]; + __weak const auto weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf setIntrinsicSize:intrinsicSize]; + }); } - (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage { - [self setStage:stage]; + __weak const auto weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf setStage:stage]; + }); } @end From bb1dcc182ee8bd57db16f6c5ac6ab44edf808434 Mon Sep 17 00:00:00 2001 From: Shelly Willard Date: Fri, 27 Nov 2020 11:12:37 -0800 Subject: [PATCH 0123/1810] Migrate jsi wrapper + pass markerId to get next instance key Summary: Migrating jsi wrapper userflow v2. Also pass markerId to the method that gets instance key Changelog: [internal] Differential Revision: D25184462 fbshipit-source-id: c316720b0b3d47b345156bb71d51d6f4c473ceef --- Libraries/Reliability/UserFlow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Reliability/UserFlow.js b/Libraries/Reliability/UserFlow.js index 5116e2af3f6431..b7f62b91320727 100644 --- a/Libraries/Reliability/UserFlow.js +++ b/Libraries/Reliability/UserFlow.js @@ -53,7 +53,7 @@ const UserFlow = { var resolvedInstanceKey = instanceKey; if (instanceKey === AUTO_INSTANCE_KEY) { if (global.nativeUserFlowNextInstanceKey) { - resolvedInstanceKey = global.nativeUserFlowNextInstanceKey(); + resolvedInstanceKey = global.nativeUserFlowNextInstanceKey(markerId); } else { // There is no JSI methods installed, API won't do anything resolvedInstanceKey = 0; From aa03c836b4904b0110e41989344acb910df77162 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sat, 28 Nov 2020 21:47:46 -0800 Subject: [PATCH 0124/1810] RN: Migrate `View` to NativeComponentRegistry Summary: Migrates `View` to use `NativeComponentRegistry`, which enables configuring it to avoid reflection by using a static `ViewConfig`. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25136054 fbshipit-source-id: f2abda1105bd2a8b396db6f1a640430b62bbcdaf --- .../Components/View/ViewNativeComponent.js | 77 ++++--------------- 1 file changed, 17 insertions(+), 60 deletions(-) diff --git a/Libraries/Components/View/ViewNativeComponent.js b/Libraries/Components/View/ViewNativeComponent.js index 902414c4eb45e3..16970ecda376bc 100644 --- a/Libraries/Components/View/ViewNativeComponent.js +++ b/Libraries/Components/View/ViewNativeComponent.js @@ -4,72 +4,27 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow strict-local * @format - * @flow */ 'use strict'; -const Platform = require('../../Utilities/Platform'); -const ReactNativeViewViewConfigAndroid = require('./ReactNativeViewViewConfigAndroid'); - -const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig'); -const requireNativeComponent = require('../../ReactNative/requireNativeComponent'); - -import * as React from 'react'; - +import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; +import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import Platform from '../../Utilities/Platform'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; -import type {ViewProps} from './ViewPropTypes'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; - -export type ViewNativeComponentType = HostComponent; - -let NativeViewComponent; -let viewConfig: - | {...} - | {| - bubblingEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{| - phasedRegistrationNames: $ReadOnly<{| - bubbled: string, - captured: string, - |}>, - |}>, - ..., - }>, - directEventTypes?: $ReadOnly<{ - [eventName: string]: $ReadOnly<{|registrationName: string|}>, - ..., - }>, - uiViewClassName: string, - validAttributes?: { - [propName: string]: - | true - | $ReadOnly<{| - diff?: (arg1: any, arg2: any) => boolean, - process?: (arg1: any) => any, - |}>, - ..., - }, - |}; - -if (__DEV__ || global.RN$Bridgeless) { - // On Android, View extends the base component with additional view-only props - // On iOS, the base component is View - if (Platform.OS === 'android') { - viewConfig = ReactNativeViewViewConfigAndroid; - registerGeneratedViewConfig('RCTView', ReactNativeViewViewConfigAndroid); - } else { - viewConfig = {}; - registerGeneratedViewConfig('RCTView', {uiViewClassName: 'RCTView'}); - } - - NativeViewComponent = 'RCTView'; -} else { - NativeViewComponent = requireNativeComponent('RCTView'); -} +import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid'; +import {type ViewProps as Props} from './ViewPropTypes'; +import * as React from 'react'; -export const __INTERNAL_VIEW_CONFIG = viewConfig; +const ViewNativeComponent: HostComponent = NativeComponentRegistry.get( + 'RCTView', + () => + Platform.OS === 'android' + ? ReactNativeViewViewConfigAndroid + : {uiViewClassName: 'RCTView'}, +); interface NativeCommands { +hotspotUpdate: ( @@ -87,4 +42,6 @@ export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate', 'setPressed'], }); -export default ((NativeViewComponent: any): ViewNativeComponentType); +export default ViewNativeComponent; + +export type ViewNativeComponentType = HostComponent; From 5677d812aaf18acac5c0f7c889c3a563aaf3e4b4 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 30 Nov 2020 07:52:46 -0800 Subject: [PATCH 0125/1810] Disable assert in StubViewTree until it is resolved Summary: Changelog: [internal] The assert is still firing, let's disable it until we can investigate why layout animations creates two delete mount instructions. Reviewed By: majak Differential Revision: D25216794 fbshipit-source-id: 6328a2afb5eaf7fceebdc05bc75804f2eb44ddd2 --- ReactCommon/react/renderer/mounting/StubViewTree.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index 4268b35e166c5f..1b58f59e5d3521 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -61,10 +61,12 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_ASSERT(mutation.parentShadowView == ShadowView{}); STUB_VIEW_ASSERT(mutation.newChildShadowView == ShadowView{}); auto tag = mutation.oldChildShadowView.tag; + /* Disable this assert until T76057501 is resolved. STUB_VIEW_ASSERT(registry.find(tag) != registry.end()); auto stubView = registry[tag]; STUB_VIEW_ASSERT( (ShadowView)(*stubView) == mutation.oldChildShadowView); + */ registry.erase(tag); break; } From 8478f461df1ab7dce58edcb2a774239b9e485b5a Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 30 Nov 2020 12:25:55 -0800 Subject: [PATCH 0126/1810] Simplify interface of LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations Summary: Changelog: [internal] Return value from `LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations` was a tuple with 3 elements. Two of them are not being used so let's get rid of them. Reviewed By: JoshuaGross Differential Revision: D25220601 fbshipit-source-id: 35781e735b6a2e518337fdeaf956c18bb370993b --- .../LayoutAnimationKeyFrameManager.cpp | 32 +++++-------------- .../LayoutAnimationKeyFrameManager.h | 3 +- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index d9dd34033a5618..ddc2353e0efd99 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -483,7 +483,8 @@ void LayoutAnimationKeyFrameManager:: std::remove_if( candidateMutations.begin(), candidateMutations.end(), - [&](ShadowViewMutation *candidateMutation) { + [&changed, &mutation, &adjustedDelta, &isRemoveMutation]( + ShadowViewMutation *candidateMutation) { bool indexConflicts = (candidateMutation->index < mutation.index || (isRemoveMutation && @@ -625,13 +626,12 @@ void LayoutAnimationKeyFrameManager::adjustDelayedMutationIndicesForMutation( } } -std::vector> +std::vector LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( SurfaceId surfaceId, ShadowViewMutationList const &mutations, bool deletesOnly) const { - std::vector> - conflictingAnimations{}; + std::vector conflictingAnimations{}; for (auto const &mutation : mutations) { if (deletesOnly && mutation.type != ShadowViewMutation::Type::Delete) { @@ -669,17 +669,6 @@ LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( // animation, or deleting the parent of a tag under animation, or // reparenting. if (conflicting) { - auto const layoutAnimationConfig = - inflightAnimation.layoutAnimationConfig; - - auto const &mutationConfig = - (animatedKeyFrame.type == AnimationConfigurationType::Delete - ? layoutAnimationConfig.deleteConfig - : (animatedKeyFrame.type == - AnimationConfigurationType::Create - ? layoutAnimationConfig.createConfig - : layoutAnimationConfig.updateConfig)); - animatedKeyFrame.invalidated = true; // We construct a list of all conflicting animations, whether or not @@ -689,8 +678,7 @@ LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( if (!(animatedKeyFrame.finalMutationForKeyFrame.has_value() && mutatedViewIsVirtual( *animatedKeyFrame.finalMutationForKeyFrame))) { - conflictingAnimations.push_back(std::make_tuple( - animatedKeyFrame, mutationConfig, &inflightAnimation)); + conflictingAnimations.push_back(animatedKeyFrame); } #ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING @@ -1127,8 +1115,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( } // Handle conflicting animations - for (auto &conflictingKeyframeTuple : conflictingAnimations) { - auto &conflictingKeyFrame = std::get<0>(conflictingKeyframeTuple); + for (auto &conflictingKeyFrame : conflictingAnimations) { auto const &conflictingMutationBaselineShadowView = conflictingKeyFrame.viewStart; @@ -1192,9 +1179,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( #endif auto finalConflictingMutations = ShadowViewMutationList{}; - for (auto &conflictingKeyframeTuple : conflictingAnimations) { - auto &keyFrame = std::get<0>(conflictingKeyframeTuple); - + for (auto &keyFrame : conflictingAnimations) { // Special-case: if we have some (1) ongoing UPDATE animation, // (2) it conflicted with a new MOVE operation (REMOVE+INSERT) // without another corresponding UPDATE, we should re-queue the @@ -1402,8 +1387,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( LOG(ERROR) << "No Animation: Queue up final conflicting animations"; #endif ShadowViewMutationList finalMutationsForConflictingAnimations{}; - for (auto const &conflictingKeyframeTuple : conflictingAnimations) { - auto &keyFrame = std::get<0>(conflictingKeyframeTuple); + for (auto const &keyFrame : conflictingAnimations) { if (keyFrame.finalMutationForKeyFrame.hasValue()) { auto &finalMutation = (*keyFrame.finalMutationForKeyFrame); auto mutation = ShadowViewMutation{finalMutation.type, diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 0c57bb01c153a2..de5239c30f838f 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -223,8 +223,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, ShadowViewMutation const &mutation, bool skipLastAnimation = false) const; - std::vector> - getAndEraseConflictingAnimations( + std::vector getAndEraseConflictingAnimations( SurfaceId surfaceId, ShadowViewMutationList const &mutations, bool deletesOnly = false) const; From b9b22151740059436f237a36ef150ed99ff8b326 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yin Date: Mon, 30 Nov 2020 14:13:14 -0800 Subject: [PATCH 0127/1810] Add DoNotStrip annotations to TurboModulePerfLogger Summary: Prevent proguard from stripping these methods Changelog: [Internal] Add DoNotStrip annotations to TurboModulePerfLogger Reviewed By: RSNara Differential Revision: D25101027 fbshipit-source-id: 673e97446a36fe0e8c10916aa7eb4c39c2187ba8 --- .../src/main/java/com/facebook/react/turbomodule/core/BUCK | 1 + .../facebook/react/turbomodule/core/TurboModulePerfLogger.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK index 721fe18d0cc7f1..63dfbaa6977994 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK @@ -14,6 +14,7 @@ rn_android_library( "PUBLIC", ], deps = [ + "//fbandroid/java/com/facebook/proguard/annotations:annotations", react_native_dep("third-party/android/androidx:annotation"), react_native_dep("java/com/facebook/proguard/annotations:annotations"), react_native_dep("java/com/facebook/systrace:systrace"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModulePerfLogger.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModulePerfLogger.java index eb8e49d5dfdae0..36d7d1d010c4de 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModulePerfLogger.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModulePerfLogger.java @@ -7,10 +7,12 @@ package com.facebook.react.turbomodule.core; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.perflogger.NativeModulePerfLogger; import com.facebook.soloader.SoLoader; import javax.annotation.Nullable; +@DoNotStrip public class TurboModulePerfLogger { @Nullable private static NativeModulePerfLogger sNativeModulePerfLogger = null; private static boolean sIsSoLibraryLoaded = false; From 5cf4ab8dd28b5a336d7af29d295ede51f0d19587 Mon Sep 17 00:00:00 2001 From: Su Min Kim Date: Tue, 1 Dec 2020 09:04:19 -0800 Subject: [PATCH 0128/1810] Remove filter pills from example page (#30198) Summary: rickhanlonii Removes filter pills from example page in RNTester app. ## Changelog Removed filter pills from example page by changing hideFilterPills property to true in RNTesterExampleList.js
[Android] [Removed] - Remove filter pills [iOS] [Removed] - Remove filter pills Pull Request resolved: https://github.com/facebook/react-native/pull/30198 Test Plan: RNTester app builds and runs as expected and filter pills are removed from the screen.
Reviewed By: cpojer Differential Revision: D24395513 Pulled By: rickhanlonii fbshipit-source-id: 7351ce8972185f973ad302d70929491cc6f56907 --- packages/rn-tester/js/components/RNTesterExampleList.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/rn-tester/js/components/RNTesterExampleList.js b/packages/rn-tester/js/components/RNTesterExampleList.js index 4f47b3fed6d507..2b32664b7853a5 100644 --- a/packages/rn-tester/js/components/RNTesterExampleList.js +++ b/packages/rn-tester/js/components/RNTesterExampleList.js @@ -152,6 +152,7 @@ const RNTesterExampleList: React$AbstractComponent = React.memo( page="components_page" sections={sections} filter={filter} + hideFilterPills={true} render={({filteredSections}) => ( Date: Tue, 1 Dec 2020 09:20:45 -0800 Subject: [PATCH 0129/1810] Remove duplicate declaration Summary: Changelog: [internal] This is already defined in Touch.h Reviewed By: shergin Differential Revision: D25242843 fbshipit-source-id: 23bac2a60f3d995e34d342c3a189760875f4bc77 --- ReactCommon/react/renderer/components/view/TouchEvent.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ReactCommon/react/renderer/components/view/TouchEvent.h b/ReactCommon/react/renderer/components/view/TouchEvent.h index 4725fa4eec4d32..02f7ab4e636191 100644 --- a/ReactCommon/react/renderer/components/view/TouchEvent.h +++ b/ReactCommon/react/renderer/components/view/TouchEvent.h @@ -16,8 +16,6 @@ namespace facebook { namespace react { -using Touches = std::unordered_set; - /* * Defines the `touchstart`, `touchend`, `touchmove`, and `touchcancel` event * types. From e28b25cd99c93cd880523b9d6ad83ce0d96daf9f Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 1 Dec 2020 09:20:45 -0800 Subject: [PATCH 0130/1810] Avoid sending NaN as force of Touch Summary: Changelog: [internal] This avoids getting NaN in JS. Paper does it as well. Reviewed By: shergin Differential Revision: D25243147 fbshipit-source-id: 48dd1aa6daa7de23550850bd5d30fc3b20e6828d --- React/Fabric/RCTSurfaceTouchHandler.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index 04e09ddfd5718c..e556a3af6d1d72 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -96,7 +96,7 @@ static void UpdateActiveTouchWithUITouch( activeTouch.touch.timestamp = uiTouch.timestamp; if (RCTForceTouchAvailable()) { - activeTouch.touch.force = uiTouch.force / uiTouch.maximumPossibleForce; + activeTouch.touch.force = RCTZeroIfNaN(uiTouch.force / uiTouch.maximumPossibleForce); } } From ae6f4f308e1dad6c3cdf45a2393426682c543a55 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 1 Dec 2020 09:20:45 -0800 Subject: [PATCH 0131/1810] Align format of touch events with Paper Summary: Changelog: [internal] Touch events should be of a type PressEvent. Fabric only provided touches, changedTouches and targetTouches and leaves out force, identifier, locationX, locationY, pageX, pageY and timestamp. Reviewed By: shergin Differential Revision: D25243347 fbshipit-source-id: e824558bd43f51c0c6dcca62bfc98318aa61678e --- .../components/view/TouchEventEmitter.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp b/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp index 738dec8d6467c7..c02b1c3bcc784e 100644 --- a/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp @@ -12,8 +12,10 @@ namespace react { #pragma mark - Touches -static jsi::Value touchPayload(jsi::Runtime &runtime, Touch const &touch) { - auto object = jsi::Object(runtime); +static void setTouchPayloadOnObject( + jsi::Object &object, + jsi::Runtime &runtime, + Touch const &touch) { object.setProperty(runtime, "locationX", touch.offsetPoint.x); object.setProperty(runtime, "locationY", touch.offsetPoint.y); object.setProperty(runtime, "pageX", touch.pagePoint.x); @@ -24,7 +26,6 @@ static jsi::Value touchPayload(jsi::Runtime &runtime, Touch const &touch) { object.setProperty(runtime, "target", touch.target); object.setProperty(runtime, "timestamp", touch.timestamp * 1000); object.setProperty(runtime, "force", touch.force); - return object; } static jsi::Value touchesPayload( @@ -33,7 +34,9 @@ static jsi::Value touchesPayload( auto array = jsi::Array(runtime, touches.size()); int i = 0; for (auto const &touch : touches) { - array.setValueAtIndex(runtime, i++, touchPayload(runtime, touch)); + auto object = jsi::Object(runtime); + setTouchPayloadOnObject(object, runtime, touch); + array.setValueAtIndex(runtime, i++, object); } return array; } @@ -48,6 +51,11 @@ static jsi::Value touchEventPayload( runtime, "changedTouches", touchesPayload(runtime, event.changedTouches)); object.setProperty( runtime, "targetTouches", touchesPayload(runtime, event.targetTouches)); + + if (!event.changedTouches.empty()) { + auto const &firstChangedTouch = *event.changedTouches.begin(); + setTouchPayloadOnObject(object, runtime, firstChangedTouch); + } return object; } From d435d26d87d69afcaf1d89d8a92f91c84aff2d71 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Tue, 1 Dec 2020 15:00:04 -0800 Subject: [PATCH 0132/1810] Check if result from native UIManager is null before accessing view config Summary: As titled - attempt to mitigate a JS error on iOS while we work on getting JS view configs. It seems like this happens when the bridge is invalid. Changelog: [Fixed][iOS] Don't throw an error if the UIManager returns null when fetching a view config Reviewed By: kacieb Differential Revision: D25247203 fbshipit-source-id: e2003f99b818f9657c60ff95b266be74fe18a94b --- Libraries/ReactNative/PaperUIManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/ReactNative/PaperUIManager.js b/Libraries/ReactNative/PaperUIManager.js index 776fa431e8298c..35f456809da0a7 100644 --- a/Libraries/ReactNative/PaperUIManager.js +++ b/Libraries/ReactNative/PaperUIManager.js @@ -71,7 +71,7 @@ const UIManagerJS = { ) { const result = NativeUIManager.lazilyLoadView(viewManagerName); triedLoadingConfig.add(viewManagerName); - if (result.viewConfig) { + if (result != null && result.viewConfig != null) { getConstants()[viewManagerName] = result.viewConfig; lazifyViewManagerConfig(viewManagerName); } From 1a67dda668c71d961a4bb3b0cdf6aa22c0e5c138 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Tue, 1 Dec 2020 17:15:07 -0800 Subject: [PATCH 0133/1810] Don't minify JS bundle by default when using hermes (#30496) Summary: Minification is not needed for hermes as it does all required optimisations on the bytecode. This is what facebook does internally for hermes bundles and I also validated by comparing the bytecode bundle size on a minified and non-minified bundle. ## Changelog [General] [Changed] - Don't minify JS bundle by default when using hermes Pull Request resolved: https://github.com/facebook/react-native/pull/30496 Test Plan: Verified that the JS bundled generated on Android and iOS when using hermes is not minified by checking the generated JS file manually. Reviewed By: rickhanlonii Differential Revision: D25235195 Pulled By: cpojer fbshipit-source-id: ad2131aab4dfd17ab53b6a5720ed0e2f1b09cca4 --- react.gradle | 17 +++++++++++++---- scripts/react-native-xcode.sh | 7 ++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/react.gradle b/react.gradle index 5a3bf6ba9cb982..04b94aad9ee513 100644 --- a/react.gradle +++ b/react.gradle @@ -159,12 +159,21 @@ afterEvaluate { def devEnabled = !(config."devDisabledIn${targetName}" || targetName.toLowerCase().contains("release")) - def extraArgs = config.extraPackagerArgs ?: []; + def extraArgs = [] if (bundleConfig) { - extraArgs = extraArgs.clone() - extraArgs.add("--config"); - extraArgs.add(bundleConfig); + extraArgs.add("--config") + extraArgs.add(bundleConfig) + } + + // Hermes doesn't require JS minification. + if (enableHermes && !devEnabled) { + extraArgs.add("--minify") + extraArgs.add("false") + } + + if (config.extraPackagerArgs) { + extraArgs.addAll(config.extraPackagerArgs) } commandLine(*execCommand, bundleCommand, "--platform", "android", "--dev", "${devEnabled}", diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 9b059a6597d776..228a5ec885e5cc 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -163,6 +163,11 @@ if [[ $EMIT_SOURCEMAP == true ]]; then EXTRA_ARGS="$EXTRA_ARGS --sourcemap-output $PACKAGER_SOURCEMAP_FILE" fi +# Hermes doesn't require JS minification. +if [[ $USE_HERMES == true && $DEV == false ]]; then + EXTRA_ARGS="$EXTRA_ARGS --minify false" +fi + "$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \ $CONFIG_ARG \ --entry-file "$ENTRY_FILE" \ @@ -187,7 +192,7 @@ else if [[ $EMIT_SOURCEMAP == true ]]; then EXTRA_COMPILER_ARGS="$EXTRA_COMPILER_ARGS -output-source-map" fi - "$HERMES_CLI_PATH" -emit-binary $EXTRA_COMPILER_ARGS -out "$DEST/main.jsbundle" "$BUNDLE_FILE" + "$HERMES_CLI_PATH" -emit-binary $EXTRA_COMPILER_ARGS -out "$DEST/main.jsbundle" "$BUNDLE_FILE" if [[ $EMIT_SOURCEMAP == true ]]; then HBC_SOURCEMAP_FILE="$BUNDLE_FILE.map" "$NODE_BINARY" "$COMPOSE_SOURCEMAP_PATH" "$PACKAGER_SOURCEMAP_FILE" "$HBC_SOURCEMAP_FILE" -o "$SOURCEMAP_FILE" From 6864e5f3ac66ee242607c61f7aadbb2a86c4d80d Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 1 Dec 2020 19:50:55 -0800 Subject: [PATCH 0134/1810] Ship reparenting differ everywhere on iOS and Android Summary: The "reparenting differ" has been the default differ for several months; ship it by removing config and the old differ. Some functions can't be deleted yet because unit testing relies on it heavily; this can be refactored in the future if we care a lot. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25257205 fbshipit-source-id: 6f1dcc490bb1efe3d12506addf5f0843ca48c5c6 --- .../renderer/mounting/Differentiator.cpp | 383 +----------------- .../react/renderer/mounting/Differentiator.h | 17 +- .../renderer/mounting/MountingCoordinator.cpp | 10 +- .../renderer/mounting/MountingCoordinator.h | 5 +- .../react/renderer/mounting/ShadowTree.cpp | 9 +- .../react/renderer/mounting/ShadowTree.h | 12 +- ReactCommon/react/renderer/mounting/stubs.cpp | 4 +- .../renderer/mounting/tests/MountingTest.cpp | 30 +- .../tests/ShadowTreeLifeCycleTest.cpp | 38 +- .../react/renderer/scheduler/Scheduler.cpp | 7 +- .../react/renderer/scheduler/Scheduler.h | 1 - 11 files changed, 53 insertions(+), 463 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/Differentiator.cpp b/ReactCommon/react/renderer/mounting/Differentiator.cpp index 1bf8fe6e40d8fe..eb2fa09a3e863a 100644 --- a/ReactCommon/react/renderer/mounting/Differentiator.cpp +++ b/ReactCommon/react/renderer/mounting/Differentiator.cpp @@ -1442,7 +1442,10 @@ static void calculateShadowViewMutationsV2( std::back_inserter(mutations)); } -static void sliceChildShadowNodeViewPairsRecursively( +/** + * Only used by unit tests currently. + */ +static void sliceChildShadowNodeViewPairsRecursivelyLegacy( ShadowViewNodePair::List &pairList, Point layoutOffset, ShadowNode const &shadowNode) { @@ -1473,13 +1476,16 @@ static void sliceChildShadowNodeViewPairsRecursively( pairList.push_back({shadowView, &childShadowNode}); } - sliceChildShadowNodeViewPairsRecursively( + sliceChildShadowNodeViewPairsRecursivelyLegacy( pairList, origin, childShadowNode); } } } -ShadowViewNodePair::List sliceChildShadowNodeViewPairs( +/** + * Only used by unit tests currently. + */ +ShadowViewNodePair::List sliceChildShadowNodeViewPairsLegacy( ShadowNode const &shadowNode) { auto pairList = ShadowViewNodePair::List{}; @@ -1489,363 +1495,14 @@ ShadowViewNodePair::List sliceChildShadowNodeViewPairs( return pairList; } - sliceChildShadowNodeViewPairsRecursively(pairList, {0, 0}, shadowNode); + sliceChildShadowNodeViewPairsRecursivelyLegacy(pairList, {0, 0}, shadowNode); return pairList; } -static void calculateShadowViewMutations( - ShadowViewMutation::List &mutations, - ShadowView const &parentShadowView, - ShadowViewNodePair::List &&oldChildPairs, - ShadowViewNodePair::List &&newChildPairs) { - if (oldChildPairs.empty() && newChildPairs.empty()) { - return; - } - - // Sorting pairs based on `orderIndex` if needed. - reorderInPlaceIfNeeded(oldChildPairs); - reorderInPlaceIfNeeded(newChildPairs); - - auto index = int{0}; - - // Lists of mutations - auto createMutations = ShadowViewMutation::List{}; - auto deleteMutations = ShadowViewMutation::List{}; - auto insertMutations = ShadowViewMutation::List{}; - auto removeMutations = ShadowViewMutation::List{}; - auto updateMutations = ShadowViewMutation::List{}; - auto downwardMutations = ShadowViewMutation::List{}; - auto destructiveDownwardMutations = ShadowViewMutation::List{}; - - // Stage 1: Collecting `Update` mutations - for (index = 0; index < oldChildPairs.size() && index < newChildPairs.size(); - index++) { - auto const &oldChildPair = oldChildPairs[index]; - auto const &newChildPair = newChildPairs[index]; - - if (oldChildPair.shadowView.tag != newChildPair.shadowView.tag) { - DEBUG_LOGS({ - LOG(ERROR) << "Differ Branch 1.1: Tags Different: [" - << oldChildPair.shadowView.tag << "] [" - << newChildPair.shadowView.tag << "]"; - }); - - // Totally different nodes, updating is impossible. - break; - } - - DEBUG_LOGS({ - LOG(ERROR) << "Differ Branch 1.2: Same tags, update and recurse: [" - << oldChildPair.shadowView.tag << "]" - << (oldChildPair.flattened ? " (flattened)" : "") - << (oldChildPair.isConcreteView ? " (concrete)" : "") << "[" - << newChildPair.shadowView.tag << "]" - << (newChildPair.flattened ? " (flattened)" : "") - << (newChildPair.isConcreteView ? " (concrete)" : ""); - }); - - if (oldChildPair.shadowView != newChildPair.shadowView) { - updateMutations.push_back(ShadowViewMutation::UpdateMutation( - parentShadowView, - oldChildPair.shadowView, - newChildPair.shadowView, - index)); - } - - auto oldGrandChildPairs = - sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode); - auto newGrandChildPairs = - sliceChildShadowNodeViewPairs(*newChildPair.shadowNode); - calculateShadowViewMutations( - *(newGrandChildPairs.size() ? &downwardMutations - : &destructiveDownwardMutations), - oldChildPair.shadowView, - std::move(oldGrandChildPairs), - std::move(newGrandChildPairs)); - } - - size_t lastIndexAfterFirstStage = index; - - if (index == newChildPairs.size()) { - // We've reached the end of the new children. We can delete+remove the - // rest. - for (; index < oldChildPairs.size(); index++) { - auto const &oldChildPair = oldChildPairs[index]; - - DEBUG_LOGS({ - LOG(ERROR) - << "Differ Branch 2: Deleting Tag/Tree (may be reparented): [" - << oldChildPair.shadowView.tag << "]"; - }); - - deleteMutations.push_back( - ShadowViewMutation::DeleteMutation(oldChildPair.shadowView)); - removeMutations.push_back(ShadowViewMutation::RemoveMutation( - parentShadowView, oldChildPair.shadowView, index)); - - // We also have to call the algorithm recursively to clean up the entire - // subtree starting from the removed view. - calculateShadowViewMutations( - destructiveDownwardMutations, - oldChildPair.shadowView, - sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode), - {}); - } - } else if (index == oldChildPairs.size()) { - // If we don't have any more existing children we can choose a fast path - // since the rest will all be create+insert. - for (; index < newChildPairs.size(); index++) { - auto const &newChildPair = newChildPairs[index]; - - DEBUG_LOGS({ - LOG(ERROR) - << "Differ Branch 3: Creating Tag/Tree (may be reparented): [" - << newChildPair.shadowView.tag << "]"; - }); - - insertMutations.push_back(ShadowViewMutation::InsertMutation( - parentShadowView, newChildPair.shadowView, index)); - createMutations.push_back( - ShadowViewMutation::CreateMutation(newChildPair.shadowView)); - - calculateShadowViewMutations( - downwardMutations, - newChildPair.shadowView, - {}, - sliceChildShadowNodeViewPairs(*newChildPair.shadowNode)); - } - } else { - // Collect map of tags in the new list - // In the future it would be nice to use TinyMap for newInsertedPairs, but - // it's challenging to build an iterator that will work for our use-case - // here. - auto newRemainingPairs = TinyMap{}; - auto newInsertedPairs = TinyMap{}; - for (; index < newChildPairs.size(); index++) { - auto const &newChildPair = newChildPairs[index]; - newRemainingPairs.insert({newChildPair.shadowView.tag, &newChildPair}); - } - - // Walk through both lists at the same time - // We will perform updates, create+insert, remove+delete, remove+insert - // (move) here. - size_t oldIndex = lastIndexAfterFirstStage, - newIndex = lastIndexAfterFirstStage, newSize = newChildPairs.size(), - oldSize = oldChildPairs.size(); - while (newIndex < newSize || oldIndex < oldSize) { - bool haveNewPair = newIndex < newSize; - bool haveOldPair = oldIndex < oldSize; - - // Advance both pointers if pointing to the same element - if (haveNewPair && haveOldPair) { - auto const &newChildPair = newChildPairs[newIndex]; - auto const &oldChildPair = oldChildPairs[oldIndex]; - - Tag newTag = newChildPair.shadowView.tag; - Tag oldTag = oldChildPair.shadowView.tag; - - if (newTag == oldTag) { - DEBUG_LOGS({ - LOG(ERROR) << "Differ Branch 5: Matched Tags at indices: " - << oldIndex << " " << newIndex << ": [" - << oldChildPair.shadowView.tag << "][" - << newChildPair.shadowView.tag << "]"; - }); - - // Generate Update instructions - if (oldChildPair.shadowView != newChildPair.shadowView) { - updateMutations.push_back(ShadowViewMutation::UpdateMutation( - parentShadowView, - oldChildPair.shadowView, - newChildPair.shadowView, - index)); - } - - // Remove from newRemainingPairs - auto newRemainingPairIt = newRemainingPairs.find(oldTag); - if (newRemainingPairIt != newRemainingPairs.end()) { - newRemainingPairs.erase(newRemainingPairIt); - } - - // Update subtrees - if (oldChildPair.shadowNode != newChildPair.shadowNode) { - auto oldGrandChildPairs = - sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode); - auto newGrandChildPairs = - sliceChildShadowNodeViewPairs(*newChildPair.shadowNode); - calculateShadowViewMutations( - *(newGrandChildPairs.size() ? &downwardMutations - : &destructiveDownwardMutations), - oldChildPair.shadowView, - std::move(oldGrandChildPairs), - std::move(newGrandChildPairs)); - } - - newIndex++; - oldIndex++; - continue; - } - } - - if (haveOldPair) { - auto const &oldChildPair = oldChildPairs[oldIndex]; - Tag oldTag = oldChildPair.shadowView.tag; - - // Was oldTag already inserted? This indicates a reordering, not just - // a move. The new node has already been inserted, we just need to - // remove the node from its old position now. - auto const insertedIt = newInsertedPairs.find(oldTag); - if (insertedIt != newInsertedPairs.end()) { - DEBUG_LOGS({ - LOG(ERROR) - << "Differ Branch 6: Removing tag that was already inserted: " - << oldIndex << ": [" << oldChildPair.shadowView.tag << "]"; - }); - - removeMutations.push_back(ShadowViewMutation::RemoveMutation( - parentShadowView, oldChildPair.shadowView, oldIndex)); - - // Generate update instruction since we have an iterator ref to the - // new node - auto const &newChildPair = *insertedIt->second; - if (oldChildPair.shadowView != newChildPair.shadowView) { - updateMutations.push_back(ShadowViewMutation::UpdateMutation( - parentShadowView, - oldChildPair.shadowView, - newChildPair.shadowView, - index)); - } - - // Update subtrees - if (oldChildPair.shadowNode != newChildPair.shadowNode) { - auto oldGrandChildPairs = - sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode); - auto newGrandChildPairs = - sliceChildShadowNodeViewPairs(*newChildPair.shadowNode); - calculateShadowViewMutations( - *(newGrandChildPairs.size() ? &downwardMutations - : &destructiveDownwardMutations), - oldChildPair.shadowView, - std::move(oldGrandChildPairs), - std::move(newGrandChildPairs)); - } - - newInsertedPairs.erase(insertedIt); - oldIndex++; - continue; - } - - // Should we generate a delete+remove instruction for the old node? - // If there's an old node and it's not found in the "new" list, we - // generate remove+delete for this node and its subtree. - auto const newIt = newRemainingPairs.find(oldTag); - if (newIt == newRemainingPairs.end()) { - DEBUG_LOGS({ - LOG(ERROR) - << "Differ Branch 8: Removing tag/tree that was not reinserted (may be reparented): " - << oldIndex << ": [" << oldChildPair.shadowView.tag << "]"; - }); - - removeMutations.push_back(ShadowViewMutation::RemoveMutation( - parentShadowView, oldChildPair.shadowView, oldIndex)); - - deleteMutations.push_back( - ShadowViewMutation::DeleteMutation(oldChildPair.shadowView)); - - // We also have to call the algorithm recursively to clean up the - // entire subtree starting from the removed view. - calculateShadowViewMutations( - destructiveDownwardMutations, - oldChildPair.shadowView, - sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode), - {}); - - oldIndex++; - continue; - } - } - - // At this point, oldTag is -1 or is in the new list, and hasn't been - // inserted or matched yet. We're not sure yet if the new node is in the - // old list - generate an insert instruction for the new node. - auto const &newChildPair = newChildPairs[newIndex]; - DEBUG_LOGS({ - LOG(ERROR) - << "Differ Branch 9: Inserting tag/tree that was not yet removed from hierarchy (may be reparented): " - << newIndex << ": [" << newChildPair.shadowView.tag << "]"; - }); - insertMutations.push_back(ShadowViewMutation::InsertMutation( - parentShadowView, newChildPair.shadowView, newIndex)); - newInsertedPairs.insert({newChildPair.shadowView.tag, &newChildPair}); - newIndex++; - } - - // Final step: generate Create instructions for new nodes - for (auto it = newInsertedPairs.begin(); it != newInsertedPairs.end(); - it++) { - // Erased elements of a TinyMap will have a Tag/key of 0 - skip those - // These *should* be removed by the map; there are currently no KNOWN - // cases where TinyMap will do the wrong thing, but there are not yet - // any unit tests explicitly for TinyMap, so this is safer for now. - if (it->first == 0) { - continue; - } - - auto const &newChildPair = *it->second; - - DEBUG_LOGS({ - LOG(ERROR) - << "Differ Branch 9: Inserting tag/tree that was not yet removed from hierarchy (may be reparented): " - << newIndex << ": [" << newChildPair.shadowView.tag << "]"; - }); - - createMutations.push_back( - ShadowViewMutation::CreateMutation(newChildPair.shadowView)); - - calculateShadowViewMutations( - downwardMutations, - newChildPair.shadowView, - {}, - sliceChildShadowNodeViewPairs(*newChildPair.shadowNode)); - } - } - - // All mutations in an optimal order: - std::move( - destructiveDownwardMutations.begin(), - destructiveDownwardMutations.end(), - std::back_inserter(mutations)); - std::move( - updateMutations.begin(), - updateMutations.end(), - std::back_inserter(mutations)); - std::move( - removeMutations.rbegin(), - removeMutations.rend(), - std::back_inserter(mutations)); - std::move( - deleteMutations.begin(), - deleteMutations.end(), - std::back_inserter(mutations)); - std::move( - createMutations.begin(), - createMutations.end(), - std::back_inserter(mutations)); - std::move( - downwardMutations.begin(), - downwardMutations.end(), - std::back_inserter(mutations)); - std::move( - insertMutations.begin(), - insertMutations.end(), - std::back_inserter(mutations)); -} - ShadowViewMutation::List calculateShadowViewMutations( ShadowNode const &oldRootShadowNode, - ShadowNode const &newRootShadowNode, - bool enableReparentingDetection) { + ShadowNode const &newRootShadowNode) { SystraceSection s("calculateShadowViewMutations"); // Root shadow nodes must be belong the same family. @@ -1862,19 +1519,11 @@ ShadowViewMutation::List calculateShadowViewMutations( ShadowView(), oldRootShadowView, newRootShadowView, -1)); } - if (enableReparentingDetection) { - calculateShadowViewMutationsV2( - mutations, - ShadowView(oldRootShadowNode), - sliceChildShadowNodeViewPairsV2(oldRootShadowNode), - sliceChildShadowNodeViewPairsV2(newRootShadowNode)); - } else { - calculateShadowViewMutations( - mutations, - ShadowView(oldRootShadowNode), - sliceChildShadowNodeViewPairs(oldRootShadowNode), - sliceChildShadowNodeViewPairs(newRootShadowNode)); - } + calculateShadowViewMutationsV2( + mutations, + ShadowView(oldRootShadowNode), + sliceChildShadowNodeViewPairsV2(oldRootShadowNode), + sliceChildShadowNodeViewPairsV2(newRootShadowNode)); return mutations; } diff --git a/ReactCommon/react/renderer/mounting/Differentiator.h b/ReactCommon/react/renderer/mounting/Differentiator.h index 762bb43ae6bedd..15ba37f4088696 100644 --- a/ReactCommon/react/renderer/mounting/Differentiator.h +++ b/ReactCommon/react/renderer/mounting/Differentiator.h @@ -22,15 +22,7 @@ enum class ReparentMode { Flatten, Unflatten }; */ ShadowViewMutationList calculateShadowViewMutations( ShadowNode const &oldRootShadowNode, - ShadowNode const &newRootShadowNode, - bool enableReparentingDetection = false); - -/* - * Generates a list of `ShadowViewNodePair`s that represents a layer of a - * flattened view hierarchy. - */ -ShadowViewNodePair::List sliceChildShadowNodeViewPairs( - ShadowNode const &shadowNode); + ShadowNode const &newRootShadowNode); /** * Generates a list of `ShadowViewNodePair`s that represents a layer of a @@ -41,5 +33,12 @@ ShadowViewNodePair::List sliceChildShadowNodeViewPairsV2( ShadowNode const &shadowNode, bool allowFlattened = false); +/* + * Generates a list of `ShadowViewNodePair`s that represents a layer of a + * flattened view hierarchy. This is *only* used by unit tests currently. + */ +ShadowViewNodePair::List sliceChildShadowNodeViewPairsLegacy( + ShadowNode const &shadowNode); + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 2c9af008a80447..8fc0ae83833350 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -21,13 +21,11 @@ namespace react { MountingCoordinator::MountingCoordinator( ShadowTreeRevision baseRevision, - std::weak_ptr delegate, - bool enableReparentingDetection) + std::weak_ptr delegate) : surfaceId_(baseRevision.rootShadowNode->getSurfaceId()), baseRevision_(baseRevision), mountingOverrideDelegate_(delegate), - telemetryController_(*this), - enableReparentingDetection_(enableReparentingDetection) { + telemetryController_(*this) { #ifdef RN_SHADOW_TREE_INTROSPECTION stubViewTree_ = stubViewTreeFromShadowNode(*baseRevision_.rootShadowNode); #endif @@ -93,9 +91,7 @@ better::optional MountingCoordinator::pullTransaction() telemetry.willDiff(); auto mutations = calculateShadowViewMutations( - *baseRevision_.rootShadowNode, - *lastRevision_->rootShadowNode, - enableReparentingDetection_); + *baseRevision_.rootShadowNode, *lastRevision_->rootShadowNode); telemetry.didDiff(); diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.h b/ReactCommon/react/renderer/mounting/MountingCoordinator.h index 4563dc7bd0aa5c..8d9aace9a8627c 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.h +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.h @@ -45,8 +45,7 @@ class MountingCoordinator final { */ MountingCoordinator( ShadowTreeRevision baseRevision, - std::weak_ptr delegate, - bool enableReparentingDetection = false); + std::weak_ptr delegate); /* * Returns the id of the surface that the coordinator belongs to. @@ -114,8 +113,6 @@ class MountingCoordinator final { TelemetryController telemetryController_; - bool enableReparentingDetection_{false}; // temporary - #ifdef RN_SHADOW_TREE_INTROSPECTION mutable StubViewTree stubViewTree_; // Protected by `mutex_`. #endif diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index 0cd895fc627b0f..e87ac12704f18a 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -223,11 +223,8 @@ ShadowTree::ShadowTree( LayoutContext const &layoutContext, RootComponentDescriptor const &rootComponentDescriptor, ShadowTreeDelegate const &delegate, - std::weak_ptr mountingOverrideDelegate, - bool enableReparentingDetection) - : surfaceId_(surfaceId), - delegate_(delegate), - enableReparentingDetection_(enableReparentingDetection) { + std::weak_ptr mountingOverrideDelegate) + : surfaceId_(surfaceId), delegate_(delegate) { const auto noopEventEmitter = std::make_shared( nullptr, -1, std::shared_ptr()); @@ -249,7 +246,7 @@ ShadowTree::ShadowTree( rootShadowNode, ShadowTreeRevision::Number{0}, TransactionTelemetry{}}; mountingCoordinator_ = std::make_shared( - currentRevision_, mountingOverrideDelegate, enableReparentingDetection); + currentRevision_, mountingOverrideDelegate); } ShadowTree::~ShadowTree() { diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.h b/ReactCommon/react/renderer/mounting/ShadowTree.h index 5d208f76aaa705..9f01e01da4a660 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -53,8 +53,7 @@ class ShadowTree final { LayoutContext const &layoutContext, RootComponentDescriptor const &rootComponentDescriptor, ShadowTreeDelegate const &delegate, - std::weak_ptr mountingOverrideDelegate, - bool enableReparentingDetection = false); + std::weak_ptr mountingOverrideDelegate); ~ShadowTree(); @@ -99,14 +98,6 @@ class ShadowTree final { MountingCoordinator::Shared getMountingCoordinator() const; - /* - * Temporary. - * Do not use. - */ - void setEnableReparentingDetection(bool value) { - enableReparentingDetection_ = value; - } - private: void emitLayoutEvents( std::vector &affectedLayoutableNodes) const; @@ -116,7 +107,6 @@ class ShadowTree final { mutable better::shared_mutex commitMutex_; mutable ShadowTreeRevision currentRevision_; // Protected by `commitMutex_`. MountingCoordinator::Shared mountingCoordinator_; - bool enableReparentingDetection_{false}; }; } // namespace react diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index 370989a21a8d7a..f85cf17a90b925 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -33,7 +33,7 @@ static void calculateShadowViewMutationsForNewTree( parentShadowView, newChildPair.shadowView, index)); auto const newGrandChildPairs = - sliceChildShadowNodeViewPairs(*newChildPair.shadowNode); + sliceChildShadowNodeViewPairsLegacy(*newChildPair.shadowNode); calculateShadowViewMutationsForNewTree( mutations, newChildPair.shadowView, newGrandChildPairs); @@ -47,7 +47,7 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { calculateShadowViewMutationsForNewTree( mutations, ShadowView(rootShadowNode), - sliceChildShadowNodeViewPairs(rootShadowNode)); + sliceChildShadowNodeViewPairsLegacy(rootShadowNode)); auto emptyRootShadowNode = rootShadowNode.clone( ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(), diff --git a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp index 172134fa39c5e6..4a01adc6b99ce9 100644 --- a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp @@ -240,8 +240,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) { }*/ // Calculating mutations. - auto mutations1 = - calculateShadowViewMutations(*rootNodeV1, *rootNodeV2, false); + auto mutations1 = calculateShadowViewMutations(*rootNodeV1, *rootNodeV2); // The order and exact mutation instructions here may change at any time. // This test just ensures that any changes are intentional. @@ -257,8 +256,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) { EXPECT_TRUE(mutations1[1].index == 0); // Calculating mutations. - auto mutations2 = - calculateShadowViewMutations(*rootNodeV2, *rootNodeV3, false); + auto mutations2 = calculateShadowViewMutations(*rootNodeV2, *rootNodeV3); // The order and exact mutation instructions here may change at any time. // This test just ensures that any changes are intentional. @@ -274,8 +272,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) { EXPECT_TRUE(mutations2[1].oldChildShadowView.tag == 100); // Calculating mutations. - auto mutations3 = - calculateShadowViewMutations(*rootNodeV3, *rootNodeV4, false); + auto mutations3 = calculateShadowViewMutations(*rootNodeV3, *rootNodeV4); LOG(ERROR) << "Num mutations IN OLD TEST mutations3: " << mutations3.size(); // The order and exact mutation instructions here may change at any time. @@ -297,8 +294,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) { EXPECT_TRUE(mutations3[3].index == 2); // Calculating mutations. - auto mutations4 = - calculateShadowViewMutations(*rootNodeV4, *rootNodeV5, false); + auto mutations4 = calculateShadowViewMutations(*rootNodeV4, *rootNodeV5); // The order and exact mutation instructions here may change at any time. // This test just ensures that any changes are intentional. @@ -323,8 +319,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) { EXPECT_TRUE(mutations4[5].newChildShadowView.tag == 102); EXPECT_TRUE(mutations4[5].index == 3); - auto mutations5 = - calculateShadowViewMutations(*rootNodeV5, *rootNodeV6, false); + auto mutations5 = calculateShadowViewMutations(*rootNodeV5, *rootNodeV6); // The order and exact mutation instructions here may change at any time. // This test just ensures that any changes are intentional. @@ -343,8 +338,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) { EXPECT_TRUE(mutations5[3].newChildShadowView.tag == 105); EXPECT_TRUE(mutations5[3].index == 3); - auto mutations6 = - calculateShadowViewMutations(*rootNodeV6, *rootNodeV7, false); + auto mutations6 = calculateShadowViewMutations(*rootNodeV6, *rootNodeV7); // The order and exact mutation instructions here may change at any time. // This test just ensures that any changes are intentional. @@ -598,8 +592,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) { rootNodeV5->sealRecursive(); // Calculating mutations. - auto mutations1 = - calculateShadowViewMutations(*rootNodeV1, *rootNodeV2, true); + auto mutations1 = calculateShadowViewMutations(*rootNodeV1, *rootNodeV2); EXPECT_EQ(mutations1.size(), 5); EXPECT_EQ(mutations1[0].type, ShadowViewMutation::Update); @@ -613,8 +606,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) { EXPECT_EQ(mutations1[4].type, ShadowViewMutation::Insert); EXPECT_EQ(mutations1[4].newChildShadowView.tag, 1000); - auto mutations2 = - calculateShadowViewMutations(*rootNodeV2, *rootNodeV3, true); + auto mutations2 = calculateShadowViewMutations(*rootNodeV2, *rootNodeV3); EXPECT_EQ(mutations2.size(), 5); EXPECT_EQ(mutations2[0].type, ShadowViewMutation::Update); @@ -630,8 +622,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) { EXPECT_EQ(mutations2[4].type, ShadowViewMutation::Insert); EXPECT_EQ(mutations2[4].newChildShadowView.tag, 1000); - auto mutations3 = - calculateShadowViewMutations(*rootNodeV3, *rootNodeV4, true); + auto mutations3 = calculateShadowViewMutations(*rootNodeV3, *rootNodeV4); // between these two trees, lots of new nodes are created and inserted - this // is all correct, and this is the minimal amount of mutations @@ -668,8 +659,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) { EXPECT_EQ(mutations3[14].type, ShadowViewMutation::Insert); EXPECT_EQ(mutations3[14].newChildShadowView.tag, 1000); - auto mutations4 = - calculateShadowViewMutations(*rootNodeV4, *rootNodeV5, true); + auto mutations4 = calculateShadowViewMutations(*rootNodeV4, *rootNodeV5); EXPECT_EQ(mutations4.size(), 9); EXPECT_EQ(mutations4[0].type, ShadowViewMutation::Update); diff --git a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index 1ecfd21a69b670..df6c63722fcb18 100644 --- a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -26,8 +26,7 @@ static void testShadowNodeTreeLifeCycle( uint_fast32_t seed, int treeSize, int repeats, - int stages, - bool useFlattener) { + int stages) { auto entropy = seed == 0 ? Entropy() : Entropy(seed); auto eventDispatcher = EventDispatcher::Shared{}; @@ -102,12 +101,12 @@ static void testShadowNodeTreeLifeCycle( allNodes.push_back(nextRootNode); // Calculating mutations. - auto mutations = calculateShadowViewMutations( - *currentRootNode, *nextRootNode, useFlattener); + auto mutations = + calculateShadowViewMutations(*currentRootNode, *nextRootNode); - // If using flattener: make sure that in a single frame, a DELETE for a + // Make sure that in a single frame, a DELETE for a // view is not followed by a CREATE for the same view. - if (useFlattener) { + { std::vector deletedTags{}; for (auto const &mutation : mutations) { if (mutation.type == ShadowViewMutation::Type::Delete) { @@ -174,31 +173,12 @@ static void testShadowNodeTreeLifeCycle( using namespace facebook::react; -TEST(MountingTest, stableBiggerTreeFewerIterationsOptimizedMoves) { - testShadowNodeTreeLifeCycle( - /* seed */ 0, - /* size */ 512, - /* repeats */ 32, - /* stages */ 32, - false); -} - -TEST(MountingTest, stableSmallerTreeMoreIterationsOptimizedMoves) { - testShadowNodeTreeLifeCycle( - /* seed */ 0, - /* size */ 16, - /* repeats */ 512, - /* stages */ 32, - false); -} - TEST(MountingTest, stableBiggerTreeFewerIterationsOptimizedMovesFlattener) { testShadowNodeTreeLifeCycle( /* seed */ 0, /* size */ 512, /* repeats */ 32, - /* stages */ 32, - true); + /* stages */ 32); } TEST(MountingTest, stableBiggerTreeFewerIterationsOptimizedMovesFlattener2) { @@ -206,8 +186,7 @@ TEST(MountingTest, stableBiggerTreeFewerIterationsOptimizedMovesFlattener2) { /* seed */ 1, /* size */ 512, /* repeats */ 32, - /* stages */ 32, - true); + /* stages */ 32); } TEST(MountingTest, stableSmallerTreeMoreIterationsOptimizedMovesFlattener) { @@ -215,6 +194,5 @@ TEST(MountingTest, stableSmallerTreeMoreIterationsOptimizedMovesFlattener) { /* seed */ 0, /* size */ 16, /* repeats */ 512, - /* stages */ 32, - true); + /* stages */ 32); } diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 1e8ab5f50c5b11..9fe70284e2f309 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -107,16 +107,12 @@ Scheduler::Scheduler( uiManager_->setAnimationDelegate(animationDelegate); #ifdef ANDROID - enableReparentingDetection_ = reactNativeConfig_->getBool( - "react_fabric:enable_reparenting_detection_android"); removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( "react_fabric:remove_outstanding_surfaces_on_destruction_android"); uiManager_->experimentEnableStateUpdateWithAutorepeat = reactNativeConfig_->getBool( "react_fabric:enable_state_update_with_autorepeat_android"); #else - enableReparentingDetection_ = reactNativeConfig_->getBool( - "react_fabric:enable_reparenting_detection_ios"); removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( "react_fabric:remove_outstanding_surfaces_on_destruction_ios"); uiManager_->experimentEnableStateUpdateWithAutorepeat = @@ -192,8 +188,7 @@ void Scheduler::startSurface( layoutContext, *rootComponentDescriptor_, *uiManager_, - mountingOverrideDelegate, - enableReparentingDetection_); + mountingOverrideDelegate); auto uiManager = uiManager_; diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 3b5693cb724093..4cdb652b64bbaa 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -137,7 +137,6 @@ class Scheduler final : public UIManagerDelegate { /* * Temporary flags. */ - bool enableReparentingDetection_{false}; bool removeOutstandingSurfacesOnDestruction_{false}; }; From 067d2eee033561b3455f10b40af629c6056124b2 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 1 Dec 2020 19:50:55 -0800 Subject: [PATCH 0135/1810] Remove `enableDrawMutationFix` feature flag and ship it Summary: This was added to prevent mutating the UI during draw or measure, and appears to have been effective. Keep the comments, ship the feature, remove flags. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25258409 fbshipit-source-id: 36ad8a03d1eb82bc9dcd769372c03f1ebe8b8da8 --- .../com/facebook/react/config/ReactFeatureFlags.java | 3 --- .../com/facebook/react/fabric/FabricUIManager.java | 12 +++++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index d972c83330ed70..58ffe7db73a844 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -86,9 +86,6 @@ public class ReactFeatureFlags { /** Disable customDrawOrder in ReactViewGroup under Fabric only. */ public static boolean disableCustomDrawOrderFabric = false; - /** Potential bugfix for crashes caused by mutating the view hierarchy during onDraw. */ - public static boolean enableDrawMutationFix = true; - /** Use lock-free data structures for Fabric MountItems. */ public static boolean enableLockFreeMountInstructions = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 76ab25a54633dc..b8d3dc7e60976a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -586,11 +586,11 @@ public void synchronouslyUpdateViewOnUIThread( int commitNumber = mCurrentSynchronousCommitNumber++; - // We are on the UI thread so this would otherwise be safe to call, *BUT* we don't know - // where we are on the callstack. Why isn't this safe, and why do we have additional safeguards - // here? + // We are on the UI thread so it would otherwise be safe to call `tryDispatchMountItems` here to + // flush previously-queued mountitems, *BUT* we don't know where we are on the callstack. + // Why isn't it safe, and why do we have additional safeguards here? // - // A tangible example where this will cause a crash: + // A tangible example where it would cause a crash, and did in the past: // 1. There are queued "delete" mutations // 2. We're called by this stack trace: // FabricUIManager.synchronouslyUpdateViewOnUIThread(FabricUIManager.java:574) @@ -607,9 +607,7 @@ public void synchronouslyUpdateViewOnUIThread( // android.widget.ScrollView.overScrollBy(ScrollView.java:2040) // android.widget.ScrollView.computeScroll(ScrollView.java:1481) // android.view.View.updateDisplayListIfDirty(View.java:20466) - if (!ReactFeatureFlags.enableDrawMutationFix) { - tryDispatchMountItems(); - } + // 3. A view is deleted while its parent is being drawn, causing a crash. MountItem synchronousMountItem = new MountItem() { From 328590d2d942b281982ab47b6ddab81297ff793f Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Wed, 2 Dec 2020 08:57:48 -0800 Subject: [PATCH 0136/1810] Added examples for SectionList (#30390) Summary: `Added examples for the following missing props in SectionList` * Prop: initialNumToRender * Prop: ListEmptyComponent * Prop: onEndReached **Motivation** - Missing examples for these props in the RNTester app ## Changelog [General] [Added] - `Added examples for the missing props in SectionList` Pull Request resolved: https://github.com/facebook/react-native/pull/30390 Test Plan: ![empty](https://user-images.githubusercontent.com/26821140/99139935-49667000-2663-11eb-8b89-5a6b17abc3e9.png) ![end](https://user-images.githubusercontent.com/26821140/99139944-4e2b2400-2663-11eb-8e95-08e863614dec.png) Reviewed By: cpojer Differential Revision: D25245322 Pulled By: rickhanlonii fbshipit-source-id: 3e44b9cf86128f1d3df535799519631cf2296a7e --- .../js/examples/SectionList/SectionListExample.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionListExample.js index b00cc81c71e1fa..239372b574995f 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionListExample.js @@ -67,6 +67,12 @@ const CustomSeparatorComponent = ({highlighted, text}) => ( ); +const EmptySectionList = () => ( + + This is rendered when the list is empty + +); + class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { state: | any @@ -174,6 +180,15 @@ class SectionListExample extends React.PureComponent<{...}, $FlowFixMeState> { renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter} stickySectionHeadersEnabled + initialNumToRender={10} + ListEmptyComponent={EmptySectionList} + onEndReached={() => + Alert.alert( + 'onEndReached called', + 'You have reached the end of this list', + ) + } + onEndReachedThreshold={0} sections={[ { key: 'empty section', From a4a517a09d78ae1f9b11c8efb8dff186ec126f95 Mon Sep 17 00:00:00 2001 From: Su Min Kim Date: Wed, 2 Dec 2020 08:59:57 -0800 Subject: [PATCH 0137/1810] Add example for focus and blur events to AppStateExample (#30381) Summary: Added an example to test focus and blur events in AppState (Android only) ## Changelog [Android] [Added] - Add example for focus and blur events to AppStateExample Pull Request resolved: https://github.com/facebook/react-native/pull/30381 Test Plan: ![Example](http://g.recordit.co/6FGnSzKQaG.gif) Reviewed By: cpojer Differential Revision: D25245334 Pulled By: rickhanlonii fbshipit-source-id: 916f18a74140cc43e0d513eb4073cbcc44e41427 --- .../js/examples/AppState/AppStateExample.js | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/rn-tester/js/examples/AppState/AppStateExample.js b/packages/rn-tester/js/examples/AppState/AppStateExample.js index 54d83415780212..ebdfa0e4281cee 100644 --- a/packages/rn-tester/js/examples/AppState/AppStateExample.js +++ b/packages/rn-tester/js/examples/AppState/AppStateExample.js @@ -12,7 +12,7 @@ const React = require('react'); -const {AppState, Text, View} = require('react-native'); +const {AppState, Text, View, Platform} = require('react-native'); class AppStateSubscription extends React.Component< $FlowFixMeProps, @@ -22,22 +22,43 @@ class AppStateSubscription extends React.Component< appState: AppState.currentState, previousAppStates: [], memoryWarnings: 0, + eventsDetected: [], }; componentDidMount() { AppState.addEventListener('change', this._handleAppStateChange); AppState.addEventListener('memoryWarning', this._handleMemoryWarning); + if (Platform.OS === 'android') { + AppState.addEventListener('focus', this._handleFocus); + AppState.addEventListener('blur', this._handleBlur); + } } componentWillUnmount() { AppState.removeEventListener('change', this._handleAppStateChange); AppState.removeEventListener('memoryWarning', this._handleMemoryWarning); + if (Platform.OS === 'android') { + AppState.removeEventListener('focus', this._handleFocus); + AppState.removeEventListener('blur', this._handleBlur); + } } _handleMemoryWarning = () => { this.setState({memoryWarnings: this.state.memoryWarnings + 1}); }; + _handleBlur = () => { + const eventsDetected = this.state.eventsDetected.slice(); + eventsDetected.push('blur'); + this.setState({eventsDetected}); + }; + + _handleFocus = () => { + const eventsDetected = this.state.eventsDetected.slice(); + eventsDetected.push('focus'); + this.setState({eventsDetected}); + }; + _handleAppStateChange = appState => { const previousAppStates = this.state.previousAppStates.slice(); previousAppStates.push(this.state.appState); @@ -62,6 +83,13 @@ class AppStateSubscription extends React.Component< ); } + if (this.props.detectEvents) { + return ( + + {JSON.stringify(this.state.eventsDetected)} + + ); + } return ( {JSON.stringify(this.state.previousAppStates)} @@ -105,4 +133,13 @@ exports.examples = [ return ; }, }, + { + platform: 'android', + title: 'Focus/Blur Events', + description: + 'In the Android simulator, toggle the notification drawer to fire events.', + render(): React.Element { + return ; + }, + }, ]; From c901c1fbce080c6e9b6ed56dbccaa7f2fa0571b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 2 Dec 2020 14:25:46 -0800 Subject: [PATCH 0138/1810] Integrate Native Module codegen into Xcode build pipeline (#30449) Summary: Move the codegen invocation out of Podfiles and into the FBReactNativeSpec Pod itself. With this change, developers do not need to modify their existing project's Podfiles, and yet the codegen will be integrated into their projects automatically by way of the FBReactNativeSpec Pod. This is accomplished in part by injecting a script build phase into the Pods Xcode project that is generated by CocoaPods. The build phase will save the output of the codegen script to a log in the derived files directory. The codegen will be executed if the codegen log file is not present, or if the contents of the Libraries directory has changed. The codegen will thus be invoked in these situations: **RNTester:** * When `packages/rn-tester/RNTesterPods.xcworkspace` is built, if the codegen output logfile is not present or if the input files have changed. **OSS React Native apps:** * When `ios/AwesomeProject.xcworkspace` is built, if the codegen output file is not present or if the input files have changed. Normally, this should not happen, as we do not expect folks to update the contents of `node_modules/react-native/Libraries`. Pull Request resolved: https://github.com/facebook/react-native/pull/30449 Changelog: [Internal] - Moved codegen invocation out of Podfile and into FBReactNativeSpec Pod Reviewed By: fkgozali Differential Revision: D25138896 fbshipit-source-id: 4779f822459cea2c30fd544eee19a49e8d80153d --- .gitignore | 1 - .../FBReactNativeSpec.podspec | 18 +++++ package.json | 1 + packages/rn-tester/Podfile | 10 --- packages/rn-tester/Podfile.lock | 18 ++--- scripts/generate-native-modules-specs.sh | 78 +++++++++++++------ scripts/react_native_pods.rb | 18 ----- template/ios/Podfile | 4 - 8 files changed, 84 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index 272b9bbfba849b..7dd758b61058ae 100644 --- a/.gitignore +++ b/.gitignore @@ -103,7 +103,6 @@ package-lock.json /Libraries/FBReactNativeSpec/FBReactNativeSpec /packages/react-native-codegen/lib /ReactCommon/fabric/components/rncore/ -/schema-native-modules.json /schema-rncore.json # Visual studio diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec index de5e03607754d2..d02b4c9b84aca5 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -9,13 +9,22 @@ package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) version = package['version'] source = { :git => 'https://github.com/facebook/react-native.git' } +codegen_path_prefix = ".." if version == '1000.0.0' # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. source[:commit] = `git rev-parse HEAD`.strip + codegen_path_prefix = "packages" else source[:tag] = "v#{version}" end +react_native_path = File.join(__dir__, "..", "..") +srcs_dir = File.join(__dir__, "..") +codegen_script_path = File.join(react_native_path, "scripts", "generate-native-modules-specs.sh") +codegen_path = File.join(react_native_path, codegen_path_prefix, "react-native-codegen") +generated_files = [File.join(__dir__, "FBReactNativeSpec", "FBReactNativeSpec.h"), File.join(__dir__, "FBReactNativeSpec", "FBReactNativeSpec-generated.mm")] +codegen_command = "CODEGEN_PATH=#{codegen_path} sh '#{codegen_script_path}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"" + folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' folly_version = '2020.01.13.00' @@ -44,4 +53,13 @@ Pod::Spec.new do |s| s.dependency "React-Core", version s.dependency "React-jsi", version s.dependency "ReactCommon/turbomodule/core", version + + s.prepare_command = "touch #{generated_files.reduce() { |str, file| str + " " + file }}" + s.script_phase = { + :name => 'Generate Native Modules Code', + :input_files => [srcs_dir], + :output_files => ["$(DERIVED_FILE_DIR)/FBReactNativeSpec-codegen.log"], + :script => codegen_command, + :execution_position => :before_compile + } end diff --git a/package.json b/package.json index 2a1a84cfd1d77c..42df7b41226dd5 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "README.md", "rn-get-polyfills.js", "scripts/compose-source-maps.js", + "scripts/generate-native-modules-specs.sh", "scripts/generate-native-modules-specs-cli.js", "scripts/ios-configure-glog.sh", "scripts/launchPackager.bat", diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index e939c4f2f0b7a8..efc5c339ad5b98 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -60,16 +60,6 @@ def frameworks_pre_install(installer) end end -pre_install do |installer| - frameworks_pre_install(installer) if ENV['USE_FRAMEWORKS'] == '1' - if ENV['USE_CODEGEN'] != '0' - prefix_path = "../.." - codegen_path = "../../packages/react-native-codegen" - system("./#{codegen_path}/scripts/oss/build.sh") or raise "Could not build react-native-codegen package" - codegen_pre_install(installer, {path:prefix_path, codegen_path:codegen_path}) - end -end - post_install do |installer| flipper_post_install(installer) end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 6ba9855fd1872b..57bce624639667 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -15,12 +15,12 @@ PODS: - Flipper-Folly (~> 2.2) - Flipper-RSocket (~> 1.1) - Flipper-DoubleConversion (1.1.7) - - Flipper-Folly (2.2.0): + - Flipper-Folly (2.3.0): - boost-for-react-native - CocoaLibEvent (~> 1.0) - Flipper-DoubleConversion - Flipper-Glog - - OpenSSL-Universal (= 1.0.2.19) + - OpenSSL-Universal (= 1.0.2.20) - Flipper-Glog (0.3.6) - Flipper-PeerTalk (0.0.4) - Flipper-RSocket (1.1.0): @@ -58,9 +58,9 @@ PODS: - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - glog (0.3.5) - - OpenSSL-Universal (1.0.2.19): - - OpenSSL-Universal/Static (= 1.0.2.19) - - OpenSSL-Universal/Static (1.0.2.19) + - OpenSSL-Universal (1.0.2.20): + - OpenSSL-Universal/Static (= 1.0.2.20) + - OpenSSL-Universal/Static (1.0.2.20) - RCT-Folly (2020.01.13.00): - boost-for-react-native - DoubleConversion @@ -490,16 +490,16 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 20a9345af9157362b51ab0258d842cb7bb347d19 + FBReactNativeSpec: 4b0a53603445208c324b4a23d77590c399894efc Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 - Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3 + Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7 FlipperKit: ab353d41aea8aae2ea6daaf813e67496642f3d7d glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 - OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 + OpenSSL-Universal: ff34003318d5e1163e9529b08470708e389ffcdd RCT-Folly: b39288cedafe50da43317ec7d91bcc8cc0abbf33 RCTRequired: d3d4ce60e1e2282864d7560340690a3c8c646de1 RCTTypeSafety: 4da4f9f218727257c50fd3bf2683a06cdb4fede3 @@ -528,6 +528,6 @@ SPEC CHECKSUMS: Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: cd671238f92c51cd349a1c778fd089994174b101 +PODFILE CHECKSUM: 3adfe268d800503789170d1862bde422ee204fe8 COCOAPODS: 1.10.0 diff --git a/scripts/generate-native-modules-specs.sh b/scripts/generate-native-modules-specs.sh index 5edfa3e421e14d..d667c46901fe99 100755 --- a/scripts/generate-native-modules-specs.sh +++ b/scripts/generate-native-modules-specs.sh @@ -4,54 +4,88 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -# This script collects the JavaScript spec definitions for native -# modules, then uses react-native-codegen to generate native code. -# The script will copy the generated code to the final location by -# default. Optionally, call the script with a path to the desired -# output location. +# This script collects the JavaScript spec definitions for core +# native modules, then uses react-native-codegen to generate +# native code. +# The script will use the local react-native-codegen package by +# default. Optionally, set the CODEGEN_PATH to point to the +# desired codegen library (e.g. when using react-native-codegen +# from npm). # # Usage: -# ./scripts/generate-native-modules-specs.sh [output-dir] +# ./scripts/generate-native-modules-specs.sh # # Example: -# ./scripts/generate-native-modules-specs.sh ./codegen-out +# CODEGEN_PATH=.. ./scripts/generate-native-modules-specs.sh # shellcheck disable=SC2038 set -e THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +TEMP_DIR=$(mktemp -d /tmp/react-native-codegen-XXXXXXXX) RN_DIR=$(cd "$THIS_DIR/.." && pwd) -CODEGEN_DIR=$(cd "$RN_DIR/packages/react-native-codegen" && pwd) -OUTPUT_DIR="${1:-$RN_DIR/Libraries/FBReactNativeSpec/FBReactNativeSpec}" -SCHEMA_FILE="$RN_DIR/schema-native-modules.json" +CODEGEN_PATH="${CODEGEN_PATH:-$(cd "$RN_DIR/packages" && pwd)}" +CODEGEN_DIR="$CODEGEN_PATH/react-native-codegen" + YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" +cleanup () { + set +e + rm -rf "$TEMP_DIR" + set -e +} + describe () { printf "\\n\\n>>>>> %s\\n\\n\\n" "$1" } step_build_codegen () { - describe "Building react-native-codegen package" - pushd "$CODEGEN_DIR" >/dev/null || exit - "$YARN_BINARY" - "$YARN_BINARY" build - popd >/dev/null || exit + if [ ! -d "$CODEGEN_DIR/lib" ]; then + describe "Building react-native-codegen package" + pushd "$CODEGEN_DIR" >/dev/null || exit + "$YARN_BINARY" + "$YARN_BINARY" build + popd >/dev/null || exit + fi } -step_gen_schema () { +run_codegen () { + SRCS_DIR=$1 + LIBRARY_NAME=$2 + OUTPUT_DIR=$3 + + SCHEMA_FILE="$TEMP_DIR/schema-$LIBRARY_NAME.json" + + if [ ! -d "$CODEGEN_DIR/lib" ]; then + describe "Building react-native-codegen package" + pushd "$CODEGEN_DIR" >/dev/null || exit + "$YARN_BINARY" + "$YARN_BINARY" build + popd >/dev/null || exit + fi + describe "Generating schema from flow types" - SRCS_DIR=$(cd "$RN_DIR/Libraries" && pwd) "$YARN_BINARY" node "$CODEGEN_DIR/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR" -} -step_gen_specs () { describe "Generating native code from schema (iOS)" pushd "$RN_DIR" >/dev/null || exit "$YARN_BINARY" --silent node scripts/generate-native-modules-specs-cli.js ios "$SCHEMA_FILE" "$OUTPUT_DIR" popd >/dev/null || exit } -step_build_codegen -step_gen_schema -step_gen_specs +# Handle Core Modules +run_codegen_core_modules () { + LIBRARY_NAME="FBReactNativeSpec" + SRCS_DIR=$(cd "$RN_DIR/Libraries" && pwd) + OUTPUT_DIR="$SRCS_DIR/$LIBRARY_NAME/$LIBRARY_NAME" + + run_codegen "$SRCS_DIR" "$LIBRARY_NAME" "$OUTPUT_DIR" +} + +main() { + run_codegen_core_modules +} + +trap cleanup EXIT +main "$@" diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 14d6166f3da6c1..a77938c0510588 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -108,21 +108,3 @@ def flipper_post_install(installer) end end end - -# Pre Install processing for Native Modules -def codegen_pre_install(installer, options={}) - # Path to React Native - prefix = options[:path] ||= "../node_modules/react-native" - - # Path to react-native-codegen - codegen_path = options[:codegen_path] ||= "#{prefix}/../react-native-codegen" - - # Handle Core Modules - Dir.mktmpdir do |dir| - native_module_spec_name = "FBReactNativeSpec" - schema_file = dir + "/schema-#{native_module_spec_name}.json" - srcs_dir = "#{prefix}/Libraries" - schema_generated = system("node #{codegen_path}/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}") or raise "Could not generate Native Module schema" - specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}") or raise "Could not generate code for #{native_module_spec_name}" - end -end diff --git a/template/ios/Podfile b/template/ios/Podfile index 04f68e5431fb93..6701249e83ac20 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -13,10 +13,6 @@ target 'HelloWorld' do # Pods for testing end - pre_install do |installer| - codegen_pre_install(installer) - end - # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and From 5eee2f2bc01184481a663453648ab15d1d295f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 2 Dec 2020 16:11:11 -0800 Subject: [PATCH 0139/1810] Fix Circle CI iOS Tests: Make FBReactNativeSpec dir as needed Summary: Quick fix for Circle CI: Ensure FBReactNativeSpec dir exists before touching files. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25285573 fbshipit-source-id: 8dec496856c90accc687648d7068aadfea24d72b --- Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec | 5 +++-- packages/rn-tester/Podfile.lock | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec index d02b4c9b84aca5..70e90d54ea439e 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -22,7 +22,8 @@ react_native_path = File.join(__dir__, "..", "..") srcs_dir = File.join(__dir__, "..") codegen_script_path = File.join(react_native_path, "scripts", "generate-native-modules-specs.sh") codegen_path = File.join(react_native_path, codegen_path_prefix, "react-native-codegen") -generated_files = [File.join(__dir__, "FBReactNativeSpec", "FBReactNativeSpec.h"), File.join(__dir__, "FBReactNativeSpec", "FBReactNativeSpec-generated.mm")] +output_dir = File.join(__dir__, "FBReactNativeSpec") +generated_files = [File.join(output_dir, "FBReactNativeSpec.h"), File.join(output_dir, "FBReactNativeSpec-generated.mm")] codegen_command = "CODEGEN_PATH=#{codegen_path} sh '#{codegen_script_path}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"" folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' @@ -54,7 +55,7 @@ Pod::Spec.new do |s| s.dependency "React-jsi", version s.dependency "ReactCommon/turbomodule/core", version - s.prepare_command = "touch #{generated_files.reduce() { |str, file| str + " " + file }}" + s.prepare_command = "mkdir -p #{output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}" s.script_phase = { :name => 'Generate Native Modules Code', :input_files => [srcs_dir], diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 57bce624639667..832cbc0dad3105 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -490,7 +490,7 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 4b0a53603445208c324b4a23d77590c399894efc + FBReactNativeSpec: 77f376d6af8c6348f0cc6de9a96c7a288f4e03ab Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a From b61aaa1545b3308bda5ade169204f875ba417f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 2 Dec 2020 19:11:05 -0800 Subject: [PATCH 0140/1810] Fix path to react-native-codegen Summary: The wrong value for the path to react-native-codegen was being used. The issue was introduced during the refactoring of this script for use in FBReactNativeSpec.podspec. Changelog: [Internal] Motivation: Reviewed By: fkgozali Differential Revision: D25290355 fbshipit-source-id: 5a46c680e7ea41157b03cf54a640a8816fb682b3 --- scripts/generate-native-modules-specs.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/scripts/generate-native-modules-specs.sh b/scripts/generate-native-modules-specs.sh index d667c46901fe99..b9b71b33134743 100755 --- a/scripts/generate-native-modules-specs.sh +++ b/scripts/generate-native-modules-specs.sh @@ -25,9 +25,7 @@ set -e THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) TEMP_DIR=$(mktemp -d /tmp/react-native-codegen-XXXXXXXX) RN_DIR=$(cd "$THIS_DIR/.." && pwd) -CODEGEN_PATH="${CODEGEN_PATH:-$(cd "$RN_DIR/packages" && pwd)}" -CODEGEN_DIR="$CODEGEN_PATH/react-native-codegen" - +CODEGEN_PATH="${CODEGEN_PATH:-$(cd "$RN_DIR/packages/react-native-codegen" && pwd)}" YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" cleanup () { @@ -40,16 +38,6 @@ describe () { printf "\\n\\n>>>>> %s\\n\\n\\n" "$1" } -step_build_codegen () { - if [ ! -d "$CODEGEN_DIR/lib" ]; then - describe "Building react-native-codegen package" - pushd "$CODEGEN_DIR" >/dev/null || exit - "$YARN_BINARY" - "$YARN_BINARY" build - popd >/dev/null || exit - fi -} - run_codegen () { SRCS_DIR=$1 LIBRARY_NAME=$2 @@ -57,16 +45,16 @@ run_codegen () { SCHEMA_FILE="$TEMP_DIR/schema-$LIBRARY_NAME.json" - if [ ! -d "$CODEGEN_DIR/lib" ]; then + if [ ! -d "$CODEGEN_PATH/lib" ]; then describe "Building react-native-codegen package" - pushd "$CODEGEN_DIR" >/dev/null || exit + pushd "$CODEGEN_PATH" >/dev/null || exit "$YARN_BINARY" "$YARN_BINARY" build popd >/dev/null || exit fi describe "Generating schema from flow types" - "$YARN_BINARY" node "$CODEGEN_DIR/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR" + "$YARN_BINARY" node "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR" describe "Generating native code from schema (iOS)" pushd "$RN_DIR" >/dev/null || exit From 2e6eea8390ebcf6f03637050907c78f3e0d4bc05 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 2 Dec 2020 20:07:57 -0800 Subject: [PATCH 0141/1810] Remove enableStopSurfaceOnRootViewUnmount feature flag Summary: This feature flag (enableStopSurfaceOnRootViewUnmount) was used to gate usage of the "stopSurface" API, which is now fully supported, and has been used in the FB app for several months. This is safe to ship in code. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25275192 fbshipit-source-id: fa22bfd00aa023297bc19c83c138f133e9ff1645 --- .../src/main/java/com/facebook/react/ReactRootView.java | 3 +-- .../main/java/com/facebook/react/config/ReactFeatureFlags.java | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index b48c71ccdd69bb..d15ad24067a87d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -41,7 +41,6 @@ import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.common.annotations.VisibleForTesting; -import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.modules.appregistry.AppRegistry; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule; @@ -489,7 +488,7 @@ public void unmountReactApplication() { // to be committed via the Scheduler, which will cause mounting instructions // to be queued up and synchronously executed to delete and remove // all the views in the hierarchy. - if (mReactInstanceManager != null && ReactFeatureFlags.enableStopSurfaceOnRootViewUnmount) { + if (mReactInstanceManager != null) { final ReactContext reactApplicationContext = mReactInstanceManager.getCurrentReactContext(); if (reactApplicationContext != null && getUIManagerType() == FABRIC) { @Nullable diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 58ffe7db73a844..1fa7e75571b5a5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -74,9 +74,6 @@ public class ReactFeatureFlags { /** Feature flag to configure eager initialization of Fabric */ public static boolean eagerInitializeFabric = false; - /** Feature flag to use stopSurface when ReactRootView is unmounted. */ - public static boolean enableStopSurfaceOnRootViewUnmount = false; - /** Use experimental SetState retry mechanism in view? */ public static boolean enableExperimentalStateUpdateRetry = false; From 540735383d858129121ab0447a7880163c31e658 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 3 Dec 2020 09:37:12 -0800 Subject: [PATCH 0142/1810] Fix RNTester Not Resizing Examples on Rotation/Resize (#30376) Summary: Fixes https://github.com/facebook/react-native/issues/30325 After the RNTester redesign, a style started globally caching screen width. This isn't needed, but means that width is incorrect if the device is rotated, or a window is resized. Rely on default layout which will be 100% width instead. ## Changelog [Internal] [Fixed] - Fix RNTester Not Resizing Examples on Rotation/Resize Pull Request resolved: https://github.com/facebook/react-native/pull/30376 Test Plan: Tested viewing an example and rotating the device in iOS simulator Reviewed By: rickhanlonii Differential Revision: D25098642 Pulled By: appden fbshipit-source-id: 9acdb656da7de9fda05f6091b36f8d9aa2155524 --- packages/rn-tester/js/components/ExamplePage.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/rn-tester/js/components/ExamplePage.js b/packages/rn-tester/js/components/ExamplePage.js index ff9bf7f6f3ac85..879f37971b5894 100644 --- a/packages/rn-tester/js/components/ExamplePage.js +++ b/packages/rn-tester/js/components/ExamplePage.js @@ -11,7 +11,7 @@ 'use strict'; import * as React from 'react'; -import {StyleSheet, View, Text, Dimensions} from 'react-native'; +import {StyleSheet, View, Text} from 'react-native'; type Props = $ReadOnly<{| children?: React.Node, @@ -22,7 +22,6 @@ type Props = $ReadOnly<{| android?: ?boolean, |}>; -const ScreenWidth = Dimensions.get('window').width; import {RNTesterThemeContext} from './RNTesterTheme'; export default function ExamplePage(props: Props): React.Node { @@ -76,7 +75,6 @@ const styles = StyleSheet.create({ justifyContent: 'flex-end', }, examplesContainer: { - width: ScreenWidth, flexGrow: 1, }, description: { From 7f16ff8a053ebde51631c11dda2df43048d75282 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Thu, 3 Dec 2020 15:58:36 -0800 Subject: [PATCH 0143/1810] Fix use_framework RNTester crash (#30520) Summary: When building RN Tester with use_frameworks it crashes on launch because of duplicate folly singletons. Seems that it is included twice because of Flipper. From what I understand flipper is not really compatible with use_frameworks so this removes it from that build variant. We also remove hardcoded SONARKIT defines in the xcodeproject, those will be added by the Flipper podspec anyway so it is not needed. This then exposed a missing double conversion header error in Folly so this fixes the DoubleConversion podspec to add its headers path to the user project. ## Changelog [Internal] [Fixed] - Fix use_framework RNTester crash Pull Request resolved: https://github.com/facebook/react-native/pull/30520 Test Plan: Tested RN tester with use frameworks on and off. Also made sure flipper works still when frameworks is false. Reviewed By: fkgozali Differential Revision: D25307973 Pulled By: hramos fbshipit-source-id: 17b90e871734e32f5982c4fc9c07aeea232f868f --- packages/rn-tester/Podfile | 28 +++------ packages/rn-tester/Podfile.lock | 2 +- .../RNTesterPods.xcodeproj/project.pbxproj | 62 +++++++------------ third-party-podspecs/DoubleConversion.podspec | 2 + 4 files changed, 36 insertions(+), 58 deletions(-) diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index efc5c339ad5b98..db37edcc38f3f2 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -3,7 +3,9 @@ require_relative '../../scripts/react_native_pods' source 'https://cdn.cocoapods.org/' platform :ios, '10.0' -if ENV['USE_FRAMEWORKS'] == '1' +USE_FRAMEWORKS = ENV['USE_FRAMEWORKS'] == '1' + +if USE_FRAMEWORKS puts "Installing pods with use_frameworks!" use_frameworks! end @@ -31,7 +33,9 @@ end target 'RNTester' do pods() - use_flipper! + if !USE_FRAMEWORKS + use_flipper! + end end target 'RNTesterUnitTests' do @@ -44,22 +48,8 @@ target 'RNTesterIntegrationTests' do pod 'React-RCTTest', :path => "./RCTTest" end -def frameworks_pre_install(installer) - static_frameworks = ['FlipperKit', 'Flipper', 'Flipper-Folly', - 'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion', - 'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket', - 'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native'] - - Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} - installer.pod_targets.each do |pod| - if static_frameworks.include?(pod.name) - def pod.build_type - Pod::BuildType.static_library - end - end - end -end - post_install do |installer| - flipper_post_install(installer) + if !USE_FRAMEWORKS + flipper_post_install(installer) + end end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 832cbc0dad3105..f8c8fb42160bc6 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -528,6 +528,6 @@ SPEC CHECKSUMS: Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 3adfe268d800503789170d1862bde422ee204fe8 +PODFILE CHECKSUM: a36cc754d464f1cc28efaac3a4065fd58419f79d COCOAPODS: 1.10.0 diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index 98975cb09293ec..7cac6ec17b2862 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 1317FC3A10A7E894D970D9F2 /* libPods-RNTester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C2F0C3405B1D6741F52D4F6 /* libPods-RNTester.a */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 272E6B3F1BEA849E001FCF37 /* UpdatePropertiesExampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 272E6B3C1BEA849E001FCF37 /* UpdatePropertiesExampleView.m */; }; 27F441EC1BEBE5030039B79C /* FlexibleSizeExampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F441E81BEBE5030039B79C /* FlexibleSizeExampleView.m */; }; @@ -16,9 +15,10 @@ 3D2AFAF51D646CF80089D1A3 /* legacy_image@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3D2AFAF41D646CF80089D1A3 /* legacy_image@2x.png */; }; 5C60EB1C226440DB0018C04F /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C60EB1B226440DB0018C04F /* AppDelegate.mm */; }; 5CB07C9B226467E60039471C /* RNTesterTurboModuleProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB07C99226467E60039471C /* RNTesterTurboModuleProvider.mm */; }; + 682424F330D42708B52AA9A8 /* libPods-RNTester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 88EFE7E584B42816405BA434 /* libPods-RNTester.a */; }; + 7B37A0C3E18EDC90CCD01CA2 /* libPods-RNTesterIntegrationTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E6D00D70BA38970C7995F0A3 /* libPods-RNTesterIntegrationTests.a */; }; 8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8145AE05241172D900A3F8DA /* LaunchScreen.storyboard */; }; - CE8B4DF18C0491DAC01826D8 /* libPods-RNTesterUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 240ABDF8133AF49081795AFC /* libPods-RNTesterUnitTests.a */; }; - DBA671A0680021020B916DDB /* libPods-RNTesterIntegrationTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C76DE6ECEDBBAA2CA41B4D /* libPods-RNTesterIntegrationTests.a */; }; + DCB59B3E303512590BDA64B9 /* libPods-RNTesterUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6362DCCAA386FBF557077739 /* libPods-RNTesterUnitTests.a */; }; E7C1241A22BEC44B00DA25C0 /* RNTesterIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7C1241922BEC44B00DA25C0 /* RNTesterIntegrationTests.m */; }; E7DB20D122B2BAA6005AC45F /* RCTBundleURLProviderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB20A922B2BAA3005AC45F /* RCTBundleURLProviderTests.m */; }; E7DB20D222B2BAA6005AC45F /* RCTModuleInitNotificationRaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB20AA22B2BAA3005AC45F /* RCTModuleInitNotificationRaceTests.m */; }; @@ -81,7 +81,6 @@ 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RNTester/AppDelegate.h; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RNTester/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RNTester/main.m; sourceTree = ""; }; - 240ABDF8133AF49081795AFC /* libPods-RNTesterUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 272E6B3B1BEA849E001FCF37 /* UpdatePropertiesExampleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UpdatePropertiesExampleView.h; path = RNTester/NativeExampleViews/UpdatePropertiesExampleView.h; sourceTree = ""; }; 272E6B3C1BEA849E001FCF37 /* UpdatePropertiesExampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UpdatePropertiesExampleView.m; path = RNTester/NativeExampleViews/UpdatePropertiesExampleView.m; sourceTree = ""; }; 27F441E81BEBE5030039B79C /* FlexibleSizeExampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FlexibleSizeExampleView.m; path = RNTester/NativeExampleViews/FlexibleSizeExampleView.m; sourceTree = ""; }; @@ -90,16 +89,17 @@ 34028D6B10F47E490042EB27 /* Pods-RNTesterUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.debug.xcconfig"; sourceTree = ""; }; 383889D923A7398900D06C3E /* RCTConvert_UIColorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_UIColorTests.m; sourceTree = ""; }; 3D2AFAF41D646CF80089D1A3 /* legacy_image@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "legacy_image@2x.png"; path = "RNTester/legacy_image@2x.png"; sourceTree = ""; }; - 4C2F0C3405B1D6741F52D4F6 /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 5BEC8567F3741044B6A5EFC5 /* Pods-RNTester.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester.release.xcconfig"; path = "Pods/Target Support Files/Pods-RNTester/Pods-RNTester.release.xcconfig"; sourceTree = ""; }; 5C60EB1B226440DB0018C04F /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = RNTester/AppDelegate.mm; sourceTree = ""; }; 5CB07C99226467E60039471C /* RNTesterTurboModuleProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RNTesterTurboModuleProvider.mm; path = RNTester/RNTesterTurboModuleProvider.mm; sourceTree = ""; }; 5CB07C9A226467E60039471C /* RNTesterTurboModuleProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNTesterTurboModuleProvider.h; path = RNTester/RNTesterTurboModuleProvider.h; sourceTree = ""; }; + 6362DCCAA386FBF557077739 /* libPods-RNTesterUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 7D51F73F0DA20287418D98BD /* Pods-RNTesterIntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.release.xcconfig"; sourceTree = ""; }; 8145AE05241172D900A3F8DA /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNTester/LaunchScreen.storyboard; sourceTree = ""; }; + 88EFE7E584B42816405BA434 /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 972A459EE6CF8CC63531A088 /* Pods-RNTesterIntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.debug.xcconfig"; sourceTree = ""; }; 98233960D1D6A1977D1C7EAF /* Pods-RNTester.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RNTester/Pods-RNTester.debug.xcconfig"; sourceTree = ""; }; - E4C76DE6ECEDBBAA2CA41B4D /* libPods-RNTesterIntegrationTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterIntegrationTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + E6D00D70BA38970C7995F0A3 /* libPods-RNTesterIntegrationTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterIntegrationTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; E771AEEA22B44E3100EA1189 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RNTester/Info.plist; sourceTree = ""; }; E7C1241922BEC44B00DA25C0 /* RNTesterIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNTesterIntegrationTests.m; sourceTree = ""; }; E7DB209F22B2BA84005AC45F /* RNTesterUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNTesterUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -180,7 +180,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1317FC3A10A7E894D970D9F2 /* libPods-RNTester.a in Frameworks */, + 682424F330D42708B52AA9A8 /* libPods-RNTester.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -190,7 +190,7 @@ files = ( E7DB213122B2C649005AC45F /* JavaScriptCore.framework in Frameworks */, E7DB213222B2C67D005AC45F /* libOCMock.a in Frameworks */, - CE8B4DF18C0491DAC01826D8 /* libPods-RNTesterUnitTests.a in Frameworks */, + DCB59B3E303512590BDA64B9 /* libPods-RNTesterUnitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -200,7 +200,7 @@ files = ( E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */, E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */, - DBA671A0680021020B916DDB /* libPods-RNTesterIntegrationTests.a in Frameworks */, + 7B37A0C3E18EDC90CCD01CA2 /* libPods-RNTesterIntegrationTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -270,9 +270,9 @@ E7DB211822B2BD53005AC45F /* libReact-RCTText.a */, E7DB211A22B2BD53005AC45F /* libReact-RCTVibration.a */, E7DB212222B2BD53005AC45F /* libyoga.a */, - 4C2F0C3405B1D6741F52D4F6 /* libPods-RNTester.a */, - E4C76DE6ECEDBBAA2CA41B4D /* libPods-RNTesterIntegrationTests.a */, - 240ABDF8133AF49081795AFC /* libPods-RNTesterUnitTests.a */, + 88EFE7E584B42816405BA434 /* libPods-RNTester.a */, + E6D00D70BA38970C7995F0A3 /* libPods-RNTesterIntegrationTests.a */, + 6362DCCAA386FBF557077739 /* libPods-RNTesterUnitTests.a */, ); name = Frameworks; sourceTree = ""; @@ -405,7 +405,7 @@ 13B07F8E1A680F5B00A75B9A /* Resources */, 68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */, 5CF0FD27207FC6EC00C13D65 /* Start Metro */, - C1C7A9D58CE1D09515F20577 /* [CP] Copy Pods Resources */, + CD2B49A7F80C8171E7A5B233 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -424,7 +424,7 @@ E7DB209B22B2BA84005AC45F /* Sources */, E7DB209C22B2BA84005AC45F /* Frameworks */, E7DB209D22B2BA84005AC45F /* Resources */, - D45F7C4830D42738CAAC9684 /* [CP] Copy Pods Resources */, + 71ADC6D58A978687B97C823F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -444,7 +444,7 @@ E7DB214F22B2F332005AC45F /* Sources */, E7DB215022B2F332005AC45F /* Frameworks */, E7DB215122B2F332005AC45F /* Resources */, - CD1D70F24AD74F4E13B7435D /* [CP] Copy Pods Resources */, + 87FAF758B87BEA78F26A2B92 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -596,24 +596,24 @@ shellPath = /bin/sh; shellScript = "set -e\n\nexport NODE_BINARY=node\nexport PROJECT_ROOT=\"$SRCROOT/../../\"\nexport SOURCEMAP_FILE=../sourcemap.ios.map\n# export FORCE_BUNDLING=true\n\"$SRCROOT/../../scripts/react-native-xcode.sh\" $SRCROOT/../../packages/rn-tester/js/RNTesterApp.ios.js\n"; }; - C1C7A9D58CE1D09515F20577 /* [CP] Copy Pods Resources */ = { + 71ADC6D58A978687B97C823F /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - CD1D70F24AD74F4E13B7435D /* [CP] Copy Pods Resources */ = { + 87FAF758B87BEA78F26A2B92 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -630,21 +630,21 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - D45F7C4830D42738CAAC9684 /* [CP] Copy Pods Resources */ = { + CD2B49A7F80C8171E7A5B233 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-resources.sh\"\n"; showEnvVarsInLog = 0; }; F9CB97B0D9633939D43E75E0 /* [CP] Check Pods Manifest.lock */ = { @@ -752,10 +752,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; DEVELOPMENT_TEAM = ""; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "FB_SONARKIT_ENABLED=1", - ); INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -768,10 +764,6 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", ); "LIBRARY_SEARCH_PATHS[arch=*]" = "$(inherited)"; - OTHER_CFLAGS = ( - "$(inherited)", - "-DFB_SONARKIT_ENABLED=1", - ); OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -779,7 +771,6 @@ "-framework", "\"JavaScriptCore\"", ); - OTHER_SWIFT_FLAGS = "$(inherited) -Xcc -DFB_SONARKIT_ENABLED"; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp; PRODUCT_NAME = RNTester; TARGETED_DEVICE_FAMILY = "1,2"; @@ -806,10 +797,6 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", ); - OTHER_CFLAGS = ( - "$(inherited)", - "-DFB_SONARKIT_ENABLED=1", - ); OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -817,7 +804,6 @@ "-framework", "\"JavaScriptCore\"", ); - OTHER_SWIFT_FLAGS = "$(inherited) -Xcc -DFB_SONARKIT_ENABLED"; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp; PRODUCT_NAME = RNTester; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/third-party-podspecs/DoubleConversion.podspec b/third-party-podspecs/DoubleConversion.podspec index b84ba28a6b143e..cfaa84f97b0e2d 100644 --- a/third-party-podspecs/DoubleConversion.podspec +++ b/third-party-podspecs/DoubleConversion.podspec @@ -18,6 +18,8 @@ Pod::Spec.new do |spec| spec.source_files = 'double-conversion/*.{h,cc}' spec.compiler_flags = '-Wno-unreachable-code' + spec.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/DoubleConversion\"" } + # Pinning to the same version as React.podspec. spec.platforms = { :ios => "10.0" } From 7008ffb663d59c34e94b6abe5b63e0bc9ad89b04 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yin Date: Thu, 3 Dec 2020 16:40:47 -0800 Subject: [PATCH 0144/1810] Protect methods from proguard Summary: These methods were being striped from proguard, which causes release builds to instacrash Changelog: [Internal] Protect methods from Proguard Reviewed By: RSNara Differential Revision: D25314933 fbshipit-source-id: 173160eab953b7c24e02f5e6ef3bf335c1f85526 --- .../src/main/java/com/facebook/react/bridge/Arguments.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java index 6302abe043e5f3..c5e8a5ccbcfad0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java @@ -10,12 +10,14 @@ import android.os.Bundle; import android.os.Parcelable; import androidx.annotation.Nullable; +import com.facebook.proguard.annotations.DoNotStrip; import java.lang.reflect.Array; import java.util.AbstractList; import java.util.ArrayList; import java.util.List; import java.util.Map; +@DoNotStrip public class Arguments { private static Object makeNativeObject(Object object) { if (object == null) { @@ -122,6 +124,7 @@ private static void addEntry(WritableNativeMap nativeMap, String key, Object val * The best way to think of this is a way to generate a Java representation of a json object, from * Java types which have a natural representation in json. */ + @DoNotStrip public static WritableNativeMap makeNativeMap(Map objects) { WritableNativeMap nativeMap = new WritableNativeMap(); if (objects == null) { @@ -134,6 +137,7 @@ public static WritableNativeMap makeNativeMap(Map objects) { } /** Like the above, but takes a Bundle instead of a Map. */ + @DoNotStrip public static WritableNativeMap makeNativeMap(Bundle bundle) { WritableNativeMap nativeMap = new WritableNativeMap(); if (bundle == null) { From 50dde4b7b74ebcc380599249d64ee65325405aa5 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 3 Dec 2020 17:06:49 -0800 Subject: [PATCH 0145/1810] LayoutAnimations: Fix out-of-order DELETE and REMOVE instruction generation Summary: In very marginal cases, it was possible to set up an animation of the following diffing instructions: ``` REMOVE X from parent Y DELETE X ``` If your LayoutAnimation configuration had no "delete" config, the DELETE would be executed immediately; the REMOVE was erroneously being categorized as an "update" (now fixed) which caused the REMOVE to be delayed, but then executed very shortly thereafter. So the order of instructions would become: ``` DELETE X REMOVE X from parent Y ``` which would crash (or at least fail an assertion) when the REMOVE instruction was processed. This fixes the issue by ensuring that REMOVEs have a corresponding "delete" config, or they are also executed immediately; unless followed by an INSERT (and any combination of `REMOVE, DELETE, INSERT` in the same frame is not possible). Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25292560 fbshipit-source-id: 7ffdd6cbcb43126de07a70c197dfaf1ebff83555 --- .../renderer/animations/LayoutAnimationKeyFrameManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index ddc2353e0efd99..512fe8274cd73b 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -914,7 +914,9 @@ LayoutAnimationKeyFrameManager::pullTransaction( } auto const &mutationConfig = - (mutation.type == ShadowViewMutation::Type::Delete + (mutation.type == ShadowViewMutation::Type::Delete || + (mutation.type == ShadowViewMutation::Type::Remove && + !wasInsertedTagRemoved) ? layoutAnimationConfig.deleteConfig : (mutation.type == ShadowViewMutation::Type::Insert && !wasInsertedTagRemoved From a326a30e322f6cdff880734aafe965b299febb8d Mon Sep 17 00:00:00 2001 From: Steven Conaway Date: Thu, 3 Dec 2020 17:21:06 -0800 Subject: [PATCH 0146/1810] Add instructions to template/ios/Podfile for enabling hermes (#30461) Summary: Just thought I'd add these instructions so devs don't have to check the docs. Also, it makes iOS match Android with instructions in the configuration files ## Changelog N/A (in my opinion) Pull Request resolved: https://github.com/facebook/react-native/pull/30461 Test Plan: N/A (because not a code change) Reviewed By: hramos Differential Revision: D25309687 Pulled By: TheSavior fbshipit-source-id: a1907089b9d2e7fe6f2498ce27129c3ae65f7c9a --- template/ios/Podfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/template/ios/Podfile b/template/ios/Podfile index 6701249e83ac20..1b0f64d347bad6 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -6,7 +6,11 @@ platform :ios, '10.0' target 'HelloWorld' do config = use_native_modules! - use_react_native!(:path => config[:reactNativePath]) + use_react_native( + :path => config[:reactNativePath], + # to enable hermes on iOS, change `false` to `true` and then install pods + :hermes_enabled => false + ) target 'HelloWorldTests' do inherit! :complete From 5d8fcde6320c9af13738224f6653ec47f995c770 Mon Sep 17 00:00:00 2001 From: Kim Svatos Date: Thu, 3 Dec 2020 19:08:10 -0800 Subject: [PATCH 0147/1810] Back out "Avoid accessing `self.component` on background thread" Summary: Changelog: [Internal] backout change dispatching main queue before using it Reviewed By: shergin Differential Revision: D25319046 fbshipit-source-id: 4f8952e577cfd9033fb2c2248b9b056a0d468b5d --- .../RCTSurfaceHostingComponentController.mm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm b/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm index d56974f5152de0..cd69fb32b3e129 100644 --- a/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm +++ b/Libraries/SurfaceHostingComponent/RCTSurfaceHostingComponentController.mm @@ -130,18 +130,12 @@ - (void)unmountSurfaceView - (void)surface:(RCTSurface *)surface didChangeIntrinsicSize:(CGSize)intrinsicSize { - __weak const auto weakSelf = self; - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf setIntrinsicSize:intrinsicSize]; - }); + [self setIntrinsicSize:intrinsicSize]; } - (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage { - __weak const auto weakSelf = self; - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf setStage:stage]; - }); + [self setStage:stage]; } @end From 0959ff36d1f3264e117021eb1999d0bdb71377c3 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Thu, 3 Dec 2020 20:05:00 -0800 Subject: [PATCH 0148/1810] Move hermes to a separate podspec (#30478) Summary: Hermes being a subspec of ReactCore causes some build issues when RN is included in 2 different targets. It also causes it to include a lot of additional dependencies that it doesn't need. This moves it to a separate podspec loosely based on other specs in ReactCommon. ## Changelog [iOS] [Fixed] - Move hermes to a separate podspec Pull Request resolved: https://github.com/facebook/react-native/pull/30478 Test Plan: Test that it builds and run properly in an app Reviewed By: fkgozali Differential Revision: D25308237 Pulled By: hramos fbshipit-source-id: b4cc44ea2b1b854831e881dbbf9a2f30f6704001 --- React-Core.podspec | 11 ----- React/CxxBridge/RCTCxxBridge.mm | 2 +- ReactCommon/hermes/React-hermes.podspec | 53 ++++++++++++++++++++++ packages/rn-tester/RNTester/AppDelegate.mm | 2 +- scripts/react_native_pods.rb | 2 +- 5 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 ReactCommon/hermes/React-hermes.podspec diff --git a/React-Core.podspec b/React-Core.podspec index 9a2be90c4bc145..07f0ec398b3536 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -62,17 +62,6 @@ Pod::Spec.new do |s| ss.private_header_files = "React/Cxx*/*.h" end - s.subspec "Hermes" do |ss| - ss.platforms = { :osx => "10.14", :ios => "10.0" } - ss.source_files = "ReactCommon/hermes/executor/*.{cpp,h}", - "ReactCommon/hermes/inspector/*.{cpp,h}", - "ReactCommon/hermes/inspector/chrome/*.{cpp,h}", - "ReactCommon/hermes/inspector/detail/*.{cpp,h}" - ss.pod_target_xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } - ss.dependency "RCT-Folly/Futures" - ss.dependency "hermes-engine" - end - s.subspec "DevSupport" do |ss| ss.source_files = "React/DevSupport/*.{h,mm,m}", "React/Inspector/*.{h,mm,m}" diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 23222509610882..5836cf02221b6e 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -46,7 +46,7 @@ #endif #if RCT_USE_HERMES -#import "HermesExecutorFactory.h" +#import #else #import "JSCExecutorFactory.h" #endif diff --git a/ReactCommon/hermes/React-hermes.podspec b/ReactCommon/hermes/React-hermes.podspec new file mode 100644 index 00000000000000..d28d3018f13e21 --- /dev/null +++ b/ReactCommon/hermes/React-hermes.podspec @@ -0,0 +1,53 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2020.01.13.00' +boost_compiler_flags = '-Wno-documentation' + +Pod::Spec.new do |s| + s.name = "React-hermes" + s.version = version + s.summary = "-" # TODO + s.homepage = "https://reactnative.dev/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :osx => "10.14", :ios => "10.0" } + s.source = source + s.source_files = "executor/*.{cpp,h}", + "inspector/*.{cpp,h}", + "inspector/chrome/*.{cpp,h}", + "inspector/detail/*.{cpp,h}" + s.public_header_files = "executor/HermesExecutorFactory.h" + s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + s.pod_target_xcconfig = { + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"", + "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1", + } + s.header_dir = "reacthermes" + s.dependency "React-cxxreact", version + s.dependency "React-jsi", version + s.dependency "React-jsiexecutor", version + s.dependency "React-jsinspector", version + s.dependency "React-perflogger", version + s.dependency "RCT-Folly", folly_version + s.dependency "RCT-Folly/Futures", folly_version + s.dependency "DoubleConversion" + s.dependency "glog" + s.dependency "hermes-engine" +end diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index 4ce922259a5444..012c26dd9e6cf6 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -16,7 +16,7 @@ #endif #if RCT_USE_HERMES -#import +#import #else #import #endif diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index a77938c0510588..480df56be4d5c5 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -62,7 +62,7 @@ def use_react_native! (options={}) end if hermes_enabled - pod 'React-Core/Hermes', :path => "#{prefix}/" + pod 'React-hermes', :path => "#{prefix}/ReactCommon/hermes" pod 'hermes-engine' pod 'libevent', :podspec => "#{prefix}/third-party-podspecs/libevent.podspec" end From 0d3aa35a03cf9a5e3afb17fdb5abdc3c635fe46d Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 3 Dec 2020 20:47:45 -0800 Subject: [PATCH 0149/1810] remove unnecessary check Summary: EZ check to remove unnecessary check changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25315988 fbshipit-source-id: a635ce9fd7ad50109bee55f82ccf3556cc7a4b0d --- .../main/java/com/facebook/react/fabric/FabricUIManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index b8d3dc7e60976a..c22a4b1eb77fe5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -701,7 +701,7 @@ private void scheduleMountItem( mDispatchViewUpdatesTime = SystemClock.uptimeMillis(); } - if (shouldSchedule && mountItem != null) { + if (shouldSchedule) { addMountItem(mountItem); if (UiThreadUtil.isOnUiThread()) { // We only read these flags on the UI thread. From 053cd6b3760c733a24d006a39c408022a29fe97c Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Fri, 4 Dec 2020 00:23:38 -0800 Subject: [PATCH 0150/1810] Make dependencies cache more reliable on CI (#30534) Summary: I was looking into why CI was failing and could not reproduce locally, also noticed the errors seemed to come from old version of files being used, for example a missing symbol added in a JSI commit ~1 month ago. I noticed that we were using multiple cache keys for a lot of deps in the following format: ``` - v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} - v3-pods-{{ .Environment.CIRCLE_JOB }}- ``` This means that if the cache doesn't exist for the checksum of the lockfile it will get one for any other checksum. This can lead to loading old version of files that cocoapod / yarn probably doesn't detect and keeps instead of getting the proper version. To make things worst it then caches the broken dep package after. This removes all of these key fallbacks and use the cache only if we have a perfect match. This should make CI more reliable and fix random breaks after updating deps / pod configs. ## Changelog [Internal] [Fixed] - Make dependencies cache more reliable on CI Pull Request resolved: https://github.com/facebook/react-native/pull/30534 Test Plan: - Check that tests now pass when cache is bypassed - Check that it still passes with cache - Hope the issue stops happening the next time someone updates deps :) Reviewed By: fkgozali Differential Revision: D25326131 Pulled By: hramos fbshipit-source-id: f21cdfca7b2456ac0edbdcce3f9eb0a828a9b977 --- .circleci/config.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c7496960c1a1cf..3e7f86577b3ad8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -75,7 +75,6 @@ commands: - restore_cache: keys: - v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} - - v4-yarn-cache-{{ arch }} - run: name: "Yarn: Install Dependencies" command: | @@ -94,7 +93,6 @@ commands: - restore_cache: keys: - v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} - - v3-buck-v2019.01.10.01- - run: name: Install BUCK command: | @@ -151,20 +149,20 @@ commands: command: cp packages/rn-tester/Podfile.lock packages/rn-tester/Podfile.lock.bak - restore_cache: keys: - - v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} - - v3-pods-{{ .Environment.CIRCLE_JOB }}- + # The committed lockfile is generated using USE_FRAMEWORKS=0 and USE_HERMES=0 so it could load an outdated cache if a change + # only affects the frameworks or hermes config. To help prevent this also cache based on the content of Podfile. + - v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} - steps: << parameters.steps >> - save_cache: paths: - packages/rn-tester/Pods - key: v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} + key: v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} download_gradle_dependencies: steps: - restore_cache: keys: - v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} - - v1-gradle- - run: name: Download Dependencies Using Gradle command: ./scripts/circleci/gradle_download_deps.sh @@ -626,7 +624,6 @@ jobs: - restore_cache: keys: - v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} - - v1-win-yarn-cache-{{ arch }}- - run: name: "Yarn: Install Dependencies" command: yarn install --frozen-lockfile --non-interactive From bd2b459561420ec71aebfd7db9b88e0bf1db5e8b Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 4 Dec 2020 00:25:44 -0800 Subject: [PATCH 0151/1810] Non-Fabric: ensure every requestLayout is followed by a performLayout Summary: Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25319526 fbshipit-source-id: 5527d90d84ef53847b1a478bfa16c27e3ca4720b --- .../main/java/com/facebook/react/config/ReactFeatureFlags.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 1fa7e75571b5a5..e2480624737ad6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -85,4 +85,7 @@ public class ReactFeatureFlags { /** Use lock-free data structures for Fabric MountItems. */ public static boolean enableLockFreeMountInstructions = false; + + /** Temporary flag for FB-internal workaround for RN:Litho interop in non-Fabric RN. */ + public static boolean enableNonFabricRNLithoForceLayout = true; } From 959bc47c1873d134be326772b16e4c3d380ca067 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 4 Dec 2020 10:52:49 -0800 Subject: [PATCH 0152/1810] Add internal_analyticTag into RCTImageView JS view configs Summary: this diff fixes the next error: ``` 'RCTImageView' has a view config that does not match native. 'validAttributes' is missing: internal_analyticTag in RCTImageView (at Image.ios.js:149) in ImageAnalyticsTagContext.Consumer (at Image.ios.js:146) in Image (at TintedIcon.js:55) in TintedIcon (at TetraIcon.js:98) in TetraIcon (at FDSCheckbox.js:67) in FDSCheckbox (at TetraListCell.js:820) in TetraAddOnSecondary (at TetraListCell.js:576) in TetraPressable (at TetraListCell.js:603) in TetraListCell (created by TetraListCell) in TetraListCell (at RNInternalSettingsUnit.js:35) in TetraList (at RNInternalSettingsUnit.js:32) in RNInternalSettingsUnit (at RNInternalSettingsDeveloperModeUnit.new.js:73) in RNInternalSettingsDeveloperModeUnit (at RNInternalSettingsSurface.js:79) in RNInternalSettingsSurface (at withDefaultErrorBoundary.js:30) in DefaultError(React.lazy(RNInternalSettingsSurfaceForFacebook)) (at renderApplication.js:47) ``` changelog: [internal] internal Reviewed By: fkgozali Differential Revision: D25313414 fbshipit-source-id: ab951d25ac6a80809a2977c80ff059f667cc5595 --- Libraries/Image/ImageViewNativeComponent.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Image/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index 360491d5e9fbd0..b6ba39c8a16536 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -74,6 +74,7 @@ const ImageViewNativeComponent: HostComponent = NativeComponentRegistry.g defaultSrc: true, fadeDuration: true, headers: true, + internal_analyticTag: true, loadingIndicatorSrc: true, onError: true, onLoad: true, From fbf37092a8e9947f647fd8995726ab724bba4961 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Fri, 4 Dec 2020 11:01:30 -0800 Subject: [PATCH 0153/1810] Disable non-Fabric view operations after catalyst instance is destroyed Summary: Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25248836 fbshipit-source-id: 9afb0c18e7825d32857f746b038268758afaaaa8 --- .../react/config/ReactFeatureFlags.java | 3 ++ .../react/uimanager/UIImplementation.java | 45 +++++++++++++++++++ .../react/uimanager/UIManagerModule.java | 1 + 3 files changed, 49 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index e2480624737ad6..7d1729782db3f8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -88,4 +88,7 @@ public class ReactFeatureFlags { /** Temporary flag for FB-internal workaround for RN:Litho interop in non-Fabric RN. */ public static boolean enableNonFabricRNLithoForceLayout = true; + + /** Disable UI update operations in non-Fabric renderer after catalyst instance was destroyed */ + public static boolean disableNonFabricViewOperationsOnCatalystDestroy = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 16630deff02277..08ae573089a585 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -51,6 +51,13 @@ public class UIImplementation { private long mLastCalculateLayoutTime = 0; protected @Nullable LayoutUpdateListener mLayoutUpdateListener; + /** + * When react instance is being shutdown, there could be some pending operations queued in the JS + * thread. This flag ensures view related operations are not triggered if the Catalyst instance + * was destroyed. + */ + private volatile boolean mViewOperationsEnabled = true; + /** Interface definition for a callback to be invoked when the layout has been updated */ public interface LayoutUpdateListener { @@ -234,6 +241,10 @@ public Map getProfiledBatchPerfCounters() { /** Invoked by React to create a new node with a given tag, class name and properties. */ public void createView(int tag, String className, int rootViewTag, ReadableMap props) { + if (!mViewOperationsEnabled) { + return; + } + synchronized (uiImplementationThreadLock) { ReactShadowNode cssNode = createShadowNode(className); ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag); @@ -264,6 +275,10 @@ protected void handleCreateView( /** Invoked by React to create a new node with a given tag has its properties changed. */ public void updateView(int tag, String className, ReadableMap props) { + if (!mViewOperationsEnabled) { + return; + } + ViewManager viewManager = mViewManagers.get(className); if (viewManager == null) { throw new IllegalViewOperationException("Got unknown view type: " + className); @@ -314,6 +329,10 @@ public void manageChildren( @Nullable ReadableArray addChildTags, @Nullable ReadableArray addAtIndices, @Nullable ReadableArray removeFrom) { + if (!mViewOperationsEnabled) { + return; + } + synchronized (uiImplementationThreadLock) { ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); @@ -420,6 +439,10 @@ public void manageChildren( * @param childrenTags tags of the children */ public void setChildren(int viewTag, ReadableArray childrenTags) { + if (!mViewOperationsEnabled) { + return; + } + synchronized (uiImplementationThreadLock) { ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); @@ -530,6 +553,10 @@ public void viewIsDescendantOf( * view and returns the values via an async callback. */ public void measure(int reactTag, Callback callback) { + if (!mViewOperationsEnabled) { + return; + } + // This method is called by the implementation of JS touchable interface (see Touchable.js for // more details) at the moment of touch activation. That is after user starts the gesture from // a touchable view with a given reactTag, or when user drag finger back into the press @@ -543,6 +570,10 @@ public void measure(int reactTag, Callback callback) { * things like the status bar */ public void measureInWindow(int reactTag, Callback callback) { + if (!mViewOperationsEnabled) { + return; + } + mOperationsQueue.enqueueMeasureInWindow(reactTag, callback); } @@ -554,6 +585,10 @@ public void measureInWindow(int reactTag, Callback callback) { */ public void measureLayout( int tag, int ancestorTag, Callback errorCallback, Callback successCallback) { + if (!mViewOperationsEnabled) { + return; + } + try { measureLayout(tag, ancestorTag, mMeasureBuffer); float relativeX = PixelUtil.toDIPFromPixel(mMeasureBuffer[0]); @@ -571,6 +606,10 @@ public void measureLayout( */ public void measureLayoutRelativeToParent( int tag, Callback errorCallback, Callback successCallback) { + if (!mViewOperationsEnabled) { + return; + } + try { measureLayoutRelativeToParent(tag, mMeasureBuffer); float relativeX = PixelUtil.toDIPFromPixel(mMeasureBuffer[0]); @@ -747,6 +786,12 @@ public void onHostPause() { public void onHostDestroy() {} + public void onCatalystInstanceDestroyed() { + if (ReactFeatureFlags.disableNonFabricViewOperationsOnCatalystDestroy) { + mViewOperationsEnabled = false; + } + } + public void setViewHierarchyUpdateDebugListener( @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { mOperationsQueue.setViewHierarchyUpdateDebugListener(listener); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index c5340ae3b7510a..2f2e8257578441 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -242,6 +242,7 @@ public void onHostDestroy() { public void onCatalystInstanceDestroy() { super.onCatalystInstanceDestroy(); mEventDispatcher.onCatalystInstanceDestroyed(); + mUIImplementation.onCatalystInstanceDestroyed(); getReactApplicationContext().unregisterComponentCallbacks(mMemoryTrimCallback); YogaNodePool.get().clear(); From 374808f307fd0023f0eddfefe95da26664dcfa41 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 4 Dec 2020 11:57:47 -0800 Subject: [PATCH 0154/1810] Delete redundant dependency in turbomodules/core:coreAndroid Reviewed By: ejanzer Differential Revision: D25274090 fbshipit-source-id: 6f18ebee410b0866d5c5f96cc80631116f4251ff --- .../src/main/java/com/facebook/react/turbomodule/core/BUCK | 1 - 1 file changed, 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK index 63dfbaa6977994..721fe18d0cc7f1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK @@ -14,7 +14,6 @@ rn_android_library( "PUBLIC", ], deps = [ - "//fbandroid/java/com/facebook/proguard/annotations:annotations", react_native_dep("third-party/android/androidx:annotation"), react_native_dep("java/com/facebook/proguard/annotations:annotations"), react_native_dep("java/com/facebook/systrace:systrace"), From e289366b3894ad9785595af6698b8166cc01de6d Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 4 Dec 2020 14:19:27 -0800 Subject: [PATCH 0155/1810] Move TurboModuleRegistry validation into NativeModule Spec Parser Summary: ## Changes 1. In the NativeModule spec parser, the moduleName is now being extracted from the TurboModuleRegistry.get(...) call by examining the Flow ast node. Previously, we used regex parsing, which was unsafe because it could be fooled by TurboModuleRegistry.get(...) calls in comments. 2. The logic to parse and validate the TurboModuleRegistry.get(...) call is now centralized in the NativeModule Spec Parser (it was removed from the react-native-modules ESLint rule). The linter is now only responsible for three things: 1. Detecting if a JavaScript file contains a TurboModuleRegistry.get call or a TurboModule interface, and if so 2. Running the NativeModule spec parser on it. 3. It also validates that the Module spec's filename starts with the prefix "Native". The React Native Modules linter now completely delegates to the NativeModules Spec parser, without doing any error checking of its own. If an error is reported by the React Native Modules linter, and that error doesn't have anything to do with the "Native" prefix, then it *must* be addressed. Otherwise, it will cause the NativeModule Spec Parser to fail on that particular spec. Changelog: [Internal] Reviewed By: hramos Differential Revision: D25153243 fbshipit-source-id: da74dbb66b1d8dca3a2b1952402222c6696b73d6 --- .../__test_fixtures__/fixtures.js | 70 --- .../__snapshots__/index-test.js.snap | 496 ------------------ .../__tests__/react-native-modules-test.js | 95 ---- .../react-native-modules.js | 126 +---- .../src/parsers/flow/errors.js | 12 +- .../src/parsers/flow/index.js | 50 +- .../src/parsers/flow/modules/errors.js | 93 +++- .../src/parsers/flow/modules/index.js | 113 +++- .../src/parsers/flow/utils.js | 32 ++ 9 files changed, 259 insertions(+), 828 deletions(-) diff --git a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js index 2d845b8ad994b1..31449e97abe79b 100644 --- a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js +++ b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js @@ -165,80 +165,10 @@ const module = TurboModuleRegistry.getEnforcing( export default (module: Spec); `; -const SAMPLE_TURBO_MODULE_MANY_MODULES_DEFAULT_EXPORT = ` -// @flow - -import type {RootTag, TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; - -export interface Spec extends TurboModule { - // Exported methods. - +getConstants: () => {| - const1: boolean, - const2: number, - const3: string, - |}; - +voidFunc: () => void; - +getBool: (arg: boolean) => boolean; - +getNumber: (arg: number) => number; - +getString: (arg: string) => string; - +getArray: (arg: Array) => Array; - +getObject: (arg: Object) => Object; - +getRootTag: (arg: RootTag) => RootTag; - +getValue: (x: number, y: string, z: Object) => Object; - +getValueWithCallback: (callback: (value: string) => void) => void; - +getValueWithPromise: (error: boolean) => Promise; -} - -export default ( - ( - TurboModuleRegistry.getEnforcing('SampleTurboModule') || - TurboModuleRegistry.getEnforcing('SampleTurboModule2') - ): Spec); -`; - -const SAMPLE_TURBO_MODULE_MANY_MODULES_VARIABLE_ASSIGNMENT = ` -// @flow - -import type {RootTag, TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; - -export interface Spec extends TurboModule { - // Exported methods. - +getConstants: () => {| - const1: boolean, - const2: number, - const3: string, - |}; - +voidFunc: () => void; - +getBool: (arg: boolean) => boolean; - +getNumber: (arg: number) => number; - +getString: (arg: string) => string; - +getArray: (arg: Array) => Array; - +getObject: (arg: Object) => Object; - +getRootTag: (arg: RootTag) => RootTag; - +getValue: (x: number, y: string, z: Object) => Object; - +getValueWithCallback: (callback: (value: string) => void) => void; - +getValueWithPromise: (error: boolean) => Promise; -} - -const module1 = TurboModuleRegistry.getEnforcing( - 'SampleTurboModule', -); - -const module2 = TurboModuleRegistry.getEnforcing( - 'SampleTurboModule2', -); - -export default ((module1 || module2): Spec); -`; - module.exports = { 'NotANativeComponent.js': NOT_A_NATIVE_COMPONENT, 'FullNativeComponent.js': FULL_NATIVE_COMPONENT, 'FullTypedNativeComponent.js': FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT, 'NativeSampleTurboModule0.js': SAMPLE_TURBO_MODULE_SINGLE_DEFAULT_EXPORT, 'NativeSampleTurboModule1.js': SAMPLE_TURBO_MODULE_VARIABLE_ASSIGNMENT, - 'NativeSampleTurboModule2.js': SAMPLE_TURBO_MODULE_MANY_MODULES_DEFAULT_EXPORT, - 'NativeSampleTurboModule3.js': SAMPLE_TURBO_MODULE_MANY_MODULES_VARIABLE_ASSIGNMENT, }; diff --git a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap index df33cdacef093e..63a3798f838a6b 100644 --- a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap @@ -619,502 +619,6 @@ function __getModuleSchema() { }" `; -exports[`Babel plugin inline view configs can inline config for NativeSampleTurboModule2.js 1`] = ` -"// @flow -import type { RootTag, TurboModule } from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; -export interface Spec extends TurboModule { - // Exported methods. - +getConstants: () => {| - const1: boolean, - const2: number, - const3: string, - |}, - +voidFunc: () => void, - +getBool: (arg: boolean) => boolean, - +getNumber: (arg: number) => number, - +getString: (arg: string) => string, - +getArray: (arg: Array) => Array, - +getObject: (arg: Object) => Object, - +getRootTag: (arg: RootTag) => RootTag, - +getValue: (x: number, y: string, z: Object) => Object, - +getValueWithCallback: (callback: (value: string) => void) => void, - +getValueWithPromise: (error: boolean) => Promise, -} -export default (TurboModuleRegistry.getEnforcing('SampleTurboModule', __getModuleSchema()) || TurboModuleRegistry.getEnforcing('SampleTurboModule2', __getModuleSchema()): Spec); - -function __getModuleSchema() { - if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { - return undefined; - } - - return { - \\"type\\": \\"NativeModule\\", - \\"aliases\\": {}, - \\"spec\\": { - \\"properties\\": [{ - \\"name\\": \\"getConstants\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"ObjectTypeAnnotation\\", - \\"properties\\": [{ - \\"name\\": \\"const1\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - } - }, { - \\"name\\": \\"const2\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - } - }, { - \\"name\\": \\"const3\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }] - }, - \\"params\\": [] - } - }, { - \\"name\\": \\"voidFunc\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"VoidTypeAnnotation\\" - }, - \\"params\\": [] - } - }, { - \\"name\\": \\"getBool\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getNumber\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getString\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getArray\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"ArrayTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"ArrayTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getObject\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getRootTag\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"ReservedTypeAnnotation\\", - \\"name\\": \\"RootTag\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"ReservedTypeAnnotation\\", - \\"name\\": \\"RootTag\\" - } - }] - } - }, { - \\"name\\": \\"getValue\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"x\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - } - }, { - \\"name\\": \\"y\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }, { - \\"name\\": \\"z\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getValueWithCallback\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"VoidTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"callback\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"VoidTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"value\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }] - } - }] - } - }, { - \\"name\\": \\"getValueWithPromise\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"PromiseTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"error\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - } - }] - } - }] - }, - \\"moduleNames\\": [\\"SampleTurboModule\\", \\"SampleTurboModule2\\"] - }; -}" -`; - -exports[`Babel plugin inline view configs can inline config for NativeSampleTurboModule3.js 1`] = ` -"// @flow -import type { RootTag, TurboModule } from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; -export interface Spec extends TurboModule { - // Exported methods. - +getConstants: () => {| - const1: boolean, - const2: number, - const3: string, - |}, - +voidFunc: () => void, - +getBool: (arg: boolean) => boolean, - +getNumber: (arg: number) => number, - +getString: (arg: string) => string, - +getArray: (arg: Array) => Array, - +getObject: (arg: Object) => Object, - +getRootTag: (arg: RootTag) => RootTag, - +getValue: (x: number, y: string, z: Object) => Object, - +getValueWithCallback: (callback: (value: string) => void) => void, - +getValueWithPromise: (error: boolean) => Promise, -} -const module1 = TurboModuleRegistry.getEnforcing('SampleTurboModule', __getModuleSchema()); -const module2 = TurboModuleRegistry.getEnforcing('SampleTurboModule2', __getModuleSchema()); -export default (module1 || module2: Spec); - -function __getModuleSchema() { - if (!(global.RN$JSTurboModuleCodegenEnabled === true)) { - return undefined; - } - - return { - \\"type\\": \\"NativeModule\\", - \\"aliases\\": {}, - \\"spec\\": { - \\"properties\\": [{ - \\"name\\": \\"getConstants\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"ObjectTypeAnnotation\\", - \\"properties\\": [{ - \\"name\\": \\"const1\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - } - }, { - \\"name\\": \\"const2\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - } - }, { - \\"name\\": \\"const3\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }] - }, - \\"params\\": [] - } - }, { - \\"name\\": \\"voidFunc\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"VoidTypeAnnotation\\" - }, - \\"params\\": [] - } - }, { - \\"name\\": \\"getBool\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getNumber\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getString\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getArray\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"ArrayTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"ArrayTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getObject\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getRootTag\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"ReservedTypeAnnotation\\", - \\"name\\": \\"RootTag\\" - }, - \\"params\\": [{ - \\"name\\": \\"arg\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"ReservedTypeAnnotation\\", - \\"name\\": \\"RootTag\\" - } - }] - } - }, { - \\"name\\": \\"getValue\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"x\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"NumberTypeAnnotation\\" - } - }, { - \\"name\\": \\"y\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }, { - \\"name\\": \\"z\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"GenericObjectTypeAnnotation\\" - } - }] - } - }, { - \\"name\\": \\"getValueWithCallback\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"VoidTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"callback\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"VoidTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"value\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"StringTypeAnnotation\\" - } - }] - } - }] - } - }, { - \\"name\\": \\"getValueWithPromise\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"FunctionTypeAnnotation\\", - \\"returnTypeAnnotation\\": { - \\"type\\": \\"PromiseTypeAnnotation\\" - }, - \\"params\\": [{ - \\"name\\": \\"error\\", - \\"optional\\": false, - \\"typeAnnotation\\": { - \\"type\\": \\"BooleanTypeAnnotation\\" - } - }] - } - }] - }, - \\"moduleNames\\": [\\"SampleTurboModule\\", \\"SampleTurboModule2\\"] - }; -}" -`; - exports[`Babel plugin inline view configs can inline config for NotANativeComponent.js 1`] = ` "const requireNativeComponent = require('requireNativeComponent'); diff --git a/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js b/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js index 5e9913a365ca28..18880a57eac5b2 100644 --- a/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js +++ b/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js @@ -37,101 +37,6 @@ export default TurboModuleRegistry.get('XYZ'); }, ], }, - - // Untyped NativeModule require - { - code: ` -import {TurboModuleRegistry, type TurboModule} from 'react-native'; -export interface Spec extends TurboModule { - func1(a: string): {||}, -} -export default TurboModuleRegistry.get('XYZ'); - `, - filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`, - errors: [ - { - message: rule.errors.untypedModuleRequire('NativeXYZ', 'get'), - }, - ], - }, - - // Incorrectly typed NativeModule require: 0 types - { - code: ` -import {TurboModuleRegistry, type TurboModule} from 'react-native'; -export interface Spec extends TurboModule { - func1(a: string): {||}, -} -export default TurboModuleRegistry.get<>('XYZ'); - `, - filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`, - errors: [ - { - message: rule.errors.incorrectlyTypedModuleRequire('NativeXYZ', 'get'), - }, - ], - }, - - // Incorrectly typed NativeModule require: > 1 type - { - code: ` -import {TurboModuleRegistry, type TurboModule} from 'react-native'; -export interface Spec extends TurboModule { - func1(a: string): {||}, -} -export default TurboModuleRegistry.get('XYZ'); - `, - filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`, - errors: [ - { - message: rule.errors.incorrectlyTypedModuleRequire('NativeXYZ', 'get'), - }, - ], - }, - - // More than one TurboModuleRegistry call - { - code: ` -import {TurboModuleRegistry, type TurboModule} from 'react-native'; -export interface Spec extends TurboModule { - func1(a: string): {||}, -} -const NativeModule1 = TurboModuleRegistry.get('XYZ1'); -const NativeModule2 = TurboModuleRegistry.get('XYZ2'); -export default NativeModule1 || NativeModule2; - `, - filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`, - errors: [ - { - message: rule.errors.multipleModuleRequires('NativeXYZ', 2), - }, - { - message: rule.errors.multipleModuleRequires('NativeXYZ', 2), - }, - ], - }, - - // Called TurboModuleRegistry.getEnforcing with a variable - { - code: ` -import {TurboModuleRegistry, type TurboModule} from 'react-native'; -export interface Spec extends TurboModule { - func1(a: string): {||}, -} -const moduleName = 'foo'; -export default TurboModuleRegistry.get(moduleName); - `, - filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`, - errors: [ - { - message: rule.errors.calledModuleRequireWithWrongType( - 'NativeXYZ', - 'get', - 'Identifier', - ), - }, - ], - }, ]; eslintTester.run('../react-native-modules', rule, { diff --git a/packages/eslint-plugin-codegen/react-native-modules.js b/packages/eslint-plugin-codegen/react-native-modules.js index 1f294224932fa0..bf36595b0c87f7 100644 --- a/packages/eslint-plugin-codegen/react-native-modules.js +++ b/packages/eslint-plugin-codegen/react-native-modules.js @@ -17,26 +17,6 @@ const ERRORS = { misnamedHasteModule(hasteModuleName) { return `Module ${hasteModuleName}: All files using TurboModuleRegistry must start with Native.`; }, - untypedModuleRequire(hasteModuleName, requireMethodName) { - return `Module ${hasteModuleName}: Please type parameterize the Module require: TurboModuleRegistry.${requireMethodName}().`; - }, - incorrectlyTypedModuleRequire(hasteModuleName, requireMethodName) { - return `Module ${hasteModuleName}: Type parameter of Module require must be 'Spec': TurboModuleRegistry.${requireMethodName}().`; - }, - multipleModuleRequires(hasteModuleName, numCalls) { - return `Module ${hasteModuleName}: Module spec must contain exactly one call into TurboModuleRegistry, detected ${numCalls}.`; - }, - calledModuleRequireWithWrongType(hasteModuleName, requireMethodName, type) { - const a = /[aeiouy]/.test(type.toLowerCase()) ? 'an' : 'a'; - return `Module ${hasteModuleName}: TurboModuleRegistry.${requireMethodName}() must be called with a string literal, detected ${a} '${type}'.`; - }, - calledModuleRequireWithWrongLiteral( - hasteModuleName, - requireMethodName, - literal, - ) { - return `Module ${hasteModuleName}: TurboModuleRegistry.${requireMethodName}() must be called with a string literal, detected ${literal}`; - }, }; let RNModuleParser; @@ -116,23 +96,11 @@ function rule(context) { return {}; } - let moduleRequires = []; + let isModule = false; + return { 'Program:exit': function(node) { - if (moduleRequires.length === 0) { - return; - } - - if (moduleRequires.length > 1) { - moduleRequires.forEach(callExpressionNode => { - context.report({ - node: callExpressionNode, - message: ERRORS.multipleModuleRequires( - hasteModuleName, - moduleRequires.length, - ), - }); - }); + if (!isModule) { return; } @@ -154,11 +122,13 @@ function rule(context) { const sourceCode = context.getSourceCode().getText(); const ast = flowParser.parse(sourceCode); - guard(() => buildModuleSchema(hasteModuleName, [], ast, guard)); + guard(() => buildModuleSchema(hasteModuleName, ast, guard)); parsingErrors.forEach(error => { - context.report({ - loc: error.node.loc, - message: error.message, + error.nodes.forEach(flowNode => { + context.report({ + loc: flowNode.loc, + message: error.message, + }); }); }); }, @@ -167,82 +137,14 @@ function rule(context) { return; } - moduleRequires.push(node); - - /** - * Validate that NativeModule requires are typed - */ - - const {typeArguments} = node; - - if (typeArguments == null) { - const methodName = node.callee.property.name; - context.report({ - node, - message: ERRORS.untypedModuleRequire(hasteModuleName, methodName), - }); - return; - } - - if (typeArguments.type !== 'TypeParameterInstantiation') { - return; - } - - const [param] = typeArguments.params; - - /** - * Validate that NativeModule requires are correctly typed - */ - - if ( - typeArguments.params.length !== 1 || - param.type !== 'GenericTypeAnnotation' || - param.id.name !== 'Spec' - ) { - const methodName = node.callee.property.name; - context.report({ - node, - message: ERRORS.incorrectlyTypedModuleRequire( - hasteModuleName, - methodName, - ), - }); + isModule = true; + }, + InterfaceExtends(node) { + if (node.id.name !== 'TurboModule') { return; } - /** - * Validate the TurboModuleRegistry.get(...) argument - */ - - if (node.arguments.length === 1) { - const methodName = node.callee.property.name; - - if (node.arguments[0].type !== 'Literal') { - context.report({ - node: node.arguments[0], - message: ERRORS.calledModuleRequireWithWrongType( - hasteModuleName, - methodName, - node.arguments[0].type, - ), - }); - return; - } - - if (typeof node.arguments[0].value !== 'string') { - context.report({ - node: node.arguments[0], - message: ERRORS.calledModuleRequireWithWrongLiteral( - hasteModuleName, - methodName, - node.arguments[0].value, - ), - }); - return; - } - } - - return true; + isModule = true; }, }; } diff --git a/packages/react-native-codegen/src/parsers/flow/errors.js b/packages/react-native-codegen/src/parsers/flow/errors.js index 9a98c4dd334591..b480f321f592a4 100644 --- a/packages/react-native-codegen/src/parsers/flow/errors.js +++ b/packages/react-native-codegen/src/parsers/flow/errors.js @@ -11,11 +11,17 @@ 'use strict'; class ParserError extends Error { - node: $FlowFixMe; - constructor(hasteModuleName: string, astNode: $FlowFixMe, message: string) { + nodes: $ReadOnlyArray<$FlowFixMe>; + constructor( + hasteModuleName: string, + astNodeOrNodes: $FlowFixMe, + message: string, + ) { super(`Module ${hasteModuleName}: ${message}`); - this.node = astNode; + this.nodes = Array.isArray(astNodeOrNodes) + ? astNodeOrNodes + : [astNodeOrNodes]; // assign the error class name in your custom error (as a shortcut) this.name = this.constructor.name; diff --git a/packages/react-native-codegen/src/parsers/flow/index.js b/packages/react-native-codegen/src/parsers/flow/index.js index b33d32f99748b9..81787c79167c13 100644 --- a/packages/react-native-codegen/src/parsers/flow/index.js +++ b/packages/react-native-codegen/src/parsers/flow/index.js @@ -114,26 +114,6 @@ function getConfigType( } } -const withSpace = (...args) => args.join('\\s*'); -/** - * Parse the TurboModuleRegistry.get(Enforcing)? call using RegExp. - * Why? This call can appear anywhere in the NativeModule spec. Currently, - * there is no good way of traversing the AST to find the MemberExpression - * responsible for the call. - */ -const TURBO_MODULE_REGISTRY_REQUIRE_REGEX_STRING = withSpace( - 'TurboModuleRegistry', - '\\.', - 'get(Enforcing)?', - '<', - 'Spec', - '>', - '\\(', - '[\'"](?[A-Za-z$_0-9]+)[\'"]', - ',?', - '\\)', -); - function buildSchema(contents: string, filename: ?string): SchemaType { const ast = flowParser.parse(contents); @@ -147,36 +127,8 @@ function buildSchema(contents: string, filename: ?string): SchemaType { } const hasteModuleName = path.basename(filename).replace(/\.js$/, ''); - const regex = new RegExp(TURBO_MODULE_REGISTRY_REQUIRE_REGEX_STRING, 'g'); - let match = regex.exec(contents); - - const errorHeader = `Error while parsing Module '${hasteModuleName}'`; - - if (match == null) { - throw new Error( - `${errorHeader}: No call to TurboModuleRegistry.get('...') detected.`, - ); - } - - const moduleNames = []; - while (match != null) { - const resultGroups = match.groups; - invariant( - resultGroups != null, - `Couldn't parse TurboModuleRegistry.(get|getEnforcing) call in module '${hasteModuleName}'.`, - ); - - if (!moduleNames.includes(resultGroups.nativeModuleName)) { - moduleNames.push(resultGroups.nativeModuleName); - } - match = regex.exec(contents); - } - const [parsingErrors, guard] = createParserErrorCapturer(); - - const schema = guard(() => - buildModuleSchema(hasteModuleName, moduleNames, ast, guard), - ); + const schema = guard(() => buildModuleSchema(hasteModuleName, ast, guard)); if (parsingErrors.length > 0) { /** diff --git a/packages/react-native-codegen/src/parsers/flow/modules/errors.js b/packages/react-native-codegen/src/parsers/flow/modules/errors.js index 5a382052e0a8c6..b8baba4990cb22 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/errors.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/errors.js @@ -28,7 +28,7 @@ class ModuleFlowInterfaceNotParserError extends ParserError { super( hasteModuleName, ast, - `Module ${hasteModuleName}: No Flow interfaces extending TurboModule were detected in this NativeModule spec.`, + `Module ${hasteModuleName}: No Flow interfaces extending TurboModule were detected in this NativeNativeModule spec.`, ); } } @@ -206,6 +206,91 @@ class UnsupportedFunctionReturnTypeAnnotationParserError extends ParserError { } } +class UnusedModuleFlowInterfaceParserError extends ParserError { + constructor(hasteModuleName: string, flowInterface: $FlowFixMe) { + super( + hasteModuleName, + flowInterface, + "Unused NativeModule spec. Please load the NativeModule by calling TurboModuleRegistry.get('').", + ); + } +} + +class MoreThanOneModuleRegistryCallsParserError extends ParserError { + constructor( + hasteModuleName: string, + flowCallExpressions: $FlowFixMe, + numCalls: number, + ) { + super( + hasteModuleName, + flowCallExpressions, + `Every NativeModule spec file must contain exactly one NativeModule load. This file contains ${numCalls}. Please simplify this spec file, splitting it as necessary, to remove the extraneous loads.`, + ); + } +} + +class UntypedModuleRegistryCallParserError extends ParserError { + constructor( + hasteModuleName: string, + flowCallExpression: $FlowFixMe, + methodName: string, + moduleName: string, + ) { + super( + hasteModuleName, + flowCallExpression, + `Please type this NativeModule load: TurboModuleRegistry.${methodName}('${moduleName}').`, + ); + } +} + +class IncorrectModuleRegistryCallTypeParameterParserError extends ParserError { + constructor( + hasteModuleName: string, + flowTypeArguments: $FlowFixMe, + methodName: string, + moduleName: string, + ) { + super( + hasteModuleName, + flowTypeArguments, + `Please change these type arguments to reflect TurboModuleRegistry.${methodName}('${moduleName}').`, + ); + } +} + +class IncorrectModuleRegistryCallArityParserError extends ParserError { + constructor( + hasteModuleName: string, + flowCallExpression: $FlowFixMe, + methodName: string, + incorrectArity: number, + ) { + super( + hasteModuleName, + flowCallExpression, + `Please call TurboModuleRegistry.${methodName}() with exactly one argument. Detected ${incorrectArity}.`, + ); + } +} + +class IncorrectModuleRegistryCallArgumentTypeParserError extends ParserError { + constructor( + hasteModuleName: string, + flowArgument: $FlowFixMe, + methodName: string, + type: string, + ) { + const a = /[aeiouy]/.test(type.toLowerCase()) ? 'an' : 'a'; + super( + hasteModuleName, + flowArgument, + `Please call TurboModuleRegistry.${methodName}() with a string literal. Detected ${a} '${type}'`, + ); + } +} + module.exports = { IncorrectlyParameterizedFlowGenericParserError, MisnamedModuleFlowInterfaceParserError, @@ -219,4 +304,10 @@ module.exports = { UnsupportedModulePropertyParserError, UnsupportedObjectPropertyTypeAnnotationParserError, UnsupportedObjectPropertyValueTypeAnnotationParserError, + UnusedModuleFlowInterfaceParserError, + MoreThanOneModuleRegistryCallsParserError, + UntypedModuleRegistryCallParserError, + IncorrectModuleRegistryCallTypeParameterParserError, + IncorrectModuleRegistryCallArityParserError, + IncorrectModuleRegistryCallArgumentTypeParserError, }; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index c95308c7e5e802..8eb5737ec589b1 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -26,7 +26,7 @@ import type {TypeDeclarationMap} from '../utils.js'; import type {ParserErrorCapturer} from '../utils'; import type {NativeModuleTypeAnnotation} from '../../../CodegenSchema.js'; -const {resolveTypeAnnotation, getTypes} = require('../utils.js'); +const {resolveTypeAnnotation, getTypes, findChildren} = require('../utils.js'); const {unwrapNullable, wrapNullable} = require('./utils'); const { IncorrectlyParameterizedFlowGenericParserError, @@ -41,6 +41,12 @@ const { UnsupportedModulePropertyParserError, UnsupportedObjectPropertyTypeAnnotationParserError, UnsupportedObjectPropertyValueTypeAnnotationParserError, + UnusedModuleFlowInterfaceParserError, + MoreThanOneModuleRegistryCallsParserError, + UntypedModuleRegistryCallParserError, + IncorrectModuleRegistryCallTypeParameterParserError, + IncorrectModuleRegistryCallArityParserError, + IncorrectModuleRegistryCallArgumentTypeParserError, } = require('./errors.js'); const invariant = require('invariant'); @@ -520,9 +526,41 @@ function buildPropertySchema( }; } +function isCallIntoModuleRegistry(node) { + if (node.type !== 'CallExpression') { + return false; + } + + const callExpression = node; + + if (callExpression.callee.type !== 'MemberExpression') { + return false; + } + + const memberExpression = callExpression.callee; + if ( + !( + memberExpression.object.type === 'Identifier' && + memberExpression.object.name === 'TurboModuleRegistry' + ) + ) { + return false; + } + + if ( + !( + memberExpression.property.type === 'Identifier' && + (memberExpression.property.name === 'get' || + memberExpression.property.name === 'getEnforcing') + ) + ) { + return false; + } + return true; +} + function buildModuleSchema( hasteModuleName: string, - moduleNames: $ReadOnlyArray, /** * TODO(T71778680): Flow-type this node. */ @@ -555,6 +593,77 @@ function buildModuleSchema( ); } + // Parse Module Names + const moduleName = guard((): string => { + const callExpressions = findChildren(ast, isCallIntoModuleRegistry); + if (callExpressions.length === 0) { + throw new UnusedModuleFlowInterfaceParserError( + hasteModuleName, + types[moduleInterfaceName], + ); + } + + if (callExpressions.length > 1) { + throw new MoreThanOneModuleRegistryCallsParserError( + hasteModuleName, + callExpressions, + callExpressions.length, + ); + } + + const [callExpression] = callExpressions; + const {typeArguments} = callExpression; + const methodName = callExpression.callee.property.name; + + if (callExpression.arguments.length !== 1) { + throw new IncorrectModuleRegistryCallArityParserError( + hasteModuleName, + callExpression, + methodName, + callExpression.arguments.length, + ); + } + + if (callExpression.arguments[0].type !== 'Literal') { + const {type} = callExpression.arguments[0]; + throw new IncorrectModuleRegistryCallArgumentTypeParserError( + hasteModuleName, + callExpression.arguments[0], + methodName, + type, + ); + } + + const $moduleName = callExpression.arguments[0].value; + + if (typeArguments == null) { + throw new UntypedModuleRegistryCallParserError( + hasteModuleName, + callExpression, + methodName, + $moduleName, + ); + } + + if ( + typeArguments.type !== 'TypeParameterInstantiation' || + typeArguments.params.length !== 1 || + typeArguments.params[0].type !== 'GenericTypeAnnotation' || + typeArguments.params[0].id.name !== 'Spec' + ) { + throw new IncorrectModuleRegistryCallTypeParameterParserError( + hasteModuleName, + typeArguments, + methodName, + $moduleName, + ); + } + + return $moduleName; + }); + + const moduleNames = moduleName == null ? [] : [moduleName]; + // Some module names use platform suffix to indicate platform-exclusive modules. // Eventually this should be made explicit in the Flow type itself. // Also check the hasteModuleName for platform suffix. diff --git a/packages/react-native-codegen/src/parsers/flow/utils.js b/packages/react-native-codegen/src/parsers/flow/utils.js index d96f4d1b52ef99..6d91b98e4b0f05 100644 --- a/packages/react-native-codegen/src/parsers/flow/utils.js +++ b/packages/react-native-codegen/src/parsers/flow/utils.js @@ -137,9 +137,41 @@ function createParserErrorCapturer(): [ return [errors, guard]; } +// TODO(T71778680): Flow-type this node. +function findChildren( + astNode: $FlowFixMe, + predicate: (node: $FlowFixMe) => boolean, +): $ReadOnlyArray<$FlowFixMe> { + if (predicate(astNode)) { + return astNode; + } + + const found = []; + const queue = Object.values(astNode); + + while (queue.length !== 0) { + let item = queue.shift(); + + if (!(typeof item === 'object' && item != null)) { + continue; + } + + if (Array.isArray(item)) { + queue.push(...item); + } else if (typeof item.type === 'string' && predicate(item)) { + found.push(item); + } else { + queue.push(...Object.values(item)); + } + } + + return found; +} + module.exports = { getValueFromTypes, resolveTypeAnnotation, createParserErrorCapturer, getTypes, + findChildren, }; From 1de76d28422447f11d2864125999a09eece31e2e Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 4 Dec 2020 14:19:27 -0800 Subject: [PATCH 0156/1810] Rename the `guard` utility to `tryParse` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: ## What is `guard`? `guard` accepts some JavaScript function that can throw a ParserError. If a ParserError is thrown by that JavaScript function, it captures and pushes the error to some global array, and returns null. If no ParserError is thrown, it simply returns the return value of the JavaScript function. This utility is used in the NativeModule spec parser to help it continue parsing even after it detects errors. Why do we want to do this? In the NativeModule spec linter, we want to display all these ParserErrors via ESLint. ## Changes This diff renames `guard` to `tryParse` because `tryParse` more appropriately captures the intent/function of this utility: the work passed to it "tries" to parse some Flow types. A name like "guard" is a bit more ambiguous: What is it guarding against? What is the work doing? ¯\_(ツ)_/¯ Changelog: [Internal] Reviewed By: hramos Differential Revision: D25156185 fbshipit-source-id: 516647770579daa8613dbd67535074823f1aa848 --- .../react-native-modules.js | 8 +++-- .../src/parsers/flow/index.js | 6 ++-- .../src/parsers/flow/modules/index.js | 30 +++++++++---------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/eslint-plugin-codegen/react-native-modules.js b/packages/eslint-plugin-codegen/react-native-modules.js index bf36595b0c87f7..476624d024b705 100644 --- a/packages/eslint-plugin-codegen/react-native-modules.js +++ b/packages/eslint-plugin-codegen/react-native-modules.js @@ -118,11 +118,15 @@ function rule(context) { } = requireModuleParser(); const flowParser = require('flow-parser'); - const [parsingErrors, guard] = createParserErrorCapturer(); + const [parsingErrors, tryParse] = createParserErrorCapturer(); const sourceCode = context.getSourceCode().getText(); const ast = flowParser.parse(sourceCode); - guard(() => buildModuleSchema(hasteModuleName, ast, guard)); + + tryParse(() => { + buildModuleSchema(hasteModuleName, ast, tryParse); + }); + parsingErrors.forEach(error => { error.nodes.forEach(flowNode => { context.report({ diff --git a/packages/react-native-codegen/src/parsers/flow/index.js b/packages/react-native-codegen/src/parsers/flow/index.js index 81787c79167c13..00687f36d5246f 100644 --- a/packages/react-native-codegen/src/parsers/flow/index.js +++ b/packages/react-native-codegen/src/parsers/flow/index.js @@ -127,8 +127,10 @@ function buildSchema(contents: string, filename: ?string): SchemaType { } const hasteModuleName = path.basename(filename).replace(/\.js$/, ''); - const [parsingErrors, guard] = createParserErrorCapturer(); - const schema = guard(() => buildModuleSchema(hasteModuleName, ast, guard)); + const [parsingErrors, tryParse] = createParserErrorCapturer(); + const schema = tryParse(() => + buildModuleSchema(hasteModuleName, ast, tryParse), + ); if (parsingErrors.length > 0) { /** diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 8eb5737ec589b1..e3d49970311c7d 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -63,7 +63,7 @@ function translateTypeAnnotation( flowTypeAnnotation: $FlowFixMe, types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, - guard: ParserErrorCapturer, + tryParse: ParserErrorCapturer, ): Nullable { const { nullable, @@ -173,7 +173,7 @@ function translateTypeAnnotation( typeAnnotation.typeParameters.params[0], types, aliasMap, - guard, + tryParse, ); } case 'Stringish': { @@ -215,7 +215,7 @@ function translateTypeAnnotation( properties: (typeAnnotation.properties: Array<$FlowFixMe>) .map>>( property => { - return guard(() => { + return tryParse(() => { if (property.type !== 'ObjectTypeProperty') { throw new UnsupportedObjectPropertyTypeAnnotationParserError( hasteModuleName, @@ -235,7 +235,7 @@ function translateTypeAnnotation( property.value, types, aliasMap, - guard, + tryParse, ), ); @@ -351,7 +351,7 @@ function translateTypeAnnotation( typeAnnotation, types, aliasMap, - guard, + tryParse, ), ); } @@ -397,13 +397,13 @@ function translateFunctionTypeAnnotation( flowFunctionTypeAnnotation: $FlowFixMe, types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, - guard: ParserErrorCapturer, + tryParse: ParserErrorCapturer, ): NativeModuleFunctionTypeAnnotation { type Param = NamedShape>; const params: Array = []; for (const flowParam of (flowFunctionTypeAnnotation.params: $ReadOnlyArray<$FlowFixMe>)) { - const parsedParam = guard(() => { + const parsedParam = tryParse(() => { if (flowParam.name == null) { throw new UnnamedFunctionParamParserError(flowParam, hasteModuleName); } @@ -418,7 +418,7 @@ function translateFunctionTypeAnnotation( flowParam.typeAnnotation, types, aliasMap, - guard, + tryParse, ), ); @@ -461,7 +461,7 @@ function translateFunctionTypeAnnotation( flowFunctionTypeAnnotation.returnType, types, aliasMap, - guard, + tryParse, ), ); @@ -492,7 +492,7 @@ function buildPropertySchema( property: $FlowFixMe, types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, - guard: ParserErrorCapturer, + tryParse: ParserErrorCapturer, ): NativeModulePropertyShape { let nullable = false; let {key, value} = property; @@ -520,7 +520,7 @@ function buildPropertySchema( value, types, aliasMap, - guard, + tryParse, ), ), }; @@ -565,7 +565,7 @@ function buildModuleSchema( * TODO(T71778680): Flow-type this node. */ ast: $FlowFixMe, - guard: ParserErrorCapturer, + tryParse: ParserErrorCapturer, ): NativeModuleSchema { const types = getTypes(ast); const moduleInterfaceNames = (Object.keys( @@ -594,7 +594,7 @@ function buildModuleSchema( } // Parse Module Names - const moduleName = guard((): string => { + const moduleName = tryParse((): string => { const callExpressions = findChildren(ast, isCallIntoModuleRegistry); if (callExpressions.length === 0) { throw new UnusedModuleFlowInterfaceParserError( @@ -687,14 +687,14 @@ function buildModuleSchema( }>(property => { const aliasMap: {...NativeModuleAliasMap} = {}; - return guard(() => ({ + return tryParse(() => ({ aliasMap: aliasMap, propertyShape: buildPropertySchema( hasteModuleName, property, types, aliasMap, - guard, + tryParse, ), })); }) From 3e5779ce93dfa5ece9c43b9cde88a1fc3e3885e9 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 4 Dec 2020 14:19:27 -0800 Subject: [PATCH 0157/1810] Move num(NativeModule flow interface) > 1 error into `buildModuleSchema` Summary: **Motivation:** After this change, we can show this ParserError using the React Native Module ESLint rule. Previously when we declared more than one NativeModule spec in a file, we incorrectly reported that there were *no* NativeModule specs in the file. Changelog: [Internal] Reviewed By: hramos Differential Revision: D25163299 fbshipit-source-id: 92bc09d09cdbc323e0ac1f317c40a767880f5bc2 --- .../src/parsers/flow/index.js | 8 ------ .../module-parser-snapshot-test.js.snap | 2 +- .../src/parsers/flow/modules/errors.js | 28 +++++++++++++++++-- .../src/parsers/flow/modules/index.js | 15 ++++++++-- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/packages/react-native-codegen/src/parsers/flow/index.js b/packages/react-native-codegen/src/parsers/flow/index.js index 00687f36d5246f..1462be4350b11a 100644 --- a/packages/react-native-codegen/src/parsers/flow/index.js +++ b/packages/react-native-codegen/src/parsers/flow/index.js @@ -77,14 +77,6 @@ function isModule( return false; } - if (moduleInterfaces.length > 1) { - throw new Error( - 'File contains declarations of more than one module: ' + - moduleInterfaces.join(', ') + - '. Please declare exactly one module in this file.', - ); - } - return true; } diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap index 0592287aea105d..1ce7e4797ddad4 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap @@ -12,7 +12,7 @@ exports[`RN Codegen Flow Parser Fails with error message NATIVE_MODULES_WITH_REA exports[`RN Codegen Flow Parser Fails with error message NATIVE_MODULES_WITH_UNNAMED_PARAMS 1`] = `"Module NativeSampleTurboModule: All function parameters must be named."`; -exports[`RN Codegen Flow Parser Fails with error message TWO_NATIVE_EXTENDING_TURBO_MODULE 1`] = `"File contains declarations of more than one module: Spec, Spec2. Please declare exactly one module in this file."`; +exports[`RN Codegen Flow Parser Fails with error message TWO_NATIVE_EXTENDING_TURBO_MODULE 1`] = `"Module NativeSampleTurboModule: Every NativeModule spec file must declare exactly one NativeModule Flow interface. This file declares 2: 'Spec', and 'Spec2'. Please remove the extraneous Flow interface declarations."`; exports[`RN Codegen Flow Parser Fails with error message TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT 1`] = `"File neither contains a module declaration, nor a component declaration. For module declarations, please make sure your file has an InterfaceDeclaration extending TurboModule. For component declarations, please make sure your file has a default export calling the codegenNativeComponent(...) macro."`; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/errors.js b/packages/react-native-codegen/src/parsers/flow/modules/errors.js index b8baba4990cb22..370262cfcb7448 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/errors.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/errors.js @@ -23,12 +23,33 @@ class MisnamedModuleFlowInterfaceParserError extends ParserError { } } -class ModuleFlowInterfaceNotParserError extends ParserError { +class ModuleFlowInterfaceNotFoundParserError extends ParserError { constructor(hasteModuleName: string, ast: $FlowFixMe) { super( hasteModuleName, ast, - `Module ${hasteModuleName}: No Flow interfaces extending TurboModule were detected in this NativeNativeModule spec.`, + 'No Flow interfaces extending TurboModule were detected in this NativeModule spec.', + ); + } +} + +class MoreThanOneModuleFlowInterfaceParserError extends ParserError { + constructor( + hasteModuleName: string, + flowModuleInterfaces: $ReadOnlyArray<$FlowFixMe>, + names: $ReadOnlyArray, + ) { + const finalName = names[names.length - 1]; + const allButLastName = names.slice(0, -1); + const quote = x => `'${x}'`; + + const nameStr = + allButLastName.map(quote).join(', ') + ', and ' + quote(finalName); + + super( + hasteModuleName, + flowModuleInterfaces, + `Every NativeModule spec file must declare exactly one NativeModule Flow interface. This file declares ${names.length}: ${nameStr}. Please remove the extraneous Flow interface declarations.`, ); } } @@ -294,7 +315,8 @@ class IncorrectModuleRegistryCallArgumentTypeParserError extends ParserError { module.exports = { IncorrectlyParameterizedFlowGenericParserError, MisnamedModuleFlowInterfaceParserError, - ModuleFlowInterfaceNotParserError, + ModuleFlowInterfaceNotFoundParserError, + MoreThanOneModuleFlowInterfaceParserError, UnnamedFunctionParamParserError, UnsupportedArrayElementTypeAnnotationParserError, UnsupportedFlowGenericParserError, diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index e3d49970311c7d..178519bef9e69b 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -31,7 +31,8 @@ const {unwrapNullable, wrapNullable} = require('./utils'); const { IncorrectlyParameterizedFlowGenericParserError, MisnamedModuleFlowInterfaceParserError, - ModuleFlowInterfaceNotParserError, + ModuleFlowInterfaceNotFoundParserError, + MoreThanOneModuleFlowInterfaceParserError, UnnamedFunctionParamParserError, UnsupportedArrayElementTypeAnnotationParserError, UnsupportedFlowGenericParserError, @@ -580,8 +581,16 @@ function buildModuleSchema( ); }); - if (moduleInterfaceNames.length !== 1) { - throw new ModuleFlowInterfaceNotParserError(hasteModuleName, ast); + if (moduleInterfaceNames.length === 0) { + throw new ModuleFlowInterfaceNotFoundParserError(hasteModuleName, ast); + } + + if (moduleInterfaceNames.length > 1) { + throw new MoreThanOneModuleFlowInterfaceParserError( + hasteModuleName, + moduleInterfaceNames.map(name => types[name]), + moduleInterfaceNames, + ); } const [moduleInterfaceName] = moduleInterfaceNames; From 898f73deef5bdf0e87a9f3d8d4f0f3b1d20f87bb Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 4 Dec 2020 14:19:27 -0800 Subject: [PATCH 0158/1810] Introduce `visit(ast, visitor)` utility Summary: In the Codegen, we need to answer the following questions: *Question:* What are all the calls into TurboModuleRegistry? *Answer:* Find all CallExpressions that represent TurboModuleRegistry.get() or TurboModuleRegisty.getEnforcing(). *Question:* Is this a component spec? *Answer:* Does this spec have a CallExpression where the callee is 'codegenNativeComponent'? *Question:* Is this a module spec? *Answer:* Does this spec have an interface that extends TurboModule? All these answers can be implemented using the visitor pattern. Hence, this diff introduces the `visit` utility, and uses it to answer these questions. **Motivation:** Cleaner code. Changelog: [Internal] Reviewed By: hramos Differential Revision: D25162617 fbshipit-source-id: 66ec95fc07ecb29aa9bf9993cb826204af283d03 --- .../src/parsers/flow/index.js | 141 +++++++----------- .../src/parsers/flow/modules/index.js | 56 ++++--- .../src/parsers/flow/utils.js | 32 ++-- 3 files changed, 99 insertions(+), 130 deletions(-) diff --git a/packages/react-native-codegen/src/parsers/flow/index.js b/packages/react-native-codegen/src/parsers/flow/index.js index 1462be4350b11a..0cf479b01b14ae 100644 --- a/packages/react-native-codegen/src/parsers/flow/index.js +++ b/packages/react-native-codegen/src/parsers/flow/index.js @@ -19,83 +19,41 @@ const {buildComponentSchema} = require('./components'); const {wrapComponentSchema} = require('./components/schema'); const {buildModuleSchema} = require('./modules'); const {wrapModuleSchema} = require('./modules/schema'); -const {createParserErrorCapturer} = require('./utils'); +const {createParserErrorCapturer, visit} = require('./utils'); const invariant = require('invariant'); -function isComponent(ast) { - const defaultExports = ast.body.filter( - node => node.type === 'ExportDefaultDeclaration', - ); - - if (defaultExports.length === 0) { - return false; - } - - let declaration = defaultExports[0].declaration; - // codegenNativeComponent can be nested inside a cast - // expression so we need to go one level deeper - if (declaration.type === 'TypeCastExpression') { - declaration = declaration.expression; - } - - if (declaration.type !== 'CallExpression') { - return false; - } - - return ( - declaration.callee.type === 'Identifier' && - declaration.callee.name === 'codegenNativeComponent' - ); -} - -function isModule( +function getConfigType( // TODO(T71778680): Flow-type this node. ast: $FlowFixMe, -) { - const moduleInterfaces = ast.body - .map(node => { +): 'module' | 'component' { + let isComponent = false; + let isModule = false; + + visit(ast, { + CallExpression(node) { if ( - node.type === 'ExportNamedDeclaration' && - node.exportKind === 'type' && - node.declaration.type === 'InterfaceDeclaration' + node.callee.type === 'Identifier' && + node.callee.name === 'codegenNativeComponent' ) { - return node.declaration; + isComponent = true; } - return node; - }) - .filter(declaration => { - return ( - declaration.type === 'InterfaceDeclaration' && - declaration.extends.length === 1 && - declaration.extends[0].type === 'InterfaceExtends' && - declaration.extends[0].id.name === 'TurboModule' - ); - }) - .map(declaration => declaration.id.name); - - if (moduleInterfaces.length === 0) { - return false; - } - - return true; -} - -function getConfigType( - // TODO(T71778680): Flow-type this node. - ast: $FlowFixMe, -): 'module' | 'component' { - const isConfigAComponent = isComponent(ast); - const isConfigAModule = isModule(ast); + }, + InterfaceExtends(node) { + if (node.id.name === 'TurboModule') { + isModule = true; + } + }, + }); - if (isConfigAModule && isConfigAComponent) { + if (isModule && isComponent) { throw new Error( 'Found type extending "TurboModule" and exported "codegenNativeComponent" declaration in one file. Split them into separated files.', ); } - if (isConfigAModule) { + if (isModule) { return 'module'; - } else if (isConfigAComponent) { + } else if (isComponent) { return 'component'; } else { throw new Error( @@ -108,40 +66,45 @@ function getConfigType( function buildSchema(contents: string, filename: ?string): SchemaType { const ast = flowParser.parse(contents); - const configType = getConfigType(ast); - if (configType === 'component') { - return wrapComponentSchema(buildComponentSchema(ast)); - } else { - if (filename === undefined || filename === null) { - throw new Error('Filepath expected while parasing a module'); + switch (configType) { + case 'component': { + return wrapComponentSchema(buildComponentSchema(ast)); } - const hasteModuleName = path.basename(filename).replace(/\.js$/, ''); + case 'module': { + if (filename === undefined || filename === null) { + throw new Error('Filepath expected while parasing a module'); + } + const hasteModuleName = path.basename(filename).replace(/\.js$/, ''); - const [parsingErrors, tryParse] = createParserErrorCapturer(); - const schema = tryParse(() => - buildModuleSchema(hasteModuleName, ast, tryParse), - ); + const [parsingErrors, tryParse] = createParserErrorCapturer(); + const schema = tryParse(() => + buildModuleSchema(hasteModuleName, ast, tryParse), + ); - if (parsingErrors.length > 0) { - /** - * TODO(T77968131): We have two options: - * - Throw the first error, but indicate there are more then one errors. - * - Display all errors, nicely formatted. - * - * For the time being, we're just throw the first error. - **/ + if (parsingErrors.length > 0) { + /** + * TODO(T77968131): We have two options: + * - Throw the first error, but indicate there are more then one errors. + * - Display all errors, nicely formatted. + * + * For the time being, we're just throw the first error. + **/ - throw parsingErrors[0]; - } + throw parsingErrors[0]; + } - invariant( - schema != null, - 'When there are no parsing errors, the schema should not be null', - ); + invariant( + schema != null, + 'When there are no parsing errors, the schema should not be null', + ); - return wrapModuleSchema(schema, hasteModuleName); + return wrapModuleSchema(schema, hasteModuleName); + } + default: + (configType: empty); + throw new Error(`Unsupported config type '${configType}'`); } } diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 178519bef9e69b..955f8358d5ab5f 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -26,7 +26,7 @@ import type {TypeDeclarationMap} from '../utils.js'; import type {ParserErrorCapturer} from '../utils'; import type {NativeModuleTypeAnnotation} from '../../../CodegenSchema.js'; -const {resolveTypeAnnotation, getTypes, findChildren} = require('../utils.js'); +const {resolveTypeAnnotation, getTypes, visit} = require('../utils.js'); const {unwrapNullable, wrapNullable} = require('./utils'); const { IncorrectlyParameterizedFlowGenericParserError, @@ -527,7 +527,7 @@ function buildPropertySchema( }; } -function isCallIntoModuleRegistry(node) { +function isModuleRegistryCall(node) { if (node.type !== 'CallExpression') { return false; } @@ -560,6 +560,15 @@ function isCallIntoModuleRegistry(node) { return true; } +function isModuleInterface(node) { + return ( + node.type === 'InterfaceDeclaration' && + node.extends.length === 1 && + node.extends[0].type === 'InterfaceExtends' && + node.extends[0].id.name === 'TurboModule' + ); +} + function buildModuleSchema( hasteModuleName: string, /** @@ -569,46 +578,46 @@ function buildModuleSchema( tryParse: ParserErrorCapturer, ): NativeModuleSchema { const types = getTypes(ast); - const moduleInterfaceNames = (Object.keys( - types, - ): $ReadOnlyArray).filter((typeName: string) => { - const declaration = types[typeName]; - return ( - declaration.type === 'InterfaceDeclaration' && - declaration.extends.length === 1 && - declaration.extends[0].type === 'InterfaceExtends' && - declaration.extends[0].id.name === 'TurboModule' - ); - }); + const moduleSpecs = (Object.values(types): $ReadOnlyArray<$FlowFixMe>).filter( + isModuleInterface, + ); - if (moduleInterfaceNames.length === 0) { + if (moduleSpecs.length === 0) { throw new ModuleFlowInterfaceNotFoundParserError(hasteModuleName, ast); } - if (moduleInterfaceNames.length > 1) { + if (moduleSpecs.length > 1) { throw new MoreThanOneModuleFlowInterfaceParserError( hasteModuleName, - moduleInterfaceNames.map(name => types[name]), - moduleInterfaceNames, + moduleSpecs, + moduleSpecs.map(node => node.id.name), ); } - const [moduleInterfaceName] = moduleInterfaceNames; + const [moduleSpec] = moduleSpecs; - if (moduleInterfaceName !== 'Spec') { + if (moduleSpec.id.name !== 'Spec') { throw new MisnamedModuleFlowInterfaceParserError( hasteModuleName, - types[moduleInterfaceName].id, + moduleSpec.id, ); } // Parse Module Names const moduleName = tryParse((): string => { - const callExpressions = findChildren(ast, isCallIntoModuleRegistry); + const callExpressions = []; + visit(ast, { + CallExpression(node) { + if (isModuleRegistryCall(node)) { + callExpressions.push(node); + } + }, + }); + if (callExpressions.length === 0) { throw new UnusedModuleFlowInterfaceParserError( hasteModuleName, - types[moduleInterfaceName], + moduleSpec, ); } @@ -687,8 +696,7 @@ function buildModuleSchema( } }); - const declaration = types[moduleInterfaceName]; - return (declaration.body.properties: $ReadOnlyArray<$FlowFixMe>) + return (moduleSpec.body.properties: $ReadOnlyArray<$FlowFixMe>) .filter(property => property.type === 'ObjectTypeProperty') .map boolean, -): $ReadOnlyArray<$FlowFixMe> { - if (predicate(astNode)) { - return astNode; - } - - const found = []; - const queue = Object.values(astNode); - + visitor: { + [type: string]: (node: $FlowFixMe) => void, + }, +) { + const queue = [astNode]; while (queue.length !== 0) { let item = queue.shift(); @@ -156,16 +152,18 @@ function findChildren( continue; } - if (Array.isArray(item)) { + if ( + typeof item.type === 'string' && + typeof visitor[item.type] === 'function' + ) { + // Don't visit any children + visitor[item.type](item); + } else if (Array.isArray(item)) { queue.push(...item); - } else if (typeof item.type === 'string' && predicate(item)) { - found.push(item); } else { queue.push(...Object.values(item)); } } - - return found; } module.exports = { @@ -173,5 +171,5 @@ module.exports = { resolveTypeAnnotation, createParserErrorCapturer, getTypes, - findChildren, + visit, }; From c224e9f15521842b0de9f98d9654a131ae00349f Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 4 Dec 2020 14:44:09 -0800 Subject: [PATCH 0159/1810] Fix LayoutAnimations issue that could result in elements getting stuck with opacity ~0 Summary: If a ShadowNode is being animated from opacity 0 to 1, and that animation is interrupted by another update to the same ShadowNode, we stop the animation and send the original "final" ShadowView to the mounting layer. On iOS, this is enough to make the Mounting layer consistent with the Shadow layer. However, on Android, since only prop deltas are passed to the mounting layer and not the entire props bag, this will NOT be enough because the opacity will not be updated in that final step. Therefore, in those cases where we've detected a conflict and we're cleaning up after an interrupted animation, we must send two updates to the mounting layer: one to force the opacity to 1, and another to make the ShadowTree consistent with the Mounting layer. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D25324942 fbshipit-source-id: 5d9666128feaae87d7530c394ef05db580aa5a75 --- .../LayoutAnimationKeyFrameManager.cpp | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 512fe8274cd73b..24a8fb9296ce6b 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1242,14 +1242,34 @@ LayoutAnimationKeyFrameManager::pullTransaction( // for, for example, INSERT mutations being animated from opacity 0 // to 1. If the animation is interrupted we must force the View to be // at opacity 1. + // For Android - since it passes along only deltas, not an entire bag + // of props - generate an "animation" frame corresponding to a final + // update for this view. Only then, generate an update that will cause + // the ShadowTree to be consistent with the Mounting layer by passing + // viewEnd, unmodified, to the mounting layer. This helps with, for + // example, opacity animations. + auto mutatedShadowView = createInterpolatedShadowView( + 1, keyFrame.viewStart, keyFrame.viewEnd); + auto generatedPenultimateMutation = + ShadowViewMutation::UpdateMutation( + keyFrame.parentView, + keyFrame.viewPrev, + mutatedShadowView, + -1); + assert(generatedPenultimateMutation.oldChildShadowView.tag != 0); + assert(generatedPenultimateMutation.newChildShadowView.tag != 0); + PrintMutationInstruction( + "Queueing up penultimate mutation instruction - synthetic", + generatedPenultimateMutation); + finalConflictingMutations.push_back(generatedPenultimateMutation); + auto generatedMutation = ShadowViewMutation::UpdateMutation( - keyFrame.parentView, keyFrame.viewPrev, keyFrame.viewEnd, -1); + keyFrame.parentView, mutatedShadowView, keyFrame.viewEnd, -1); assert(generatedMutation.oldChildShadowView.tag != 0); assert(generatedMutation.newChildShadowView.tag != 0); PrintMutationInstruction( "Queueing up final mutation instruction - synthetic", generatedMutation); - // Create the mutation instruction finalConflictingMutations.push_back(generatedMutation); } } @@ -1407,14 +1427,35 @@ LayoutAnimationKeyFrameManager::pullTransaction( // for, for example, INSERT mutations being animated from opacity 0 // to 1. If the animation is interrupted we must force the View to be // at opacity 1. + // For Android - since it passes along only deltas, not an entire bag + // of props - generate an "animation" frame corresponding to a final + // update for this view. Only then, generate an update that will cause + // the ShadowTree to be consistent with the Mounting layer by passing + // viewEnd, unmodified, to the mounting layer. This helps with, for + // example, opacity animations. + auto mutatedShadowView = createInterpolatedShadowView( + 1, keyFrame.viewStart, keyFrame.viewEnd); + auto generatedPenultimateMutation = + ShadowViewMutation::UpdateMutation( + keyFrame.parentView, + keyFrame.viewPrev, + mutatedShadowView, + -1); + assert(generatedPenultimateMutation.oldChildShadowView.tag != 0); + assert(generatedPenultimateMutation.newChildShadowView.tag != 0); + PrintMutationInstruction( + "No Animation: Queueing up penultimate mutation instruction - synthetic", + generatedPenultimateMutation); + finalMutationsForConflictingAnimations.push_back( + generatedPenultimateMutation); + auto generatedMutation = ShadowViewMutation::UpdateMutation( - keyFrame.parentView, keyFrame.viewPrev, keyFrame.viewEnd, -1); + keyFrame.parentView, mutatedShadowView, keyFrame.viewEnd, -1); assert(generatedMutation.oldChildShadowView.tag != 0); assert(generatedMutation.newChildShadowView.tag != 0); PrintMutationInstruction( - "Queueing up final mutation instruction - synthetic", + "No Animation: Queueing up final mutation instruction - synthetic", generatedMutation); - // Create the mutation instructions finalMutationsForConflictingAnimations.push_back(generatedMutation); } } From dee937c7c12902f3a0465cd6f347c3f21f6a9e04 Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Fri, 4 Dec 2020 18:10:29 -0800 Subject: [PATCH 0160/1810] Fix retain cycle in RCTAlertController Summary: `RCTAlertController` creates a new window, and presents itself in that window. RCTAlertController strongly retains the window, and the window strongly retains RCTAlertController when presenting it. This adds a new method to break that cycle once alert is dismissed. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25312413 fbshipit-source-id: e4048922aa697eb42c4c149827bac61bc7bc5528 --- React/CoreModules/RCTAlertController.h | 3 ++- React/CoreModules/RCTAlertController.m | 5 +++++ React/CoreModules/RCTAlertManager.mm | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/React/CoreModules/RCTAlertController.h b/React/CoreModules/RCTAlertController.h index ada35e81fd846e..f5c206cb1226b4 100644 --- a/React/CoreModules/RCTAlertController.h +++ b/React/CoreModules/RCTAlertController.h @@ -10,5 +10,6 @@ @interface RCTAlertController : UIAlertController - (void)show:(BOOL)animated completion:(void (^)(void))completion; +- (void)hide; -@end \ No newline at end of file +@end diff --git a/React/CoreModules/RCTAlertController.m b/React/CoreModules/RCTAlertController.m index e38c5005a8ff62..8cd0babb5595c0 100644 --- a/React/CoreModules/RCTAlertController.m +++ b/React/CoreModules/RCTAlertController.m @@ -33,4 +33,9 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion [self.alertWindow.rootViewController presentViewController:self animated:animated completion:completion]; } +- (void)hide +{ + _alertWindow = nil; +} + @end diff --git a/React/CoreModules/RCTAlertManager.mm b/React/CoreModules/RCTAlertManager.mm index 425951e60f8c3e..e0f450e480e703 100644 --- a/React/CoreModules/RCTAlertManager.mm +++ b/React/CoreModules/RCTAlertManager.mm @@ -161,6 +161,7 @@ - (void)invalidate case RCTAlertViewStylePlainTextInput: case RCTAlertViewStyleSecureTextInput: callback(@[ buttonKey, [weakAlertController.textFields.firstObject text] ]); + [weakAlertController hide]; break; case RCTAlertViewStyleLoginAndPasswordInput: { NSDictionary *loginCredentials = @{ @@ -168,10 +169,12 @@ - (void)invalidate @"password" : [weakAlertController.textFields.lastObject text] }; callback(@[ buttonKey, loginCredentials ]); + [weakAlertController hide]; break; } case RCTAlertViewStyleDefault: callback(@[ buttonKey ]); + [weakAlertController hide]; break; } }]]; From 74a756846fdab1ef7d183c4df3069a23fcd0d49e Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 4 Dec 2020 19:55:54 -0800 Subject: [PATCH 0161/1810] Fix race condition on startSurface Summary: The root cause of this bug is a race condition between the onMeasure method and setupReactContext. ReactInstanceManager.attachRootView() method is responsible of the initialization of ReactRootViews and it is invoked by ReactRootView.onMeasure() method in the UIThread Important initialization steps: 1. Clear the Id of the ReactRootView 2. Add the ReactRootView to the mAttachedReactRoots 3. Call StartSurface (if the bridge has been initialized) Sometimes, when this method is invoked for the first time, the bridge is not initialized, in those cases we delay the start of the surface. Once the bridge is initialized, StartSurface is called by the setupReactContext() running in the NativeModuleThread. Since onMeasure can be called multiple times, it is possible that we call "StartSurface" twice for the same ReactRootView, causing the bug reported on T78832286. This diff adds an extra check to prevent calling "StartSurface" twice. The fix is done using an AtomicInteger comparison and it is gated by the flag "enableStartSurfaceRaceConditionFix". Once we verify this works fine in production we will clean up the code, remove the flags and maybe revisit the API of ReactRoot. changelog: [Android] Fix race-condition on the initialization of ReactRootViews Reviewed By: JoshuaGross Differential Revision: D25255877 fbshipit-source-id: ca8fb00f50e86891fb4c5a06240177cc1a0186d9 --- .../facebook/react/ReactInstanceManager.java | 29 +++++++++++++++---- .../com/facebook/react/ReactRootView.java | 6 ++++ .../react/config/ReactFeatureFlags.java | 6 ++++ .../facebook/react/uimanager/ReactRoot.java | 14 +++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index d685867afbbf77..95026e8385f86b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -795,6 +795,9 @@ public void showDevOptionsDialog() { } private void clearReactRoot(ReactRoot reactRoot) { + if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) { + reactRoot.getState().compareAndSet(ReactRoot.STATE_STARTED, ReactRoot.STATE_STOPPED); + } reactRoot.getRootViewGroup().removeAllViews(); reactRoot.getRootViewGroup().setId(View.NO_ID); } @@ -810,17 +813,28 @@ private void clearReactRoot(ReactRoot reactRoot) { @ThreadConfined(UI) public void attachRootView(ReactRoot reactRoot) { UiThreadUtil.assertOnUiThread(); - mAttachedReactRoots.add(reactRoot); - // Reset reactRoot content as it's going to be populated by the application content from JS. - clearReactRoot(reactRoot); + // Calling clearReactRoot is necessary to initialize the Id on reactRoot + // This is necessary independently if the RN Bridge has been initialized or not. + // Ideally reactRoot should be initialized with id == NO_ID + if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) { + if (mAttachedReactRoots.add(reactRoot)) { + clearReactRoot(reactRoot); + } + } else { + mAttachedReactRoots.add(reactRoot); + clearReactRoot(reactRoot); + } // If react context is being created in the background, JS application will be started // automatically when creation completes, as reactRoot reactRoot is part of the attached // reactRoot reactRoot list. ReactContext currentContext = getCurrentReactContext(); if (mCreateReactContextThread == null && currentContext != null) { - attachRootViewToInstance(reactRoot); + if (!ReactFeatureFlags.enableStartSurfaceRaceConditionFix + || reactRoot.getState().compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) { + attachRootViewToInstance(reactRoot); + } } } @@ -1087,7 +1101,12 @@ private void setupReactContext(final ReactApplicationContext reactContext) { ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_START); for (ReactRoot reactRoot : mAttachedReactRoots) { - attachRootViewToInstance(reactRoot); + if (!ReactFeatureFlags.enableStartSurfaceRaceConditionFix + || reactRoot + .getState() + .compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) { + attachRootViewToInstance(reactRoot); + } } ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_END); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index d15ad24067a87d..bac18eed25ef04 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -56,6 +56,7 @@ import com.facebook.react.uimanager.common.UIManagerType; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.systrace.Systrace; +import java.util.concurrent.atomic.AtomicInteger; /** * Default root view for catalyst apps. Provides the ability to listen for size changes so that a UI @@ -98,6 +99,7 @@ public interface ReactRootViewEventListener { private int mLastOffsetX = Integer.MIN_VALUE; private int mLastOffsetY = Integer.MIN_VALUE; private @UIManagerType int mUIManagerType = DEFAULT; + private final AtomicInteger mState = new AtomicInteger(STATE_STOPPED); public ReactRootView(Context context) { super(context); @@ -413,6 +415,10 @@ public String getSurfaceID() { return appProperties != null ? appProperties.getString("surfaceID") : null; } + public AtomicInteger getState() { + return mState; + } + public static Point getViewportOffset(View v) { int[] locationInWindow = new int[2]; v.getLocationInWindow(locationInWindow); diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 7d1729782db3f8..260d366e29019a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -91,4 +91,10 @@ public class ReactFeatureFlags { /** Disable UI update operations in non-Fabric renderer after catalyst instance was destroyed */ public static boolean disableNonFabricViewOperationsOnCatalystDestroy = false; + + /** + * Fixes race-condition in the initialization of RN surface. TODO T78832286: remove this flag once + * we verify the fix is correct in production + */ + public static boolean enableStartSurfaceRaceConditionFix = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRoot.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRoot.java index 2fba8c52164c75..9ce17ea680954a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRoot.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRoot.java @@ -11,10 +11,16 @@ import android.view.ViewGroup; import androidx.annotation.Nullable; import com.facebook.react.uimanager.common.UIManagerType; +import java.util.concurrent.atomic.AtomicInteger; /** Interface for the root native view of a React native application */ public interface ReactRoot { + /** This constant represents that ReactRoot hasn't started yet or it has been destroyed. */ + int STATE_STOPPED = 0; + /** This constant represents that ReactRoot has started. */ + int STATE_STARTED = 1; + /** Return cached launch properties for app */ @Nullable Bundle getAppProperties(); @@ -58,4 +64,12 @@ public interface ReactRoot { @Deprecated @Nullable String getSurfaceID(); + + /** + * This API is likely to change once the fix of T78832286 is confirmed TODO: T78832286 revisit + * this API + * + * @return an {@link AtomicInteger} that represents the state of the ReactRoot object. WARNING: + */ + AtomicInteger getState(); } From b636397a0d599be1b013dabd2a7717859f1217af Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 4 Dec 2020 19:55:54 -0800 Subject: [PATCH 0162/1810] Add annotations and thread safety checks in the initialization / teardown methods of ReactInstanceManager Summary: Add annotations and thread safety checks in the initialization / teardown methods of ReactInstanceManager changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D25321380 fbshipit-source-id: 113a7c224ae04009cda9e15676208abcef6af211 --- .../java/com/facebook/react/ReactInstanceManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 95026e8385f86b..0f2656027cc1d7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -41,6 +41,7 @@ import android.os.Bundle; import android.os.Process; import android.view.View; +import android.view.ViewGroup; import androidx.annotation.Nullable; import androidx.core.view.ViewCompat; import com.facebook.common.logging.FLog; @@ -794,12 +795,15 @@ public void showDevOptionsDialog() { mDevSupportManager.showDevOptionsDialog(); } + @ThreadConfined(UI) private void clearReactRoot(ReactRoot reactRoot) { + UiThreadUtil.assertOnUiThread(); if (ReactFeatureFlags.enableStartSurfaceRaceConditionFix) { reactRoot.getState().compareAndSet(ReactRoot.STATE_STARTED, ReactRoot.STATE_STOPPED); } - reactRoot.getRootViewGroup().removeAllViews(); - reactRoot.getRootViewGroup().setId(View.NO_ID); + ViewGroup rootViewGroup = reactRoot.getRootViewGroup(); + rootViewGroup.removeAllViews(); + rootViewGroup.setId(View.NO_ID); } /** @@ -1222,6 +1226,7 @@ private void detachViewFromInstance(ReactRoot reactRoot, CatalystInstance cataly } } + @ThreadConfined(UI) private void tearDownReactContext(ReactContext reactContext) { FLog.d(ReactConstants.TAG, "ReactInstanceManager.tearDownReactContext()"); UiThreadUtil.assertOnUiThread(); From 158abfe8bfd20d05cd67c6e861d5db02b4420916 Mon Sep 17 00:00:00 2001 From: Su Min Kim Date: Sat, 5 Dec 2020 16:03:19 -0800 Subject: [PATCH 0163/1810] Add scrollview example (#30454) Summary: Add missing examples to ScrollView for RNTester. ## Changelog [General] [Added] - Add missing examples to ScrollView for RNTester. Pull Request resolved: https://github.com/facebook/react-native/pull/30454 Test Plan: There are a lot of examples that have been added that affects the UI (see RNCore Excel sheet for details). Reviewed By: sammy-SC Differential Revision: D25310613 Pulled By: rickhanlonii fbshipit-source-id: 64a771aa8d3c3683eed983b0c36625078e5533fe --- .../examples/ScrollView/ScrollViewExample.js | 815 ++++++++++++++++++ 1 file changed, 815 insertions(+) diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js index 7aa352b4228aca..ecb390db26e305 100644 --- a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js +++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js @@ -15,14 +15,18 @@ const React = require('react'); const { Platform, ScrollView, + Picker, StyleSheet, Text, TouchableOpacity, View, + TextInput, + RefreshControl, } = require('react-native'); const nullthrows = require('nullthrows'); +import {useState, useCallback} from 'react'; import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; exports.displayName = 'ScrollViewExample'; @@ -165,6 +169,98 @@ exports.examples = [ return ; }, }, + { + title: ' Content\n', + description: 'Adjust properties of content inside ScrollView.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Deceleration Rate\n', + description: + 'Determines how quickly the scroll view decelerates after the user lifts their finger.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Enable & Disable Scrolling Behavior\n', + description: + 'DirectionalLockEnabled (iOS), disableIntervalMomentum, disableScrollViewPanResponder can be enabled or disabled.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Invert Sticky Headers\n', + description: + 'If sticky headers should stick at the bottom instead of the top of the ScrollView. This is usually used with inverted ScrollViews.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Keyboard Options\n', + description: + 'Toggle the keyboard using the search bar and determine keyboard behavior in response to drag and tap.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' OnContentSizeChange\n', + description: + 'The text below will change when scrollable content view of the ScrollView changes.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' OnMomentumScroll\n', + description: + 'An alert will be called when the momentum scroll starts or ends.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' OnScroll Options\n', + description: + 'Change the behavior of onScroll using these options: onScrollBeginDrag, onScrollEndDrag, onScrollToTop (iOS), and overScrollMode (Android).', + render: function(): React.Node { + return ; + }, + }, + { + title: ' RefreshControl\n', + description: 'Pull down to see RefreshControl indicator.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Remove Clipped Subviews\n', + description: + 'When true, offscreen child views (whose overflow value is hidden) are removed from their native backing superview when offscreen.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Scroll Indicator\n', + description: 'Adjust properties of the scroll indicator.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' SnapTo Options\n', + description: 'Adjust properties of snapping to the scroll view.', + render: function(): React.Node { + return ; + }, + }, ]; if (Platform.OS === 'ios') { exports.examples.push({ @@ -321,8 +417,712 @@ if (Platform.OS === 'ios') { return ; }, }); + exports.examples.push({ + title: ' Always Bounces\n', + description: 'Always bounce vertically or horizontally.', + render: function(): React.Node { + return ( + <> + Vertical + + Horizontal + + + ); + }, + }); + exports.examples.push({ + title: ' Bounces & Bounces Zoom\n', + description: 'There are different options for bouncing behavior.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' Indicator Style\n', + description: 'There are different options for indicator style colors.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' Maximum & Minimum Zoom Scale\n', + description: 'Set the maximum and minimum allowed zoom scale.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' Maximum & Minimum Zoom Scale\n', + description: 'Set the maximum and minimum allowed zoom scale.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' ScrollTo Options\n', + description: + 'Toggle scrollToOverflowEnabled and scrollsToTop. When scrollToOverflowEnabled is true, the scroll view can be programmatically scrolled beyond its content size. When scrollsToTop is true, the scroll view scrolls to top when the status bar is tapped.', + render: function(): React.Node { + return ; + }, + }); +} else { + exports.examples.push({ + title: ' EndFillColor & FadingEdgeLength\n', + description: 'Toggle to set endFillColor and fadingEdgeLength.', + render: function(): React.Node { + return ; + }, + }); } +const AndroidScrollBarOptions = () => { + const [persistentScrollBar, setPersistentScrollBar] = useState(false); + return ( + + + {ITEMS.map(createItemRow)} + + - - Transparent - {this.renderSwitch()} - + {this.renderSwitch()} {this.renderPickers()} - +
); } renderPickers() { @@ -219,7 +257,7 @@ class ModalExample extends React.Component<{...}, $FlowFixMeState> { - this.setState({selectedSupportedOrientation: i}) + this.setState({selectedSupportedOrientation: i.toString()}) } itemStyle={styles.pickerItem}> @@ -230,6 +268,28 @@ class ModalExample extends React.Component<{...}, $FlowFixMeState> { + + + Actions + {Platform.OS === 'ios' ? ( + this.setState({action})} + itemStyle={styles.pickerItem}> + + + + + ) : ( + this.setState({action})} + itemStyle={styles.pickerItem}> + + + + )} + ); } @@ -282,4 +342,8 @@ const styles = StyleSheet.create({ pickerItem: { fontSize: 16, }, + ScrollView: { + paddingTop: 10, + paddingBottom: 100, + }, }); From 072896e3b7a4d3fcb2e395bb06c527f7b32f6db1 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Thu, 10 Dec 2020 00:04:24 -0800 Subject: [PATCH 0191/1810] Android: introduced uimanager/interfaces target for base symbols used by codegen output Summary: Some of the existing files under uimanager/ are self contained and used by the component codegen output. This commit split out those files into a dedicated uimanager/interfaces/ dir/target so that more targets can depend on it without causing dep cycle. Also, the component codegen output doesn't need LayoutShadowNode at all, so this removed the import. This will allow us to combine the Java codegen output for TM spec and Fabric components, simplifying build and dependency management (not in this commit yet). Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25451409 fbshipit-source-id: 827545a3d78ebed1815cf9e52da2fa896b012aa1 --- .../java/com/facebook/react/uimanager/BUCK | 2 +- .../com/facebook/react/uimanager/common/BUCK | 1 - .../facebook/react/uimanager/interfaces/BUCK | 20 ++++++++++++++ .../BaseViewManagerDelegate.java | 0 .../BaseViewManagerInterface.java | 0 .../uimanager/{ => interfaces}/FloatUtil.java | 0 .../uimanager/{ => interfaces}/Spacing.java | 0 .../{ => interfaces}/ViewManagerDelegate.java | 0 .../uimanager/{ => interfaces}/ViewProps.java | 0 .../ActivityIndicatorViewManagerDelegate.java | 1 - .../AndroidDrawerLayoutManagerDelegate.java | 1 - .../AndroidProgressBarManagerDelegate.java | 1 - ...roidSwipeRefreshLayoutManagerDelegate.java | 1 - .../AndroidSwitchManagerDelegate.java | 1 - .../MaskedViewManagerDelegate.java | 1 - .../ModalHostViewManagerDelegate.java | 1 - .../ProgressViewManagerDelegate.java | 1 - .../SafeAreaViewManagerDelegate.java | 1 - .../SegmentedControlManagerDelegate.java | 1 - .../viewmanagers/SliderManagerDelegate.java | 1 - ...nimplementedNativeViewManagerDelegate.java | 1 - packages/react-native-codegen/DEFS.bzl | 4 +-- .../components/GeneratePropsJavaDelegate.js | 1 - .../GeneratePropsJavaDelegate-test.js.snap | 26 ------------------- 24 files changed, 22 insertions(+), 44 deletions(-) create mode 100644 ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK rename ReactAndroid/src/main/java/com/facebook/react/uimanager/{ => interfaces}/BaseViewManagerDelegate.java (100%) rename ReactAndroid/src/main/java/com/facebook/react/uimanager/{ => interfaces}/BaseViewManagerInterface.java (100%) rename ReactAndroid/src/main/java/com/facebook/react/uimanager/{ => interfaces}/FloatUtil.java (100%) rename ReactAndroid/src/main/java/com/facebook/react/uimanager/{ => interfaces}/Spacing.java (100%) rename ReactAndroid/src/main/java/com/facebook/react/uimanager/{ => interfaces}/ViewManagerDelegate.java (100%) rename ReactAndroid/src/main/java/com/facebook/react/uimanager/{ => interfaces}/ViewProps.java (100%) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK index 985aeb4e9ed375..be919fcba0fc41 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK @@ -43,7 +43,6 @@ rn_android_library( react_native_target("java/com/facebook/react/touch:touch"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), react_native_target("java/com/facebook/react/uimanager/util:util"), - react_native_target("java/com/facebook/react/uimanager/common:common"), react_native_target("res:uimanager"), ], exported_deps = [ @@ -51,6 +50,7 @@ rn_android_library( react_native_dep("third-party/android/androidx:annotation"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_target("java/com/facebook/react/uimanager/common:common"), + react_native_target("java/com/facebook/react/uimanager/interfaces:interfaces"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK index d8e9532b1a6a6f..516b18e0b55183 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK @@ -17,7 +17,6 @@ rn_android_library( "PUBLIC", ], deps = [ - # react_native_dep("third-party/android/androidx:appcompat"), react_native_dep("third-party/java/jsr-305:jsr-305"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK new file mode 100644 index 00000000000000..92c16aba4714f0 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK @@ -0,0 +1,20 @@ +load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library") + +rn_android_library( + name = "interfaces", + srcs = glob(["*.java"]), + is_androidx = True, + labels = ["supermodule:xplat/default/public.react_native.infra"], + provided_deps = [ + react_native_dep("third-party/android/androidx:annotation"), + ], + required_for_source_only_abi = True, + visibility = [ + "PUBLIC", + ], + deps = [ + YOGA_TARGET, + react_native_dep("third-party/java/jsr-305:jsr-305"), + react_native_target("java/com/facebook/react/bridge:bridge"), + ], +) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BaseViewManagerDelegate.java similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BaseViewManagerDelegate.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BaseViewManagerInterface.java similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BaseViewManagerInterface.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/FloatUtil.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/FloatUtil.java similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/uimanager/FloatUtil.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/FloatUtil.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/Spacing.java similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/uimanager/Spacing.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/Spacing.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewManagerDelegate.java similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewManagerDelegate.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java index 833ffe265d96f7..72b309e4f2e518 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java @@ -14,7 +14,6 @@ import com.facebook.react.bridge.ColorPropConverter; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ActivityIndicatorViewManagerDelegate & ActivityIndicatorViewManagerInterface> extends BaseViewManagerDelegate { public ActivityIndicatorViewManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java index aee5f3f9c94820..11af21261e73f9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class AndroidDrawerLayoutManagerDelegate & AndroidDrawerLayoutManagerInterface> extends BaseViewManagerDelegate { public AndroidDrawerLayoutManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java index b0417eed9ce042..9a1554d885c4dd 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java @@ -14,7 +14,6 @@ import com.facebook.react.bridge.ColorPropConverter; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class AndroidProgressBarManagerDelegate & AndroidProgressBarManagerInterface> extends BaseViewManagerDelegate { public AndroidProgressBarManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java index e5fc3ac7a2c2c2..32a60194d43213 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class AndroidSwipeRefreshLayoutManagerDelegate & AndroidSwipeRefreshLayoutManagerInterface> extends BaseViewManagerDelegate { public AndroidSwipeRefreshLayoutManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java index 1b2f225d390ae7..27505917f8855a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class AndroidSwitchManagerDelegate & AndroidSwitchManagerInterface> extends BaseViewManagerDelegate { public AndroidSwitchManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java index 315e5cd181aebb..0d95dd794afc50 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java @@ -13,7 +13,6 @@ import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class MaskedViewManagerDelegate & MaskedViewManagerInterface> extends BaseViewManagerDelegate { public MaskedViewManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java index 978224f30f73d5..52967876c20dbf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java @@ -14,7 +14,6 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ModalHostViewManagerDelegate & ModalHostViewManagerInterface> extends BaseViewManagerDelegate { public ModalHostViewManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java index df088d4a87f8ba..9a469c4f51233c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ProgressViewManagerDelegate & ProgressViewManagerInterface> extends BaseViewManagerDelegate { public ProgressViewManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java index fdf56b283822cb..586fed6ae83fa2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java @@ -13,7 +13,6 @@ import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class SafeAreaViewManagerDelegate & SafeAreaViewManagerInterface> extends BaseViewManagerDelegate { public SafeAreaViewManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java index 6763a1f1f53f0b..64e5eadd6d887d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class SegmentedControlManagerDelegate & SegmentedControlManagerInterface> extends BaseViewManagerDelegate { public SegmentedControlManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java index 5eb9360ef8e285..017b209edb02e9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class SliderManagerDelegate & SliderManagerInterface> extends BaseViewManagerDelegate { public SliderManagerDelegate(U viewManager) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java index f90b2c3b25fa11..4dce46a5381445 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java @@ -13,7 +13,6 @@ import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class UnimplementedNativeViewManagerDelegate & UnimplementedNativeViewManagerInterface> extends BaseViewManagerDelegate { public UnimplementedNativeViewManagerDelegate(U viewManager) { diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index bb6cdec5a0ea30..ba8bb17c99696a 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -481,9 +481,7 @@ def rn_codegen_components( deps = [ react_native_dep("third-party/android/androidx:annotation"), react_native_target("java/com/facebook/react/bridge:bridge"), - react_native_target("java/com/facebook/react/common:common"), - react_native_target("java/com/facebook/react/turbomodule/core:core"), - react_native_target("java/com/facebook/react/uimanager:uimanager"), + react_native_target("java/com/facebook/react/uimanager/interfaces:interfaces"), ], ) diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index b911ca7be8513a..6b3da0121392f3 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -245,7 +245,6 @@ function getDelegateImports(component) { imports.add('import androidx.annotation.Nullable;'); imports.add('import com.facebook.react.uimanager.BaseViewManagerDelegate;'); imports.add('import com.facebook.react.uimanager.BaseViewManagerInterface;'); - imports.add('import com.facebook.react.uimanager.LayoutShadowNode;'); return imports; } diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 2433ccdfec2535..2b062c4f906bc0 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -18,7 +18,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ArrayPropsNativeComponentManagerDelegate & ArrayPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { public ArrayPropsNativeComponentManagerDelegate(U viewManager) { @@ -87,7 +86,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ArrayPropsNativeComponentManagerDelegate & ArrayPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { public ArrayPropsNativeComponentManagerDelegate(U viewManager) { @@ -125,7 +123,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class BooleanPropNativeComponentManagerDelegate & BooleanPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public BooleanPropNativeComponentManagerDelegate(U viewManager) { @@ -164,7 +161,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ColorPropConverter; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ColorPropNativeComponentManagerDelegate & ColorPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public ColorPropNativeComponentManagerDelegate(U viewManager) { @@ -203,7 +199,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class CommandNativeComponentManagerDelegate & CommandNativeComponentManagerInterface> extends BaseViewManagerDelegate { public CommandNativeComponentManagerDelegate(U viewManager) { @@ -248,7 +243,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class CommandNativeComponentManagerDelegate & CommandNativeComponentManagerInterface> extends BaseViewManagerDelegate { public CommandNativeComponentManagerDelegate(U viewManager) { @@ -298,7 +292,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class DoublePropNativeComponentManagerDelegate & DoublePropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public DoublePropNativeComponentManagerDelegate(U viewManager) { @@ -351,7 +344,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class EventsNestedObjectNativeComponentManagerDelegate & EventsNestedObjectNativeComponentManagerInterface> extends BaseViewManagerDelegate { public EventsNestedObjectNativeComponentManagerDelegate(U viewManager) { @@ -389,7 +381,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class EventsNativeComponentManagerDelegate & EventsNativeComponentManagerInterface> extends BaseViewManagerDelegate { public EventsNativeComponentManagerDelegate(U viewManager) { @@ -427,7 +418,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class InterfaceOnlyComponentManagerDelegate & InterfaceOnlyComponentManagerInterface> extends BaseViewManagerDelegate { public InterfaceOnlyComponentManagerDelegate(U viewManager) { @@ -463,7 +453,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class FloatPropNativeComponentManagerDelegate & FloatPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public FloatPropNativeComponentManagerDelegate(U viewManager) { @@ -517,7 +506,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ImagePropNativeComponentManagerDelegate & ImagePropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public ImagePropNativeComponentManagerDelegate(U viewManager) { @@ -556,7 +544,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class InsetsPropNativeComponentManagerDelegate & InsetsPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public InsetsPropNativeComponentManagerDelegate(U viewManager) { @@ -594,7 +581,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class Int32EnumPropsNativeComponentManagerDelegate & Int32EnumPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { public Int32EnumPropsNativeComponentManagerDelegate(U viewManager) { @@ -632,7 +618,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class IntegerPropNativeComponentManagerDelegate & IntegerPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public IntegerPropNativeComponentManagerDelegate(U viewManager) { @@ -676,7 +661,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class InterfaceOnlyComponentManagerDelegate & InterfaceOnlyComponentManagerInterface> extends BaseViewManagerDelegate { public InterfaceOnlyComponentManagerDelegate(U viewManager) { @@ -716,7 +700,6 @@ import com.facebook.react.bridge.ColorPropConverter; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ImageColorPropNativeComponentManagerDelegate & ImageColorPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public ImageColorPropNativeComponentManagerDelegate(U viewManager) { @@ -763,7 +746,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class NoPropsNoEventsComponentManagerDelegate & NoPropsNoEventsComponentManagerInterface> extends BaseViewManagerDelegate { public NoPropsNoEventsComponentManagerDelegate(U viewManager) { @@ -796,7 +778,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class ObjectPropsManagerDelegate & ObjectPropsManagerInterface> extends BaseViewManagerDelegate { public ObjectPropsManagerDelegate(U viewManager) { @@ -835,7 +816,6 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class PointPropNativeComponentManagerDelegate & PointPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { public PointPropNativeComponentManagerDelegate(U viewManager) { @@ -873,7 +853,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class StringEnumPropsNativeComponentManagerDelegate & StringEnumPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { public StringEnumPropsNativeComponentManagerDelegate(U viewManager) { @@ -911,7 +890,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class StringPropComponentManagerDelegate & StringPropComponentManagerInterface> extends BaseViewManagerDelegate { public StringPropComponentManagerDelegate(U viewManager) { @@ -952,7 +930,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class MultiFile1NativeComponentManagerDelegate & MultiFile1NativeComponentManagerInterface> extends BaseViewManagerDelegate { public MultiFile1NativeComponentManagerDelegate(U viewManager) { @@ -985,7 +962,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class MultiFile2NativeComponentManagerDelegate & MultiFile2NativeComponentManagerInterface> extends BaseViewManagerDelegate { public MultiFile2NativeComponentManagerDelegate(U viewManager) { @@ -1023,7 +999,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class MultiComponent1NativeComponentManagerDelegate & MultiComponent1NativeComponentManagerInterface> extends BaseViewManagerDelegate { public MultiComponent1NativeComponentManagerDelegate(U viewManager) { @@ -1056,7 +1031,6 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; public class MultiComponent2NativeComponentManagerDelegate & MultiComponent2NativeComponentManagerInterface> extends BaseViewManagerDelegate { public MultiComponent2NativeComponentManagerDelegate(U viewManager) { From 11cf9ca8c2a9b02268c81bf9255528fc503022b7 Mon Sep 17 00:00:00 2001 From: Hans Halverson Date: Thu, 10 Dec 2020 15:51:21 -0800 Subject: [PATCH 0192/1810] Deploy Flow v0.140.0 Summary: Changelog: [Internal] Reviewed By: mroch Differential Revision: D25468955 fbshipit-source-id: b23880f0398413a5974b270f3d1f78da29699353 --- .flowconfig | 2 +- .flowconfig.android | 2 +- package.json | 2 +- repo-config/package.json | 2 +- template/_flowconfig | 2 +- yarn.lock | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.flowconfig b/.flowconfig index d5aa492cf7e282..f79a1216c94575 100644 --- a/.flowconfig +++ b/.flowconfig @@ -71,4 +71,4 @@ untyped-import untyped-type-import [version] -^0.138.0 +^0.140.0 diff --git a/.flowconfig.android b/.flowconfig.android index 9c087d9436dfb1..e05cf8812f5a1f 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -71,4 +71,4 @@ untyped-import untyped-type-import [version] -^0.138.0 +^0.140.0 diff --git a/package.json b/package.json index 175d9fe880ebbe..1f18019bde367d 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "ws": "^6.1.4" }, "devDependencies": { - "flow-bin": "^0.138.0", + "flow-bin": "^0.140.0", "react": "17.0.1" }, "detox": { diff --git a/repo-config/package.json b/repo-config/package.json index a1f4346e3ee58f..648509c639ec63 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -33,7 +33,7 @@ "eslint-plugin-react-hooks": "^4.0.7", "eslint-plugin-react-native": "3.8.1", "eslint-plugin-relay": "1.8.1", - "flow-bin": "^0.138.0", + "flow-bin": "^0.140.0", "jest": "^26.5.2", "jest-junit": "^10.0.0", "jscodeshift": "^0.11.0", diff --git a/template/_flowconfig b/template/_flowconfig index cd04a9ecbec161..d4f258ae45fa54 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -64,4 +64,4 @@ untyped-import untyped-type-import [version] -^0.138.0 +^0.140.0 diff --git a/yarn.lock b/yarn.lock index eb210874e90c0d..99fb618b59a46f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2993,10 +2993,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -flow-bin@^0.138.0: - version "0.138.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.138.0.tgz#a0c81a3dd1ed34771b33b7e91078ed260301aa17" - integrity sha512-y3twwNeN0FWEK0vvJo/5SiC/OQVlhubGRyOPIS6p49b2yiiWE/cBFG/aC9kFXFfh7Orewe5O5B2X0+IiEOCYIw== +flow-bin@^0.140.0: + version "0.140.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.140.0.tgz#bf1a2984a0e5604daa0d1e0432138d9897af65bb" + integrity sha512-9P/VciKACXocClhLiDg/p1ntYmgCEEc9QrNOoTqTi2SEdEZDTiAmJLONRJfw4uglPVRZ1p/esWF9KlbZiuxqVw== flow-parser@0.*, flow-parser@^0.121.0: version "0.121.0" From 81096901a8a6da75744cef7b663ccea2ff9c4c09 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Thu, 10 Dec 2020 17:15:50 -0800 Subject: [PATCH 0193/1810] Use bridgeless flag instead of specific binding in UIManagerBinding Summary: This fix is still a little hypothetical. We have a few different JS errors that we're seeing with bridgeless mode that seem to be caused by Fabric trying to access `__fbBatchedBridge` from C++. I think what's happening is: 1. User encounters an unrelated JS error very early in rendering a new surface (possibly while the bundle is still loading?) 2. In release builds, BridgelessReactFragment handles the error by stopping the surface and rendering a retry button (actually, the surface is stopped in a bunch of places in BaseFbReactFragment, which might be why this is popping up now - I recently refactored that class to share more of its logic in bridgeless mode) 3. Fabric stops the surface by first checking to see if the custom binding `RN$stopSurface` exists; if not, it falls back to calling the registered callable module `ReactFabric`. I think #3 is where things are going wrong for bridgeless mode; if you call stopSurface before `RN$stopSurface` is installed (which happens when ReactFabric shim is required) then you'll fall back to the bridge version. My solution here is to instead rely on a flag set in C++ to determine whether we're in bridgeless mode, and then check to see if the stopSurface binding has been installed. If not, we just noop - if the ReactFabric shim hasn't been required, we probably don't actually have a React surface that needs to be stopped. At least, that's my current theory. We'll see if this actually works. Changelog: [Fixed][iOS] Fix an issue calling stopSurface in bridgeless mode before surface is started Reviewed By: mdvacca Differential Revision: D25453696 fbshipit-source-id: bff76675c43989101d0ba5ae0aba60089db230bf --- .../react/renderer/uimanager/UIManagerBinding.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 9dac8a1cce9180..e772a888e2dc32 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -113,10 +113,15 @@ void UIManagerBinding::startSurface( void UIManagerBinding::stopSurface(jsi::Runtime &runtime, SurfaceId surfaceId) const { - if (runtime.global().hasProperty(runtime, "RN$stopSurface")) { - auto method = - runtime.global().getPropertyAsFunction(runtime, "RN$stopSurface"); - method.call(runtime, {jsi::Value{surfaceId}}); + auto global = runtime.global(); + if (global.hasProperty(runtime, "RN$Bridgeless")) { + if (!global.hasProperty(runtime, "RN$stopSurface")) { + // ReactFabric module has not been loaded yet; there's no surface to stop. + return; + } + // Bridgeless mode uses a custom JSI binding instead of callable module. + global.getPropertyAsFunction(runtime, "RN$stopSurface") + .call(runtime, {jsi::Value{surfaceId}}); } else { auto module = getModule(runtime, "ReactFabric"); auto method = From 0ed81b28d3d786ea3b1cf0b932a008ef1f806ec4 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 10 Dec 2020 20:21:11 -0800 Subject: [PATCH 0194/1810] Introduce RCTModuleRegistry Summary: ## Problem Many of our NativeModules are TurboModule-compatible. All our TurboModules currently use the bridge to require other NativeModules/TurboModules. As we migrate more surfaces to Venice, this lookup in many of these TurboModules will break, because the bridge will be nil. ## Initial Solution We migrate all these TurboModules over to the turboModuleRegistry. In FBiOS, this will work because all NativeModules are TurboModule-compatible, and should [have the turboModuleRegistry attached to them by the TurboModuleManager](https://fburl.com/diffusion/d747fbc3). However, this solution has a few problems: - If the TurboModule is used within a TurboModule-disabled app, it will break, because turboModuleRegistry will be nil on the module. Therefore, this solution isn't portable/flexible across apps. - Longer term, we should deprecate synthesize bridge inside NativeModules. With this approach, we can't remove the synthesize bridge = bridge call from the NativeModule. ## Suggested Solution Both NativeModules and TurboModules will be given access to an `RCTModuleRegistry` object. The RCTModuleRegistry object will use the TurboModuleManager when available and the Bridge when available to query for NativeModules and TurboModules. Otherwise, it'll just return nil. When we do a lookup via this RCTModuleRegistry: - In Venice, the bridge will be nil, so we won't search the bridge. - In FBiOS, the bridge and the TurboModuleManager will be non-nil, so we'll first search the bridge, and then the TurboModuleManager. - In standalone apps, the TurboModuleManager will be nil, so we'll only do a lookup on the bridge. Long story short, RCTModuleRegistry will do the right thing in all scenarios. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25412847 fbshipit-source-id: 13f41276158d90c68ab4925e518d71a2f369c210 --- React/Base/RCTBridgeModule.h | 11 ++++++++ React/Base/RCTModuleRegistry.m | 48 +++++++++++++++++++++++++++++++++ packages/rn-tester/Podfile.lock | 4 +-- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 React/Base/RCTModuleRegistry.m diff --git a/React/Base/RCTBridgeModule.h b/React/Base/RCTBridgeModule.h index 102f98194bd5f2..fc419e4a13ce4a 100644 --- a/React/Base/RCTBridgeModule.h +++ b/React/Base/RCTBridgeModule.h @@ -372,3 +372,14 @@ RCT_EXTERN_C_END * See RCTTurboModule.h for actual signature. */ @protocol RCTTurboModule; + +/** + * A class that allows NativeModules and TurboModules to look up one another. + */ +@interface RCTModuleRegistry : NSObject +- (void)setBridge:(RCTBridge *)bridge; +- (void)setTurboModuleRegistry:(id)turboModuleRegistry; + +- (id)moduleForName:(const char *)moduleName; +- (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad; +@end diff --git a/React/Base/RCTModuleRegistry.m b/React/Base/RCTModuleRegistry.m new file mode 100644 index 00000000000000..c5a5d10ab48eb3 --- /dev/null +++ b/React/Base/RCTModuleRegistry.m @@ -0,0 +1,48 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTBridge.h" +#import "RCTBridgeModule.h" + +@implementation RCTModuleRegistry { + __weak id _turboModuleRegistry; + __weak RCTBridge *_bridge; +} + +- (void)setBridge:(RCTBridge *)bridge +{ + _bridge = bridge; +} + +- (void)setTurboModuleRegistry:(id)turboModuleRegistry +{ + _turboModuleRegistry = turboModuleRegistry; +} + +- (id)moduleForName:(const char *)moduleName +{ + return [self moduleForName:moduleName lazilyLoadIfNecessary:YES]; +} + +- (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad +{ + id module = nil; + + RCTBridge *bridge = _bridge; + if (bridge) { + module = [bridge moduleForName:[NSString stringWithUTF8String:moduleName] lazilyLoadIfNecessary:lazilyLoad]; + } + + id turboModuleRegistry = _turboModuleRegistry; + if (module == nil && turboModuleRegistry && (lazilyLoad || [turboModuleRegistry moduleIsInitialized:moduleName])) { + module = [turboModuleRegistry moduleForName:moduleName]; + } + + return module; +} + +@end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index f8c8fb42160bc6..dca3e8b99c3fbd 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -490,7 +490,7 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 77f376d6af8c6348f0cc6de9a96c7a288f4e03ab + FBReactNativeSpec: 765701e4018375c2e423d955806400a39bdb9c63 Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a @@ -505,7 +505,7 @@ SPEC CHECKSUMS: RCTTypeSafety: 4da4f9f218727257c50fd3bf2683a06cdb4fede3 React: 87b3271d925336a94620915db5845c67c5dbbd77 React-callinvoker: e9524d75cf0b7ae108868f8d34c0b8d7dc08ec03 - React-Core: 40874579985cf440232e3f33ce172be1f04d4964 + React-Core: 2b2a8ac8bfb65779965456570a871f4cf5e5e03a React-CoreModules: 87f011fa87190ffe979e443ce578ec93ec6ff4d4 React-cxxreact: de6de17eac6bbaa4f9fad46b66e7f0c4aaaf863d React-jsi: 790da16b69a61adc36829eed43c44187c1488d10 From 6f02942dc12fe95a153c2a4cc17ae9bcaa7b0154 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 10 Dec 2020 20:21:11 -0800 Subject: [PATCH 0195/1810] Allow NativeModules to synthesize the RCTModuleRegistry Summary: NativeModules and TurboModules should use this API to lookup other NativeModules/TurboModules. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25414341 fbshipit-source-id: d8fab3d1b30b940fc5d1faa56bf195b9fda8d377 --- React/Base/RCTBridgeModule.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/React/Base/RCTBridgeModule.h b/React/Base/RCTBridgeModule.h index fc419e4a13ce4a..e4bbef2a1a73ba 100644 --- a/React/Base/RCTBridgeModule.h +++ b/React/Base/RCTBridgeModule.h @@ -11,6 +11,7 @@ @class RCTBridge; @protocol RCTBridgeMethod; +@class RCTModuleRegistry; /** * The type of a block that is capable of sending a response to a bridged @@ -113,6 +114,14 @@ RCT_EXTERN_C_END @optional +/** + * A reference to the RCTModuleRegistry. Useful for modules that require access + * to other NativeModules. To implement this in your module, just add `@synthesize + * moduleRegistry = _moduleRegistry;`. If using Swift, add + * `@objc var moduleRegistry: RCTModuleRegistry!` to your module. + */ +@property (nonatomic, weak, readonly) RCTModuleRegistry *moduleRegistry; + /** * A reference to the RCTBridge. Useful for modules that require access * to bridge features, such as sending events or making JS calls. This From 5b0957962a4c5cdba0b265edc4b5e7aa65388d10 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 10 Dec 2020 20:21:11 -0800 Subject: [PATCH 0196/1810] Attach RCTModuleRegistry to TurboModules Summary: Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25414882 fbshipit-source-id: 9e45ffb86cf69a2d1921b7ff1c713c186a8c4e01 --- .../platform/ios/RCTTurboModuleManager.mm | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index cd7ba02c510bbd..8caf2a3fb94847 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -172,6 +172,8 @@ @implementation RCTTurboModuleManager { std::shared_timed_mutex _turboModuleHoldersSharedMutex; std::mutex _turboModuleHoldersMutex; std::atomic _invalidating; + + RCTModuleRegistry *_moduleRegistry; } - (instancetype)initWithBridge:(RCTBridge *)bridge @@ -183,6 +185,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _delegate = delegate; _bridge = bridge; _invalidating = false; + _moduleRegistry = [RCTModuleRegistry new]; + [_moduleRegistry setBridge:bridge]; + [_moduleRegistry setTurboModuleRegistry:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bridgeWillInvalidateModules:) @@ -535,6 +540,25 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName } } + /** + * Attach the RCTModuleRegistry to this TurboModule, which allows this TurboModule + * To load other NativeModules & TurboModules. + * + * Usage: In the NativeModule @implementation, include: + * `@synthesize moduleRegistry = _moduleRegistry` + */ + if ([module respondsToSelector:@selector(moduleRegistry)] && _moduleRegistry) { + @try { + [(id)module setValue:_moduleRegistry forKey:@"moduleRegistry"]; + } @catch (NSException *exception) { + RCTLogError( + @"%@ has no setter or ivar for its module registry, which is not " + "permitted. You must either @synthesize the moduleRegistry property, " + "or provide your own setter method.", + RCTBridgeModuleNameForClass([module class])); + } + } + /** * Some modules need their own queues, but don't provide any, so we need to create it for them. * These modules typically have the following: From 4974e293c6f6539bd6dea3d04d98b9a7b562977f Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 10 Dec 2020 20:21:11 -0800 Subject: [PATCH 0197/1810] Attach RCTModuleRegistry to NativeModules Summary: The bridge now creates the RCTModuleRegistry, and assigns it to all NativeModules it creates. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25414108 fbshipit-source-id: 81c6a05bde0e52cff8ed60297f27d8aa3ff15a87 --- React/Base/RCTModuleData.h | 11 +++++-- React/Base/RCTModuleData.mm | 33 +++++++++++++++++-- React/CxxBridge/RCTCxxBridge.mm | 16 +++++++-- .../platform/ios/RCTTurboModuleManager.mm | 4 ++- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/React/Base/RCTModuleData.h b/React/Base/RCTModuleData.h index 5ff81532eb34b6..5e5f780d5feaa5 100644 --- a/React/Base/RCTModuleData.h +++ b/React/Base/RCTModuleData.h @@ -13,19 +13,24 @@ @protocol RCTBridgeMethod; @protocol RCTBridgeModule; @class RCTBridge; +@class RCTModuleRegistry; typedef id (^RCTBridgeModuleProvider)(void); @interface RCTModuleData : NSObject -- (instancetype)initWithModuleClass:(Class)moduleClass bridge:(RCTBridge *)bridge; +- (instancetype)initWithModuleClass:(Class)moduleClass + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry; - (instancetype)initWithModuleClass:(Class)moduleClass moduleProvider:(RCTBridgeModuleProvider)moduleProvider - bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry NS_DESIGNATED_INITIALIZER; - (instancetype)initWithModuleInstance:(id)instance - bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry NS_DESIGNATED_INITIALIZER; /** * Calls `constantsToExport` on the module and stores the result. Note that diff --git a/React/Base/RCTModuleData.mm b/React/Base/RCTModuleData.mm index c81b8a41fafb29..004bd0e570246a 100644 --- a/React/Base/RCTModuleData.mm +++ b/React/Base/RCTModuleData.mm @@ -48,6 +48,7 @@ @implementation RCTModuleData { RCTBridgeModuleProvider _moduleProvider; std::mutex _instanceLock; BOOL _setupComplete; + RCTModuleRegistry *_moduleRegistry; } @synthesize methods = _methods; @@ -97,34 +98,42 @@ - (void)setUp } } -- (instancetype)initWithModuleClass:(Class)moduleClass bridge:(RCTBridge *)bridge +- (instancetype)initWithModuleClass:(Class)moduleClass + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry { return [self initWithModuleClass:moduleClass moduleProvider:^id { return [moduleClass new]; } - bridge:bridge]; + bridge:bridge + moduleRegistry:moduleRegistry]; } - (instancetype)initWithModuleClass:(Class)moduleClass moduleProvider:(RCTBridgeModuleProvider)moduleProvider bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry { if (self = [super init]) { _bridge = bridge; _moduleClass = moduleClass; _moduleProvider = [moduleProvider copy]; + _moduleRegistry = moduleRegistry; [self setUp]; } return self; } -- (instancetype)initWithModuleInstance:(id)instance bridge:(RCTBridge *)bridge +- (instancetype)initWithModuleInstance:(id)instance + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry { if (self = [super init]) { _bridge = bridge; _instance = instance; _moduleClass = [instance class]; + _moduleRegistry = moduleRegistry; [self setUp]; } return self; @@ -185,6 +194,7 @@ - (void)setUpInstanceAndBridge:(int32_t)requestId // initialization requires it (View Managers get their queue by calling // self.bridge.uiManager.methodQueue) [self setBridgeForInstance]; + [self setModuleRegistryForInstance]; } [self setUpMethodQueue]; @@ -231,6 +241,23 @@ - (void)setBridgeForInstance } } +- (void)setModuleRegistryForInstance +{ + if ([_instance respondsToSelector:@selector(moduleRegistry)] && _instance.moduleRegistry != _moduleRegistry) { + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setModuleRegistryForInstance]", nil); + @try { + [(id)_instance setValue:_moduleRegistry forKey:@"moduleRegistry"]; + } @catch (NSException *exception) { + RCTLogError( + @"%@ has no setter or ivar for its module registry, which is not " + "permitted. You must either @synthesize the moduleRegistry property, " + "or provide your own setter method.", + self.name); + } + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); + } +} + - (void)finishSetupForInstance { if (!_setupComplete && _instance) { diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 5836cf02221b6e..8a0d815a91cd98 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -12,6 +12,7 @@ #import #import #import +#import #import #import #import @@ -230,6 +231,8 @@ @implementation RCTCxxBridge { // Necessary for searching in TurboModules in TurboModuleManager id _turboModuleRegistry; + + RCTModuleRegistry *_objCModuleRegistry; } @synthesize bridgeDescription = _bridgeDescription; @@ -240,6 +243,7 @@ @implementation RCTCxxBridge { - (void)setRCTTurboModuleRegistry:(id)turboModuleRegistry { _turboModuleRegistry = turboModuleRegistry; + [_objCModuleRegistry setTurboModuleRegistry:_turboModuleRegistry]; } - (std::shared_ptr)jsMessageThread @@ -276,6 +280,8 @@ - (instancetype)initWithParentBridge:(RCTBridge *)bridge _moduleDataByName = [NSMutableDictionary new]; _moduleClassesByID = [NSMutableArray new]; _moduleDataByID = [NSMutableArray new]; + _objCModuleRegistry = [RCTModuleRegistry new]; + [_objCModuleRegistry setBridge:self]; [RCTBridge setCurrentBridge:self]; @@ -744,7 +750,7 @@ - (void)updateModuleWithInstance:(id)instance // TODO #13258411: can we defer this until config generation? int32_t moduleDataId = getUniqueId(); BridgeNativeModulePerfLogger::moduleDataCreateStart([moduleName UTF8String], moduleDataId); - moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass bridge:self]; + moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass bridge:self moduleRegistry:_objCModuleRegistry]; BridgeNativeModulePerfLogger::moduleDataCreateEnd([moduleName UTF8String], moduleDataId); _moduleDataByName[moduleName] = moduleData; @@ -807,7 +813,9 @@ - (void)registerExtraModules // Instantiate moduleData container int32_t moduleDataId = getUniqueId(); BridgeNativeModulePerfLogger::moduleDataCreateStart([moduleName UTF8String], moduleDataId); - RCTModuleData *moduleData = [[RCTModuleData alloc] initWithModuleInstance:module bridge:self]; + RCTModuleData *moduleData = [[RCTModuleData alloc] initWithModuleInstance:module + bridge:self + moduleRegistry:_objCModuleRegistry]; BridgeNativeModulePerfLogger::moduleDataCreateEnd([moduleName UTF8String], moduleDataId); _moduleDataByName[moduleName] = moduleData; @@ -858,7 +866,9 @@ - (void)registerExtraLazyModules int32_t moduleDataId = getUniqueId(); BridgeNativeModulePerfLogger::moduleDataCreateStart([moduleName UTF8String], moduleDataId); - moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass bridge:self]; + moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass + bridge:self + moduleRegistry:_objCModuleRegistry]; BridgeNativeModulePerfLogger::moduleDataCreateEnd([moduleName UTF8String], moduleDataId); _moduleDataByName[moduleName] = moduleData; diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index 8caf2a3fb94847..f875cad99af6a7 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -619,7 +619,9 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName * rollout. */ if (_bridge) { - RCTModuleData *data = [[RCTModuleData alloc] initWithModuleInstance:(id)module bridge:_bridge]; + RCTModuleData *data = [[RCTModuleData alloc] initWithModuleInstance:(id)module + bridge:_bridge + moduleRegistry:_moduleRegistry]; [_bridge registerModuleForFrameUpdates:(id)module withModuleData:data]; } From de7cc127072e6648af153740ede06504aa60cf30 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 10 Dec 2020 20:21:11 -0800 Subject: [PATCH 0198/1810] Migrate NativeModules from [self bridge] -> _bridge Summary: This should be a noop. It just makes writing codemods easier. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25442218 fbshipit-source-id: dba0c35a6f566e83ed5b7142075fff6929efeada --- Libraries/Blob/RCTFileReaderModule.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/Blob/RCTFileReaderModule.mm b/Libraries/Blob/RCTFileReaderModule.mm index 315605acc1174d..0f2b2d5bc62e94 100644 --- a/Libraries/Blob/RCTFileReaderModule.mm +++ b/Libraries/Blob/RCTFileReaderModule.mm @@ -31,7 +31,7 @@ @implementation RCTFileReaderModule resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { - RCTBlobManager *blobManager = [[self bridge] moduleForClass:[RCTBlobManager class]]; + RCTBlobManager *blobManager = [_bridge moduleForClass:[RCTBlobManager class]]; NSData *data = [blobManager resolve:blob]; if (data == nil) { @@ -57,8 +57,8 @@ @implementation RCTFileReaderModule reject:(RCTPromiseRejectBlock)reject) { RCTBlobManager *blobManager = nil; - if ([self bridge]) { - blobManager = [[self bridge] moduleForClass:[RCTBlobManager class]]; + if (_bridge) { + blobManager = [_bridge moduleForClass:[RCTBlobManager class]]; } else { blobManager = [[self turboModuleRegistry] moduleForName:[NSStringFromClass([RCTBlobManager class]) UTF8String]]; } From e1d7dd31058e486b52da9900dc54d3a8e9338856 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Fri, 11 Dec 2020 10:15:46 -0800 Subject: [PATCH 0199/1810] sed OBJC_ARC_PREPROCESSOR_FLAGS/get_preprocessor_flags_for_build_mode Summary: This diff doesn't change any functionality. Reviewed By: adamjernst Differential Revision: D25466557 fbshipit-source-id: 813f9631b92e8145b932955cad64a0c4582281e8 --- React/CoreModules/BUCK | 4 ++-- ReactCommon/react/nativemodule/core/BUCK | 5 +++-- ReactCommon/react/nativemodule/samples/BUCK | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/React/CoreModules/BUCK b/React/CoreModules/BUCK index 1ef37f2d209f3e..e07b6ff6f12e56 100644 --- a/React/CoreModules/BUCK +++ b/React/CoreModules/BUCK @@ -1,4 +1,4 @@ -load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "OBJC_ARC_PREPROCESSOR_FLAGS", "get_preprocessor_flags_for_build_mode") +load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode") load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "rn_apple_library", "rn_extra_build_flags") load( "@fbsource//xplat/configurations/buck/apple/plugins/sad_xplat_hosted_configurations:react_module_registration.bzl", @@ -122,7 +122,7 @@ rn_apple_library( native_class_func = "RCTEventDispatcherCls", ), plugins_header = "FBCoreModulesPlugins.h", - preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_preprocessor_flags_for_build_mode() + rn_extra_build_flags() + [ + preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode() + rn_extra_build_flags() + [ "-DRN_DISABLE_OSS_PLUGIN_HEADER", ], reexport_all_header_dependencies = True, diff --git a/ReactCommon/react/nativemodule/core/BUCK b/ReactCommon/react/nativemodule/core/BUCK index d5c8981664981a..523e359bf9ffa6 100644 --- a/ReactCommon/react/nativemodule/core/BUCK +++ b/ReactCommon/react/nativemodule/core/BUCK @@ -1,4 +1,5 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "FBJNI_TARGET", "OBJC_ARC_PREPROCESSOR_FLAGS", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags", "react_native_target", "react_native_xplat_shared_library_target", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob") +load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_objc_arc_preprocessor_flags") +load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "FBJNI_TARGET", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags", "react_native_target", "react_native_xplat_shared_library_target", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob") rn_xplat_cxx_library( name = "core", @@ -39,7 +40,7 @@ rn_xplat_cxx_library( "-fobjc-arc-exceptions", ], fbobjc_inherited_buck_flags = get_static_library_ios_flags(), - fbobjc_preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_preprocessor_flags_for_build_mode(), + fbobjc_preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), ios_deps = [ "//xplat/FBBaseLite:FBBaseLite", "//xplat/js/react-native-github:RCTCxxModule", diff --git a/ReactCommon/react/nativemodule/samples/BUCK b/ReactCommon/react/nativemodule/samples/BUCK index b6b0fe3b974e52..683b2c99c0210a 100644 --- a/ReactCommon/react/nativemodule/samples/BUCK +++ b/ReactCommon/react/nativemodule/samples/BUCK @@ -1,4 +1,4 @@ -load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "OBJC_ARC_PREPROCESSOR_FLAGS", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags") +load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags") load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "FBJNI_TARGET", "react_native_dep", "react_native_target", "react_native_xplat_target", "rn_android_library", "rn_xplat_cxx_library", "subdir_glob") rn_xplat_cxx_library( @@ -39,7 +39,7 @@ rn_xplat_cxx_library( "-fobjc-arc-exceptions", ], fbobjc_inherited_buck_flags = get_static_library_ios_flags(), - fbobjc_preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_preprocessor_flags_for_build_mode(), + fbobjc_preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), force_static = True, ios_deps = [ "//xplat/FBBaseLite:FBBaseLite", From 74fd6fb1da10fc31d6cb82e19d7eda46a93ffdac Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 11 Dec 2020 10:39:18 -0800 Subject: [PATCH 0200/1810] Codemod: Migrate from bridge.eventDispatcher to RCTModuleRegistry Summary: All NativeModules that use the bridge to require the eventDispatcher are now instead using the RCTModuleRegistry I introduced in D25412847 (https://github.com/facebook/react-native/commit/0ed81b28d3d786ea3b1cf0b932a008ef1f806ec4). ## What does this codemod do? For all ObjC files that contain `synthesize bridge = _bridge`, migrate calls that access the React Native bridge from `self`, and use it to load the event dispatcher. **Thoughts on Codemod Safety:** If we can access the bridge from self, then that means that if we synthesize the module registry, we can access the module registry from self. Therefore, this codemod is safe. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25449795 fbshipit-source-id: 2f7235d14659e73d673ae08763dc2cccdde55a19 --- Libraries/Settings/RCTSettingsManager.mm | 3 ++- React/CoreModules/RCTAccessibilityManager.mm | 21 +++++++++++++------- React/CoreModules/RCTDeviceInfo.mm | 9 ++++++--- React/CoreModules/RCTRedBox.mm | 4 +++- React/Modules/RCTUIManager.m | 7 +++++-- packages/rn-tester/RCTTest/RCTTestModule.mm | 3 ++- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Libraries/Settings/RCTSettingsManager.mm b/Libraries/Settings/RCTSettingsManager.mm index 8628857bc8aad2..1adf33c4477f72 100644 --- a/Libraries/Settings/RCTSettingsManager.mm +++ b/Libraries/Settings/RCTSettingsManager.mm @@ -25,6 +25,7 @@ @implementation RCTSettingsManager } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -72,7 +73,7 @@ - (void)userDefaultsDidChange:(NSNotification *)note #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"settingsUpdated" body:RCTJSONClean([_defaults dictionaryRepresentation])]; #pragma clang diagnostic pop diff --git a/React/CoreModules/RCTAccessibilityManager.mm b/React/CoreModules/RCTAccessibilityManager.mm index fc1741c21ee7e4..7426794b9251d6 100644 --- a/React/CoreModules/RCTAccessibilityManager.mm +++ b/React/CoreModules/RCTAccessibilityManager.mm @@ -29,6 +29,7 @@ @interface RCTAccessibilityManager () @implementation RCTAccessibilityManager @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; @synthesize multipliers = _multipliers; RCT_EXPORT_MODULE() @@ -111,7 +112,7 @@ - (void)accessibilityAnnouncementDidFinish:(__unused NSNotification *)notificati #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"announcementFinished" body:response]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"announcementFinished" body:response]; #pragma clang diagnostic pop } @@ -122,7 +123,8 @@ - (void)boldTextStatusDidChange:(__unused NSNotification *)notification _isBoldTextEnabled = newBoldTextEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"boldTextChanged" body:@(_isBoldTextEnabled)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"boldTextChanged" + body:@(_isBoldTextEnabled)]; #pragma clang diagnostic pop } } @@ -134,7 +136,8 @@ - (void)grayscaleStatusDidChange:(__unused NSNotification *)notification _isGrayscaleEnabled = newGrayscaleEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"grayscaleChanged" body:@(_isGrayscaleEnabled)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"grayscaleChanged" + body:@(_isGrayscaleEnabled)]; #pragma clang diagnostic pop } } @@ -146,7 +149,8 @@ - (void)invertColorsStatusDidChange:(__unused NSNotification *)notification _isInvertColorsEnabled = newInvertColorsEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"invertColorsChanged" body:@(_isInvertColorsEnabled)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"invertColorsChanged" + body:@(_isInvertColorsEnabled)]; #pragma clang diagnostic pop } } @@ -158,7 +162,8 @@ - (void)reduceMotionStatusDidChange:(__unused NSNotification *)notification _isReduceMotionEnabled = newReduceMotionEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"reduceMotionChanged" body:@(_isReduceMotionEnabled)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"reduceMotionChanged" + body:@(_isReduceMotionEnabled)]; #pragma clang diagnostic pop } } @@ -170,7 +175,8 @@ - (void)reduceTransparencyStatusDidChange:(__unused NSNotification *)notificatio _isReduceTransparencyEnabled = newReduceTransparencyEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"reduceTransparencyChanged" body:@(_isReduceTransparencyEnabled)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"reduceTransparencyChanged" + body:@(_isReduceTransparencyEnabled)]; #pragma clang diagnostic pop } } @@ -182,7 +188,8 @@ - (void)voiceVoiceOverStatusDidChange:(__unused NSNotification *)notification _isVoiceOverEnabled = newIsVoiceOverEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"screenReaderChanged" body:@(_isVoiceOverEnabled)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"screenReaderChanged" + body:@(_isVoiceOverEnabled)]; #pragma clang diagnostic pop } } diff --git a/React/CoreModules/RCTDeviceInfo.mm b/React/CoreModules/RCTDeviceInfo.mm index b102059c279723..7d540950e7e83a 100644 --- a/React/CoreModules/RCTDeviceInfo.mm +++ b/React/CoreModules/RCTDeviceInfo.mm @@ -28,6 +28,7 @@ @implementation RCTDeviceInfo { } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; @synthesize turboModuleRegistry = _turboModuleRegistry; RCT_EXPORT_MODULE() @@ -180,8 +181,9 @@ - (void)_interfaceOrientationDidChange !UIInterfaceOrientationIsLandscape(nextOrientation))) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateDimensions" - body:RCTExportedDimensions(_bridge, _turboModuleRegistry)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] + sendDeviceEventWithName:@"didUpdateDimensions" + body:RCTExportedDimensions(_bridge, _turboModuleRegistry)]; #pragma clang diagnostic pop } @@ -203,7 +205,8 @@ - (void)_interfaceFrameDidChange if (!([nextInterfaceDimensions isEqual:_currentInterfaceDimensions])) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateDimensions" body:nextInterfaceDimensions]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateDimensions" + body:nextInterfaceDimensions]; #pragma clang diagnostic pop } diff --git a/React/CoreModules/RCTRedBox.mm b/React/CoreModules/RCTRedBox.mm index 64c9e33289460b..ce47519514d862 100644 --- a/React/CoreModules/RCTRedBox.mm +++ b/React/CoreModules/RCTRedBox.mm @@ -455,6 +455,7 @@ @implementation RCTRedBox { } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -590,7 +591,8 @@ - (void)showErrorMessage:(NSString *)message #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self->_bridge.eventDispatcher sendDeviceEventWithName:@"collectRedBoxExtraData" body:nil]; + [[self->_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"collectRedBoxExtraData" + body:nil]; #pragma clang diagnostic pop if (!self->_window) { diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index b6dfefa3e60d4c..74579d2ba07879 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -81,6 +81,7 @@ @implementation RCTUIManager { } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -196,7 +197,8 @@ - (void)didReceiveNewContentSizeMultiplier id multiplier = [[self->_bridge moduleForName:@"AccessibilityManager" lazilyLoadIfNecessary:YES] valueForKey:@"multiplier"]; if (multiplier) { - [_bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateContentSizeMultiplier" body:multiplier]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateContentSizeMultiplier" + body:multiplier]; } #pragma clang diagnostic pop @@ -256,7 +258,8 @@ - (void)namedOrientationDidChange #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendDeviceEventWithName:@"namedOrientationDidChange" body:orientationEvent]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"namedOrientationDidChange" + body:orientationEvent]; #pragma clang diagnostic pop } diff --git a/packages/rn-tester/RCTTest/RCTTestModule.mm b/packages/rn-tester/RCTTest/RCTTestModule.mm index 33e5f090983ebd..97db1f32a2b3f9 100644 --- a/packages/rn-tester/RCTTest/RCTTestModule.mm +++ b/packages/rn-tester/RCTTest/RCTTestModule.mm @@ -79,6 +79,7 @@ @implementation RCTTestModule { } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -120,7 +121,7 @@ - (dispatch_queue_t)methodQueue { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [_bridge.eventDispatcher sendAppEventWithName:name body:body]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendAppEventWithName:name body:body]; #pragma clang diagnostic pop } From 1f883192eca22f80d0979430c1106107d4c4ef54 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 11 Dec 2020 10:39:18 -0800 Subject: [PATCH 0201/1810] Manual: Migrate from bridge.eventDispatcher to RCTModuleRegistry Summary: This is an extension of D25449795. I searched for all usages of .eventDispatcher within NativeModules, and migrated them all to the Venice-compatible RCTModuleRegistry API. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25473844 fbshipit-source-id: 2b8deec236e019f3adfb59fadd745c249ff822f4 --- Libraries/NativeAnimation/RCTNativeAnimatedModule.mm | 9 +++++++-- .../NativeAnimation/RCTNativeAnimatedTurboModule.mm | 9 +++++++-- React/CoreModules/RCTDevSettings.mm | 4 ++-- React/CoreModules/RCTDeviceInfo.mm | 6 ++++-- React/Modules/RCTEventEmitter.h | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm b/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm index 33fe87ad4d4a10..5d72181502cbb2 100644 --- a/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm +++ b/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm @@ -48,7 +48,7 @@ - (void)invalidate { [super invalidate]; [_nodesManager stopAnimationLoop]; - [self.bridge.eventDispatcher removeDispatchObserver:self]; + [[self.moduleRegistry moduleForName:"EventDispatcher"] removeDispatchObserver:self]; [self.bridge.uiManager.observerCoordinator removeObserver:self]; [self.bridge.surfacePresenter removeObserver:self]; } @@ -65,11 +65,16 @@ - (void)setBridge:(RCTBridge *)bridge { [super setBridge:bridge]; _nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:self.bridge surfacePresenter:bridge.surfacePresenter]; - [bridge.eventDispatcher addDispatchObserver:self]; [bridge.uiManager.observerCoordinator addObserver:self]; [bridge.surfacePresenter addObserver:self]; } +- (void)setModuleRegistry:(RCTModuleRegistry *)moduleRegistry +{ + [super setModuleRegistry:moduleRegistry]; + [[moduleRegistry moduleForName:"EventDispatcher"] addDispatchObserver:self]; +} + /* * This selector should only be invoked in bridgeless mode, which is not compatible with this non turbo module. */ diff --git a/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm b/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm index 45213380d81d7a..e491139a93fe05 100644 --- a/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm +++ b/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm @@ -49,7 +49,7 @@ - (void)invalidate { [super invalidate]; [_nodesManager stopAnimationLoop]; - [self.bridge.eventDispatcher removeDispatchObserver:self]; + [[self.moduleRegistry moduleForName:"EventDispatcher"] removeDispatchObserver:self]; [self.bridge.uiManager.observerCoordinator removeObserver:self]; [_surfacePresenter removeObserver:self]; } @@ -67,11 +67,16 @@ - (void)setBridge:(RCTBridge *)bridge [super setBridge:bridge]; _surfacePresenter = bridge.surfacePresenter; _nodesManager = [[RCTNativeAnimatedNodesManager alloc] initWithBridge:self.bridge surfacePresenter:_surfacePresenter]; - [bridge.eventDispatcher addDispatchObserver:self]; [bridge.uiManager.observerCoordinator addObserver:self]; [_surfacePresenter addObserver:self]; } +- (void)setModuleRegistry:(RCTModuleRegistry *)moduleRegistry +{ + [super setModuleRegistry:moduleRegistry]; + [[moduleRegistry moduleForName:"EventDispatcher"] addDispatchObserver:self]; +} + /* * In bridgeless mode, `setBridge` is never called during initializtion. Instead this selector is invoked via * BridgelessTurboModuleSetup. diff --git a/React/CoreModules/RCTDevSettings.mm b/React/CoreModules/RCTDevSettings.mm index 4e11bd3c263669..a165e48b0a69a1 100644 --- a/React/CoreModules/RCTDevSettings.mm +++ b/React/CoreModules/RCTDevSettings.mm @@ -350,7 +350,7 @@ - (BOOL)isHotLoadingEnabled if (_isJSLoaded) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.bridge.eventDispatcher sendDeviceEventWithName:@"toggleElementInspector" body:nil]; + [[self.moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"toggleElementInspector" body:nil]; #pragma clang diagnostic pop } } @@ -463,7 +463,7 @@ - (void)jsLoaded:(NSNotification *)notification if ([self isElementInspectorShown]) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.bridge.eventDispatcher sendDeviceEventWithName:@"toggleElementInspector" body:nil]; + [[self.moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"toggleElementInspector" body:nil]; #pragma clang diagnostic pop } }); diff --git a/React/CoreModules/RCTDeviceInfo.mm b/React/CoreModules/RCTDeviceInfo.mm index 7d540950e7e83a..9d722f0ea832dd 100644 --- a/React/CoreModules/RCTDeviceInfo.mm +++ b/React/CoreModules/RCTDeviceInfo.mm @@ -152,12 +152,14 @@ static BOOL RCTIsIPhoneX() - (void)didReceiveNewContentSizeMultiplier { RCTBridge *bridge = _bridge; + RCTModuleRegistry *moduleRegistry = _moduleRegistry; RCTExecuteOnMainQueue(^{ // Report the event across the bridge. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateDimensions" - body:RCTExportedDimensions(bridge, self->_turboModuleRegistry)]; + [[moduleRegistry moduleForName:"EventDispatcher"] + sendDeviceEventWithName:@"didUpdateDimensions" + body:RCTExportedDimensions(bridge, self->_turboModuleRegistry)]; #pragma clang diagnostic pop }); } diff --git a/React/Modules/RCTEventEmitter.h b/React/Modules/RCTEventEmitter.h index f72f53909f4ba5..bb1abd5f7d26f8 100644 --- a/React/Modules/RCTEventEmitter.h +++ b/React/Modules/RCTEventEmitter.h @@ -15,6 +15,7 @@ @interface RCTEventEmitter : NSObject @property (nonatomic, weak) RCTBridge *bridge; +@property (nonatomic, weak) RCTModuleRegistry *moduleRegistry; - (instancetype)initWithDisabledObservation; From d8c84d3a6579f8de89b09cff6235c0af99dfb69c Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Fri, 11 Dec 2020 10:48:53 -0800 Subject: [PATCH 0202/1810] Make Metro work with Venice Summary: Now, Metro should work with Venice. This piggybacks on Lulu's fix here: D22477500 (https://github.com/facebook/react-native/commit/9b8ffeee4c54eb05ca74d626b171a958fa6db4d4). Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D25323041 fbshipit-source-id: 859958185c5be52a4bfdc12a82ecd7719042ae5f --- .../com/facebook/react/devsupport/DevSupportManagerBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index 427c7f37a1ac16..aa84c0091c5686 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -102,7 +102,7 @@ private enum ErrorType { private final Context mApplicationContext; private final ShakeDetector mShakeDetector; private final BroadcastReceiver mReloadAppBroadcastReceiver; - private final DevServerHelper mDevServerHelper; + protected final DevServerHelper mDevServerHelper; private final LinkedHashMap mCustomDevOptions = new LinkedHashMap<>(); private final ReactInstanceManagerDevHelper mReactInstanceManagerHelper; private final @Nullable String mJSAppBundleName; From e0ece12203327123e8d3e58d78afa13f163448ae Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Fri, 11 Dec 2020 11:22:09 -0800 Subject: [PATCH 0203/1810] Fix duplicate Networking module bug Summary: While investigating a bridgeless networking issue, I noticed something very peculiar. **Two** networking turbo modules are built and used in bridgeless mode. Upon debugging, I realized that each of them have a different `TurboModuleHolder`. The reason is the following: 1. In JS, the module's name is [Networking](https://fburl.com/diffusion/f2xu4wie) 2. In ObjC, we call the module "RCTNetworking" (examples in this diff) 3. Both scenarios end up creating the correct Turbo Module: [RCTNetworking](https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/Libraries/Network/RCTNetworking.mm?link_ref=search), but the `TurboModuleHolder` doesn't know that "RCTNetworking" and "Networking" are the same. Any other modules accessed this way will have the same issue. An alternative solution would be to tell `TurboModuleHolder` to strip the `RCT` suffix, which would solve the problem globally. RSNara thoughts? Changelog: [Internal] Reviewed By: RSNara Differential Revision: D25477044 fbshipit-source-id: 02219de578ef4d19e579110e4242883a30cefcd6 --- Libraries/Blob/RCTBlobManager.mm | 2 +- Libraries/Image/RCTImageLoader.mm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/Blob/RCTBlobManager.mm b/Libraries/Blob/RCTBlobManager.mm index a75844ed6ae1ed..25d3ae8f631565 100755 --- a/Libraries/Blob/RCTBlobManager.mm +++ b/Libraries/Blob/RCTBlobManager.mm @@ -140,7 +140,7 @@ - (void)remove:(NSString *)blobId RCT_EXPORT_METHOD(addNetworkingHandler) { - RCTNetworking *const networking = _bridge ? _bridge.networking : [_turboModuleRegistry moduleForName:"RCTNetworking"]; + RCTNetworking *const networking = _bridge ? _bridge.networking : [_turboModuleRegistry moduleForName:"Networking"]; // TODO(T63516227): Why can methodQueue be nil here? // We don't want to do anything when methodQueue is nil. diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index d35d0bb44270da..49f67f19b65059 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -646,7 +646,7 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request { // Check if networking module is available if (RCT_DEBUG && ![_bridge respondsToSelector:@selector(networking)] - && ![_turboModuleRegistry moduleForName:"RCTNetworking"]) { + && ![_turboModuleRegistry moduleForName:"Networking"]) { RCTLogError(@"No suitable image URL loader found for %@. You may need to " " import the RCTNetwork library in order to load images.", request.URL.absoluteString); @@ -655,7 +655,7 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request RCTNetworking *networking = [_bridge networking]; if (!networking) { - networking = [_turboModuleRegistry moduleForName:"RCTNetworking"]; + networking = [_turboModuleRegistry moduleForName:"Networking"]; } // Check if networking module can load image From 2a175b14e6f76339c17981c18b66487da35c937b Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Fri, 11 Dec 2020 11:22:09 -0800 Subject: [PATCH 0204/1810] Strip RCT prefix in TurbooduleManager Summary: This is a followup to the issue described in D25477044, basically the TM cache can get messed up if `TurboModuleManager` is asked for "RCTNetworking" vs "Networking". This solves that issue globally. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D25480624 fbshipit-source-id: 2024560eadbcf58cdc3d7d5675b4120aa2fa2582 --- .../nativemodule/core/platform/ios/RCTTurboModuleManager.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index f875cad99af6a7..14dfc0c96e09d8 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -358,6 +358,10 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName */ - (id)provideRCTTurboModule:(const char *)moduleName { + if (strncmp("RCT", moduleName, 3) == 0) { + moduleName = [[[NSString stringWithUTF8String:moduleName] substringFromIndex:3] UTF8String]; + } + TurboModuleHolder *moduleHolder = [self _getOrCreateTurboModuleHolder:moduleName]; if (!moduleHolder) { From fe887173ee5a30fb913247fa48466d09d7427d41 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 11 Dec 2020 14:05:19 -0800 Subject: [PATCH 0205/1810] Fix clone of props for legacy interop component Summary: Changelog: [internal] Cloning of `LegacyViewManagerInteropViewProps` causes loss of `sourceProps.otherProps` if the cloning happens before shadow node is mounted. This was happening in WebView and callback `onLoadEnd` was dropped because of this. Reviewed By: JoshuaGross Differential Revision: D25474581 fbshipit-source-id: 74d7c5cd32b7318bb99306c82bc8b5e5eab63db2 --- .../LegacyViewManagerInteropViewProps.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp index 891c0e0aecce1e..5d123f49f4df43 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp @@ -10,10 +10,20 @@ namespace facebook { namespace react { +static folly::dynamic recursiveMerge( + folly::dynamic const &lhs, + folly::dynamic const &rhs) { + auto copy = lhs; + copy.merge_patch(rhs); + return copy; +} + LegacyViewManagerInteropViewProps::LegacyViewManagerInteropViewProps( const LegacyViewManagerInteropViewProps &sourceProps, const RawProps &rawProps) - : ViewProps(sourceProps, rawProps), otherProps((folly::dynamic)rawProps) {} + : ViewProps(sourceProps, rawProps), + otherProps( + recursiveMerge(sourceProps.otherProps, (folly::dynamic)rawProps)) {} } // namespace react } // namespace facebook From 933cef6d9a6cf10231e5960a0f0cd3a8ebd11a3c Mon Sep 17 00:00:00 2001 From: Ron Edelstein Date: Fri, 11 Dec 2020 16:43:23 -0800 Subject: [PATCH 0206/1810] More explicit marking of autoglob as False Summary: In preparation for flipping the default, marking autoglob as False in places where it isn't explicitly specified. Changelog: [Internal] Reviewed By: strulovich Differential Revision: D25497305 fbshipit-source-id: 142e5caca2d67efcb3c25067a36934f7f6dd4b21 --- .../src/androidTest/java/com/facebook/react/testing/BUCK | 1 + .../java/com/facebook/react/testing/idledetection/BUCK | 1 + .../androidTest/java/com/facebook/react/testing/network/BUCK | 1 + .../src/androidTest/java/com/facebook/react/testing/rule/BUCK | 1 + ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK | 1 + .../src/androidTest/java/com/facebook/react/tests/core/BUCK | 1 + .../src/main/java/com/facebook/debug/debugoverlay/model/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/debug/holder/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/debug/tags/BUCK | 1 + .../src/main/java/com/facebook/hermes/instrumentation/BUCK | 2 ++ .../src/main/java/com/facebook/hermes/reactexecutor/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/hermes/unicode/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/perftest/BUCK | 1 + .../src/main/java/com/facebook/proguard/annotations/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/animated/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/bridge/BUCK | 2 ++ ReactAndroid/src/main/java/com/facebook/react/common/BUCK | 1 + .../src/main/java/com/facebook/react/common/network/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/config/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK | 2 ++ ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/jstasks/BUCK | 1 + .../src/main/java/com/facebook/react/module/annotations/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/module/model/BUCK | 1 + .../main/java/com/facebook/react/modules/accessibilityinfo/BUCK | 1 + .../src/main/java/com/facebook/react/modules/appearance/BUCK | 1 + .../src/main/java/com/facebook/react/modules/appregistry/BUCK | 1 + .../src/main/java/com/facebook/react/modules/appstate/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK | 1 + .../src/main/java/com/facebook/react/modules/bundleloader/BUCK | 1 + .../src/main/java/com/facebook/react/modules/camera/BUCK | 1 + .../src/main/java/com/facebook/react/modules/clipboard/BUCK | 1 + .../src/main/java/com/facebook/react/modules/common/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK | 1 + .../src/main/java/com/facebook/react/modules/datepicker/BUCK | 1 + .../src/main/java/com/facebook/react/modules/debug/BUCK | 2 ++ .../src/main/java/com/facebook/react/modules/deviceinfo/BUCK | 1 + .../src/main/java/com/facebook/react/modules/dialog/BUCK | 1 + .../src/main/java/com/facebook/react/modules/fabric/BUCK | 1 + .../src/main/java/com/facebook/react/modules/fresco/BUCK | 1 + .../src/main/java/com/facebook/react/modules/i18nmanager/BUCK | 1 + .../src/main/java/com/facebook/react/modules/image/BUCK | 1 + .../src/main/java/com/facebook/react/modules/intent/BUCK | 1 + .../src/main/java/com/facebook/react/modules/network/BUCK | 1 + .../src/main/java/com/facebook/react/modules/permissions/BUCK | 1 + .../src/main/java/com/facebook/react/modules/share/BUCK | 1 + .../src/main/java/com/facebook/react/modules/sound/BUCK | 1 + .../src/main/java/com/facebook/react/modules/statusbar/BUCK | 1 + .../src/main/java/com/facebook/react/modules/storage/BUCK | 1 + .../src/main/java/com/facebook/react/modules/systeminfo/BUCK | 2 ++ .../src/main/java/com/facebook/react/modules/toast/BUCK | 1 + .../src/main/java/com/facebook/react/modules/vibration/BUCK | 1 + .../src/main/java/com/facebook/react/modules/websocket/BUCK | 1 + .../src/main/java/com/facebook/react/packagerconnection/BUCK | 1 + .../src/main/java/com/facebook/react/reactperflogger/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/shell/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/surface/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/touch/BUCK | 1 + .../src/main/java/com/facebook/react/turbomodule/core/BUCK | 2 ++ .../java/com/facebook/react/turbomodule/core/interfaces/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK | 2 ++ .../src/main/java/com/facebook/react/uimanager/annotations/BUCK | 1 + .../src/main/java/com/facebook/react/uimanager/common/BUCK | 1 + .../src/main/java/com/facebook/react/uimanager/interfaces/BUCK | 1 + .../src/main/java/com/facebook/react/uimanager/util/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/util/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/viewmanagers/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/common/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK | 2 ++ .../src/main/java/com/facebook/react/views/imagehelper/BUCK | 2 ++ ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/picker/BUCK | 1 + .../src/main/java/com/facebook/react/views/progressbar/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/scroll/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK | 1 + .../src/main/java/com/facebook/react/views/swiperefresh/BUCK | 1 + .../src/main/java/com/facebook/react/views/switchview/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK | 1 + .../main/java/com/facebook/react/views/text/frescosupport/BUCK | 1 + .../src/main/java/com/facebook/react/views/textinput/BUCK | 1 + .../main/java/com/facebook/react/views/unimplementedview/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/react/views/view/BUCK | 1 + ReactAndroid/src/main/java/com/facebook/systrace/BUCK | 1 + .../fbcore/src/main/java/com/facebook/common/logging/BUCK | 1 + ReactAndroid/src/main/third-party/java/asm/BUCK | 1 + ReactAndroid/src/main/third-party/java/fest/BUCK | 1 + ReactAndroid/src/main/third-party/java/junit/BUCK | 1 + ReactAndroid/src/main/third-party/java/mockito/BUCK | 1 + ReactAndroid/src/main/third-party/java/mockito2/BUCK | 1 + ReactAndroid/src/main/third-party/java/sqlite/BUCK | 1 + ReactAndroid/src/test/java/com/facebook/common/logging/BUCK | 1 + ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK | 1 + ReactAndroid/src/test/java/org/mockito/configuration/BUCK | 1 + packages/react-native-codegen/BUCK | 1 + 97 files changed, 106 insertions(+) diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK index 6d16a702ecf400..a7162899373bd1 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK @@ -9,6 +9,7 @@ rn_android_library( "network/**/*.java", ], ), + autoglob = False, is_androidx = True, visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/BUCK index 80a28b690ef50f..b3ed32bb4e9de7 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "idledetection", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/BUCK index 980eda5d8d0601..d8e68b3f29aa64 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "network", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/BUCK index 1bf0b3c7a8ab15..86d2074e0e1e0a 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/BUCK @@ -11,6 +11,7 @@ load( rn_android_library( name = "rule", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK index 0b29ef31268c22..6cd9d22f56df70 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_int rn_android_library( name = "tests", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/core/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/core/BUCK index 0c2c6a3781d998..2aa06b7cbf83ba 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/core/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/core/BUCK @@ -11,6 +11,7 @@ load( rn_android_library( name = "core", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, deps = ([ react_native_dep("third-party/android/androidx:test-espresso-core"), diff --git a/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/BUCK b/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/BUCK index a161001ec1cab1..3ccc5d058d7d85 100644 --- a/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "model", srcs = glob(["*.java"]), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/main/java/com/facebook/debug/holder/BUCK b/ReactAndroid/src/main/java/com/facebook/debug/holder/BUCK index 2daef176010bf5..13c5da59066b27 100644 --- a/ReactAndroid/src/main/java/com/facebook/debug/holder/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/debug/holder/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "holder", srcs = glob(["*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/debug/tags/BUCK b/ReactAndroid/src/main/java/com/facebook/debug/tags/BUCK index 3e2e015c78e8d2..2133f0f6b9978b 100644 --- a/ReactAndroid/src/main/java/com/facebook/debug/tags/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/debug/tags/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "tags", srcs = glob(["*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK index 439ae4b4743578..c78901a85f6c1d 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_nat rn_android_library( name = "instrumentation", srcs = ["HermesMemoryDumper.java"], + autoglob = False, visibility = [ "PUBLIC", ], @@ -11,6 +12,7 @@ rn_android_library( rn_android_library( name = "hermes_samplingprofiler", srcs = ["HermesSamplingProfiler.java"], + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = ["PUBLIC"], deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK index 5f42f833dfb309..d80f1ec535cf3b 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK @@ -6,6 +6,7 @@ rn_android_library( "HermesExecutor.java", "HermesExecutorFactory.java", ], + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/unicode/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/unicode/BUCK index 8f5636e166283b..49f7e87f72be9a 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/unicode/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/hermes/unicode/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "unicode", srcs = glob(["**/*.java"]), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/main/java/com/facebook/perftest/BUCK b/ReactAndroid/src/main/java/com/facebook/perftest/BUCK index 974cfdbcd02591..1809442c8eae59 100644 --- a/ReactAndroid/src/main/java/com/facebook/perftest/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/perftest/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library") rn_android_library( name = "perftest", srcs = glob(["*.java"]), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/main/java/com/facebook/proguard/annotations/BUCK b/ReactAndroid/src/main/java/com/facebook/proguard/annotations/BUCK index 31dc81e24005ae..fd767a6dcf14f3 100644 --- a/ReactAndroid/src/main/java/com/facebook/proguard/annotations/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/proguard/annotations/BUCK @@ -16,6 +16,7 @@ fb_native.remote_file( rn_android_library( name = "annotations", srcs = glob(["*.java"]), + autoglob = False, proguard_config = "proguard_annotations.pro", visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/BUCK b/ReactAndroid/src/main/java/com/facebook/react/BUCK index e2a345df18109c..0897152fd12c0e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "react", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK b/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK index 9c1b8a17ecc67c..81527da4f69178 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK @@ -5,6 +5,7 @@ rn_android_library( srcs = glob([ "*.java", ]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/BUCK b/ReactAndroid/src/main/java/com/facebook/react/bridge/BUCK index fcf60e30696589..0f54a3c0b0b57f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/BUCK @@ -20,6 +20,7 @@ rn_android_library( ["**/*.java"], exclude = INTERFACES, ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], proguard_config = "reactnative.pro", @@ -65,6 +66,7 @@ rn_android_library( rn_android_library( name = "interfaces", srcs = glob(INTERFACES), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], proguard_config = "reactnative.pro", diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/common/BUCK index ef52fb6fb78abf..c8a8cb7d18e144 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/common/BUCK @@ -10,6 +10,7 @@ rn_android_library( ["**/*.java"], exclude = SUB_PROJECTS, ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/network/BUCK b/ReactAndroid/src/main/java/com/facebook/react/common/network/BUCK index 25f39b59688c28..2eca2adf3f72ca 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/network/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/common/network/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "network", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/BUCK b/ReactAndroid/src/main/java/com/facebook/react/config/BUCK index 6120fdec936c2d..d2a96d88cfeeea 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/config/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library") rn_android_library( name = "config", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK index a2113e6fc542a1..0240a2666fa622 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "devsupport", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], manifest = "AndroidManifest.xml", @@ -46,6 +47,7 @@ rn_android_library( rn_android_library( name = "interfaces", srcs = glob(["interfaces/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK index a1882a6cdbd5d1..f3cb842381849b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK @@ -8,6 +8,7 @@ rn_android_library( "jsi/*.java", "mounting/**/*.java", ]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK index a1a374ef936b36..d601632a0f3bdb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_nat rn_android_library( name = "jscexecutor", srcs = glob(["*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/jstasks/BUCK b/ReactAndroid/src/main/java/com/facebook/react/jstasks/BUCK index 26444912bf4e73..d5a734f79243ef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/jstasks/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/jstasks/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "jstasks", srcs = glob(["*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/module/annotations/BUCK b/ReactAndroid/src/main/java/com/facebook/react/module/annotations/BUCK index b213c9d3133a0f..ec9fc4e9e07e9e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/module/annotations/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/module/annotations/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "annotations", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/module/model/BUCK b/ReactAndroid/src/main/java/com/facebook/react/module/model/BUCK index 85f23a35691b69..22d2f5a6625890 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/module/model/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/module/model/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "model", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK index 832ee9de355957..d032844ae7bc56 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "accessibilityinfo", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK index ed7eba28bfb908..ee8429aa991239 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "appearance", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appregistry/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/appregistry/BUCK index d54b2cd82034de..727a8d30d1ee91 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appregistry/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appregistry/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_target", "rn_android_li rn_android_library( name = "appregistry", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK index f1b8ad181290c6..295c630477ad5d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "appstate", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK index 266f87cf28f7bf..95b880422d10f0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "blob", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK index dcc9cbd7a419b5..0a129c6c7a61f9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "bundleloader", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK index 217b26ea0deb36..f679963f07467f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "camera", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/BUCK index d755fa2dd9aa55..0e46f8795096e5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "clipboard", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/common/BUCK index 47dad24dd0491a..d42deef1d60f4c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/common/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "common", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK index c8694abe9810e9..118339191a1282 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "core", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK index 56be88ecc46b9e..02bc5fbc3ebe0d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "datepicker", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK index dd5f58313cd3b0..034c8e312bcbfe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "debug", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ @@ -30,6 +31,7 @@ rn_android_library( rn_android_library( name = "interfaces", srcs = glob(["interfaces/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK index c4f485bd0995f3..da57d4876626c8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "deviceinfo", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK index 60eb0750f50825..40a7d8c6e998f8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "dialog", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/fabric/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/fabric/BUCK index f88d3d22465bda..361c17d91f7afb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/fabric/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/fabric/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_target", "rn_android_li rn_android_library( name = "fabric", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ ], diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/BUCK index a0762971a030ed..5f4e8ce6a5815d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "fresco", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/BUCK index 2b7eeb854d9425..1b479ecd3e2797 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "i18nmanager", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK index 7a5ef484c3d957..4fba41ae0fd81c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "image", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK index ef9571e84e6deb..d89eb671861503 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "intent", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK index 592da58ca8362b..0d7020d1a9fa2a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "network", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK index 3aa6d043e9e635..54e9a48eab1168 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "permissions", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK index 8b788efbcc6319..d3ead4b3ae47c3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "share", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK index a3a401b9b2bba0..411ade4a0efd1b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "sound", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK index fd0d6b732a25fc..2b6cf951aef714 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "statusbar", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK index 5f54664eec412a..ed16e94bb9b3ff 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "storage", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK index 9170b3c036b9c4..695140160c82bc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK @@ -6,6 +6,7 @@ rn_android_library( "AndroidInfoModule.java", "ReactNativeVersion.java", ], + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ @@ -31,6 +32,7 @@ rn_android_library( srcs = [ "AndroidInfoHelpers.java", ], + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK index dc3d6cb5c6a3bd..f0c2b1dae8a5de 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "toast", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK index 40c531ec051ae6..e80dbb0ce5d619 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "vibration", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK index 990b45769e2dab..9bf4b604c8ae3c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_roo rn_android_library( name = "websocket", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/BUCK b/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/BUCK index 3aa924ecad3ad6..76c5775ea9d04e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/BUCK @@ -5,6 +5,7 @@ rn_android_library( srcs = glob( ["**/*.java"], ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/BUCK b/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/BUCK index d8d99e703d2b02..3575b09bb06b13 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/BUCK @@ -7,6 +7,7 @@ rn_android_library( "*.java", ], ), + autoglob = False, labels = [ "supermodule:xplat/default/public.react_native.infra", ], diff --git a/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK b/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK index e8e27ee8e2b900..7b44b22136b874 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "shell", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/surface/BUCK b/ReactAndroid/src/main/java/com/facebook/react/surface/BUCK index beb35ce40c1055..6a21268b9c579b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/surface/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/surface/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "surface", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/touch/BUCK b/ReactAndroid/src/main/java/com/facebook/react/touch/BUCK index 839bd5beb44bb0..c9d6bbbe59e0a9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/touch/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/touch/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "touch", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK index 721fe18d0cc7f1..e42fe4e012d4d4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK @@ -8,6 +8,7 @@ rn_android_library( ], exclude = ["CallInvokerHolderImpl.java"], ), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, visibility = [ @@ -40,6 +41,7 @@ rn_android_library( rn_android_library( name = "callinvokerholder", srcs = ["CallInvokerHolderImpl.java"], + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/BUCK index ad97b93f20d94a..5526d046ddfef7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/BUCK @@ -5,6 +5,7 @@ rn_android_library( srcs = glob( ["*.java"], ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK index be919fcba0fc41..6e8ed014b95f13 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK @@ -13,6 +13,7 @@ rn_android_library( "DisplayMetricsHolder.java", ], ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ @@ -59,6 +60,7 @@ rn_android_library( srcs = [ "DisplayMetricsHolder.java", ], + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/annotations/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/annotations/BUCK index 11bc3ba33e01ef..b876ba18bc5b23 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/annotations/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/annotations/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "annotations", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK index 516b18e0b55183..6d46fd8953e9c2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "common", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK index 92c16aba4714f0..8922b82d73d756 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "interfaces", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/util/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/util/BUCK index 6d31563ef3a53f..c8173be0b382a6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/util/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/util/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "util", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/util/BUCK b/ReactAndroid/src/main/java/com/facebook/react/util/BUCK index 679245155e108d..67fc95476d5954 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/util/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/util/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "util", srcs = glob(["**/*.java"]), + autoglob = False, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/BUCK b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/BUCK index 039099fb0d634a..33af2c1e53c0b5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "viewmanagers", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/common/BUCK index 2b6f2c1e932a8e..720c0618c0f9a8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/common/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "common", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK index ac71cc153ec774..4b8d23644be731 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "drawer", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK index 663357ac133d7f..40f0d2f5592b3f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK @@ -7,6 +7,7 @@ IMAGE_EVENT_FILES = [ rn_android_library( name = "imageevents", srcs = IMAGE_EVENT_FILES, + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ @@ -31,6 +32,7 @@ rn_android_library( ["*.java"], exclude = IMAGE_EVENT_FILES, ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/BUCK index 4e9cafe129a021..3776c3389f849f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/BUCK @@ -6,6 +6,7 @@ rn_android_library( ["*.java"], exclude = ["MultiSourceHelper.java"], ), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ @@ -21,6 +22,7 @@ rn_android_library( rn_android_library( name = "withmultisource", srcs = ["MultiSourceHelper.java"], + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK index 53e6a5a987f584..27c9e712a583d5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "modal", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/picker/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/picker/BUCK index 00b41242092acb..3cc6179ada7bb7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/picker/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/picker/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "picker", srcs = glob(["**/*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK index af7909efc1e8ee..7cdbb3e964fa35 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "progressbar", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/BUCK index 736a73dc537560..60f607899a3a10 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "scroll", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK index 63f1658e470b6f..346c3512f352fc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "slider", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK index 528c4af8a55056..a138ce884bd02c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "swiperefresh", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK index cd59cc2b720430..166dc14a57fd19 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "switchview", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK index ac69e03c258350..49b14f8a7176a0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "text", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/BUCK index fef31ebea6c4aa..38985bbf96b449 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "frescosupport", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK index 3b408b3d319e69..ae5cec1338544f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "textinput", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], required_for_source_only_abi = True, diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/unimplementedview/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/unimplementedview/BUCK index 24d0a3f2d916fa..62b23d28001acf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/unimplementedview/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/unimplementedview/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "unimplementedview", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/view/BUCK index 66386a0ffbfd5c..8dc27557662720 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_android_library( name = "view", srcs = glob(["*.java"]), + autoglob = False, is_androidx = True, labels = ["supermodule:xplat/default/public.react_native.infra"], provided_deps = [ diff --git a/ReactAndroid/src/main/java/com/facebook/systrace/BUCK b/ReactAndroid/src/main/java/com/facebook/systrace/BUCK index 21006f1842c39a..ef6249a999177f 100644 --- a/ReactAndroid/src/main/java/com/facebook/systrace/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/systrace/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library") rn_android_library( name = "systrace", srcs = glob(["*.java"]), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/main/libraries/fbcore/src/main/java/com/facebook/common/logging/BUCK b/ReactAndroid/src/main/libraries/fbcore/src/main/java/com/facebook/common/logging/BUCK index e8c4380c800a5f..e18c8ef06ee157 100644 --- a/ReactAndroid/src/main/libraries/fbcore/src/main/java/com/facebook/common/logging/BUCK +++ b/ReactAndroid/src/main/libraries/fbcore/src/main/java/com/facebook/common/logging/BUCK @@ -2,6 +2,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "logging", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ react_native_dep("libraries/fresco/fresco-react-native:fbcore"), diff --git a/ReactAndroid/src/main/third-party/java/asm/BUCK b/ReactAndroid/src/main/third-party/java/asm/BUCK index f344506a49ca34..5741e1c0ea7998 100644 --- a/ReactAndroid/src/main/third-party/java/asm/BUCK +++ b/ReactAndroid/src/main/third-party/java/asm/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "asm", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ ":asm-analysis", diff --git a/ReactAndroid/src/main/third-party/java/fest/BUCK b/ReactAndroid/src/main/third-party/java/fest/BUCK index 10f995f166d306..50285d715060a0 100644 --- a/ReactAndroid/src/main/third-party/java/fest/BUCK +++ b/ReactAndroid/src/main/third-party/java/fest/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "fest", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ ":fest-core", diff --git a/ReactAndroid/src/main/third-party/java/junit/BUCK b/ReactAndroid/src/main/third-party/java/junit/BUCK index 9f4cbec6221d28..555a01989f107f 100644 --- a/ReactAndroid/src/main/third-party/java/junit/BUCK +++ b/ReactAndroid/src/main/third-party/java/junit/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "junit", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ ":hamcrest", diff --git a/ReactAndroid/src/main/third-party/java/mockito/BUCK b/ReactAndroid/src/main/third-party/java/mockito/BUCK index a7f91609227a4c..9fda3bf174d9d6 100644 --- a/ReactAndroid/src/main/third-party/java/mockito/BUCK +++ b/ReactAndroid/src/main/third-party/java/mockito/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "mockito", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ ":mockito-core", diff --git a/ReactAndroid/src/main/third-party/java/mockito2/BUCK b/ReactAndroid/src/main/third-party/java/mockito2/BUCK index 4d2ea058b7713f..b5332e4f2ec559 100644 --- a/ReactAndroid/src/main/third-party/java/mockito2/BUCK +++ b/ReactAndroid/src/main/third-party/java/mockito2/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "mockito2", + autoglob = False, visibility = ["PUBLIC"], exported_deps = [ ":byte-buddy", diff --git a/ReactAndroid/src/main/third-party/java/sqlite/BUCK b/ReactAndroid/src/main/third-party/java/sqlite/BUCK index 7fd47e8a19d975..f93cb4833b10b5 100644 --- a/ReactAndroid/src/main/third-party/java/sqlite/BUCK +++ b/ReactAndroid/src/main/third-party/java/sqlite/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "sqlite", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ ":sqlite4java", diff --git a/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK b/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK index b315429ee1af2a..71326c7077e3b6 100644 --- a/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "logging", srcs = glob(["**/*.java"]), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK index c774e197673e51..06562939cf9e4d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK @@ -25,6 +25,7 @@ rn_android_library( rn_robolectric_test( name = "bridge", srcs = glob(STANDARD_TEST_SRCS), + autoglob = False, contacts = ["oncall+react_native@xmail.facebook.com"], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/test/java/org/mockito/configuration/BUCK b/ReactAndroid/src/test/java/org/mockito/configuration/BUCK index a29174b85a037e..ed96ae2d0653cf 100644 --- a/ReactAndroid/src/test/java/org/mockito/configuration/BUCK +++ b/ReactAndroid/src/test/java/org/mockito/configuration/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_android_toplevel_dep", rn_android_library( name = "configuration", srcs = glob(["**/*.java"]), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index 0dccaccecc50f9..c058291e1b7cbc 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -54,6 +54,7 @@ rn_android_library( ["**/*.java"], exclude = ["android/gradlePlugin-build/**/*"], ), + autoglob = False, visibility = [ "PUBLIC", ], From 47a9d1891236e5be372b7f5a5e2251bd0e894413 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Sat, 12 Dec 2020 03:37:50 -0800 Subject: [PATCH 0207/1810] Delete LayoutAnimations gating code and related dead code Summary: Ship LayoutAnimations to 100% of users by removing feature-flag gating. The `collapseDeleteCreateMountingInstructions_` stuff is always disabled for LayoutAnimations, so we can get rid of that too. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25510740 fbshipit-source-id: 71bac44f829530458e4906ecd1e7e68e766de2ec --- .../java/com/facebook/react/fabric/jni/BUCK | 1 - .../com/facebook/react/fabric/jni/Binding.cpp | 61 +------------------ .../com/facebook/react/fabric/jni/Binding.h | 1 - 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK index 0d6dd21aaaaef3..8f9d8e9e4793b3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK @@ -27,7 +27,6 @@ rn_xplat_cxx_library( soname = "libfabricjni.$(ext)", visibility = ["PUBLIC"], deps = [ - react_native_xplat_target("better:better"), react_native_xplat_target("react/config:config"), react_native_xplat_target("react/renderer/animations:animations"), react_native_xplat_target("react/renderer/uimanager:uimanager"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 62571a1f7018e9..3800b495bb5de0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -11,7 +11,6 @@ #include "ReactNativeConfigHolder.h" #include "StateWrapperImpl.h" -#include #include #include #include @@ -437,13 +436,6 @@ void Binding::installFabricUIManager( // Keep reference to config object and cache some feature flags here reactNativeConfig_ = config; - collapseDeleteCreateMountingInstructions_ = - reactNativeConfig_->getBool( - "react_fabric:enabled_collapse_delete_create_mounting_instructions") && - !reactNativeConfig_->getBool( - "react_fabric:enable_reparenting_detection_android") && - !reactNativeConfig_->getBool( - "react_fabric:enabled_layout_animations_android"); useIntBufferBatchMountItem_ = reactNativeConfig_->getBool( "react_fabric:use_int_buffer_batch_mountitem_android"); @@ -451,9 +443,6 @@ void Binding::installFabricUIManager( disablePreallocateViews_ = reactNativeConfig_->getBool( "react_fabric:disabled_view_preallocation_android"); - bool enableLayoutAnimations = reactNativeConfig_->getBool( - "react_fabric:enabled_layout_animations_android"); - auto toolbox = SchedulerToolbox{}; toolbox.contextContainer = contextContainer; toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction; @@ -467,10 +456,8 @@ void Binding::installFabricUIManager( toolbox.backgroundExecutor = backgroundExecutor_->get(); } - if (enableLayoutAnimations) { - animationDriver_ = - std::make_shared(runtimeExecutor, this); - } + animationDriver_ = + std::make_shared(runtimeExecutor, this); scheduler_ = std::make_shared( toolbox, (animationDriver_ ? animationDriver_.get() : nullptr), this); } @@ -1224,33 +1211,6 @@ void Binding::schedulerDidFinishTransaction( auto surfaceId = mountingTransaction->getSurfaceId(); auto &mutations = mountingTransaction->getMutations(); - facebook::better::set createAndDeleteTagsToProcess; - // When collapseDeleteCreateMountingInstructions_ is enabled, the - // createAndDeleteTagsToProcess set will contain all the tags belonging to - // CREATE and DELETE mutation instructions that needs to be processed. If a - // CREATE or DELETE mutation instruction does not belong in the set, it means - // that the we received a pair of mutation instructions: DELETE - CREATE and - // it is not necessary to create or delete on the screen. - if (collapseDeleteCreateMountingInstructions_) { - for (const auto &mutation : mutations) { - if (mutation.type == ShadowViewMutation::Delete) { - // TAG on 'Delete' mutation instructions are part of the - // oldChildShadowView - createAndDeleteTagsToProcess.insert(mutation.oldChildShadowView.tag); - } else if (mutation.type == ShadowViewMutation::Create) { - // TAG on 'Create' mutation instructions are part of the - // newChildShadowView - Tag tag = mutation.newChildShadowView.tag; - if (createAndDeleteTagsToProcess.find(tag) == - createAndDeleteTagsToProcess.end()) { - createAndDeleteTagsToProcess.insert(tag); - } else { - createAndDeleteTagsToProcess.erase(tag); - } - } - } - } - auto revisionNumber = telemetry.getRevisionNumber(); std::vector> queue; @@ -1270,23 +1230,6 @@ void Binding::schedulerDidFinishTransaction( for (const auto &mutation : mutations) { auto oldChildShadowView = mutation.oldChildShadowView; auto newChildShadowView = mutation.newChildShadowView; - auto mutationType = mutation.type; - - if (collapseDeleteCreateMountingInstructions_ && - (mutationType == ShadowViewMutation::Create || - mutationType == ShadowViewMutation::Delete) && - createAndDeleteTagsToProcess.size() > 0) { - // The TAG on 'Delete' mutation instructions are part of the - // oldChildShadowView. On the other side, the TAG on 'Create' mutation - // instructions are part of the newChildShadowView - Tag tag = mutationType == ShadowViewMutation::Create - ? mutation.newChildShadowView.tag - : mutation.oldChildShadowView.tag; - if (createAndDeleteTagsToProcess.find(tag) == - createAndDeleteTagsToProcess.end()) { - continue; - } - } bool isVirtual = newChildShadowView.layoutMetrics == EmptyLayoutMetrics && oldChildShadowView.layoutMetrics == EmptyLayoutMetrics; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index d0f13cc6e9ba28..61e2e2b783bd34 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -170,7 +170,6 @@ class Binding : public jni::HybridClass, std::shared_ptr reactNativeConfig_{nullptr}; bool useIntBufferBatchMountItem_{false}; - bool collapseDeleteCreateMountingInstructions_{false}; bool disablePreallocateViews_{false}; bool disableVirtualNodePreallocation_{false}; bool enableFabricLogs_{false}; From 62640d44108e4bc9481e5f3a6ac608c67492ff71 Mon Sep 17 00:00:00 2001 From: Will Holen Date: Sat, 12 Dec 2020 13:31:23 -0800 Subject: [PATCH 0208/1810] Disable verbose inspector state logging by default Summary: We currently spam the log with verbose state change messages by default. These messages are really only useful for internal Inspector development, so turn them off by default. Changelog: [Internal] Reviewed By: avp Differential Revision: D25500449 fbshipit-source-id: 57e0901856f104be613f79de3b3ac9e3e95b2655 --- ReactCommon/hermes/inspector/Inspector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactCommon/hermes/inspector/Inspector.cpp b/ReactCommon/hermes/inspector/Inspector.cpp index 39407af2db3a5e..1b5a09d356355f 100644 --- a/ReactCommon/hermes/inspector/Inspector.cpp +++ b/ReactCommon/hermes/inspector/Inspector.cpp @@ -85,7 +85,7 @@ namespace debugger = ::facebook::hermes::debugger; */ // TODO: read this out of an env variable or config -static constexpr bool kShouldLog = true; +static constexpr bool kShouldLog = false; // Logging state transitions is done outside of transition() in a macro so that // function and line numbers in the log will be accurate. From e041c616d1cb14e36ea27475e1dbbeb2445421b0 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0209/1810] Codemod: Migrate from bridge.imageStoreManager to RCTModuleRegistry Summary: All NativeModules that access the _bridge from self to require the ImageStoreManager now instead get the ImageStoreManager from the `_moduleRegistry`. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25498774 fbshipit-source-id: 1d97888ed2ef8d295aa35cf08cb9e9f3bc33ed05 --- Libraries/Image/RCTImageEditingManager.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Image/RCTImageEditingManager.mm b/Libraries/Image/RCTImageEditingManager.mm index 650362d81d412d..1e604c02c57eff 100644 --- a/Libraries/Image/RCTImageEditingManager.mm +++ b/Libraries/Image/RCTImageEditingManager.mm @@ -27,6 +27,7 @@ @implementation RCTImageEditingManager RCT_EXPORT_MODULE() @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; /** * Crops an image and adds the result to the image store. @@ -80,7 +81,7 @@ @implementation RCTImageEditingManager } // Store image - [self->_bridge.imageStoreManager storeImage:croppedImage withBlock:^(NSString *croppedImageTag) { + [[self->_moduleRegistry moduleForName:"ImageStoreManager"] storeImage:croppedImage withBlock:^(NSString *croppedImageTag) { if (!croppedImageTag) { NSString *errorMessage = @"Error storing cropped image in RCTImageStoreManager"; RCTLogWarn(@"%@", errorMessage); From ad6705f14229b92624540139c880a9e8a4117768 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0210/1810] Codemod: Migrate from bridge.networking to RCTModuleRegistry Summary: All NativeModules that access the _bridge from self to require the Networking NativeModule now instead get the Networking NativeModule from the _moduleRegistry. NOTE: xbgs .networking reveal any other usages. So, there won't be a manual migration diff associated with this codemod. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25499412 fbshipit-source-id: 7b0e33135c6c91ffc1e041ad3ab95f1346a8bc22 --- Libraries/Blob/RCTBlobManager.mm | 6 +++--- Libraries/Image/RCTImageLoader.mm | 3 ++- Libraries/Network/RCTHTTPRequestHandler.mm | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Libraries/Blob/RCTBlobManager.mm b/Libraries/Blob/RCTBlobManager.mm index 25d3ae8f631565..aa9e78ed969806 100755 --- a/Libraries/Blob/RCTBlobManager.mm +++ b/Libraries/Blob/RCTBlobManager.mm @@ -37,8 +37,8 @@ @implementation RCTBlobManager RCT_EXPORT_MODULE(BlobModule) @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; @synthesize methodQueue = _methodQueue; -@synthesize turboModuleRegistry = _turboModuleRegistry; - (void)setBridge:(RCTBridge *)bridge { @@ -140,9 +140,9 @@ - (void)remove:(NSString *)blobId RCT_EXPORT_METHOD(addNetworkingHandler) { - RCTNetworking *const networking = _bridge ? _bridge.networking : [_turboModuleRegistry moduleForName:"Networking"]; + RCTNetworking *const networking = [_moduleRegistry moduleForName:"Networking"]; - // TODO(T63516227): Why can methodQueue be nil here? + // TODO(T63516227): Why can methodQueue be nil here? // We don't want to do anything when methodQueue is nil. if (!networking.methodQueue) { return; diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index 49f67f19b65059..2aba728a52dca1 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -109,6 +109,7 @@ @implementation RCTImageLoader } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; @synthesize maxConcurrentLoadingTasks = _maxConcurrentLoadingTasks; @synthesize maxConcurrentDecodingTasks = _maxConcurrentDecodingTasks; @synthesize maxConcurrentDecodingBytes = _maxConcurrentDecodingBytes; @@ -653,7 +654,7 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request return NULL; } - RCTNetworking *networking = [_bridge networking]; + RCTNetworking *networking = [_moduleRegistry moduleForName:"Networking"]; if (!networking) { networking = [_turboModuleRegistry moduleForName:"Networking"]; } diff --git a/Libraries/Network/RCTHTTPRequestHandler.mm b/Libraries/Network/RCTHTTPRequestHandler.mm index 274f3810f25980..8018f028c7c696 100644 --- a/Libraries/Network/RCTHTTPRequestHandler.mm +++ b/Libraries/Network/RCTHTTPRequestHandler.mm @@ -26,6 +26,7 @@ @implementation RCTHTTPRequestHandler } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; @synthesize methodQueue = _methodQueue; RCT_EXPORT_MODULE() @@ -74,7 +75,7 @@ - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request NSOperationQueue *callbackQueue = [NSOperationQueue new]; callbackQueue.maxConcurrentOperationCount = 1; - callbackQueue.underlyingQueue = [[_bridge networking] methodQueue]; + callbackQueue.underlyingQueue = [[_moduleRegistry moduleForName:"Networking"] methodQueue]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; // Set allowsCellularAccess to NO ONLY if key ReactNetworkForceWifiOnly exists AND its value is YES if (useWifiOnly) { From f50d9c41b227302eb1dca3a6ca9e29fc645fddb4 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0211/1810] Manual: Clean up bridge.networking -> RCTModuleRegistry codemod Summary: Spotted a few errors in Codemod that migrated bridge.networking calls to [_moduleRegistry moduleForName:"Networking"] calls. This diff fixes those mistakes. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25499699 fbshipit-source-id: 29f296fc1011cf65d30e083e0ef001e3185edbfb --- Libraries/Image/RCTImageLoader.mm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index 2aba728a52dca1..757b17f8d1309a 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -113,7 +113,6 @@ @implementation RCTImageLoader @synthesize maxConcurrentLoadingTasks = _maxConcurrentLoadingTasks; @synthesize maxConcurrentDecodingTasks = _maxConcurrentDecodingTasks; @synthesize maxConcurrentDecodingBytes = _maxConcurrentDecodingBytes; -@synthesize turboModuleRegistry = _turboModuleRegistry; RCT_EXPORT_MODULE() @@ -645,20 +644,14 @@ - (RCTImageLoaderCancellationBlock)_loadURLRequest:(NSURLRequest *)request progressBlock:(RCTImageLoaderProgressBlock)progressHandler completionBlock:(void (^)(NSError *error, id imageOrData, NSURLResponse *response))completionHandler { - // Check if networking module is available - if (RCT_DEBUG && ![_bridge respondsToSelector:@selector(networking)] - && ![_turboModuleRegistry moduleForName:"Networking"]) { + RCTNetworking *networking = [_moduleRegistry moduleForName:"Networking"]; + if (RCT_DEBUG && !networking) { RCTLogError(@"No suitable image URL loader found for %@. You may need to " " import the RCTNetwork library in order to load images.", request.URL.absoluteString); return NULL; } - RCTNetworking *networking = [_moduleRegistry moduleForName:"Networking"]; - if (!networking) { - networking = [_turboModuleRegistry moduleForName:"Networking"]; - } - // Check if networking module can load image if (RCT_DEBUG && ![networking canHandleRequest:request]) { RCTLogError(@"No suitable image URL loader found for %@", request.URL.absoluteString); From e1fea9d1529559581f984695f933995df8148108 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0212/1810] Manual: Migrate from bridge.devMenu to RCTModuleRegistry Summary: Ran xbgs `.devMenu`, and found all the NativeModules that used the bridge to access DevMenu. Then, I migrated them to use RCTModuleRegistry. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25499960 fbshipit-source-id: 70478616d44808f3788dd0b194da155db0877db9 --- React/CoreModules/RCTDevSettings.mm | 13 +++++++------ React/CoreModules/RCTPerfMonitor.mm | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/React/CoreModules/RCTDevSettings.mm b/React/CoreModules/RCTDevSettings.mm index a165e48b0a69a1..ccce3b2931f5a1 100644 --- a/React/CoreModules/RCTDevSettings.mm +++ b/React/CoreModules/RCTDevSettings.mm @@ -358,11 +358,11 @@ - (BOOL)isHotLoadingEnabled RCT_EXPORT_METHOD(addMenuItem : (NSString *)title) { __weak __typeof(self) weakSelf = self; - [self.bridge.devMenu addItem:[RCTDevMenuItem buttonItemWithTitle:title - handler:^{ - [weakSelf sendEventWithName:@"didPressMenuItem" - body:@{@"title" : title}]; - }]]; + [(RCTDevMenu *)[self.moduleRegistry moduleForName:"DevMenu"] + addItem:[RCTDevMenuItem buttonItemWithTitle:title + handler:^{ + [weakSelf sendEventWithName:@"didPressMenuItem" body:@{@"title" : title}]; + }]]; } - (BOOL)isElementInspectorShown @@ -463,7 +463,8 @@ - (void)jsLoaded:(NSNotification *)notification if ([self isElementInspectorShown]) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [[self.moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"toggleElementInspector" body:nil]; + [[self.moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"toggleElementInspector" + body:nil]; #pragma clang diagnostic pop } }); diff --git a/React/CoreModules/RCTPerfMonitor.mm b/React/CoreModules/RCTPerfMonitor.mm index 790591d3afcacd..49219a3e18cab8 100644 --- a/React/CoreModules/RCTPerfMonitor.mm +++ b/React/CoreModules/RCTPerfMonitor.mm @@ -136,6 +136,7 @@ @implementation RCTPerfMonitor { } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -149,12 +150,11 @@ - (dispatch_queue_t)methodQueue return dispatch_get_main_queue(); } -- (void)setBridge:(RCTBridge *)bridge +- (void)setModuleRegistry:(RCTModuleRegistry *)moduleRegistry { - _bridge = bridge; - + _moduleRegistry = moduleRegistry; #if __has_include() - [_bridge.devMenu addItem:self.devMenuItem]; + [(RCTDevMenu *)[_moduleRegistry moduleForName:"DevMenu"] addItem:self.devMenuItem]; #endif } From c7e1355dec53cf149db4a48cd2bc2e584c28e675 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0213/1810] Manual: Migrate from bridge.webSocketModule to RCTModuleRegistry Summary: All NativeModules that access the _bridge from self to require the WebSocketModule NativeModule now instead get the WebSocketModule NativeModule from the _moduleRegistry. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25500433 fbshipit-source-id: 21aebc5684dd6a058de4e35b042c9fb255ffcb33 --- Libraries/Blob/RCTBlobManager.mm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/Blob/RCTBlobManager.mm b/Libraries/Blob/RCTBlobManager.mm index aa9e78ed969806..551c910584fad4 100755 --- a/Libraries/Blob/RCTBlobManager.mm +++ b/Libraries/Blob/RCTBlobManager.mm @@ -156,23 +156,23 @@ - (void)remove:(NSString *)blobId RCT_EXPORT_METHOD(addWebSocketHandler:(double)socketID) { - dispatch_async(_bridge.webSocketModule.methodQueue, ^{ - [self->_bridge.webSocketModule setContentHandler:self forSocketID:[NSNumber numberWithDouble:socketID]]; + dispatch_async(((RCTWebSocketModule *)[_moduleRegistry moduleForName:"WebSocketModule"]).methodQueue, ^{ + [[self->_moduleRegistry moduleForName:"WebSocketModule"] setContentHandler:self forSocketID:[NSNumber numberWithDouble:socketID]]; }); } RCT_EXPORT_METHOD(removeWebSocketHandler:(double)socketID) { - dispatch_async(_bridge.webSocketModule.methodQueue, ^{ - [self->_bridge.webSocketModule setContentHandler:nil forSocketID:[NSNumber numberWithDouble:socketID]]; + dispatch_async(((RCTWebSocketModule *)[_moduleRegistry moduleForName:"WebSocketModule"]).methodQueue, ^{ + [[self->_moduleRegistry moduleForName:"WebSocketModule"] setContentHandler:nil forSocketID:[NSNumber numberWithDouble:socketID]]; }); } // @lint-ignore FBOBJCUNTYPEDCOLLECTION1 RCT_EXPORT_METHOD(sendOverSocket:(NSDictionary *)blob socketID:(double)socketID) { - dispatch_async(_bridge.webSocketModule.methodQueue, ^{ - [self->_bridge.webSocketModule sendData:[self resolve:blob] forSocketID:[NSNumber numberWithDouble:socketID]]; + dispatch_async(((RCTWebSocketModule *)[_moduleRegistry moduleForName:"WebSocketModule"]).methodQueue, ^{ + [[self->_moduleRegistry moduleForName:"WebSocketModule"] sendData:[self resolve:blob] forSocketID:[NSNumber numberWithDouble:socketID]]; }); } From 41929eb9c5767474c4f4cb4e73d5dbd1a0575f73 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0214/1810] Codemod: Migrate from bridge.devSettings to RCTModuleRegistry Summary: All NativeModules that access the _bridge from self to require the DevSettings NativeModule now instead get the DevSettings NativeModule from the _moduleRegistry. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25503289 fbshipit-source-id: ebd1fd45d40aca37c0ead83bbaab59fa99d45044 --- React/CoreModules/RCTDevMenu.mm | 19 ++++++++++--------- React/CoreModules/RCTPerfMonitor.mm | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/React/CoreModules/RCTDevMenu.mm b/React/CoreModules/RCTDevMenu.mm index 3e9e78e85a5897..1ea0cf6561203b 100644 --- a/React/CoreModules/RCTDevMenu.mm +++ b/React/CoreModules/RCTDevMenu.mm @@ -95,6 +95,7 @@ @implementation RCTDevMenu { } @synthesize bridge = _bridge; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -164,7 +165,7 @@ - (void)invalidate - (void)showOnShake { - if ([_bridge.devSettings isShakeToShowDevMenuEnabled]) { + if ([((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]) isShakeToShowDevMenuEnabled]) { [self show]; } } @@ -210,7 +211,7 @@ - (void)setDefaultJSBundle // Add built-in items __weak RCTBridge *bridge = _bridge; - __weak RCTDevSettings *devSettings = _bridge.devSettings; + __weak RCTDevSettings *devSettings = [_moduleRegistry moduleForName:"DevSettings"]; __weak RCTDevMenu *weakSelf = self; [items addObject:[RCTDevMenuItem buttonItemWithTitle:@"Reload" @@ -469,12 +470,12 @@ - (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *__ - (void)setShakeToShow:(BOOL)shakeToShow { - _bridge.devSettings.isShakeToShowDevMenuEnabled = shakeToShow; + ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isShakeToShowDevMenuEnabled = shakeToShow; } - (BOOL)shakeToShow { - return _bridge.devSettings.isShakeToShowDevMenuEnabled; + return ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isShakeToShowDevMenuEnabled; } RCT_EXPORT_METHOD(reload) @@ -486,29 +487,29 @@ - (BOOL)shakeToShow RCT_EXPORT_METHOD(debugRemotely : (BOOL)enableDebug) { WARN_DEPRECATED_DEV_MENU_EXPORT(); - _bridge.devSettings.isDebuggingRemotely = enableDebug; + ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isDebuggingRemotely = enableDebug; } RCT_EXPORT_METHOD(setProfilingEnabled : (BOOL)enabled) { WARN_DEPRECATED_DEV_MENU_EXPORT(); - _bridge.devSettings.isProfilingEnabled = enabled; + ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isProfilingEnabled = enabled; } - (BOOL)profilingEnabled { - return _bridge.devSettings.isProfilingEnabled; + return ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isProfilingEnabled; } RCT_EXPORT_METHOD(setHotLoadingEnabled : (BOOL)enabled) { WARN_DEPRECATED_DEV_MENU_EXPORT(); - _bridge.devSettings.isHotLoadingEnabled = enabled; + ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isHotLoadingEnabled = enabled; } - (BOOL)hotLoadingEnabled { - return _bridge.devSettings.isHotLoadingEnabled; + return ((RCTDevSettings *)[_moduleRegistry moduleForName:"DevSettings"]).isHotLoadingEnabled; } - (std::shared_ptr)getTurboModule: diff --git a/React/CoreModules/RCTPerfMonitor.mm b/React/CoreModules/RCTPerfMonitor.mm index 49219a3e18cab8..7ad8770dffc676 100644 --- a/React/CoreModules/RCTPerfMonitor.mm +++ b/React/CoreModules/RCTPerfMonitor.mm @@ -168,7 +168,7 @@ - (RCTDevMenuItem *)devMenuItem { if (!_devMenuItem) { __weak __typeof__(self) weakSelf = self; - __weak RCTDevSettings *devSettings = self.bridge.devSettings; + __weak RCTDevSettings *devSettings = [self->_moduleRegistry moduleForName:"DevSettings"]; if (devSettings.isPerfMonitorShown) { [weakSelf show]; } From 60641c543d720aa4b70fcd25adf6fbe8aac83182 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0215/1810] Manual: Migrate from bridge.devSettings to RCTModuleRegistry Summary: Ran `xbgs .devSettings`, and found all the NativeModules that used the bridge to access DevSettings. Then, I migrated them to use RCTModuleRegistry. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25503402 fbshipit-source-id: 26afc45cd1bc63d5de99ea331e7b2949b66be7ce --- React/CoreModules/RCTDevMenu.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/React/CoreModules/RCTDevMenu.mm b/React/CoreModules/RCTDevMenu.mm index 1ea0cf6561203b..78a3b9def5a284 100644 --- a/React/CoreModules/RCTDevMenu.mm +++ b/React/CoreModules/RCTDevMenu.mm @@ -136,14 +136,16 @@ - (instancetype)init [commands registerKeyCommandWithInput:@"i" modifierFlags:UIKeyModifierCommand action:^(__unused UIKeyCommand *command) { - [weakSelf.bridge.devSettings toggleElementInspector]; + [(RCTDevSettings *)[weakSelf.moduleRegistry moduleForName:"DevSettings"] + toggleElementInspector]; }]; // Reload in normal mode [commands registerKeyCommandWithInput:@"n" modifierFlags:UIKeyModifierCommand action:^(__unused UIKeyCommand *command) { - [weakSelf.bridge.devSettings setIsDebuggingRemotely:NO]; + [(RCTDevSettings *)[weakSelf.moduleRegistry moduleForName:"DevSettings"] + setIsDebuggingRemotely:NO]; }]; #endif } From 938bfed96dc27c195a2699c1a01468bd721e7109 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0216/1810] Manual: Migrate from bridge.redBox to RCTModuleRegistry Summary: Ran `xbgs .redBox`, and found all the NativeModules that used the bridge to access RedBox. Then, I migrated them to use RCTModuleRegistry. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25507829 fbshipit-source-id: 91033ca4c57d5be5e8e6fa904b636960ec12c584 --- React/CoreModules/RCTExceptionsManager.mm | 29 ++++++----------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/React/CoreModules/RCTExceptionsManager.mm b/React/CoreModules/RCTExceptionsManager.mm index cd2c2f34013156..e45b270031ff72 100644 --- a/React/CoreModules/RCTExceptionsManager.mm +++ b/React/CoreModules/RCTExceptionsManager.mm @@ -24,7 +24,7 @@ @interface RCTExceptionsManager () @implementation RCTExceptionsManager @synthesize bridge = _bridge; -@synthesize turboModuleRegistry = _turboModuleRegistry; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() @@ -42,13 +42,8 @@ - (void)reportSoft:(NSString *)message suppressRedBox:(BOOL)suppressRedBox { if (!suppressRedBox) { - // TODO T5287269 - Delete _bridge case when TM ships. - if (_bridge) { - [_bridge.redBox showErrorMessage:message withStack:stack errorCookie:((int)exceptionId)]; - } else { - RCTRedBox *redbox = [_turboModuleRegistry moduleForName:"RCTRedBox"]; - [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; - } + RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; + [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; } if (_delegate) { @@ -64,13 +59,8 @@ - (void)reportFatal:(NSString *)message suppressRedBox:(BOOL)suppressRedBox { if (!suppressRedBox) { - // TODO T5287269 - Delete _bridge case when TM ships. - if (_bridge) { - [_bridge.redBox showErrorMessage:message withStack:stack errorCookie:((int)exceptionId)]; - } else { - RCTRedBox *redbox = [_turboModuleRegistry moduleForName:"RCTRedBox"]; - [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; - } + RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; + [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; } if (_delegate) { @@ -111,13 +101,8 @@ - (void)reportFatal:(NSString *)message : (NSArray *)stack exceptionId : (double)exceptionId) { - // TODO T5287269 - Delete _bridge case when TM ships. - if (_bridge) { - [_bridge.redBox updateErrorMessage:message withStack:stack errorCookie:((int)exceptionId)]; - } else { - RCTRedBox *redbox = [_turboModuleRegistry moduleForName:"RCTRedBox"]; - [redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; - } + RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; + [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; if (_delegate && [_delegate respondsToSelector:@selector(updateJSExceptionWithMessage:stack:exceptionId:)]) { [_delegate updateJSExceptionWithMessage:message stack:stack exceptionId:[NSNumber numberWithDouble:exceptionId]]; From 282b1a880f1c66b2c6b74ec7efe7d07cacb09fec Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0217/1810] Manual: Migrate from bridge.moduleForClass to RCTModuleRegistry Summary: All NativeModules that use `[RCTBridge moduleForClass:]` to access other NativeModules are now instead using the Venice-compatible RCTModuleRegistry to access other NativeModules. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25508277 fbshipit-source-id: 1b415a5ad4055290940879e100ceaa84ae83feeb --- Libraries/Blob/RCTFileReaderModule.mm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Libraries/Blob/RCTFileReaderModule.mm b/Libraries/Blob/RCTFileReaderModule.mm index 0f2b2d5bc62e94..0384aec40021e0 100644 --- a/Libraries/Blob/RCTFileReaderModule.mm +++ b/Libraries/Blob/RCTFileReaderModule.mm @@ -24,14 +24,14 @@ @implementation RCTFileReaderModule RCT_EXPORT_MODULE(FileReaderModule) @synthesize bridge = _bridge; -@synthesize turboModuleRegistry = _turboModuleRegistry; +@synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_METHOD(readAsText:(NSDictionary *)blob encoding:(NSString *)encoding resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { - RCTBlobManager *blobManager = [_bridge moduleForClass:[RCTBlobManager class]]; + RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobManager"]; NSData *data = [blobManager resolve:blob]; if (data == nil) { @@ -56,12 +56,7 @@ @implementation RCTFileReaderModule resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { - RCTBlobManager *blobManager = nil; - if (_bridge) { - blobManager = [_bridge moduleForClass:[RCTBlobManager class]]; - } else { - blobManager = [[self turboModuleRegistry] moduleForName:[NSStringFromClass([RCTBlobManager class]) UTF8String]]; - } + RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobManager"]; NSData *data = [blobManager resolve:blob]; if (data == nil) { From 6c3dd87ef1a427408c70a7ad51d29c41d31c6153 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0218/1810] Manual: Migrate from bridge.moduleForName to RCTModuleRegistry Summary: All NativeModules that use `[RCTBridge moduleForName:]` to access other NativeModules are now instead using the Venice-compatible RCTModuleRegistry to access other NativeModules. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25508910 fbshipit-source-id: 85fc390063af264f2f2843e5640fa7336a784ab4 --- Libraries/Image/RCTImageEditingManager.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Image/RCTImageEditingManager.mm b/Libraries/Image/RCTImageEditingManager.mm index 1e604c02c57eff..742e1b5eee1261 100644 --- a/Libraries/Image/RCTImageEditingManager.mm +++ b/Libraries/Image/RCTImageEditingManager.mm @@ -54,11 +54,11 @@ @implementation RCTImageEditingManager @"height": @(cropData.size().height()), }] }; - + // We must keep a copy of cropData so that we can access data from it at a later time JS::NativeImageEditor::Options cropDataCopy = cropData; - [[_bridge moduleForName:@"ImageLoader" lazilyLoadIfNecessary:YES] + [[_moduleRegistry moduleForName:"ImageLoader"] loadImageWithURLRequest:imageRequest callback:^(NSError *error, UIImage *image) { if (error) { errorCallback(@[RCTJSErrorFromNSError(error)]); From ff980050c94b5bb550b40837a84bc0e7f69c2e27 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 12 Dec 2020 18:58:58 -0800 Subject: [PATCH 0219/1810] Manual: Migrate from bridge.accessibilityManager to RCTModuleRegistry Summary: Ran `xbgs .accibilityManager`, and found all the NativeModules that used the bridge to access AccessibilityManager. Then, I migrated them to use RCTModuleRegistry. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25504726 fbshipit-source-id: fcfb1fffbeedc136ee160d043949d9859300b1e3 --- React/CoreModules/RCTDeviceInfo.mm | 35 +++++++++++++----------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/React/CoreModules/RCTDeviceInfo.mm b/React/CoreModules/RCTDeviceInfo.mm index 9d722f0ea832dd..6084c9ffeaf258 100644 --- a/React/CoreModules/RCTDeviceInfo.mm +++ b/React/CoreModules/RCTDeviceInfo.mm @@ -43,14 +43,13 @@ - (dispatch_queue_t)methodQueue return dispatch_get_main_queue(); } -- (void)setBridge:(RCTBridge *)bridge +- (void)setModuleRegistry:(RCTModuleRegistry *)moduleRegistry { - _bridge = bridge; - + _moduleRegistry = moduleRegistry; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNewContentSizeMultiplier) name:RCTAccessibilityManagerDidUpdateMultiplierNotification - object:_bridge.accessibilityManager]; + object:[moduleRegistry moduleForName:"AccessibilityManager"]]; _currentInterfaceOrientation = [RCTSharedApplication() statusBarOrientation]; @@ -59,7 +58,7 @@ - (void)setBridge:(RCTBridge *)bridge name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; - _currentInterfaceDimensions = RCTExportedDimensions(_bridge, _turboModuleRegistry); + _currentInterfaceDimensions = RCTExportedDimensions(_moduleRegistry); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interfaceFrameDidChange) @@ -98,17 +97,15 @@ static BOOL RCTIsIPhoneX() return isIPhoneX; } -static NSDictionary *RCTExportedDimensions(RCTBridge *bridge, id turboModuleRegistry) +static NSDictionary *RCTExportedDimensions(RCTModuleRegistry *moduleRegistry) { RCTAssertMainQueue(); RCTDimensions dimensions; - if (bridge) { - dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier ?: 1.0); - } else if (turboModuleRegistry) { + if (moduleRegistry) { dimensions = RCTGetDimensions( - ((RCTAccessibilityManager *)[turboModuleRegistry moduleForName:"RCTAccessibilityManager"]).multiplier ?: 1.0); + ((RCTAccessibilityManager *)[moduleRegistry moduleForName:"AccessibilityManager"]).multiplier ?: 1.0); } else { - RCTAssert(false, @"Bridge or TurboModuleRegistry must be set to properly init dimensions."); + RCTAssert(false, @"ModuleRegistry must be set to properly init dimensions."); } __typeof(dimensions.window) window = dimensions.window; NSDictionary *dimsWindow = @{ @@ -135,9 +132,10 @@ static BOOL RCTIsIPhoneX() - (NSDictionary *)getConstants { __block NSDictionary *constants; + RCTModuleRegistry *moduleRegistry = _moduleRegistry; RCTUnsafeExecuteOnMainQueueSync(^{ constants = @{ - @"Dimensions" : RCTExportedDimensions(self->_bridge, self->_turboModuleRegistry), + @"Dimensions" : RCTExportedDimensions(moduleRegistry), // Note: // This prop is deprecated and will be removed in a future release. // Please use this only for a quick and temporary solution. @@ -151,15 +149,13 @@ static BOOL RCTIsIPhoneX() - (void)didReceiveNewContentSizeMultiplier { - RCTBridge *bridge = _bridge; RCTModuleRegistry *moduleRegistry = _moduleRegistry; RCTExecuteOnMainQueue(^{ // Report the event across the bridge. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [[moduleRegistry moduleForName:"EventDispatcher"] - sendDeviceEventWithName:@"didUpdateDimensions" - body:RCTExportedDimensions(bridge, self->_turboModuleRegistry)]; + [[moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateDimensions" + body:RCTExportedDimensions(moduleRegistry)]; #pragma clang diagnostic pop }); } @@ -183,9 +179,8 @@ - (void)_interfaceOrientationDidChange !UIInterfaceOrientationIsLandscape(nextOrientation))) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [[_moduleRegistry moduleForName:"EventDispatcher"] - sendDeviceEventWithName:@"didUpdateDimensions" - body:RCTExportedDimensions(_bridge, _turboModuleRegistry)]; + [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateDimensions" + body:RCTExportedDimensions(_moduleRegistry)]; #pragma clang diagnostic pop } @@ -202,7 +197,7 @@ - (void)interfaceFrameDidChange - (void)_interfaceFrameDidChange { - NSDictionary *nextInterfaceDimensions = RCTExportedDimensions(_bridge, _turboModuleRegistry); + NSDictionary *nextInterfaceDimensions = RCTExportedDimensions(_moduleRegistry); if (!([nextInterfaceDimensions isEqual:_currentInterfaceDimensions])) { #pragma clang diagnostic push From 272ef6b86fbe6a0ebe44bffbb7b1bcf03c10de6e Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 13 Dec 2020 22:33:47 -0800 Subject: [PATCH 0220/1810] Fabric: `AccessibilityProps::testId` mapped to `testID` and implemented for iOS Summary: This should make `testID` prop work as it works in pre-Fabric renderer on iOS. On Android it should already work fine. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D25524890 fbshipit-source-id: 3f25eb427d4449abaab790099546be18ae573f98 --- .../ComponentViews/View/RCTViewComponentView.mm | 5 +++++ .../renderer/components/view/AccessibilityProps.cpp | 2 +- .../react/renderer/components/view/ViewShadowNode.cpp | 3 ++- .../tests/UITemplateProcessorTest.cpp | 10 +++++----- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 70eec56a685b8c..c17553b1523200 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -248,6 +248,11 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & #endif } + // `testId` + if (oldViewProps.testId != newViewProps.testId) { + self.accessibilityIdentifier = RCTNSStringFromString(newViewProps.testId); + } + _needsInvalidateLayer = _needsInvalidateLayer || needsInvalidateLayer; _props = std::static_pointer_cast(props); diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp index aa4c1f47795cdd..d47d3782a6bf4e 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp @@ -88,7 +88,7 @@ AccessibilityProps::AccessibilityProps( "importantForAccessibility", sourceProps.importantForAccessibility, ImportantForAccessibility::Auto)), - testId(convertRawProp(rawProps, "testId", sourceProps.testId, "")) {} + testId(convertRawProp(rawProps, "testID", sourceProps.testId, "")) {} #pragma mark - DebugStringConvertible diff --git a/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp b/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp index 124babc4c195a5..657169b5395ba7 100644 --- a/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp @@ -54,7 +54,8 @@ void ViewShadowNode::initialize() noexcept { bool formsView = isColorMeaningful(viewProps.backgroundColor) || isColorMeaningful(viewProps.foregroundColor) || - !(viewProps.yogaStyle.border() == YGStyle::Edges{}); + !(viewProps.yogaStyle.border() == YGStyle::Edges{}) || + !viewProps.testId.empty(); formsView = formsView || formsStackingContext; diff --git a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp index 5c7220f52a44bf..add08294321f05 100644 --- a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp +++ b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp @@ -89,8 +89,8 @@ TEST(UITemplateProcessorTest, testSimpleBytecode) { auto nativeModuleRegistry = buildNativeModuleRegistry(); auto bytecode = R"delim({"version":0.1,"commands":[ - ["createNode",2,"RCTView",-1,{"opacity": 0.5, "testId": "root"}], - ["createNode",4,"RCTView",2,{"testId": "child"}], + ["createNode",2,"RCTView",-1,{"opacity": 0.5, "testID": "root"}], + ["createNode",4,"RCTView",2,{"testID": "child"}], ["returnRoot",2] ]})delim"; @@ -124,11 +124,11 @@ TEST(UITemplateProcessorTest, testConditionalBytecode) { auto nativeModuleRegistry = buildNativeModuleRegistry(); auto bytecode = R"delim({"version":0.1,"commands":[ - ["createNode",2,"RCTView",-1,{"testId": "root"}], + ["createNode",2,"RCTView",-1,{"testID": "root"}], ["loadNativeBool",1,"MobileConfig","getBool",["qe:simple_test"]], ["conditional",1, - [["createNode",4,"RCTView",2,{"testId": "cond_true"}]], - [["createNode",4,"RCTView",2,{"testId": "cond_false"}]] + [["createNode",4,"RCTView",2,{"testID": "cond_true"}]], + [["createNode",4,"RCTView",2,{"testID": "cond_false"}]] ], ["returnRoot",2] ]})delim"; From 3cebd35b95439f7f86380977556e883f88c76b69 Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Mon, 14 Dec 2020 06:10:12 -0800 Subject: [PATCH 0221/1810] (eslint-config): update eslint-plugin-react-native (#30350) Summary: Currently, installing `react-native-community/eslint-config` with projects using eslint v7 causes the following warning ``` warning "react-native-community/eslint-config > eslint-plugin-react-native@3.8.1" has incorrect peer dependency "eslint@^3.17.0 || ^4 || ^5 || ^6". ``` This PR updates the eslint-plugin-react-native module to suppress the warning ## Changelog [Internal] [Changed] - update eslint-plugin-react-native for community eslint-config Pull Request resolved: https://github.com/facebook/react-native/pull/30350 Test Plan: eslint working without error with projects using eslint v7 Reviewed By: GijsWeterings Differential Revision: D25480912 Pulled By: nadiia fbshipit-source-id: 2a956070e5bb75168d68501f9ec9486a34011349 --- .../package.json | 2 +- .../yarn.lock | 146 +++++++++--------- repo-config/package.json | 2 +- yarn.lock | 47 +++++- 4 files changed, 118 insertions(+), 79 deletions(-) diff --git a/packages/eslint-config-react-native-community/package.json b/packages/eslint-config-react-native-community/package.json index e079f7c7b4d600..ec1a217296bf7c 100644 --- a/packages/eslint-config-react-native-community/package.json +++ b/packages/eslint-config-react-native-community/package.json @@ -22,7 +22,7 @@ "eslint-plugin-prettier": "3.1.2", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.0.7", - "eslint-plugin-react-native": "^3.8.1", + "eslint-plugin-react-native": "^3.10.0", "prettier": "^2.0.2" }, "peerDependencies": { diff --git a/packages/eslint-config-react-native-community/yarn.lock b/packages/eslint-config-react-native-community/yarn.lock index 8fdadf1d775bec..e87360ec0c7797 100644 --- a/packages/eslint-config-react-native-community/yarn.lock +++ b/packages/eslint-config-react-native-community/yarn.lock @@ -2,64 +2,63 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" - integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g== +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" + integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== dependencies: - "@babel/highlight" "^7.8.3" + "@babel/highlight" "^7.10.4" -"@babel/generator@^7.9.0": - version "7.9.4" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.9.4.tgz#12441e90c3b3c4159cdecf312075bf1a8ce2dbce" - integrity sha512-rjP8ahaDy/ouhrvCoU1E5mqaitWrxwuNGU+dy1EpaoK48jZay4MdkskKGIMHLZNewg8sAsqpGSREJwP0zH3YQA== +"@babel/generator@^7.12.10": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.10.tgz#2b188fc329fb8e4f762181703beffc0fe6df3460" + integrity sha512-6mCdfhWgmqLdtTkhXjnIz0LcdVCd26wS2JXRtj2XY0u5klDsXBREA/pG5NVOuVnF2LUrBGNFtQkIqqTbblg0ww== dependencies: - "@babel/types" "^7.9.0" + "@babel/types" "^7.12.10" jsesc "^2.5.1" - lodash "^4.17.13" source-map "^0.5.0" -"@babel/helper-function-name@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz#eeeb665a01b1f11068e9fb86ad56a1cb1a824cca" - integrity sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA== +"@babel/helper-function-name@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz#d2d3b20c59ad8c47112fa7d2a94bc09d5ef82f1a" + integrity sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ== dependencies: - "@babel/helper-get-function-arity" "^7.8.3" - "@babel/template" "^7.8.3" - "@babel/types" "^7.8.3" + "@babel/helper-get-function-arity" "^7.10.4" + "@babel/template" "^7.10.4" + "@babel/types" "^7.10.4" -"@babel/helper-get-function-arity@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz#b894b947bd004381ce63ea1db9f08547e920abd5" - integrity sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA== +"@babel/helper-get-function-arity@^7.10.4": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.12.10.tgz#b158817a3165b5faa2047825dfa61970ddcc16cf" + integrity sha512-mm0n5BPjR06wh9mPQaDdXWDoll/j5UpCAPl1x8fS71GHm7HA6Ua2V4ylG1Ju8lvcTOietbPNNPaSilKj+pj+Ag== dependencies: - "@babel/types" "^7.8.3" + "@babel/types" "^7.12.10" -"@babel/helper-split-export-declaration@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz#31a9f30070f91368a7182cf05f831781065fc7a9" - integrity sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA== +"@babel/helper-split-export-declaration@^7.11.0": + version "7.11.0" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz#f8a491244acf6a676158ac42072911ba83ad099f" + integrity sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg== dependencies: - "@babel/types" "^7.8.3" + "@babel/types" "^7.11.0" -"@babel/helper-validator-identifier@^7.9.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz#ad53562a7fc29b3b9a91bbf7d10397fd146346ed" - integrity sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw== +"@babel/helper-validator-identifier@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" + integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== -"@babel/highlight@^7.8.3": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079" - integrity sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ== +"@babel/highlight@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" + integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== dependencies: - "@babel/helper-validator-identifier" "^7.9.0" + "@babel/helper-validator-identifier" "^7.10.4" chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.7.0", "@babel/parser@^7.8.6", "@babel/parser@^7.9.0": - version "7.9.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.4.tgz#68a35e6b0319bbc014465be43828300113f2f2e8" - integrity sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA== +"@babel/parser@^7.12.10", "@babel/parser@^7.12.7", "@babel/parser@^7.7.0": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.10.tgz#824600d59e96aea26a5a2af5a9d812af05c3ae81" + integrity sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== "@babel/runtime-corejs3@^7.8.3": version "7.9.2" @@ -69,37 +68,37 @@ core-js-pure "^3.0.0" regenerator-runtime "^0.13.4" -"@babel/template@^7.8.3": - version "7.8.6" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.8.6.tgz#86b22af15f828dfb086474f964dcc3e39c43ce2b" - integrity sha512-zbMsPMy/v0PWFZEhQJ66bqjhH+z0JgMoBWuikXybgG3Gkd/3t5oQ1Rw2WQhnSrsOmsKXnZOx15tkC4qON/+JPg== - dependencies: - "@babel/code-frame" "^7.8.3" - "@babel/parser" "^7.8.6" - "@babel/types" "^7.8.6" - -"@babel/traverse@^7.7.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.9.0.tgz#d3882c2830e513f4fe4cec9fe76ea1cc78747892" - integrity sha512-jAZQj0+kn4WTHO5dUZkZKhbFrqZE7K5LAQ5JysMnmvGij+wOdr+8lWqPeW0BcF4wFwrEXXtdGO7wcV6YPJcf3w== - dependencies: - "@babel/code-frame" "^7.8.3" - "@babel/generator" "^7.9.0" - "@babel/helper-function-name" "^7.8.3" - "@babel/helper-split-export-declaration" "^7.8.3" - "@babel/parser" "^7.9.0" - "@babel/types" "^7.9.0" +"@babel/template@^7.10.4": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc" + integrity sha512-GkDzmHS6GV7ZeXfJZ0tLRBhZcMcY0/Lnb+eEbXDBfCAcZCjrZKe6p3J4we/D24O9Y8enxWAg1cWwof59yLh2ow== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/parser" "^7.12.7" + "@babel/types" "^7.12.7" + +"@babel/traverse@^7.7.0", "@babel/traverse@^7.7.4": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.10.tgz#2d1f4041e8bf42ea099e5b2dc48d6a594c00017a" + integrity sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/generator" "^7.12.10" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-split-export-declaration" "^7.11.0" + "@babel/parser" "^7.12.10" + "@babel/types" "^7.12.10" debug "^4.1.0" globals "^11.1.0" - lodash "^4.17.13" + lodash "^4.17.19" -"@babel/types@^7.7.0", "@babel/types@^7.8.3", "@babel/types@^7.8.6", "@babel/types@^7.9.0": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.0.tgz#00b064c3df83ad32b2dbf5ff07312b15c7f1efb5" - integrity sha512-BS9JKfXkzzJl8RluW4JGknzpiUV7ZrvTayM6yfqLTVBEnFtyowVIOu6rqxRd5cVO6yGoWf4T8u8dgK9oB+GCng== +"@babel/types@^7.10.4", "@babel/types@^7.11.0", "@babel/types@^7.12.10", "@babel/types@^7.12.7", "@babel/types@^7.7.0": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.10.tgz#7965e4a7260b26f09c56bcfcb0498af1f6d9b260" + integrity sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== dependencies: - "@babel/helper-validator-identifier" "^7.9.0" - lodash "^4.17.13" + "@babel/helper-validator-identifier" "^7.10.4" + lodash "^4.17.19" to-fast-properties "^2.0.0" "@eslint/eslintrc@^0.2.0": @@ -463,11 +462,12 @@ eslint-plugin-react-native-globals@^0.1.1: resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz#ee1348bc2ceb912303ce6bdbd22e2f045ea86ea2" integrity sha512-9aEPf1JEpiTjcFAmmyw8eiIXmcNZOqaZyHO77wgm0/dWfT/oxC1SrIq8ET38pMxHYrcB6Uew+TzUVsBeczF88g== -eslint-plugin-react-native@^3.8.1: - version "3.8.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.8.1.tgz#92811e37191ecb0d29c0f0a0c9e5c943ee573821" - integrity sha512-6Z4s4nvgFRdda/1s1+uu4a6EMZwEjjJ9Bk/1yBImv0fd9U2CsGu2cUakAtV83cZKhizbWhSouXoaK4JtlScdFg== +eslint-plugin-react-native@^3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.10.0.tgz#240f7e6979a908af3dfd9ba9652434c33f4d64cd" + integrity sha512-4f5+hHYYq5wFhB5eptkPEAR7FfvqbS7AzScUOANfAMZtYw5qgnCxRq45bpfBaQF+iyPMim5Q8pubcpvLv75NAg== dependencies: + "@babel/traverse" "^7.7.4" eslint-plugin-react-native-globals "^0.1.1" eslint-plugin-react@^7.20.0: @@ -852,7 +852,7 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19: +lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.15, lodash@^4.17.19: version "4.17.20" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== diff --git a/repo-config/package.json b/repo-config/package.json index 648509c639ec63..8799da761e95c5 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -31,7 +31,7 @@ "eslint-plugin-prettier": "2.6.2", "eslint-plugin-react": "7.21.5", "eslint-plugin-react-hooks": "^4.0.7", - "eslint-plugin-react-native": "3.8.1", + "eslint-plugin-react-native": "3.10.0", "eslint-plugin-relay": "1.8.1", "flow-bin": "^0.140.0", "jest": "^26.5.2", diff --git a/yarn.lock b/yarn.lock index 99fb618b59a46f..fc2cc068f910df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -40,6 +40,15 @@ jsesc "^2.5.1" source-map "^0.5.0" +"@babel/generator@^7.12.10": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.10.tgz#2b188fc329fb8e4f762181703beffc0fe6df3460" + integrity sha512-6mCdfhWgmqLdtTkhXjnIz0LcdVCd26wS2JXRtj2XY0u5klDsXBREA/pG5NVOuVnF2LUrBGNFtQkIqqTbblg0ww== + dependencies: + "@babel/types" "^7.12.10" + jsesc "^2.5.1" + source-map "^0.5.0" + "@babel/helper-annotate-as-pure@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3" @@ -250,6 +259,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.5.tgz#b4af32ddd473c0bfa643bd7ff0728b8e71b81ea0" integrity sha512-FVM6RZQ0mn2KCf1VUED7KepYeUWoVShczewOCfm3nzoBybaih51h+sYVVGthW9M6lPByEPTQf+xm27PBdlpwmQ== +"@babel/parser@^7.12.10": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.10.tgz#824600d59e96aea26a5a2af5a9d812af05c3ae81" + integrity sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== + "@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.1.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de" @@ -707,6 +721,21 @@ globals "^11.1.0" lodash "^4.17.19" +"@babel/traverse@^7.7.4": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.10.tgz#2d1f4041e8bf42ea099e5b2dc48d6a594c00017a" + integrity sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/generator" "^7.12.10" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-split-export-declaration" "^7.11.0" + "@babel/parser" "^7.12.10" + "@babel/types" "^7.12.10" + debug "^4.1.0" + globals "^11.1.0" + lodash "^4.17.19" + "@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.7.0": version "7.12.6" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.6.tgz#ae0e55ef1cce1fbc881cd26f8234eb3e657edc96" @@ -716,6 +745,15 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" +"@babel/types@^7.12.10": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.10.tgz#7965e4a7260b26f09c56bcfcb0498af1f6d9b260" + integrity sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== + dependencies: + "@babel/helper-validator-identifier" "^7.10.4" + lodash "^4.17.19" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -2604,11 +2642,12 @@ eslint-plugin-react-native-globals@^0.1.1: resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz#ee1348bc2ceb912303ce6bdbd22e2f045ea86ea2" integrity sha512-9aEPf1JEpiTjcFAmmyw8eiIXmcNZOqaZyHO77wgm0/dWfT/oxC1SrIq8ET38pMxHYrcB6Uew+TzUVsBeczF88g== -eslint-plugin-react-native@3.8.1: - version "3.8.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.8.1.tgz#92811e37191ecb0d29c0f0a0c9e5c943ee573821" - integrity sha512-6Z4s4nvgFRdda/1s1+uu4a6EMZwEjjJ9Bk/1yBImv0fd9U2CsGu2cUakAtV83cZKhizbWhSouXoaK4JtlScdFg== +eslint-plugin-react-native@3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.10.0.tgz#240f7e6979a908af3dfd9ba9652434c33f4d64cd" + integrity sha512-4f5+hHYYq5wFhB5eptkPEAR7FfvqbS7AzScUOANfAMZtYw5qgnCxRq45bpfBaQF+iyPMim5Q8pubcpvLv75NAg== dependencies: + "@babel/traverse" "^7.7.4" eslint-plugin-react-native-globals "^0.1.1" eslint-plugin-react@7.21.5: From af4edbb8c034ebc4619e3d1f9fb58815ba924406 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 14 Dec 2020 11:13:50 -0800 Subject: [PATCH 0222/1810] Fabric: Asserts in `[RCTImageComponentView updateState:oldState:]` Summary: We see crashes in this method, so we need asserts to understand why exactly it happens. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25535606 fbshipit-source-id: 8b0d275825a028f51343e4ab91682c8299904e8d --- .../Mounting/ComponentViews/Image/RCTImageComponentView.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm index 105e55257b4517..114a85b9c0c782 100644 --- a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm @@ -7,6 +7,7 @@ #import "RCTImageComponentView.h" +#import #import #import #import @@ -76,6 +77,11 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { + RCTAssert(state, @"`state` must not be null."); + RCTAssert( + std::dynamic_pointer_cast(state), + @"`state` must be a pointer to `ImageShadowNode::ConcreteState`."); + auto oldImageState = std::static_pointer_cast(_state); auto newImageState = std::static_pointer_cast(state); From 18149e4fa8f4733d1d9ce50b6bf169a1c2d9c2e1 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 14 Dec 2020 11:13:50 -0800 Subject: [PATCH 0223/1810] Fabric: Asserts in RCTMountingManager ensuring that props are not null Summary: We see crashes in `updateProps:oldProps:` methods in several components, and we suspect it might happen because of the props object being null. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25535605 fbshipit-source-id: f278a5cec47b7fd54d31d015427fa918c02d913b --- React/Fabric/Mounting/RCTMountingManager.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index 387542399fc409..2d737a7fe62e6a 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -67,6 +67,8 @@ static void RCTPerformMountInstructions( UIView *newChildComponentView = newChildViewDescriptor.view; + RCTAssert(newChildShadowView.props, @"`newChildShadowView.props` must not be null."); + [newChildComponentView updateProps:newChildShadowView.props oldProps:oldChildShadowView.props]; [newChildComponentView updateEventEmitter:newChildShadowView.eventEmitter]; [newChildComponentView updateState:newChildShadowView.state oldState:oldChildShadowView.state]; @@ -95,6 +97,8 @@ static void RCTPerformMountInstructions( auto mask = RNComponentViewUpdateMask{}; + RCTAssert(newChildShadowView.props, @"`newChildShadowView.props` must not be null."); + if (oldChildShadowView.props != newChildShadowView.props) { [newChildComponentView updateProps:newChildShadowView.props oldProps:oldChildShadowView.props]; mask |= RNComponentViewUpdateMaskProps; From 687ddf0f32d10112ec0f1678ce2e903f36e8fcd7 Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Mon, 14 Dec 2020 12:56:19 -0800 Subject: [PATCH 0224/1810] Downgrade TurboModule crash to warning Summary: This is to address a UBN blocking FBiOSv300 rollout. A TM is attempting to invoke a promise more than once and crashing. We can't find the TM, so downgrading this to a warning to unblock the release. Plan going forward: - Replace this with some better logging to try and identify the culprit module. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D25539676 fbshipit-source-id: 5b75b71110eaa393378049de6e0d9a77e6328831 --- .../react/nativemodule/core/platform/ios/RCTTurboModule.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm index 4c7d3031bfb442..c605a0ff977519 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm @@ -244,7 +244,8 @@ static int32_t getUniqueId() } if (resolveWasCalled) { - throw std::runtime_error("Tried to resolve a promise more than once."); + RCTLogWarn(@"Tried to resolve a promise more than once."); + return; } auto strongResolveWrapper = weakResolveWrapper.lock(); From fdcacd7f76ea8ca6dafda32ac431c8adc7bdad00 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Mon, 14 Dec 2020 14:06:07 -0800 Subject: [PATCH 0225/1810] fix: building in release mode for simulator (#30543) Summary: Fixes https://github.com/facebook/react-native/issues/29984 Right now, running a React Native application with Xcode 12 in Release mode on an iPhone Simulator will fail with something like below: > [some file path], building for iOS Simulator, but linking in object file built for iOS, file '[some file path]' for architecture arm64 The best explanation of this issue has been provided by alloy in https://github.com/facebook/react-native/issues/29984: > This issue has started coming up with Xcode 12 and support for the new ARM based Macs, as `arm64` now no longer can be assumed to _only_ be for iOS devices. This means Xcode 12 will now also build for `arm64` simulator SDKs and it has become ambiguous if an arch slice in a prebuilt binary is meant for a simulator or device. > > In any case, for now this means that you can configure your Xcode project to exclude `arm64` when building for any iOS simulator SDK. This PR implements aforementioned workaround. ## Changelog [FIX] [IOS] - Fix running React Native project with Xcode 12 in Release on iPhone Simulator Pull Request resolved: https://github.com/facebook/react-native/pull/30543 Test Plan: Switch your scheme to Release and run the app on simulator. Will complete w/o issues. Reviewed By: appden Differential Revision: D25537295 Pulled By: TheSavior fbshipit-source-id: 2dc05cb80e59f1d95d2a84ab55ed6a5b5446411c --- scripts/react_native_pods.rb | 21 +++++++++++++++++++++ template/ios/Podfile | 14 ++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 480df56be4d5c5..27b8defbb4a151 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -108,3 +108,24 @@ def flipper_post_install(installer) end end end + +def react_native_post_install(installer) + projects = installer.aggregate_targets + .map{ |t| t.user_project } + .uniq{ |p| p.path } + .push(installer.pods_project) + + arm_value = `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i + + projects.each do |project| + project.build_configurations.each do |config| + if arm_value == 1 then + config.build_settings.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]") + else + config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" + end + end + + project.save() + end +end diff --git a/template/ios/Podfile b/template/ios/Podfile index 1b0f64d347bad6..284cce626e320b 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -20,9 +20,15 @@ target 'HelloWorld' do # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and - # you should disable these next few lines. - use_flipper! + # you should disable the next line. + use_flipper!() + post_install do |installer| - flipper_post_install(installer) + react_native_post_install(installer) + + # Enables Flipper. + # + # Disable the next line if you are not using Flipper. + flipper_post_install(installer) end -end +end \ No newline at end of file From e54ead6556f813fc622fd5e1f27ab2b41fa4f213 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Mon, 14 Dec 2020 17:25:47 -0800 Subject: [PATCH 0226/1810] fix: default template on iOS (#30571) Summary: Recently introduced steps to run Hermes accidentally removed `!` from the `use_react_native`, causing `pod install` to fail with an error. ## Changelog [INTERNAL] [iOS] - Fix Podfle in default template Pull Request resolved: https://github.com/facebook/react-native/pull/30571 Test Plan: Run `pod install` with this file and it should work. Reviewed By: appden Differential Revision: D25537263 Pulled By: TheSavior fbshipit-source-id: da7f21775cbe641e34aded87a92c696539f4d5c3 --- template/ios/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/ios/Podfile b/template/ios/Podfile index 284cce626e320b..83f678deecd3f7 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -6,7 +6,7 @@ platform :ios, '10.0' target 'HelloWorld' do config = use_native_modules! - use_react_native( + use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :hermes_enabled => false From 42dde12aac81208c4e69da991f4e08b9e62d18f6 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Tue, 15 Dec 2020 11:13:12 -0800 Subject: [PATCH 0227/1810] Exclude `i386` from valid architectures when building with Hermes on iOS (#30592) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: When building React Native application in Release mode for an iPhone Simulator _and_ targeting `armv7`, Xcode will build all architectures (due to `ONLY_ACTIVE_ARCH` set to `false`, unlike in Debug mode). As a result, Xcode will try building for `i386` (32-bit iPhone Simulator), which fails as we don’t build Hermes binaries for `i386`. Fix is to disable `i386`, since it is not supported by `Hermes` and certain `Folly` features. ## Changelog [IOS] [BREAKING] - `i386` architecture will be automatically disabled when Hermes is being used. This might be potentially breaking for your workflow if you target `armv7` devices, as you will no longer be able to test on the simulator. [IOS] [FEATURE] - Replace `flipper_post_install` with `react_native_post_install` hook. Will automatically detect if Flipper is enabled. Pull Request resolved: https://github.com/facebook/react-native/pull/30592 Test Plan: Run React Native application with Hermes enabled (or Flipper) in Release mode and it should work just fine. Reviewed By: appden Differential Revision: D25564738 Pulled By: TheSavior fbshipit-source-id: e786ab73fb0a77de5869cf9e5999726c7d29f1d4 --- scripts/react_native_pods.rb | 21 ++++++++++++++++++--- template/ios/Podfile | 5 ----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 27b8defbb4a151..b07641ffb6093d 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -98,6 +98,10 @@ def use_flipper!(versions = {}, configurations: ['Debug']) pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configurations => configurations end +def has_pod(installer, name) + installer.pods_project.pod_group(name) != nil +end + # Post Install processing for Flipper def flipper_post_install(installer) installer.pods_project.targets.each do |target| @@ -109,7 +113,7 @@ def flipper_post_install(installer) end end -def react_native_post_install(installer) +def exclude_architectures(installer) projects = installer.aggregate_targets .map{ |t| t.user_project } .uniq{ |p| p.path } @@ -117,15 +121,26 @@ def react_native_post_install(installer) arm_value = `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i + # Hermes does not support `i386` architecture + excluded_archs_default = has_pod(installer, 'hermes-engine') ? "i386" : "" + projects.each do |project| project.build_configurations.each do |config| if arm_value == 1 then - config.build_settings.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]") + config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default else - config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" + config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 " + excluded_archs_default end end project.save() end end + +def react_native_post_install(installer) + if has_pod(installer, 'Flipper') + flipper_post_install(installer) + end + + exclude_architectures(installer) +end diff --git a/template/ios/Podfile b/template/ios/Podfile index 83f678deecd3f7..18369a7e68920c 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -25,10 +25,5 @@ target 'HelloWorld' do post_install do |installer| react_native_post_install(installer) - - # Enables Flipper. - # - # Disable the next line if you are not using Flipper. - flipper_post_install(installer) end end \ No newline at end of file From 0da02ab1ca8f7ce4212eecd8d9d671f88428f1b6 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 15 Dec 2020 11:16:12 -0800 Subject: [PATCH 0228/1810] Don't lookup TurboModules post-invalidation Summary: During cleanup, RCTNativeAnimatedModule [requires the RCTEventDispatcher](https://fburl.com/diffusion/0bnln893) to remove itself from the dispatcher a dispatch observer. When the bridge is invalidated, if RCTEventDispatcher is has been cleaned up by then, we don't warn when this lookup fails: https://fburl.com/diffusion/rfioe5ay. This diff replicates that behaviour in the TurboModule infra. Notes: - In the legacy NativeModule infra, we can still query NativeModules post invalidation - we just won't create them. In the TurboModule infra, all requests for TurboModules from the TurboModuleManager start returning nil. Therefore, I simply did an early return inside TurboModuleManager moduleForName in the case that we're already invalidated. In addition to not displaying the warning, we just don't request/create the TurboModule in the first place. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25560228 fbshipit-source-id: 102dcc147bab6121daacdb39890bad48c0e60894 --- .../nativemodule/core/platform/ios/RCTTurboModuleManager.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index 14dfc0c96e09d8..8519045cbff47b 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -761,6 +761,12 @@ - (id)moduleForName:(const char *)moduleName - (id)moduleForName:(const char *)moduleName warnOnLookupFailure:(BOOL)warnOnLookupFailure { + // When the bridge is invalidating, TurboModules will be nil. + // Therefore, don't (1) do the lookup, and (2) warn on lookup. + if (_invalidating) { + return nil; + } + id module = [self provideRCTTurboModule:moduleName]; if (warnOnLookupFailure && !module) { From 5d4514b4920cafb017dc227eb809cbaaf1e0276a Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 15 Dec 2020 11:43:05 -0800 Subject: [PATCH 0229/1810] Fabric: Small improvements in StubViewTree for more easier testing Summary: Added a couple of simple methods for quering view information. Changelog: [Internal] Fabric-specific internal change. Reviewed By: mdvacca Differential Revision: D25562530 fbshipit-source-id: 697bea8d87c21d72475fb4896af3215f9279f34b --- .../react/renderer/mounting/StubViewTree.cpp | 8 ++++++++ ReactCommon/react/renderer/mounting/StubViewTree.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index 1b58f59e5d3521..481974997d1f53 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -38,6 +38,14 @@ StubView const &StubViewTree::getRootStubView() const { return *registry.at(rootTag); } +StubView const &StubViewTree::getStubView(Tag tag) const { + return *registry.at(tag); +} + +size_t StubViewTree::size() const { + return registry.size(); +} + void StubViewTree::mutate(ShadowViewMutationList const &mutations) { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Mutating Begin"; }); for (auto const &mutation : mutations) { diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.h b/ReactCommon/react/renderer/mounting/StubViewTree.h index 6ffb00e63ce96a..c3ce25c8fdf10e 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.h +++ b/ReactCommon/react/renderer/mounting/StubViewTree.h @@ -25,8 +25,22 @@ class StubViewTree { StubView const &getRootStubView() const; + /* + * Returns a view with given tag. + */ + StubView const &getStubView(Tag tag) const; + + /* + * Returns the total amount of views in the tree. + */ + size_t size() const; + + private: Tag rootTag; std::unordered_map registry{}; + + friend bool operator==(StubViewTree const &lhs, StubViewTree const &rhs); + friend bool operator!=(StubViewTree const &lhs, StubViewTree const &rhs); }; bool operator==(StubViewTree const &lhs, StubViewTree const &rhs); From 5a4685b44e73013ab013154e6ae2c73c67e599f6 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 15 Dec 2020 11:43:05 -0800 Subject: [PATCH 0230/1810] Fabric: A basic unit test for Stacking Context Summary: It tests some basic flattening operations. More tests are coming. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC, mdvacca Differential Revision: D25562529 fbshipit-source-id: 25978d97acdade8b6dc91c91fc227b6cbbd61899 --- .../mounting/tests/StackingContextTest.cpp | 359 ++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp new file mode 100644 index 00000000000000..9957ff87967734 --- /dev/null +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -0,0 +1,359 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +class StackingContextTest : public ::testing::Test { + protected: + ComponentBuilder builder_; + std::shared_ptr rootShadowNode_; + std::shared_ptr nodeA_; + std::shared_ptr nodeAA_; + std::shared_ptr nodeB_; + std::shared_ptr nodeBA_; + std::shared_ptr nodeBB_; + std::shared_ptr nodeBBA_; + std::shared_ptr nodeBBB_; + std::shared_ptr nodeBC_; + std::shared_ptr nodeBD_; + + StackingContextTest() : builder_(simpleComponentBuilder()) { + // ┌────────────── (Root) ──────────────┐ + // │ ┏━ A (tag: 2) ━━━━━━━━━━━━━━━━━━━┓ │ + // │ ┃ ┃ │ + // │ ┃ ┃ │ + // │ ┃ ┃ │ + // │ ┃ ┃ │ + // │ ┃ ┏━ AA (tag: 3) ━━━━━━━━━━━━━━┓ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┏━ B (tag: 4) ━━━━━━━━━━━━━━━━━━━┓ │ + // │ ┃ ┃ │ + // │ ┃ ┃ │ + // │ ┃ ┃ │ + // │ ┃ ┃ │ + // │ ┃ ┏━ BA (tag: 5) ━━━━━━━━━━━━━━┓ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ ┃ ┏━ BB (tag: 6) ━━━━━━━━━━━━━━┓ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┏━ BBA (tag: 7) ━━━━━━━━━┓ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ + // │ ┃ ┃ ┏━ BBB (tag: 8) ━━━━━━━━━┓ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ ┃ ┏━ BC (tag: 9) ━━━━━━━━━━━━━━┓ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ ┃ ┏━ BD (tag: 10) ━━━━━━━━━━━━━┓ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // └────────────────────────────────────┘ + + // clang-format off + auto element = + Element() + .reference(rootShadowNode_) + .tag(1) + .children({ + Element() + .tag(2) + .reference(nodeA_) + .children({ + Element() + .tag(3) + .reference(nodeAA_) + }), + Element() + .tag(4) + .reference(nodeB_) + .children({ + Element() + .tag(5) + .reference(nodeBA_), + Element() + .tag(6) + .reference(nodeBB_) + .children({ + Element() + .tag(7) + .reference(nodeBBA_), + Element() + .tag(8) + .reference(nodeBBB_) + }), + Element() + .tag(9) + .reference(nodeBC_), + Element() + .tag(10) + .reference(nodeBD_) + }) + }); + // clang-format on + + builder_.build(element); + } + + void mutateViewShadowNodeProps_( + std::shared_ptr node, + std::function callback) { + rootShadowNode_ = + std::static_pointer_cast(rootShadowNode_->cloneTree( + node->getFamily(), [&](ShadowNode const &oldShadowNode) { + auto viewProps = std::make_shared(); + callback(*viewProps); + return oldShadowNode.clone(ShadowNodeFragment{viewProps}); + })); + } +}; + +TEST_F(StackingContextTest, defaultPropsMakeEverythingFlattened) { + rootShadowNode_->layoutIfNeeded(); + auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); + + // 1 view in total. + EXPECT_EQ(viewTree.size(), 1); + + // The root view has no subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 0); +} + +TEST_F(StackingContextTest, mostPropsDoNotForceViewsToMaterialize) { + // ┌────────────── (Root) ──────────────┐ ┌────────── (Root) ───────────┐ + // │ ┏━ A (tag: 2) ━━━━━━━━━━━━━━━━━━━┓ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┏━ AA (tag: 3) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ padding: 10; ┃ ┃ │ │ │ + // │ ┃ ┃ margin: 9001; ┃ ┃ │ │ │ + // │ ┃ ┃ position: absolute; ┃ ┃ │ │ │ + // │ ┃ ┃ shadowRadius: 10; ┃ ┃ │ │ │ + // │ ┃ ┃ shadowOffset: [42, 42]; ┃ ┃ │ │ │ + // │ ┃ ┃ backgroundColor: clear; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ │ + // │ ┏━ B (tag: 4) ━━━━━━━━━━━━━━━━━━━┓ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┏━ BA (tag: 5) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ zIndex: 42; ┃ ┃ │ │ │ + // │ ┃ ┃ margin: 42; ┃ ┃ │ │ │ + // │ ┃ ┃ shadowColor: clear; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BB (tag: 6) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ No observable side-effects. │ + // │ ┃ ┃ ┃ ┃ │━━━▶│ No views are generated. │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┏━ BBA (tag: 7) ━━━━━━━━━┓ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ position: relative; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ borderRadii: 42; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ borderColor: black; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ │ + // │ ┃ ┃ ┏━ BBB (tag: 8) ━━━━━━━━━┓ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BC (tag: 9) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BD (tag: 10) ━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ onLayout: true; ┃ ┃ │ │ │ + // │ ┃ ┃ hitSlop: 42; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ │ + // └────────────────────────────────────┘ └─────────────────────────────┘ + + mutateViewShadowNodeProps_(nodeAA_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.padding()[YGEdgeAll] = YGValue{42, YGUnitPoint}; + yogaStyle.margin()[YGEdgeAll] = YGValue{42, YGUnitPoint}; + yogaStyle.positionType() = YGPositionTypeAbsolute; + props.shadowRadius = 42; + props.shadowOffset = Size{42, 42}; + props.backgroundColor = clearColor(); + }); + + mutateViewShadowNodeProps_(nodeBA_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + props.zIndex = 42; + yogaStyle.margin()[YGEdgeAll] = YGValue{42, YGUnitPoint}; + props.shadowColor = clearColor(); + props.shadowOpacity = 0.42; + }); + + mutateViewShadowNodeProps_(nodeBBA_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + + props.borderRadii.all = 42; + props.borderColors.all = blackColor(); + }); + + mutateViewShadowNodeProps_(nodeBD_, [](ViewProps &props) { + props.onLayout = true; + props.hitSlop = EdgeInsets{42, 42, 42, 42}; + }); + + rootShadowNode_->layoutIfNeeded(); + auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); + + // 1 view in total. + EXPECT_EQ(viewTree.size(), 1); + + // The root view has no subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 0); +} + +TEST_F(StackingContextTest, somePropsForceViewsToMaterialize1) { + // ┌────────────── (Root) ──────────────┐ ┌─────────── (Root) ──────────┐ + // │ ┏━ A (tag: 2) ━━━━━━━━━━━━━━━━━━━┓ │ │ ┏━ AA (tag: 3) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┏━ AA (tag: 3) ━━━━━━━━━━━━━━┓ ┃ │ │ ┏━ BA (tag: 5) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ backgroundColor: black; ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ │ │ ┏━ BBA (tag: 7) ━━━━━━━━━━┓ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┃ ┃ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┏━ B (tag: 4) ━━━━━━━━━━━━━━━━━━━┓ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┃ │ │ │ + // │ ┃ ┏━ BA (tag: 5) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ backgroundColor: white; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BB (tag: 6) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │━━━▶│ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┏━ BBA (tag: 7) ━━━━━━━━━┓ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ shadowColor: black; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ │ + // │ ┃ ┃ ┏━ BBB (tag: 8) ━━━━━━━━━┓ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BC (tag: 9) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BD (tag: 10) ━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ │ + // └────────────────────────────────────┘ └─────────────────────────────┘ + + mutateViewShadowNodeProps_( + nodeAA_, [](ViewProps &props) { props.backgroundColor = blackColor(); }); + + mutateViewShadowNodeProps_( + nodeBA_, [](ViewProps &props) { props.backgroundColor = whiteColor(); }); + + mutateViewShadowNodeProps_( + nodeBBA_, [](ViewProps &props) { props.shadowColor = blackColor(); }); + + rootShadowNode_->layoutIfNeeded(); + auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); + + // 4 views in total. + EXPECT_EQ(viewTree.size(), 4); + + // The root view has all 3 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 3); + + // The root view subviews are [3, 5, 7]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 3); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 5); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 7); +} + +} // namespace react +} // namespace facebook From 7485208498939378d5756dbf0adcfce930896e7e Mon Sep 17 00:00:00 2001 From: simek Date: Tue, 15 Dec 2020 11:48:00 -0800 Subject: [PATCH 0231/1810] Pressability: fix typo in variable, follow event check pattern, small tweak (#30151) Summary: This small PR introduces the following changes to the `Pressability`: * fixes typo in internal `isActivationTransiton` variable name * assigns `onPressMove` to variable before check and potential usage (this is the common pattern in this file) * utilizes destructuring assignment to simplify passing coordinates to `_touchActivatePosition` ## Changelog [Internal] [Fixed] - Pressability: fix typo in variable, follow event check pattern, small tweak Pull Request resolved: https://github.com/facebook/react-native/pull/30151 Test Plan: Successful `yarn test` run. Reviewed By: kacieb Differential Revision: D25545662 Pulled By: nadiia fbshipit-source-id: 8d311fe21b485ee707e05dad120322b3027e686b --- Libraries/Pressability/Pressability.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Libraries/Pressability/Pressability.js b/Libraries/Pressability/Pressability.js index ba6ba885dff9ad..17dae80c59ccaf 100644 --- a/Libraries/Pressability/Pressability.js +++ b/Libraries/Pressability/Pressability.js @@ -491,8 +491,9 @@ export default class Pressability { }, onResponderMove: (event: PressEvent): void => { - if (this._config.onPressMove != null) { - this._config.onPressMove(event); + const {onPressMove} = this._config; + if (onPressMove != null) { + onPressMove(event); } // Region may not have finished being measured, yet. @@ -655,10 +656,10 @@ export default class Pressability { prevState === 'NOT_RESPONDER' && nextState === 'RESPONDER_INACTIVE_PRESS_IN'; - const isActivationTransiton = + const isActivationTransition = !isActivationSignal(prevState) && isActivationSignal(nextState); - if (isInitialTransition || isActivationTransiton) { + if (isInitialTransition || isActivationTransition) { this._measureResponderRegion(); } @@ -704,11 +705,8 @@ export default class Pressability { _activate(event: PressEvent): void { const {onPressIn} = this._config; - const touch = getTouchFromPressEvent(event); - this._touchActivatePosition = { - pageX: touch.pageX, - pageY: touch.pageY, - }; + const {pageX, pageY} = getTouchFromPressEvent(event); + this._touchActivatePosition = {pageX, pageY}; this._touchActivateTime = Date.now(); if (onPressIn != null) { onPressIn(event); From 67309277fe588c4dd64fe0c680d1d00d2f3fb2b6 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 15 Dec 2020 12:02:08 -0800 Subject: [PATCH 0232/1810] Fix infinite loop in KeyboardAvoidingView Summary: Changelog: [General][Fixed] Fix stalling UI due to a bug in KeyboardAvoidingView I introduced this bug in D22764192 (https://github.com/facebook/react-native/commit/b08fff6f869e00c20c0dcdf7aca71284c2f276f0). The stalling was caused by onLayout in JavaScript triggering native layout which called onLayout in JavaScript without terminating condition. The fix is to only cause native layout once from JavaScript's onLayout function. This makes sure both Fabric and Paper works correctly and UI stall isn't caused. Resolves: https://github.com/facebook/react-native/issues/30495 https://github.com/facebook/react-native/issues/30532 Reviewed By: TheSavior Differential Revision: D25522362 fbshipit-source-id: 602e540bb1c40ae4f421b3e6ebc5a047cd920c17 --- Libraries/Components/Keyboard/KeyboardAvoidingView.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 4e87a3f16c8d76..b3b33f838bec24 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -97,13 +97,16 @@ class KeyboardAvoidingView extends React.Component { }; _onLayout = (event: ViewLayoutEvent) => { + const wasFrameNull = this._frame == null; this._frame = event.nativeEvent.layout; if (!this._initialFrameHeight) { // save the initial frame height, before the keyboard is visible this._initialFrameHeight = this._frame.height; } - this._updateBottomIfNecesarry(); + if (wasFrameNull) { + this._updateBottomIfNecesarry(); + } }; _updateBottomIfNecesarry = () => { From ad75a3fbb0f1be140ed931b52e29b4cf86cacd3f Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 15 Dec 2020 15:12:57 -0800 Subject: [PATCH 0233/1810] Fix RCTBlobManager require inside RCTFileReaderModule Summary: RCTBlobManager actually has the name "BlobModule", not "BlobManager". Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25569865 fbshipit-source-id: f6b41300bda6485cef3f18d3d0308dad9c002b77 --- Libraries/Blob/RCTFileReaderModule.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Blob/RCTFileReaderModule.mm b/Libraries/Blob/RCTFileReaderModule.mm index 0384aec40021e0..715a34575373d9 100644 --- a/Libraries/Blob/RCTFileReaderModule.mm +++ b/Libraries/Blob/RCTFileReaderModule.mm @@ -31,7 +31,7 @@ @implementation RCTFileReaderModule resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { - RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobManager"]; + RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobModule"]; NSData *data = [blobManager resolve:blob]; if (data == nil) { @@ -56,7 +56,7 @@ @implementation RCTFileReaderModule resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { - RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobManager"]; + RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobModule"]; NSData *data = [blobManager resolve:blob]; if (data == nil) { From 9f05544b35fb3a0902c0e5d0a7299987443e114f Mon Sep 17 00:00:00 2001 From: Ron Edelstein Date: Tue, 15 Dec 2020 18:23:01 -0800 Subject: [PATCH 0234/1810] Explicitly set autoglob in bzl files Reviewed By: strulovich Differential Revision: D25537172 fbshipit-source-id: 6d1d0b1cab35059b8ed848d7c1de34c7e94347f7 --- packages/react-native-codegen/DEFS.bzl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index ba8bb17c99696a..aca528ac5f4bf0 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -161,6 +161,7 @@ def rn_codegen_modules( srcs = [ ":{}".format(generate_module_java_zip_name), ], + autoglob = False, labels = library_labels + ["codegen_rule"], visibility = ["PUBLIC"], deps = [ @@ -476,6 +477,7 @@ def rn_codegen_components( srcs = [ ":{}".format(zip_generated_java_files), ], + autoglob = False, labels = library_labels + ["codegen_rule"], visibility = ["PUBLIC"], deps = [ @@ -490,6 +492,7 @@ def rn_codegen_components( srcs = [ ":{}".format(zip_generated_cxx_files), ], + autoglob = False, labels = library_labels + ["codegen_rule"], visibility = ["PUBLIC"], deps = [ From c4950610e40f2019c828bc99e29769cd4089c217 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 16 Dec 2020 10:11:31 -0800 Subject: [PATCH 0235/1810] fix: First press not working after pull to refresh (#30291) Summary: According to https://github.com/facebook/react-native/issues/20011, the first onPress will not work after pull to refresh. Dive into the code, found out that is because the state `isTouching` in `Libraries/Components/ScrollResponder.js` is not updated after the pull to refresh. Update the `isTouching` state in `scrollResponderHandleResponderRelease` to fix this. ## Changelog [iOS] [Fixed] - First press not working after pull to refresh Pull Request resolved: https://github.com/facebook/react-native/pull/30291 Test Plan: ### Before - The first onPress fail ![ezgif-4-c6aa5383e898](https://user-images.githubusercontent.com/48589760/97789482-cd4c4100-1bfb-11eb-8a6b-649e8a966b99.gif) ### After - The first onPress success ![ezgif-4-195f9f6c302e](https://user-images.githubusercontent.com/48589760/97789488-da693000-1bfb-11eb-9a87-f005e61b8ad0.gif) Eli: I tested this myself internally using this code sample: ``` 'use strict'; import PlaygroundRoute from 'PlaygroundRoute'; import type {SurfaceProps} from 'Surface'; import TetraText from 'TetraText'; import TetraView from 'TetraView'; import {TouchableOpacity, Text, View, ScrollView, RefreshControl, StyleSheet} from 'react-native'; import * as React from 'react'; type Props = SurfaceProps; class App extends React.Component<{}> { constructor() { super(); this.state = {refreshing: true, items: []}; } componentDidMount() { this.refresh(); } refresh = () => { this.setState({ refreshing: true, items: [], }); setTimeout( () => this.setState({ refreshing: false, items: [0, 1, 2, 3, 4, 5], }), 1500, ); }; renderItem = ({item}) => { return ( alert('pressed!')} key={`${item}`}> {item} ); }; render() { return ( `${item}`} refreshControl={ }> {this.state.items.map(item => this.renderItem({item}))} ); } } export default function Playground(props: Props): React.Node { return ( ); } const styles = StyleSheet.create({ container: { padding: 10, paddingTop: 30, }, }); ``` {F351458967} Reviewed By: appden Differential Revision: D25574927 Pulled By: TheSavior fbshipit-source-id: 7abf8a2f947d94150419e51d46a19e792441c981 --- Libraries/Components/ScrollResponder.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index c6b0794e2f4b7a..55571c86e08f60 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -330,6 +330,7 @@ const ScrollResponderMixin = { * Invoke this from an `onResponderRelease` event. */ scrollResponderHandleResponderRelease: function(e: PressEvent) { + this.state.isTouching = e.nativeEvent.touches.length !== 0; this.props.onResponderRelease && this.props.onResponderRelease(e); if (typeof e.target === 'number') { From bc7a43b15e7ed5254eb1248daeda6ae639c20685 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 16 Dec 2020 10:53:49 -0800 Subject: [PATCH 0236/1810] Fabric: Added yet another test for Stacking Context Summary: The test covers most props that must generate views. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25576921 fbshipit-source-id: df5bedb8f6d409b5142e472ca2edcb1953bee4e1 --- .../mounting/tests/StackingContextTest.cpp | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index 9957ff87967734..a8112d987ae103 100644 --- a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -355,5 +355,108 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize1) { EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 7); } +TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) { + // ┌────────────── (Root) ──────────────┐ ┌─────────── (Root) ──────────┐ + // │ ┏━ A (tag: 2) ━━━━━━━━━━━━━━━━━━━┓ │ │ ┏━ A (tag: 2) ━━━━━━━━━━━━┓ │ + // │ ┃ backgroundColor: black; ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┏━ AA (tag: 3) ━━━━━━━━━━━━━━┓ ┃ │ │ ┏━ AA (tag: 3) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ pointerEvents: none; ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ │ │ ┏━ B (tag: 4) ━━━━━━━━━━━━┓ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┃ ┃ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┏━ B (tag: 4) ━━━━━━━━━━━━━━━━━━━┓ │ │ ┏━ BA (tag: 5) ━━━━━━━━━━━┓ │ + // │ ┃ testId: "42" ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┏━ BA (tag: 5) ━━━━━━━━━━━━━━┓ ┃ │ │ ┏━ BB (tag: 6) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ nativeId: "42" ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┏━ BBA (tag: 7) ━━━━━━━━━━┓ │ + // │ ┃ ┏━ BB (tag: 6) ━━━━━━━━━━━━━━┓ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ foregroundColor: black; ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ ┃ │━━━▶│ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ │ │ ┏━ BBB (tag: 8) ━━━━━━━━━━┓ │ + // │ ┃ ┃ ┏━ BBA (tag: 7) ━━━━━━━━━┓ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ transform: scale(2); ┃ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ ┏━ BC (tag: 9) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┏━ BBB (tag: 8) ━━━━━━━━━┓ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ position: relative; ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ zIndex: 42; ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ ┏━ BD (tag: 10) ━━━━━━━━━━┓ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┃ ┃ │ + // │ ┃ ┏━ BC (tag: 9) ━━━━━━━━━━━━━━┓ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ shadowColor: black; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BD (tag: 10) ━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ opacity: 0.42; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ │ + // └────────────────────────────────────┘ └─────────────────────────────┘ + + mutateViewShadowNodeProps_( + nodeA_, [](ViewProps &props) { props.backgroundColor = blackColor(); }); + + mutateViewShadowNodeProps_(nodeAA_, [](ViewProps &props) { + props.pointerEvents = PointerEventsMode::None; + }); + + mutateViewShadowNodeProps_( + nodeB_, [](ViewProps &props) { props.testId = "42"; }); + + mutateViewShadowNodeProps_( + nodeBA_, [](ViewProps &props) { props.nativeId = "42"; }); + + mutateViewShadowNodeProps_( + nodeBB_, [](ViewProps &props) { props.foregroundColor = blackColor(); }); + + mutateViewShadowNodeProps_(nodeBBA_, [](ViewProps &props) { + props.transform = Transform::Scale(2, 2, 2); + }); + + mutateViewShadowNodeProps_(nodeBBB_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 42; + }); + + mutateViewShadowNodeProps_( + nodeBC_, [](ViewProps &props) { props.shadowColor = blackColor(); }); + + mutateViewShadowNodeProps_( + nodeBD_, [](ViewProps &props) { props.opacity = 0.42; }); + + rootShadowNode_->layoutIfNeeded(); + auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); + + // 10 views in total. + EXPECT_EQ(viewTree.size(), 10); + + // The root view has all 9 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 9); +} + } // namespace react } // namespace facebook From 426b19073dc7f6553a66c99408d82be57147ed0b Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 16 Dec 2020 10:53:49 -0800 Subject: [PATCH 0237/1810] Fabric: calculateShadowViewMutationsForNewTree now takes order-index into account Summary: Working on zIndex tests I found that calculateShadowViewMutationsForNewTree (that we use for testing) does not take zIndex into account. This fixes it. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25576923 fbshipit-source-id: a71b3a4630430488c783cd5010c0fbb7273bdaa5 --- ReactCommon/react/renderer/mounting/stubs.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index f85cf17a90b925..bd239553ba5cc1 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -14,6 +14,25 @@ namespace facebook { namespace react { +/* + * Sorting comparator for `reorderInPlaceIfNeeded`. + */ +static bool shouldFirstPairComesBeforeSecondOne( + ShadowViewNodePair const &lhs, + ShadowViewNodePair const &rhs) noexcept { + return lhs.shadowNode->getOrderIndex() < rhs.shadowNode->getOrderIndex(); +} + +/* + * Reorders pairs in-place based on `orderIndex` using a stable sort algorithm. + */ +static void reorderInPlaceIfNeeded(ShadowViewNodePair::List &pairs) noexcept { + // This is a simplified version of the function intentionally copied from + // `Differentiator.cpp`. + std::stable_sort( + pairs.begin(), pairs.end(), &shouldFirstPairComesBeforeSecondOne); +} + /* * Generates `create` and `insert` instructions recursively traversing a shadow * tree. @@ -23,7 +42,11 @@ namespace react { static void calculateShadowViewMutationsForNewTree( ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, - ShadowViewNodePair::List const &newChildPairs) { + ShadowViewNodePair::List newChildPairs) { + + // Sorting pairs based on `orderIndex` if needed. + reorderInPlaceIfNeeded(newChildPairs); + for (auto index = 0; index < newChildPairs.size(); index++) { auto const &newChildPair = newChildPairs[index]; From 9a720ad47f0d241743f03530b527a8fbdba74e5d Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 16 Dec 2020 10:53:49 -0800 Subject: [PATCH 0238/1810] Fabric: buildStubViewTreeWithoutUsingDifferentiator & buildStubViewTreeUsingDifferentiator Summary: After fixing `calculateShadowViewMutationsForNewTree` I realized that it will be even better to test Stacking Context and mutation instructions infra using both functions: `calculateShadowViewMutationsForNewTree` (used for testing) and the Differentiator itself. This diff implements it. Now we have two similarly working functions with different implementations that we can use for testing Differentiator and other parts of the infra. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25576922 fbshipit-source-id: 7922e9ebfb9d6ef1792566554ba0c4a14f835ae2 --- .../renderer/mounting/MountingCoordinator.cpp | 7 +- ReactCommon/react/renderer/mounting/stubs.cpp | 20 +++++- ReactCommon/react/renderer/mounting/stubs.h | 14 +++- .../tests/ShadowTreeLifeCycleTest.cpp | 5 +- .../mounting/tests/StackingContextTest.cpp | 68 ++++++++++--------- 5 files changed, 73 insertions(+), 41 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 8fc0ae83833350..85dc2aec5e5bec 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -27,7 +27,8 @@ MountingCoordinator::MountingCoordinator( mountingOverrideDelegate_(delegate), telemetryController_(*this) { #ifdef RN_SHADOW_TREE_INTROSPECTION - stubViewTree_ = stubViewTreeFromShadowNode(*baseRevision_.rootShadowNode); + stubViewTree_ = buildStubViewTreeWithoutUsingDifferentiator( + *baseRevision_.rootShadowNode); #endif } @@ -138,8 +139,8 @@ better::optional MountingCoordinator::pullTransaction() // tree therefore we cannot validate the validity of the mutation // instructions. if (!shouldOverridePullTransaction && lastRevision_.has_value()) { - auto stubViewTree = - stubViewTreeFromShadowNode(*lastRevision_->rootShadowNode); + auto stubViewTree = buildStubViewTreeWithoutUsingDifferentiator( + *lastRevision_->rootShadowNode); bool treesEqual = stubViewTree_ == stubViewTree; diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index bd239553ba5cc1..a9664894192b60 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -43,7 +43,6 @@ static void calculateShadowViewMutationsForNewTree( ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, ShadowViewNodePair::List newChildPairs) { - // Sorting pairs based on `orderIndex` if needed. reorderInPlaceIfNeeded(newChildPairs); @@ -55,7 +54,7 @@ static void calculateShadowViewMutationsForNewTree( mutations.push_back(ShadowViewMutation::InsertMutation( parentShadowView, newChildPair.shadowView, index)); - auto const newGrandChildPairs = + auto newGrandChildPairs = sliceChildShadowNodeViewPairsLegacy(*newChildPair.shadowNode); calculateShadowViewMutationsForNewTree( @@ -63,7 +62,8 @@ static void calculateShadowViewMutationsForNewTree( } } -StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { +StubViewTree buildStubViewTreeWithoutUsingDifferentiator( + ShadowNode const &rootShadowNode) { auto mutations = ShadowViewMutation::List{}; mutations.reserve(256); @@ -81,5 +81,19 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { return stubViewTree; } +StubViewTree buildStubViewTreeUsingDifferentiator( + ShadowNode const &rootShadowNode) { + auto emptyRootShadowNode = rootShadowNode.clone( + ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(), + ShadowNode::emptySharedShadowNodeSharedList()}); + + auto mutations = + calculateShadowViewMutations(*emptyRootShadowNode, rootShadowNode); + + auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode)); + stubViewTree.mutate(mutations); + return stubViewTree; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/mounting/stubs.h b/ReactCommon/react/renderer/mounting/stubs.h index 8a7b564c081073..73ac7b1d8ecccf 100644 --- a/ReactCommon/react/renderer/mounting/stubs.h +++ b/ReactCommon/react/renderer/mounting/stubs.h @@ -14,7 +14,19 @@ namespace facebook { namespace react { -StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode); +/* + * Builds a ShadowView tree from given root ShadowNode using custom built-in + * implementation (*without* using Differentiator). + */ +StubViewTree buildStubViewTreeWithoutUsingDifferentiator( + ShadowNode const &rootShadowNode); + +/* + * Builds a ShadowView tree from given root ShadowNode using Differentiator by + * generating mutation instructions between empty and final trees. + */ +StubViewTree buildStubViewTreeUsingDifferentiator( + ShadowNode const &rootShadowNode); } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index df6c63722fcb18..2009d262596fcc 100644 --- a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -73,7 +73,7 @@ static void testShadowNodeTreeLifeCycle( SharedShadowNodeList{singleRootChildNode})})); // Building an initial view hierarchy. - auto viewTree = stubViewTreeFromShadowNode(*emptyRootNode); + auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode); viewTree.mutate( calculateShadowViewMutations(*emptyRootNode, *currentRootNode)); @@ -131,7 +131,8 @@ static void testShadowNodeTreeLifeCycle( viewTree.mutate(mutations); // Building a view tree to compare with. - auto rebuiltViewTree = stubViewTreeFromShadowNode(*nextRootNode); + auto rebuiltViewTree = + buildStubViewTreeWithoutUsingDifferentiator(*nextRootNode); // Comparing the newly built tree with the updated one. if (rebuiltViewTree != viewTree) { diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index a8112d987ae103..3bffc91cb8f0a6 100644 --- a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -155,17 +155,24 @@ class StackingContextTest : public ::testing::Test { return oldShadowNode.clone(ShadowNodeFragment{viewProps}); })); } + + void testViewTree( + std::function callback) { + rootShadowNode_->layoutIfNeeded(); + + callback(buildStubViewTreeUsingDifferentiator(*rootShadowNode_)); + callback(buildStubViewTreeWithoutUsingDifferentiator(*rootShadowNode_)); + } }; TEST_F(StackingContextTest, defaultPropsMakeEverythingFlattened) { - rootShadowNode_->layoutIfNeeded(); - auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); + testViewTree([](StubViewTree const &viewTree) { + // 1 view in total. + EXPECT_EQ(viewTree.size(), 1); - // 1 view in total. - EXPECT_EQ(viewTree.size(), 1); - - // The root view has no subviews. - EXPECT_EQ(viewTree.getRootStubView().children.size(), 0); + // The root view has no subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 0); + }); } TEST_F(StackingContextTest, mostPropsDoNotForceViewsToMaterialize) { @@ -260,14 +267,13 @@ TEST_F(StackingContextTest, mostPropsDoNotForceViewsToMaterialize) { props.hitSlop = EdgeInsets{42, 42, 42, 42}; }); - rootShadowNode_->layoutIfNeeded(); - auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); - - // 1 view in total. - EXPECT_EQ(viewTree.size(), 1); + testViewTree([](StubViewTree const &viewTree) { + // 1 view in total. + EXPECT_EQ(viewTree.size(), 1); - // The root view has no subviews. - EXPECT_EQ(viewTree.getRootStubView().children.size(), 0); + // The root view has no subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 0); + }); } TEST_F(StackingContextTest, somePropsForceViewsToMaterialize1) { @@ -340,19 +346,18 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize1) { mutateViewShadowNodeProps_( nodeBBA_, [](ViewProps &props) { props.shadowColor = blackColor(); }); - rootShadowNode_->layoutIfNeeded(); - auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); - - // 4 views in total. - EXPECT_EQ(viewTree.size(), 4); + testViewTree([](StubViewTree const &viewTree) { + // 4 views in total. + EXPECT_EQ(viewTree.size(), 4); - // The root view has all 3 subviews. - EXPECT_EQ(viewTree.getRootStubView().children.size(), 3); + // The root view has all 3 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 3); - // The root view subviews are [3, 5, 7]. - EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 3); - EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 5); - EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 7); + // The root view subviews are [3, 5, 7]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 3); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 5); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 7); + }); } TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) { @@ -448,14 +453,13 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) { mutateViewShadowNodeProps_( nodeBD_, [](ViewProps &props) { props.opacity = 0.42; }); - rootShadowNode_->layoutIfNeeded(); - auto viewTree = stubViewTreeFromShadowNode(*rootShadowNode_); + testViewTree([](StubViewTree const &viewTree) { + // 10 views in total. + EXPECT_EQ(viewTree.size(), 10); - // 10 views in total. - EXPECT_EQ(viewTree.size(), 10); - - // The root view has all 9 subviews. - EXPECT_EQ(viewTree.getRootStubView().children.size(), 9); + // The root view has all 9 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 9); + }); } } // namespace react From 98f1825f5652bbd60064c30fb149d3d31020f20c Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 16 Dec 2020 10:53:49 -0800 Subject: [PATCH 0239/1810] Fabric: Basic tests for zIndex and flattening Summary: Finally, a test for zIndex. Yay! Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25576920 fbshipit-source-id: daf8971f7d751e3316b89aae672fee4d25fe5b3e --- .../mounting/tests/StackingContextTest.cpp | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index 3bffc91cb8f0a6..a64ea7514c9eac 100644 --- a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -462,5 +462,119 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) { }); } +TEST_F(StackingContextTest, zIndexAndFlattenedNodes) { + // ┌────────────── (Root) ──────────────┐ ┌────────── (Root) ───────────┐ + // │ ┏━ A (tag: 2) ━━━━━━━━━━━━━━━━━━━┓ │ │ ┏━ BD (tag: 10) ━━━━━━━━━━┓ │ + // │ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┏━ AA (tag: 3) ━━━━━━━━━━━━━━┓ ┃ │ │ ┏━ BC (tag: 9) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ position: relative; ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ zIndex: 9001; ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ │ │ ┏━ BBB (tag: 8) ━━━━━━━━━━┓ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┃ ┃ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┏━ B (tag: 4) ━━━━━━━━━━━━━━━━━━━┓ │ │ ┏━ BBA (tag: 7) ━━━━━━━━━━┓ │ + // │ ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┏━ BA (tag: 5) ━━━━━━━━━━━━━━┓ ┃ │ │ ┏━ BA (tag: 5) ━━━━━━━━━━━┓ │ + // │ ┃ ┃ position: relative; ┃ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ zIndex: 9000; ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┏━ AA (tag: 3) ━━━━━━━━━━━┓ │ + // │ ┃ ┏━ BB (tag: 6) ━━━━━━━━━━━━━━┓ ┃ │ │ ┃ #FormsView ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │ + // │ ┃ ┃ ┃ ┃ │━━━▶│ ┃ ┃ │ + // │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┏━ BBA (tag: 7) ━━━━━━━━━┓ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ position: relative; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ zIndex: 8999; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ │ + // │ ┃ ┃ ┏━ BBB (tag: 8) ━━━━━━━━━┓ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ position: relative; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ zIndex: 8998; ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BC (tag: 9) ━━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ position: relative; ┃ ┃ │ │ │ + // │ ┃ ┃ zIndex: 8997; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┃ ┏━ BD (tag: 10) ━━━━━━━━━━━━━┓ ┃ │ │ │ + // │ ┃ ┃ position: relative; ┃ ┃ │ │ │ + // │ ┃ ┃ zIndex: 8996; ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┃ ┃ ┃ │ │ │ + // │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ │ + // │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ │ │ + // └────────────────────────────────────┘ └─────────────────────────────┘ + + mutateViewShadowNodeProps_(nodeAA_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 9001; + }); + + mutateViewShadowNodeProps_(nodeBA_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 9000; + }); + + mutateViewShadowNodeProps_(nodeBBA_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 8999; + }); + + mutateViewShadowNodeProps_(nodeBBB_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 8998; + }); + + mutateViewShadowNodeProps_(nodeBC_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 8997; + }); + + mutateViewShadowNodeProps_(nodeBD_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 8996; + }); + + testViewTree([](StubViewTree const &viewTree) { + // 7 views in total. + EXPECT_EQ(viewTree.size(), 7); + + // The root view has all 6 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 6); + + // The root view subviews are [10, 9, 8, 7, 5, 3]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 10); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 9); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 8); + EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 7); + EXPECT_EQ(viewTree.getRootStubView().children.at(4)->tag, 5); + EXPECT_EQ(viewTree.getRootStubView().children.at(5)->tag, 3); + }); +} + } // namespace react } // namespace facebook From 453713187815b023cbc32cd434580a452f3e97ac Mon Sep 17 00:00:00 2001 From: Keion Anvaripour Date: Wed, 16 Dec 2020 16:02:08 -0800 Subject: [PATCH 0240/1810] Bytecode client for Android (#30595) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/30595 Changelog: [Internal] Add support for loading HBC bundles from Metro in Twilight. * adds `runtimeBytecodeVersion` to the bundleURL * adds logic to check chunk hermes bytecode bundles * adds support for running the bytecode bundles Reviewed By: cpojer Differential Revision: D24966992 fbshipit-source-id: acdd03a2e9e2b3e4c29c99c35a7c9136a3a7ef01 --- React/Base/RCTJavaScriptLoader.mm | 1 + ReactAndroid/build.gradle | 1 + .../main/java/com/facebook/react/common/BUCK | 1 + .../react/common/build/ReactBuildConfig.java | 1 + .../react/devsupport/DevServerHelper.java | 10 ++++++-- .../jni/react/jni/CatalystInstanceImpl.cpp | 25 ++++++++++++++++++- ReactCommon/cxxreact/Instance.cpp | 12 +++++++++ ReactCommon/cxxreact/Instance.h | 1 + ReactCommon/cxxreact/JSBundleType.cpp | 5 ++++ ReactCommon/cxxreact/JSBundleType.h | 1 + 10 files changed, 55 insertions(+), 3 deletions(-) diff --git a/React/Base/RCTJavaScriptLoader.mm b/React/Base/RCTJavaScriptLoader.mm index d902f0c92d0002..dfce0d5e93a253 100755 --- a/React/Base/RCTJavaScriptLoader.mm +++ b/React/Base/RCTJavaScriptLoader.mm @@ -177,6 +177,7 @@ + (NSData *)attemptSynchronousLoadOfBundleAtURL:(NSURL *)scriptURL facebook::react::ScriptTag tag = facebook::react::parseTypeFromHeader(header); switch (tag) { + case facebook::react::ScriptTag::HBCBundle: case facebook::react::ScriptTag::RAMBundle: break; diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index e651b5be40fd87..2b33e77be7157c 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -399,6 +399,7 @@ android { buildConfigField("boolean", "IS_INTERNAL_BUILD", "false") buildConfigField("int", "EXOPACKAGE_FLAGS", "0") + buildConfigField("int", "HERMES_BYTECODE_VERSION", "0") resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort() resValue "integer", "react_native_inspector_proxy_port", reactNativeInspectorProxyPort() diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/common/BUCK index c8a8cb7d18e144..596d953a230158 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/common/BUCK @@ -40,6 +40,7 @@ rn_android_build_config( package = "com.facebook.react", values = [ "boolean IS_INTERNAL_BUILD = true", + "int HERMES_BYTECODE_VERSION = 0", ], visibility = [ "PUBLIC", diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/build/ReactBuildConfig.java b/ReactAndroid/src/main/java/com/facebook/react/common/build/ReactBuildConfig.java index a90ec674e12edd..093bd88c580a45 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/build/ReactBuildConfig.java +++ b/ReactAndroid/src/main/java/com/facebook/react/common/build/ReactBuildConfig.java @@ -20,4 +20,5 @@ public class ReactBuildConfig { public static final boolean DEBUG = BuildConfig.DEBUG; public static final boolean IS_INTERNAL_BUILD = BuildConfig.IS_INTERNAL_BUILD; public static final int EXOPACKAGE_FLAGS = BuildConfig.EXOPACKAGE_FLAGS; + public static final int HERMES_BYTECODE_VERSION = BuildConfig.HERMES_BYTECODE_VERSION; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index 83e7ca48cb1558..88bb1764b90d13 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -14,6 +14,7 @@ import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.ReactContext; import com.facebook.react.common.ReactConstants; +import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; import com.facebook.react.devsupport.interfaces.PackagerStatusCallback; import com.facebook.react.devsupport.interfaces.StackFrame; @@ -428,9 +429,13 @@ private String createSplitBundleURL(String mainModuleID, String host) { private String createBundleURL( String mainModuleID, BundleType type, String host, boolean modulesOnly, boolean runModule) { + String runtimeBytecodeVersion = + ReactBuildConfig.HERMES_BYTECODE_VERSION != 0 + ? "&runtimeBytecodeVersion=" + ReactBuildConfig.HERMES_BYTECODE_VERSION + : ""; return String.format( Locale.US, - "http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s", + "http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s%s", host, mainModuleID, type.typeID(), @@ -438,7 +443,8 @@ private String createBundleURL( getJSMinifyMode(), mPackageName, modulesOnly ? "true" : "false", - runModule ? "true" : "false"); + runModule ? "true" : "false", + runtimeBytecodeVersion); } private String createBundleURL(String mainModuleID, BundleType type) { diff --git a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp index 659c8235a64bbb..2a33fa3d0f8294 100644 --- a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +++ b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp @@ -227,7 +227,30 @@ void CatalystInstanceImpl::jniLoadScriptFromFile( const std::string &fileName, const std::string &sourceURL, bool loadSynchronously) { - if (Instance::isIndexedRAMBundle(fileName.c_str())) { + auto reactInstance = instance_; + if (reactInstance && Instance::isHBCBundle(fileName.c_str())) { + std::unique_ptr script; + RecoverableError::runRethrowingAsRecoverable( + [&fileName, &script]() { + script = JSBigFileString::fromPath(fileName); + }); + const char *buffer = script->c_str(); + uint32_t bufferLength = (uint32_t)script->size(); + uint32_t offset = 8; + while (offset < bufferLength) { + uint32_t segment = offset + 4; + uint32_t moduleLength = + bufferLength < segment ? 0 : *(((uint32_t *)buffer) + offset / 4); + + reactInstance->loadScriptFromString( + std::make_unique( + std::string(buffer + segment, buffer + moduleLength + segment)), + sourceURL, + false); + + offset += ((moduleLength + 3) & ~3) + 4; + } + } else if (Instance::isIndexedRAMBundle(fileName.c_str())) { instance_->loadRAMBundleFromFile(fileName, sourceURL, loadSynchronously); } else { std::unique_ptr script; diff --git a/ReactCommon/cxxreact/Instance.cpp b/ReactCommon/cxxreact/Instance.cpp index 2f2dc5d448d168..d809a87c737734 100644 --- a/ReactCommon/cxxreact/Instance.cpp +++ b/ReactCommon/cxxreact/Instance.cpp @@ -108,6 +108,18 @@ void Instance::loadScriptFromString( } } +bool Instance::isHBCBundle(const char *sourcePath) { + std::ifstream bundle_stream(sourcePath, std::ios_base::in); + BundleHeader header; + + if (!bundle_stream || + !bundle_stream.read(reinterpret_cast(&header), sizeof(header))) { + return false; + } + + return parseTypeFromHeader(header) == ScriptTag::HBCBundle; +} + bool Instance::isIndexedRAMBundle(const char *sourcePath) { std::ifstream bundle_stream(sourcePath, std::ios_base::in); BundleHeader header; diff --git a/ReactCommon/cxxreact/Instance.h b/ReactCommon/cxxreact/Instance.h index f475bf8a7fa72c..7cd11f9bdf50b4 100644 --- a/ReactCommon/cxxreact/Instance.h +++ b/ReactCommon/cxxreact/Instance.h @@ -56,6 +56,7 @@ class RN_EXPORT Instance { std::unique_ptr string, std::string sourceURL, bool loadSynchronously); + static bool isHBCBundle(const char *sourcePath); static bool isIndexedRAMBundle(const char *sourcePath); static bool isIndexedRAMBundle(std::unique_ptr *string); void loadRAMBundleFromString( diff --git a/ReactCommon/cxxreact/JSBundleType.cpp b/ReactCommon/cxxreact/JSBundleType.cpp index 05bacb4107c7b7..f76610d461a98e 100644 --- a/ReactCommon/cxxreact/JSBundleType.cpp +++ b/ReactCommon/cxxreact/JSBundleType.cpp @@ -13,11 +13,14 @@ namespace facebook { namespace react { static uint32_t constexpr RAMBundleMagicNumber = 0xFB0BD1E5; +static uint32_t constexpr HBCBundleMagicNumber = 0xffe7c3c3; ScriptTag parseTypeFromHeader(const BundleHeader &header) { switch (folly::Endian::little(header.magic)) { case RAMBundleMagicNumber: return ScriptTag::RAMBundle; + case HBCBundleMagicNumber: + return ScriptTag::HBCBundle; default: return ScriptTag::String; } @@ -29,6 +32,8 @@ const char *stringForScriptTag(const ScriptTag &tag) { return "String"; case ScriptTag::RAMBundle: return "RAM Bundle"; + case ScriptTag::HBCBundle: + return "HBC Bundle"; } return ""; } diff --git a/ReactCommon/cxxreact/JSBundleType.h b/ReactCommon/cxxreact/JSBundleType.h index 45a9045818897c..be39711dd8d630 100644 --- a/ReactCommon/cxxreact/JSBundleType.h +++ b/ReactCommon/cxxreact/JSBundleType.h @@ -27,6 +27,7 @@ namespace react { enum struct ScriptTag { String = 0, RAMBundle, + HBCBundle, }; /** From 8c8172f143754269933d6b75869755c03d13ff38 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Thu, 17 Dec 2020 08:46:26 -0800 Subject: [PATCH 0241/1810] Upgrade react/jsx-no-comment-textnodes lint to an error Summary: Upgrades the severity of the [`react/jsx-no-comment-textnodes`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md) lint rule from warning to error. The higher severity is warranted because, in React Native code in particular, rendering an unintended text node is likely to throw an error at runtime (unless it happens to be wrapped in ``). Furthermore, this lint is highly actionable because there's always a workaround that is less ambiguous: 1. If intending to write a comment (likely), wrap it in curly braces: `<>{ /* this is a comment */ }` 2. If intending to write an actual text node beginning with `//` or `/*` (unlikely), wrap it in curly braces and quotes: `<>{'/* this is a text node */'}` Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D25615642 fbshipit-source-id: d5a59989b04c244111071893efc546083641ac54 --- packages/eslint-config-react-native-community/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-react-native-community/index.js b/packages/eslint-config-react-native-community/index.js index 3302717db60fcb..b388eb4db03c2a 100644 --- a/packages/eslint-config-react-native-community/index.js +++ b/packages/eslint-config-react-native-community/index.js @@ -285,7 +285,7 @@ module.exports = { 'react/display-name': 0, 'react/jsx-boolean-value': 0, - 'react/jsx-no-comment-textnodes': 1, + 'react/jsx-no-comment-textnodes': 2, 'react/jsx-no-duplicate-props': 2, 'react/jsx-no-undef': 2, 'react/jsx-sort-props': 0, From b4c9f13fe794283d76766c1baef87888d174cb1c Mon Sep 17 00:00:00 2001 From: doniwinata0309 <38415463+doniwinata0309@users.noreply.github.com> Date: Thu, 17 Dec 2020 09:38:50 -0800 Subject: [PATCH 0242/1810] Remove Okhttp3 Android Proguard Rules (#30514) Summary: Remove proguard keep rules on okhttp3. The library already contains its own consumer proguard --> see https://square.github.io/okhttp/r8_proguard/ The keep rules will increase the final apk size of android app. Currently, there is no way to disable proguard rules from transitive dependencies ( https://issuetracker.google.com/issues/37073777). So any android app that use react native will also contains this proguard rules. ## Changelog [Android] [Removed] - Remove okhttp3 proguard rules Pull Request resolved: https://github.com/facebook/react-native/pull/30514 Test Plan: n/a Reviewed By: mdvacca Differential Revision: D25616704 Pulled By: fkgozali fbshipit-source-id: eb0bcbc4ace398a55ce6902e34c17b030bb87130 --- ReactAndroid/proguard-rules.pro | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ReactAndroid/proguard-rules.pro b/ReactAndroid/proguard-rules.pro index ce3f77b22ee9df..93a74c617b83fa 100644 --- a/ReactAndroid/proguard-rules.pro +++ b/ReactAndroid/proguard-rules.pro @@ -55,13 +55,6 @@ # hermes -keep class com.facebook.jni.** { *; } -# okhttp - --keepattributes Signature --keepattributes *Annotation* --keep class okhttp3.** { *; } --keep interface okhttp3.** { *; } --dontwarn okhttp3.** # okio From df0bfec2012b4a1c10a3747ab646bcd4597d2e21 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 17 Dec 2020 10:11:05 -0800 Subject: [PATCH 0243/1810] Round 2: Remove synthesize bridge = _bridge Summary: All NativeModules that used to use the bridge to require other NativeModules now require other NativeModules via the Venice-compatible RCTModuleRegistry abstraction. Therefore, we can safely get rid of synthesize bridge = _bridge from them. ## How did I generate this diff? 1. Search for all NativeModules that have `synthesize bridge =` 2. Remove the `synthesize bridge = _bridge` from each NativeModule, and if it doesn't contain `_bridge`, `setBridge:`, or `elf.bridge`, add it to this codemod. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25551295 fbshipit-source-id: 585d50ad55cb9ab083e430b07e1cf30e31f0d3c5 --- Libraries/Blob/RCTFileReaderModule.mm | 1 - Libraries/Image/RCTImageEditingManager.mm | 1 - Libraries/Network/RCTHTTPRequestHandler.mm | 1 - Libraries/Settings/RCTSettingsManager.mm | 1 - React/CoreModules/RCTDeviceInfo.mm | 1 - React/CoreModules/RCTExceptionsManager.mm | 1 - 6 files changed, 6 deletions(-) diff --git a/Libraries/Blob/RCTFileReaderModule.mm b/Libraries/Blob/RCTFileReaderModule.mm index 715a34575373d9..2525de0c201b2b 100644 --- a/Libraries/Blob/RCTFileReaderModule.mm +++ b/Libraries/Blob/RCTFileReaderModule.mm @@ -23,7 +23,6 @@ @implementation RCTFileReaderModule RCT_EXPORT_MODULE(FileReaderModule) -@synthesize bridge = _bridge; @synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_METHOD(readAsText:(NSDictionary *)blob diff --git a/Libraries/Image/RCTImageEditingManager.mm b/Libraries/Image/RCTImageEditingManager.mm index 742e1b5eee1261..47b2f60f849762 100644 --- a/Libraries/Image/RCTImageEditingManager.mm +++ b/Libraries/Image/RCTImageEditingManager.mm @@ -26,7 +26,6 @@ @implementation RCTImageEditingManager RCT_EXPORT_MODULE() -@synthesize bridge = _bridge; @synthesize moduleRegistry = _moduleRegistry; /** diff --git a/Libraries/Network/RCTHTTPRequestHandler.mm b/Libraries/Network/RCTHTTPRequestHandler.mm index 8018f028c7c696..6b1f240daa45c9 100644 --- a/Libraries/Network/RCTHTTPRequestHandler.mm +++ b/Libraries/Network/RCTHTTPRequestHandler.mm @@ -25,7 +25,6 @@ @implementation RCTHTTPRequestHandler std::mutex _mutex; } -@synthesize bridge = _bridge; @synthesize moduleRegistry = _moduleRegistry; @synthesize methodQueue = _methodQueue; diff --git a/Libraries/Settings/RCTSettingsManager.mm b/Libraries/Settings/RCTSettingsManager.mm index 1adf33c4477f72..585d60aee224b3 100644 --- a/Libraries/Settings/RCTSettingsManager.mm +++ b/Libraries/Settings/RCTSettingsManager.mm @@ -24,7 +24,6 @@ @implementation RCTSettingsManager NSUserDefaults *_defaults; } -@synthesize bridge = _bridge; @synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() diff --git a/React/CoreModules/RCTDeviceInfo.mm b/React/CoreModules/RCTDeviceInfo.mm index 6084c9ffeaf258..f470f99572e8cf 100644 --- a/React/CoreModules/RCTDeviceInfo.mm +++ b/React/CoreModules/RCTDeviceInfo.mm @@ -27,7 +27,6 @@ @implementation RCTDeviceInfo { NSDictionary *_currentInterfaceDimensions; } -@synthesize bridge = _bridge; @synthesize moduleRegistry = _moduleRegistry; @synthesize turboModuleRegistry = _turboModuleRegistry; diff --git a/React/CoreModules/RCTExceptionsManager.mm b/React/CoreModules/RCTExceptionsManager.mm index e45b270031ff72..175c5612cff592 100644 --- a/React/CoreModules/RCTExceptionsManager.mm +++ b/React/CoreModules/RCTExceptionsManager.mm @@ -23,7 +23,6 @@ @interface RCTExceptionsManager () @implementation RCTExceptionsManager -@synthesize bridge = _bridge; @synthesize moduleRegistry = _moduleRegistry; RCT_EXPORT_MODULE() From 18ea422e91d2d4a3591592f51755f550bf53a188 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 17 Dec 2020 10:27:24 -0800 Subject: [PATCH 0244/1810] Show RedBoxes during promise resolve/reject errors Summary: Previously, we'd throw std::runtime_error objects when we invoked RCTPromiseResolveBlock and RCTPromiseRejectBlock. This would crash the app. Now, we'll just show RedBoxes. The RedBoxes also contain the name of the NativeModule, along with the method. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25549149 fbshipit-source-id: 33d5fc4480a577a1c17961c856ac42a9363b35f6 --- .../core/platform/ios/RCTTurboModule.h | 7 ++++-- .../core/platform/ios/RCTTurboModule.mm | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h index 0f6bd7cb30f1b1..7e16a5a40dac48 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h @@ -90,8 +90,11 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule { NSMutableArray *retainedObjectsForInvocation); using PromiseInvocationBlock = void (^)(RCTPromiseResolveBlock resolveWrapper, RCTPromiseRejectBlock rejectWrapper); - jsi::Value - createPromise(jsi::Runtime &runtime, std::shared_ptr jsInvoker, PromiseInvocationBlock invoke); + jsi::Value createPromise( + jsi::Runtime &runtime, + std::shared_ptr jsInvoker, + std::string methodName, + PromiseInvocationBlock invoke); }; } // namespace react diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm index c605a0ff977519..4a8dc20832c07e 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm @@ -208,6 +208,7 @@ static int32_t getUniqueId() jsi::Value ObjCTurboModule::createPromise( jsi::Runtime &runtime, std::shared_ptr jsInvoker, + std::string methodName, PromiseInvocationBlock invoke) { if (!invoke) { @@ -215,6 +216,7 @@ static int32_t getUniqueId() } jsi::Function Promise = runtime.global().getPropertyAsFunction(runtime, "Promise"); + std::string moduleName = name_; // Note: the passed invoke() block is not retained by default, so let's retain it here to help keep it longer. // Otherwise, there's a risk of it getting released before the promise function below executes. @@ -223,10 +225,14 @@ static int32_t getUniqueId() runtime, jsi::PropNameID::forAscii(runtime, "fn"), 2, - [invokeCopy, jsInvoker](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) { + [invokeCopy, jsInvoker, moduleName, methodName]( + jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) { + std::string moduleMethod = moduleName + "." + methodName + "()"; + if (count != 2) { throw std::invalid_argument( - "Promise must pass constructor function two args. Passed " + std::to_string(count) + " args."); + moduleMethod + ": Promise must pass constructor function two args. Passed " + std::to_string(count) + + " args."); } if (!invokeCopy) { return jsi::Value::undefined(); @@ -240,11 +246,12 @@ static int32_t getUniqueId() RCTPromiseResolveBlock resolveBlock = ^(id result) { if (rejectWasCalled) { - throw std::runtime_error("Tried to resolve a promise after it's already been rejected."); + RCTLogError(@"%s: Tried to resolve a promise after it's already been rejected.", moduleMethod.c_str()); + return; } if (resolveWasCalled) { - RCTLogWarn(@"Tried to resolve a promise more than once."); + RCTLogError(@"%s: Tried to resolve a promise more than once.", moduleMethod.c_str()); return; } @@ -274,11 +281,13 @@ static int32_t getUniqueId() RCTPromiseRejectBlock rejectBlock = ^(NSString *code, NSString *message, NSError *error) { if (resolveWasCalled) { - throw std::runtime_error("Tried to reject a promise after it's already been resolved."); + RCTLogError(@"%s: Tried to reject a promise after it's already been resolved.", moduleMethod.c_str()); + return; } if (rejectWasCalled) { - throw std::runtime_error("Tried to reject a promise more than once."); + RCTLogError(@"%s: Tried to reject a promise more than once.", moduleMethod.c_str()); + return; } auto strongResolveWrapper = weakResolveWrapper.lock(); @@ -640,6 +649,7 @@ static int32_t getUniqueId() ? createPromise( runtime, jsInvoker_, + methodNameStr, ^(RCTPromiseResolveBlock resolveBlock, RCTPromiseRejectBlock rejectBlock) { RCTPromiseResolveBlock resolveCopy = resolveBlock; RCTPromiseRejectBlock rejectCopy = rejectBlock; From d51cc6b5e67416e03d7acbd9ab0c39404d3ef6c6 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 17 Dec 2020 10:46:00 -0800 Subject: [PATCH 0245/1810] Implement default input accessory view for text input Summary: Changelog: [internal] Fabric didn't implement default input accessory view. Paper implementation: https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/Libraries/Text/TextInput/RCTBaseTextInputView.m?commit=1e2cd9ea1637&lines=589-629 Reviewed By: shergin Differential Revision: D25612690 fbshipit-source-id: 7529c730211682bcffe17fdd4974e5df83c450d7 --- .../TextInput/RCTTextInputComponentView.mm | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index d43a49275e9d3a..deb8c9304878f1 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -210,6 +210,8 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & } [super updateProps:props oldProps:oldProps]; + + [self setDefaultInputAccessoryView]; } - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState @@ -429,6 +431,50 @@ - (void)setTextAndSelection:(NSInteger)eventCount _comingFromJS = NO; } +#pragma mark - Default input accessory view + +- (void)setDefaultInputAccessoryView +{ + UIKeyboardType keyboardType = _backedTextInputView.keyboardType; + + // These keyboard types (all are number pads) don't have a "Done" button by default, + // so we create an `inputAccessoryView` with this button for them. + BOOL shouldHaveInputAccesoryView = + (keyboardType == UIKeyboardTypeNumberPad || keyboardType == UIKeyboardTypePhonePad || + keyboardType == UIKeyboardTypeDecimalPad || keyboardType == UIKeyboardTypeASCIICapableNumberPad) && + _backedTextInputView.returnKeyType == UIReturnKeyDone; + + if ((_backedTextInputView.inputAccessoryView != nil) == shouldHaveInputAccesoryView) { + return; + } + + if (shouldHaveInputAccesoryView) { + UIToolbar *toolbarView = [[UIToolbar alloc] init]; + [toolbarView sizeToFit]; + UIBarButtonItem *flexibleSpace = + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; + UIBarButtonItem *doneButton = + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone + target:self + action:@selector(handleInputAccessoryDoneButton)]; + toolbarView.items = @[ flexibleSpace, doneButton ]; + _backedTextInputView.inputAccessoryView = toolbarView; + } else { + _backedTextInputView.inputAccessoryView = nil; + } + + if (_backedTextInputView.isFirstResponder) { + [_backedTextInputView reloadInputViews]; + } +} + +- (void)handleInputAccessoryDoneButton +{ + if ([self textInputShouldReturn]) { + [_backedTextInputView endEditing:YES]; + } +} + #pragma mark - Other - (TextInputMetrics)_textInputMetrics From 5a37773e53ef7e611a4f5e9ffbda3b0b31746b6e Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 17 Dec 2020 16:15:55 -0800 Subject: [PATCH 0246/1810] Fix race condition in FabricUIManager.StartSurface method Summary: This diff fixes a race condition in the execution of FabricUIManager.StartSurface method. The rootcause is that startSurface is executing getViewportOffset from a background thread. changelog: [internal] Reviewed By: shergin Differential Revision: D25617154 fbshipit-source-id: 9351201088164e74bb0b9454e30651e1de0da912 --- .../src/main/java/com/facebook/react/ReactRootView.java | 2 ++ .../java/com/facebook/react/fabric/FabricUIManager.java | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index f9a8f3d83cbf12..6219ab08075558 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -27,6 +27,7 @@ import android.view.WindowManager; import android.widget.FrameLayout; import androidx.annotation.Nullable; +import androidx.annotation.UiThread; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.ThreadConfined; @@ -418,6 +419,7 @@ public AtomicInteger getState() { return mState; } + @UiThread public static Point getViewportOffset(View v) { int[] locationInWindow = new int[2]; v.getLocationInWindow(locationInWindow); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index acf4057d12fab3..8948750319465a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -248,7 +248,12 @@ public int startSurface( mMountingManager.addRootView(rootTag, rootView); mReactContextForRootTag.put(rootTag, reactContext); - Point viewportOffset = ReactRootView.getViewportOffset(rootView); + // If startSurface is executed in the UIThread then, it uses the ViewportOffset from the View, + // Otherwise Fabric relies on calling {@link Binding#setConstraints} method to update the + // ViewportOffset during measurement or onLayout. + @SuppressLint("WrongThread") + Point viewportOffset = + UiThreadUtil.isOnUiThread() ? ReactRootView.getViewportOffset(rootView) : new Point(0, 0); mBinding.startSurfaceWithConstraints( rootTag, From 40115d87d45c85a154f1bedfe5c9b00d7899c903 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 17 Dec 2020 17:22:11 -0800 Subject: [PATCH 0247/1810] Roll out package info validation Summary: ## Context Every time we require a NativeModule in Java, we [first try to create it with the TurboModuleManager](https://fburl.com/diffusion/3nkjwea2). In the TurboModule infra, when a NativeModule is requested, [we first create it](https://fburl.com/diffusion/d2c6iout), then [if it's not a TurboModule, we discard the newly created object](https://fburl.com/diffusion/44gjlo6y). This is extremely wasteful, especially when a NativeModule is requested frequently and periodically, like UIManagerModule. Therefore, in D24811838 (https://github.com/facebook/react-native/commit/803a26cb003e6b790e3a1ab31beb0c95795fff0c) fkgozali launched a fix to the infra that would avoid creating the non-TurboModule object in the first place. Today, we're launching this optimization. Reviewed By: fkgozali Differential Revision: D25621570 fbshipit-source-id: dedba4d5ac6fcf2ec3c31e7163a6a226065c708b --- .../react/config/ReactFeatureFlags.java | 5 --- ...eactPackageTurboModuleManagerDelegate.java | 32 +++++++------------ .../react/uiapp/RNTesterApplication.java | 1 - 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 626a99fccd97c3..c0e8f35cd0011a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -29,11 +29,6 @@ public class ReactFeatureFlags { /** Enable TurboModule JS Codegen. */ public static volatile boolean useTurboModuleJSCodegen = false; - /** - * Enable the fix to validate the TurboReactPackage's module info before resolving a TurboModule. - */ - public static volatile boolean enableTurboModulePackageInfoValidation = false; - /* * This feature flag enables logs for Fabric */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java index 74a7ca72d2f4c9..59c2fc9794ab92 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/ReactPackageTurboModuleManagerDelegate.java @@ -15,7 +15,6 @@ import com.facebook.react.bridge.CxxModuleWrapper; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.module.model.ReactModuleInfo; import com.facebook.react.turbomodule.core.interfaces.TurboModule; import java.util.ArrayList; @@ -37,9 +36,7 @@ protected ReactPackageTurboModuleManagerDelegate( if (reactPackage instanceof TurboReactPackage) { TurboReactPackage pkg = (TurboReactPackage) reactPackage; mPackages.add(pkg); - if (ReactFeatureFlags.enableTurboModulePackageInfoValidation) { - mPackageModuleInfos.put(pkg, pkg.getReactModuleInfoProvider().getReactModuleInfos()); - } + mPackageModuleInfos.put(pkg, pkg.getReactModuleInfoProvider().getReactModuleInfos()); } } } @@ -81,23 +78,16 @@ private TurboModule resolveModule(String moduleName) { for (final TurboReactPackage pkg : mPackages) { try { - if (ReactFeatureFlags.enableTurboModulePackageInfoValidation) { - final ReactModuleInfo moduleInfo = mPackageModuleInfos.get(pkg).get(moduleName); - if (moduleInfo == null - || !moduleInfo.isTurboModule() - || resolvedModule != null && !moduleInfo.canOverrideExistingModule()) { - continue; - } - - final NativeModule module = pkg.getModule(moduleName, mReactApplicationContext); - if (module != null) { - resolvedModule = module; - } - } else { - final NativeModule module = pkg.getModule(moduleName, mReactApplicationContext); - if (resolvedModule == null || module != null && module.canOverrideExistingModule()) { - resolvedModule = module; - } + final ReactModuleInfo moduleInfo = mPackageModuleInfos.get(pkg).get(moduleName); + if (moduleInfo == null + || !moduleInfo.isTurboModule() + || resolvedModule != null && !moduleInfo.canOverrideExistingModule()) { + continue; + } + + final NativeModule module = pkg.getModule(moduleName, mReactApplicationContext); + if (module != null) { + resolvedModule = module; } } catch (IllegalArgumentException ex) { /** diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index 14700729103f98..b892f527c0e4a9 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -206,7 +206,6 @@ public double getDouble(final String s) { @Override public void onCreate() { ReactFeatureFlags.useTurboModules = BuildConfig.ENABLE_TURBOMODULE; - ReactFeatureFlags.enableTurboModulePackageInfoValidation = true; ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik); super.onCreate(); SoLoader.init(this, /* native exopackage */ false); From 5c4f145e33d92969f8a86284360a5a2f09308500 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 17 Dec 2020 17:22:11 -0800 Subject: [PATCH 0248/1810] Roll out TurboModule Promise Async Dispatch Summary: ## Context The legacy NativeModule infra implements promise methods using [async NativeModule method calls](https://fburl.com/diffusion/tpkff6vg). In the TurboModule infra, promise methods [treat as sync methods](https://fburl.com/diffusion/yde7xw71), and executed directly on the JavaScript thread. This experiment makes TurboModule promise methods async, and dispatches them to the NativeModules thread, when they're executed from JavaScript. Reviewed By: fkgozali Differential Revision: D25623192 fbshipit-source-id: 2b50d771c5272af3b6edf150054bb3e80cab0040 --- .../turbomodule/core/TurboModuleManager.java | 2 - .../jni/ReactCommon/TurboModuleManager.cpp | 3 - .../core/jni/ReactCommon/TurboModuleManager.h | 1 - .../android/ReactCommon/JavaTurboModule.cpp | 114 +++++++----------- .../android/ReactCommon/JavaTurboModule.h | 6 - 5 files changed, 45 insertions(+), 81 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index 000770aec1d5c2..2d254d69ec4c6a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -61,7 +61,6 @@ public TurboModuleManager( (CallInvokerHolderImpl) jsCallInvokerHolder, (CallInvokerHolderImpl) nativeCallInvokerHolder, delegate, - ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch, ReactFeatureFlags.useTurboModuleJSCodegen); installJSIBindings(); @@ -295,7 +294,6 @@ private native HybridData initHybrid( CallInvokerHolderImpl jsCallInvokerHolder, CallInvokerHolderImpl nativeCallInvokerHolder, TurboModuleManagerDelegate tmmDelegate, - boolean enablePromiseAsyncDispatch, boolean enableTurboModuleJSCodegen); private native void installJSIBindings(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp index a6d90b615d8427..7a69cc6dc4a04c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp @@ -43,13 +43,10 @@ jni::local_ref TurboModuleManager::initHybrid( jni::alias_ref jsCallInvokerHolder, jni::alias_ref nativeCallInvokerHolder, jni::alias_ref delegate, - bool enablePromiseAsyncDispatch, bool enableJSCodegen) { auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker(); auto nativeCallInvoker = nativeCallInvokerHolder->cthis()->getCallInvoker(); - JavaTurboModule::enablePromiseAsyncDispatch(enablePromiseAsyncDispatch); - return makeCxxInstance( jThis, runtimeExecutor->cthis()->get(), diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h index 92716800d24e20..384c5952d68f1b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.h @@ -33,7 +33,6 @@ class TurboModuleManager : public jni::HybridClass { jni::alias_ref jsCallInvokerHolder, jni::alias_ref nativeCallInvokerHolder, jni::alias_ref delegate, - bool enablePromiseAsyncDispatch, bool enableJSCodegen); static void registerNatives(); diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index f7af1f517f53ed..25fb83470bf127 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -51,11 +51,6 @@ JavaTurboModule::~JavaTurboModule() { }); } -bool JavaTurboModule::isPromiseAsyncDispatchEnabled_ = false; -void JavaTurboModule::enablePromiseAsyncDispatch(bool enable) { - isPromiseAsyncDispatchEnabled_ = enable; -} - JavaTurboModule::JavaTurboModule( const InitParams ¶ms, TurboModuleSchema &&schema) @@ -322,8 +317,7 @@ JNIArgs JavaTurboModule::convertJSIArgsToJNIArgs( auto makeGlobalIfNecessary = [&globalRefs, env, valueKind](jobject obj) -> jobject { - if (valueKind == VoidKind || - (valueKind == PromiseKind && isPromiseAsyncDispatchEnabled_)) { + if (valueKind == VoidKind || valueKind == PromiseKind) { jobject globalObj = env->NewGlobalRef(obj); globalRefs.push_back(globalObj); env->DeleteLocalRef(obj); @@ -491,9 +485,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod( const char *methodName = methodNameStr.c_str(); const char *moduleName = name_.c_str(); - bool isMethodSync = - !(valueKind == VoidKind || - (valueKind == PromiseKind && isPromiseAsyncDispatchEnabled_)); + bool isMethodSync = !(valueKind == VoidKind || valueKind == PromiseKind); if (isMethodSync) { TMPL::syncMethodCallStart(moduleName, methodName); @@ -834,60 +826,48 @@ jsi::Value JavaTurboModule::invokeJavaMethod( const char *moduleName = moduleNameStr.c_str(); const char *methodName = methodNameStr.c_str(); - if (isPromiseAsyncDispatchEnabled_) { - jobject globalPromise = env->NewGlobalRef(promise); - - globalRefs.push_back(globalPromise); - env->DeleteLocalRef(promise); - - jargs[argCount].l = globalPromise; - TMPL::asyncMethodCallArgConversionEnd(moduleName, methodName); - TMPL::asyncMethodCallDispatch(moduleName, methodName); - - nativeInvoker_->invokeAsync( - [jargs, - globalRefs, - methodID, - instance_ = instance_, - moduleNameStr, - methodNameStr, - id = getUniqueId()]() mutable -> void { - /** - * TODO(ramanpreet): Why do we have to require the - * environment again? Why does JNI crash when we use the env - * from the upper scope? - */ - JNIEnv *env = jni::Environment::current(); - const char *moduleName = moduleNameStr.c_str(); - const char *methodName = methodNameStr.c_str(); - - TMPL::asyncMethodCallExecutionStart( - moduleName, methodName, id); - env->CallVoidMethodA( - instance_.get(), methodID, jargs.data()); - try { - FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); - } catch (...) { - TMPL::asyncMethodCallExecutionFail( - moduleName, methodName, id); - throw; - } - - for (auto globalRef : globalRefs) { - env->DeleteGlobalRef(globalRef); - } - TMPL::asyncMethodCallExecutionEnd( + jobject globalPromise = env->NewGlobalRef(promise); + + globalRefs.push_back(globalPromise); + env->DeleteLocalRef(promise); + + jargs[argCount].l = globalPromise; + TMPL::asyncMethodCallArgConversionEnd(moduleName, methodName); + TMPL::asyncMethodCallDispatch(moduleName, methodName); + + nativeInvoker_->invokeAsync( + [jargs, + globalRefs, + methodID, + instance_ = instance_, + moduleNameStr, + methodNameStr, + id = getUniqueId()]() mutable -> void { + /** + * TODO(ramanpreet): Why do we have to require the + * environment again? Why does JNI crash when we use the env + * from the upper scope? + */ + JNIEnv *env = jni::Environment::current(); + const char *moduleName = moduleNameStr.c_str(); + const char *methodName = methodNameStr.c_str(); + + TMPL::asyncMethodCallExecutionStart( + moduleName, methodName, id); + env->CallVoidMethodA(instance_.get(), methodID, jargs.data()); + try { + FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); + } catch (...) { + TMPL::asyncMethodCallExecutionFail( moduleName, methodName, id); - }); - - } else { - jargs[argCount].l = promise; - TMPL::syncMethodCallArgConversionEnd(moduleName, methodName); - TMPL::syncMethodCallExecutionStart(moduleName, methodName); - env->CallVoidMethodA(instance_.get(), methodID, jargs.data()); - TMPL::syncMethodCallExecutionEnd(moduleName, methodName); - TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); - } + throw; + } + + for (auto globalRef : globalRefs) { + env->DeleteGlobalRef(globalRef); + } + TMPL::asyncMethodCallExecutionEnd(moduleName, methodName, id); + }); return jsi::Value::undefined(); }); @@ -896,12 +876,8 @@ jsi::Value JavaTurboModule::invokeJavaMethod( Promise.callAsConstructor(runtime, promiseConstructorArg); checkJNIErrorForMethodCall(); - if (isPromiseAsyncDispatchEnabled_) { - TMPL::asyncMethodCallEnd(moduleName, methodName); - } else { - TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); - TMPL::syncMethodCallEnd(moduleName, methodName); - } + TMPL::asyncMethodCallEnd(moduleName, methodName); + return promise; } default: diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h index 2e15fea7176dae..259924a16a14bd 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h @@ -55,7 +55,6 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { const jsi::Value *args, size_t argCount); - static void enablePromiseAsyncDispatch(bool enable); jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &propName) override; @@ -64,11 +63,6 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { std::shared_ptr nativeInvoker_; folly::Optional turboModuleSchema_; - /** - * Experiments - */ - static bool isPromiseAsyncDispatchEnabled_; - JNIArgs convertJSIArgsToJNIArgs( JNIEnv *env, jsi::Runtime &rt, From 5275895af5136bc278c0c5eb07ae93e395c5b29b Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 17 Dec 2020 17:22:11 -0800 Subject: [PATCH 0249/1810] Roll out TurboModule block copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: ## Description During TurboModule method invocation, when we convert JavaScript callbacks (i.e: jsi::Functions) into ObjC blocks inside the TurboModule jsi::HostObject, we [push them into an array](https://fburl.com/diffusion/r1n75ikx) that [gets cleared after the method gets invoked](https://fburl.com/diffusion/ubbvdmfs). Prior to this experiment, we pushed these ObjC blocks into the array without copying them first. This goes contrary to ObjC best practices, which suggest that if you need to retain a block past its creation context for later invocation, you should defensively copy it to prevent it from being freed early. See the [Apple docs](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html#//apple_ref/doc/uid/TP40007502-CH5-SW1): > Typically, you shouldn’t need to copy (or retain) a block. You only need to make a copy when you expect the block to be used after destruction of the scope within which it was declared. Copying moves a block to the heap. The diff that introduced the fix: D23764329 (https://github.com/facebook/react-native/commit/9b76e217bb16935069f0ea5b60f4c4d9b73f86d6). Reviewed By: PeteTheHeat Differential Revision: D25617672 fbshipit-source-id: 24863b31a2d82c8d39a91c8ea8eb3a62724b800a --- React/Base/RCTBridge.h | 4 ---- React/Base/RCTBridge.m | 11 ----------- .../core/platform/ios/RCTTurboModule.mm | 15 +++------------ 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index 5ce3ebe35a3c39..d86a0d27b97b20 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -160,10 +160,6 @@ RCT_EXTERN void RCTEnableTurboModuleEagerInit(BOOL enabled); RCT_EXTERN BOOL RCTTurboModuleSharedMutexInitEnabled(void); RCT_EXTERN void RCTEnableTurboModuleSharedMutexInit(BOOL enabled); -// Turn on TurboModule block copy -RCT_EXTERN BOOL RCTTurboModuleBlockCopyEnabled(void); -RCT_EXTERN void RCTEnableTurboModuleBlockCopy(BOOL enabled); - // Turn on TurboModule JS Codegen RCT_EXTERN BOOL RCTTurboModuleJSCodegenEnabled(void); RCT_EXTERN void RCTEnableTurboModuleJSCodegen(BOOL enabled); diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 1adc463bf060e1..d8d5594a12fa1b 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -135,17 +135,6 @@ void RCTEnableTurboModuleSharedMutexInit(BOOL enabled) turboModuleSharedMutexInitEnabled = enabled; } -static BOOL turboModuleBlockCopyEnabled = NO; -BOOL RCTTurboModuleBlockCopyEnabled(void) -{ - return turboModuleBlockCopyEnabled; -} - -void RCTEnableTurboModuleBlockCopy(BOOL enabled) -{ - turboModuleBlockCopyEnabled = enabled; -} - static BOOL turboModuleJSCodegenEnabled = NO; BOOL RCTTurboModuleJSCodegenEnabled(void) { diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm index 4a8dc20832c07e..de1bed23f8ea50 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm @@ -195,11 +195,7 @@ static int32_t getUniqueId() wrapperWasCalled = YES; }; - if (RCTTurboModuleBlockCopyEnabled()) { - return [callback copy]; - } - - return callback; + return [callback copy]; } namespace facebook { @@ -651,13 +647,8 @@ static int32_t getUniqueId() jsInvoker_, methodNameStr, ^(RCTPromiseResolveBlock resolveBlock, RCTPromiseRejectBlock rejectBlock) { - RCTPromiseResolveBlock resolveCopy = resolveBlock; - RCTPromiseRejectBlock rejectCopy = rejectBlock; - - if (RCTTurboModuleBlockCopyEnabled()) { - resolveCopy = [resolveBlock copy]; - rejectCopy = [rejectBlock copy]; - } + RCTPromiseResolveBlock resolveCopy = [resolveBlock copy]; + RCTPromiseRejectBlock rejectCopy = [rejectBlock copy]; [inv setArgument:(void *)&resolveCopy atIndex:count + 2]; [inv setArgument:(void *)&rejectCopy atIndex:count + 3]; From 0e0d2e84f56ea233e72d980ff6bd9797df250553 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 17 Dec 2020 17:22:11 -0800 Subject: [PATCH 0250/1810] Roll out RCTNetworking extraneous NativeModule call removal Summary: ## Context Every time we call RCTNetworking.sendRequest(), we [set up six event listeners inside XMLHttpRequest](https://fburl.com/diffusion/85k6ou5w) by calling RCTNetworking.addListener(). Seeing how RCTNetworking.addListener() is implemented, each call results in two async NativeModule call: [one to addListener()](https://fburl.com/diffusion/ng21jek6), and [another to removeEventListener()](https://fburl.com/diffusion/nua3y973). For RCTNetworking, both of these NativeModule calls are unnecessary, as explained in D24272663 (https://github.com/facebook/react-native/commit/dabca52f77799bcdedb6b0ec44b1f6297483a46d) > RCTNetworking.startObserving and RCTNetworking.stopObserving don't exist. The main purpose of RCTEventEmitter.addListener is to call these methods, and increment the _listeners counter, so that we can start dispatching events when _listeners > 0. In D24272560 (https://github.com/facebook/react-native/commit/82187bfb6b54fdffc5dadaa56e8bf97d2209708a), I made RCTEventEmitter dispatch events even when _listeners <= 0. This is sufficient for us to stop calling these two RCTNetworking methods entirely. Therefore, this experiment gets rid of on average 6-8 NativeModule method calls for every network call we make in React Native on iOS. Reviewed By: PeteTheHeat Differential Revision: D25618704 fbshipit-source-id: 0da20475a0882ed737cf32de27f266fd2cd016af --- Libraries/Network/RCTNetworking.ios.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Libraries/Network/RCTNetworking.ios.js b/Libraries/Network/RCTNetworking.ios.js index bc1081aab357d6..b10a833ad198f3 100644 --- a/Libraries/Network/RCTNetworking.ios.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -18,13 +18,8 @@ import type {RequestBody} from './convertRequestBody'; class RCTNetworking extends NativeEventEmitter { constructor() { - const disableCallsIntoModule = - typeof global.__disableRCTNetworkingExtraneousModuleCalls === 'function' - ? global.__disableRCTNetworkingExtraneousModuleCalls() - : false; - super(NativeNetworkingIOS, { - __SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: disableCallsIntoModule, + __SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: true, }); } From 8b4e2ac8e51763624b0bb008bbcd76347bddb0c6 Mon Sep 17 00:00:00 2001 From: Ron Edelstein Date: Thu, 17 Dec 2020 19:33:39 -0800 Subject: [PATCH 0251/1810] Explicitly set autoglob (long tail) Reviewed By: fbanurag, strulovich Differential Revision: D25620908 fbshipit-source-id: 1dd737d451ddfd07baa427902bdf1c96d7e67e64 --- ReactAndroid/src/main/java/com/facebook/BUCK | 1 + .../src/main/java/com/facebook/hermes/reactexecutor/BUCK | 1 + ReactAndroid/src/main/libraries/fresco/fresco-react-native/BUCK | 1 + ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK | 1 + ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK | 1 + .../libraries/fbcore/src/test/java/com/facebook/powermock/BUCK | 2 ++ ReactCommon/react/nativemodule/samples/BUCK | 1 + 7 files changed, 8 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/BUCK b/ReactAndroid/src/main/java/com/facebook/BUCK index a7461d145d8fc2..f24e877ad0ad4f 100644 --- a/ReactAndroid/src/main/java/com/facebook/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "yoga", srcs = glob(["yoga/*.java"]), + autoglob = False, visibility = ["PUBLIC"], deps = [ react_native_dep("libraries/fbjni:java"), diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK index d80f1ec535cf3b..fca40c1027f765 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK @@ -26,6 +26,7 @@ rn_android_library( srcs = [ "RuntimeConfig.java", ], + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/main/libraries/fresco/fresco-react-native/BUCK b/ReactAndroid/src/main/libraries/fresco/fresco-react-native/BUCK index 830cfd9da3f4f4..19c74093d5c8a6 100644 --- a/ReactAndroid/src/main/libraries/fresco/fresco-react-native/BUCK +++ b/ReactAndroid/src/main/libraries/fresco/fresco-react-native/BUCK @@ -27,6 +27,7 @@ fb_native.remote_file( rn_android_library( name = "imagepipeline", + autoglob = False, visibility = ["//ReactAndroid/..."], exported_deps = [ ":bolts", diff --git a/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK b/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK index 92c97fbfdd329b..39db5c323fe735 100644 --- a/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK +++ b/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "robolectric", + autoglob = False, visibility = ["PUBLIC"], exported_deps = [ ":android-all-5.0.2_r3-robolectric-r0", diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK index 06562939cf9e4d..c531a38f4a8bd3 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK @@ -10,6 +10,7 @@ rn_android_library( ["*.java"], exclude = STANDARD_TEST_SRCS, ), + autoglob = False, visibility = [ "PUBLIC", ], diff --git a/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK b/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK index 2a86bc6af780b5..2a9f6a05bb329b 100644 --- a/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK +++ b/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "powermock2", + autoglob = False, visibility = ["PUBLIC"], exported_deps = [ ":javassist-prebuilt", @@ -20,6 +21,7 @@ rn_android_library( rn_android_library( name = "powermock-reflect", + autoglob = False, visibility = ["PUBLIC"], exported_deps = [ ":byte-buddy", diff --git a/ReactCommon/react/nativemodule/samples/BUCK b/ReactCommon/react/nativemodule/samples/BUCK index 683b2c99c0210a..1d6db27fd64816 100644 --- a/ReactCommon/react/nativemodule/samples/BUCK +++ b/ReactCommon/react/nativemodule/samples/BUCK @@ -85,6 +85,7 @@ rn_xplat_cxx_library( rn_android_library( name = "impl", srcs = glob(["platform/android/*.java"]), + autoglob = False, required_for_source_only_abi = True, visibility = [ "PUBLIC", From c4cc636d9aa643a5b044ff2c79e9bcf64b5d3147 Mon Sep 17 00:00:00 2001 From: Ron Edelstein Date: Thu, 17 Dec 2020 20:39:47 -0800 Subject: [PATCH 0252/1810] Add autoglob to unbreak master Reviewed By: mendoncakeegan Differential Revision: D25633286 fbshipit-source-id: 69ca253a5494e0908d1091e7a01a404d4bbf24a8 --- packages/react-native-codegen/DEFS.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index aca528ac5f4bf0..0e71c3e37f17ac 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -470,7 +470,7 @@ def rn_codegen_components( # Android handling ################## if is_running_buck_project(): - rn_android_library(name = "generated_components_java-{}".format(name)) + rn_android_library(name = "generated_components_java-{}".format(name), autoglob = False) else: rn_android_library( name = "generated_components_java-{}".format(name), From 932c04cc9996f8e67386b42633cc38feb0a24afd Mon Sep 17 00:00:00 2001 From: Javier Fraire Date: Fri, 18 Dec 2020 11:07:52 -0800 Subject: [PATCH 0253/1810] Back out "Roll out RCTNetworking extraneous NativeModule call removal" Summary: It broke Forecast. Original commit changeset: 0da20475a088 Changelog: [Internal] Differential Revision: D25641098 fbshipit-source-id: 94daf0479963745bbca50b409b5a1dec1c8e8e71 --- Libraries/Network/RCTNetworking.ios.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/Network/RCTNetworking.ios.js b/Libraries/Network/RCTNetworking.ios.js index b10a833ad198f3..bc1081aab357d6 100644 --- a/Libraries/Network/RCTNetworking.ios.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -18,8 +18,13 @@ import type {RequestBody} from './convertRequestBody'; class RCTNetworking extends NativeEventEmitter { constructor() { + const disableCallsIntoModule = + typeof global.__disableRCTNetworkingExtraneousModuleCalls === 'function' + ? global.__disableRCTNetworkingExtraneousModuleCalls() + : false; + super(NativeNetworkingIOS, { - __SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: true, + __SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: disableCallsIntoModule, }); } From d2ae775bf72951361f84246623b2458d8bb9f6a2 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 18 Dec 2020 15:59:30 -0800 Subject: [PATCH 0254/1810] Fabric: Introducing `ShadowTreeDelegate::shadowTreeWillCommit()` Summary: With the change, a new delegate method allows a receiver to alter a new (proposed) shadow tree with another tree by returning the altered tree. We will it use in future diffs to implement Commit Hooks. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25221313 fbshipit-source-id: 9f83577d862b713fff71fa365ce660cc1de87c84 --- ReactCommon/react/renderer/mounting/ShadowTree.cpp | 8 ++++++++ .../react/renderer/mounting/ShadowTreeDelegate.h | 11 +++++++++++ .../mounting/tests/StateReconciliationTest.cpp | 7 +++++++ ReactCommon/react/renderer/uimanager/UIManager.cpp | 8 ++++++++ ReactCommon/react/renderer/uimanager/UIManager.h | 5 +++++ 5 files changed, 39 insertions(+) diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index e87ac12704f18a..ce3d04fc4dc5f5 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -299,6 +299,7 @@ CommitStatus ShadowTree::tryCommit( oldRevision = currentRevision_; } + auto oldRootShadowNode = oldRevision.rootShadowNode; auto newRootShadowNode = transaction(*oldRevision.rootShadowNode); if (!newRootShadowNode || @@ -338,6 +339,13 @@ CommitStatus ShadowTree::tryCommit( auto newRevisionNumber = oldRevision.number + 1; + newRootShadowNode = delegate_.shadowTreeWillCommit( + *this, oldRootShadowNode, newRootShadowNode); + + if (!newRootShadowNode) { + return CommitStatus::Cancelled; + } + { std::lock_guard dispatchLock(EventEmitter::DispatchMutex()); diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h b/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h index e7e5880e1de9cc..45e762c5314013 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h +++ b/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h @@ -19,6 +19,17 @@ class ShadowTree; */ class ShadowTreeDelegate { public: + /* + * Called right before a ShadowTree commits a new tree. + * The receiver can alter a new (proposed) shadow tree with another tree + * by returning the altered tree. + * Returning a `nullptr` cancels the commit. + */ + virtual RootShadowNode::Unshared shadowTreeWillCommit( + ShadowTree const &shadowTree, + RootShadowNode::Shared const &oldRootShadowNode, + RootShadowNode::Unshared const &newRootShadowNode) const = 0; + /* * Called right after Shadow Tree commit a new state of the tree. */ diff --git a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp index 088814a2a13a81..bf8f34c350268d 100644 --- a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp @@ -24,6 +24,13 @@ using namespace facebook::react; class DummyShadowTreeDelegate : public ShadowTreeDelegate { public: + virtual RootShadowNode::Unshared shadowTreeWillCommit( + ShadowTree const &shadowTree, + RootShadowNode::Shared const &oldRootShadowNode, + RootShadowNode::Unshared const &newRootShadowNode) const override { + return newRootShadowNode; + }; + virtual void shadowTreeDidFinishTransaction( ShadowTree const &shadowTree, MountingCoordinator::Shared const &mountingCoordinator) const override{}; diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index 8a55d7e58822f5..4c9883b068ba75 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -332,6 +332,14 @@ ShadowTreeRegistry const &UIManager::getShadowTreeRegistry() const { #pragma mark - ShadowTreeDelegate +RootShadowNode::Unshared UIManager::shadowTreeWillCommit( + ShadowTree const &shadowTree, + RootShadowNode::Shared const &oldRootShadowNode, + RootShadowNode::Unshared const &newRootShadowNode) const { + auto resultRootShadowNode = newRootShadowNode; + return resultRootShadowNode; +} + void UIManager::shadowTreeDidFinishTransaction( ShadowTree const &shadowTree, MountingCoordinator::Shared const &mountingCoordinator) const { diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index 6eb517fd9dc824..07073f4750ed08 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -78,6 +78,11 @@ class UIManager final : public ShadowTreeDelegate { */ bool experimentEnableStateUpdateWithAutorepeat{false}; + RootShadowNode::Unshared shadowTreeWillCommit( + ShadowTree const &shadowTree, + RootShadowNode::Shared const &oldRootShadowNode, + RootShadowNode::Unshared const &newRootShadowNode) const override; + private: friend class UIManagerBinding; friend class Scheduler; From fb4e06b1a5d767a5d77c6eb455a2f0382aad62b3 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 18 Dec 2020 15:59:30 -0800 Subject: [PATCH 0255/1810] Fabric: Introducing `UIManagerCommitHook`, unified way to alter commits Summary: The new UIManagerCommitHook can be used to implement commit-atering features without modifying the core. E.g. State Reconciation seems can be implemented as a coomit hook but first we will use it for a new feature called Timeline (see the coming diffs). Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25221312 fbshipit-source-id: dbe41b475bc8b36e1780d81447ab43b32758bdff --- .../react/renderer/uimanager/UIManager.cpp | 28 ++++++++++++ .../react/renderer/uimanager/UIManager.h | 10 +++++ .../renderer/uimanager/UIManagerCommitHook.h | 45 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index 4c9883b068ba75..2ff70c92659550 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -330,13 +331,40 @@ ShadowTreeRegistry const &UIManager::getShadowTreeRegistry() const { return shadowTreeRegistry_; } +void UIManager::registerCommitHook( + UIManagerCommitHook const &commitHook) const { + std::unique_lock lock(commitHookMutex_); + assert( + std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook) == + commitHooks_.end()); + commitHook.commitHookWasRegistered(*this); + commitHooks_.push_back(&commitHook); +} + +void UIManager::unregisterCommitHook( + UIManagerCommitHook const &commitHook) const { + std::unique_lock lock(commitHookMutex_); + auto iterator = + std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook); + assert(iterator != commitHooks_.end()); + commitHooks_.erase(iterator); + commitHook.commitHookWasUnregistered(*this); +} + #pragma mark - ShadowTreeDelegate RootShadowNode::Unshared UIManager::shadowTreeWillCommit( ShadowTree const &shadowTree, RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const { + std::shared_lock lock(commitHookMutex_); + auto resultRootShadowNode = newRootShadowNode; + for (auto const *commitHook : commitHooks_) { + resultRootShadowNode = commitHook->shadowTreeWillCommit( + shadowTree, oldRootShadowNode, resultRootShadowNode); + } + return resultRootShadowNode; } diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index 07073f4750ed08..e138a6ec6e6d72 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -25,6 +25,7 @@ namespace facebook { namespace react { class UIManagerBinding; +class UIManagerCommitHook; class UIManager final : public ShadowTreeDelegate { public: @@ -67,6 +68,12 @@ class UIManager final : public ShadowTreeDelegate { std::function callback) const; + /* + * Registers and unregisters a commit hook. + */ + void registerCommitHook(UIManagerCommitHook const &commitHook) const; + void unregisterCommitHook(UIManagerCommitHook const &commitHook) const; + #pragma mark - ShadowTreeDelegate void shadowTreeDidFinishTransaction( @@ -167,6 +174,9 @@ class UIManager final : public ShadowTreeDelegate { // determine whether a commit should be cancelled. Only to be used // inside UIManagerBinding. std::atomic_uint_fast8_t completeRootEventCounter_{0}; + + mutable better::shared_mutex commitHookMutex_; + mutable std::vector commitHooks_; }; } // namespace react diff --git a/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h b/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h new file mode 100644 index 00000000000000..c074fffa1e842f --- /dev/null +++ b/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook { +namespace react { + +class ShadowTree; +class UIManager; + +/* + * Implementing a commit hook allows to observe and alter Shadow Tree commits. + */ +class UIManagerCommitHook { + public: + /* + * Called right after the commit hook is registered or unregistered. + */ + virtual void commitHookWasRegistered(UIManager const &uiManager) const + noexcept = 0; + virtual void commitHookWasUnregistered(UIManager const &uiManager) const + noexcept = 0; + + /* + * Called right before a `ShadowTree` commits a new tree. + * The semantic of the method corresponds to a method of the same name + * from `ShadowTreeDelegate`. + */ + virtual RootShadowNode::Unshared shadowTreeWillCommit( + ShadowTree const &shadowTree, + RootShadowNode::Shared const &oldRootShadowNode, + RootShadowNode::Unshared const &newRootShadowNode) const noexcept = 0; + + virtual ~UIManagerCommitHook() noexcept = default; +}; + +} // namespace react +} // namespace facebook From fced0765d6162ddf2de4b9afdd1877b6d2b204f9 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 19 Dec 2020 05:59:22 -0800 Subject: [PATCH 0256/1810] Introduce RCTViewRegistry Summary: ## Problem Many of our NativeModules use the bridge to access the UIManager. They then use the UIManager to call viewForReactTag. This makes all these NativeModules Venice-incompatible. P155700869 ## Solution This diff introduces a Venice-compatible API called RCTViewRegistry that will implement viewForReactTag. When the bridge exists, RCTViewRegistry will delegate to the UIManager. When the bridge doesn't exist, it'll delegate to RCTSurfacePresenter. Fingers crossed, this should allow us move ~50 NativeModuels off the bridge. Changelog: [Internal] Reviewed By: PeteTheHeat Differential Revision: D25641391 fbshipit-source-id: 144f4f7a35af1245401ad640068852dd66bbf65d --- React/Base/RCTBridgeModule.h | 25 ++++++++++++++++++++ React/Base/RCTViewRegistry.m | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 React/Base/RCTViewRegistry.m diff --git a/React/Base/RCTBridgeModule.h b/React/Base/RCTBridgeModule.h index e4bbef2a1a73ba..b8d3ea6ee71fc0 100644 --- a/React/Base/RCTBridgeModule.h +++ b/React/Base/RCTBridgeModule.h @@ -6,12 +6,14 @@ */ #import +#import #import @class RCTBridge; @protocol RCTBridgeMethod; @class RCTModuleRegistry; +@class RCTViewRegistry; /** * The type of a block that is capable of sending a response to a bridged @@ -122,6 +124,17 @@ RCT_EXTERN_C_END */ @property (nonatomic, weak, readonly) RCTModuleRegistry *moduleRegistry; +/** + * A reference to the RCTViewRegistry. Useful for modules that query UIViews, + * given a react tag. This API is deprecated, and only exists to help migrate + * NativeModules to Venice. + * + * To implement this in your module, just add `@synthesize + * viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;`. If using Swift, add + * `@objc var viewRegistry_DEPRECATED: RCTViewRegistry!` to your module. + */ +@property (nonatomic, weak, readonly) RCTViewRegistry *viewRegistry_DEPRECATED; + /** * A reference to the RCTBridge. Useful for modules that require access * to bridge features, such as sending events or making JS calls. This @@ -392,3 +405,15 @@ RCT_EXTERN_C_END - (id)moduleForName:(const char *)moduleName; - (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad; @end + +typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *); + +/** + * A class that allows NativeModules to query for views, given React Tags. + */ +@interface RCTViewRegistry : NSObject +- (void)setBridge:(RCTBridge *)bridge; +- (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)bridgelessComponentViewProvider; + +- (UIView *)viewForReactTag:(NSNumber *)reactTag; +@end diff --git a/React/Base/RCTViewRegistry.m b/React/Base/RCTViewRegistry.m new file mode 100644 index 00000000000000..d66caa17bb6197 --- /dev/null +++ b/React/Base/RCTViewRegistry.m @@ -0,0 +1,45 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import +#import + +#import "RCTBridge.h" +#import "RCTBridgeModule.h" + +@implementation RCTViewRegistry { + RCTBridgelessComponentViewProvider _bridgelessComponentViewProvider; + __weak RCTBridge *_bridge; +} + +- (void)setBridge:(RCTBridge *)bridge +{ + _bridge = bridge; +} + +- (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)bridgelessComponentViewProvider +{ + _bridgelessComponentViewProvider = bridgelessComponentViewProvider; +} + +- (UIView *)viewForReactTag:(NSNumber *)reactTag +{ + UIView *view = nil; + + RCTBridge *bridge = _bridge; + if (bridge) { + view = [bridge.uiManager viewForReactTag:reactTag]; + } + + if (view == nil && _bridgelessComponentViewProvider) { + view = _bridgelessComponentViewProvider(reactTag); + } + + return view; +} + +@end From b71ebd10e52089edb144f9cb8ed6040700d6ce57 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 19 Dec 2020 05:59:22 -0800 Subject: [PATCH 0257/1810] Attach RCTViewRegistry to TurboModules Summary: Now, TurboModules that synthesize RCTModuleRegistry will have it available at runtime. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25643260 fbshipit-source-id: e9915f3da8412de823ae3d3e17849979c5cbd465 --- .../platform/ios/RCTTurboModuleManager.mm | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index 8519045cbff47b..f0b0e9ba4f1fe5 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -174,6 +174,7 @@ @implementation RCTTurboModuleManager { std::atomic _invalidating; RCTModuleRegistry *_moduleRegistry; + RCTViewRegistry *_viewRegistry_DEPRECATED; } - (instancetype)initWithBridge:(RCTBridge *)bridge @@ -189,6 +190,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge [_moduleRegistry setBridge:bridge]; [_moduleRegistry setTurboModuleRegistry:self]; + _viewRegistry_DEPRECATED = [RCTViewRegistry new]; + [_viewRegistry_DEPRECATED setBridge:bridge]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bridgeWillInvalidateModules:) name:RCTBridgeWillInvalidateModulesNotification @@ -563,6 +567,25 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName } } + /** + * Attach the RCTViewRegistry to this TurboModule, which allows this TurboModule + * To query a React component's UIView, given its reactTag. + * + * Usage: In the NativeModule @implementation, include: + * `@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED` + */ + if ([module respondsToSelector:@selector(viewRegistry_DEPRECATED)] && _viewRegistry_DEPRECATED) { + @try { + [(id)module setValue:_viewRegistry_DEPRECATED forKey:@"viewRegistry_DEPRECATED"]; + } @catch (NSException *exception) { + RCTLogError( + @"%@ has no setter or ivar for its module registry, which is not " + "permitted. You must either @synthesize the viewRegistry_DEPRECATED property, " + "or provide your own setter method.", + RCTBridgeModuleNameForClass([module class])); + } + } + /** * Some modules need their own queues, but don't provide any, so we need to create it for them. * These modules typically have the following: From 86cdd8856955cc67238595d9519904e70db9bb2a Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 19 Dec 2020 05:59:22 -0800 Subject: [PATCH 0258/1810] Integrate TurboModules with Venice's RCTSurfacePresenter Summary: After we create the RCTSurfacePresenter in Venice, we use it to create an RCTBridgelessComponentViewProvider, and pass it over to the RCTTurboModuleManager. In Venice, this allows all TurboModules to query components' UIViews given their reactTag. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25643261 fbshipit-source-id: 31da07c490d249534f700b7c8430e9cb43b5b0db --- .../nativemodule/core/platform/ios/RCTTurboModuleManager.h | 1 + .../nativemodule/core/platform/ios/RCTTurboModuleManager.mm | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h index 8ee2eaeefe582e..18756624d42797 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h @@ -51,6 +51,7 @@ jsInvoker:(std::shared_ptr)jsInvoker; - (void)installJSBindingWithRuntimeExecutor:(facebook::react::RuntimeExecutor)runtimeExecutor; +- (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)bridgelessComponentViewProvider; - (void)invalidate; diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index f0b0e9ba4f1fe5..b226b2bc7fad06 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -205,6 +205,11 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge return self; } +- (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)viewProvider +{ + [_viewRegistry_DEPRECATED setBridgelessComponentViewProvider:viewProvider]; +} + - (void)notifyAboutTurboModuleSetup:(const char *)name { NSString *moduleName = [[NSString alloc] initWithUTF8String:name]; From 1a2d1dbae81c80f906ab1382576c7637f623af9b Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 19 Dec 2020 05:59:22 -0800 Subject: [PATCH 0259/1810] Attach RCTViewRegistry to NativeModules Summary: After this diff, NativeModules can synthesize the RCTModuleRegistry, and use that to query for UIViews of components, given their reactTags. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25645052 fbshipit-source-id: bb17606cc4862d07b739ef2c31a5e57f59201364 --- React/Base/RCTModuleData.h | 10 +++++-- React/Base/RCTModuleData.mm | 28 ++++++++++++++++++- React/CxxBridge/RCTCxxBridge.mm | 14 ++++++++-- .../platform/ios/RCTTurboModuleManager.mm | 3 +- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/React/Base/RCTModuleData.h b/React/Base/RCTModuleData.h index 5e5f780d5feaa5..cefd6209313f09 100644 --- a/React/Base/RCTModuleData.h +++ b/React/Base/RCTModuleData.h @@ -14,6 +14,7 @@ @protocol RCTBridgeModule; @class RCTBridge; @class RCTModuleRegistry; +@class RCTViewRegistry; typedef id (^RCTBridgeModuleProvider)(void); @@ -21,16 +22,19 @@ typedef id (^RCTBridgeModuleProvider)(void); - (instancetype)initWithModuleClass:(Class)moduleClass bridge:(RCTBridge *)bridge - moduleRegistry:(RCTModuleRegistry *)moduleRegistry; + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED; - (instancetype)initWithModuleClass:(Class)moduleClass moduleProvider:(RCTBridgeModuleProvider)moduleProvider bridge:(RCTBridge *)bridge - moduleRegistry:(RCTModuleRegistry *)moduleRegistry NS_DESIGNATED_INITIALIZER; + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED NS_DESIGNATED_INITIALIZER; - (instancetype)initWithModuleInstance:(id)instance bridge:(RCTBridge *)bridge - moduleRegistry:(RCTModuleRegistry *)moduleRegistry NS_DESIGNATED_INITIALIZER; + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED NS_DESIGNATED_INITIALIZER; /** * Calls `constantsToExport` on the module and stores the result. Note that diff --git a/React/Base/RCTModuleData.mm b/React/Base/RCTModuleData.mm index 004bd0e570246a..f8a5459e66bf00 100644 --- a/React/Base/RCTModuleData.mm +++ b/React/Base/RCTModuleData.mm @@ -49,6 +49,7 @@ @implementation RCTModuleData { std::mutex _instanceLock; BOOL _setupComplete; RCTModuleRegistry *_moduleRegistry; + RCTViewRegistry *_viewRegistry_DEPRECATED; } @synthesize methods = _methods; @@ -101,25 +102,29 @@ - (void)setUp - (instancetype)initWithModuleClass:(Class)moduleClass bridge:(RCTBridge *)bridge moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED { return [self initWithModuleClass:moduleClass moduleProvider:^id { return [moduleClass new]; } bridge:bridge - moduleRegistry:moduleRegistry]; + moduleRegistry:moduleRegistry + viewRegistry_DEPRECATED:viewRegistry_DEPRECATED]; } - (instancetype)initWithModuleClass:(Class)moduleClass moduleProvider:(RCTBridgeModuleProvider)moduleProvider bridge:(RCTBridge *)bridge moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED { if (self = [super init]) { _bridge = bridge; _moduleClass = moduleClass; _moduleProvider = [moduleProvider copy]; _moduleRegistry = moduleRegistry; + _viewRegistry_DEPRECATED = viewRegistry_DEPRECATED; [self setUp]; } return self; @@ -128,12 +133,14 @@ - (instancetype)initWithModuleClass:(Class)moduleClass - (instancetype)initWithModuleInstance:(id)instance bridge:(RCTBridge *)bridge moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED { if (self = [super init]) { _bridge = bridge; _instance = instance; _moduleClass = [instance class]; _moduleRegistry = moduleRegistry; + _viewRegistry_DEPRECATED = viewRegistry_DEPRECATED; [self setUp]; } return self; @@ -195,6 +202,7 @@ - (void)setUpInstanceAndBridge:(int32_t)requestId // self.bridge.uiManager.methodQueue) [self setBridgeForInstance]; [self setModuleRegistryForInstance]; + [self setViewRegistryForInstance]; } [self setUpMethodQueue]; @@ -258,6 +266,24 @@ - (void)setModuleRegistryForInstance } } +- (void)setViewRegistryForInstance +{ + if ([_instance respondsToSelector:@selector(viewRegistry_DEPRECATED)] && + _instance.viewRegistry_DEPRECATED != _viewRegistry_DEPRECATED) { + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setViewRegistryForInstance]", nil); + @try { + [(id)_instance setValue:_viewRegistry_DEPRECATED forKey:@"viewRegistry_DEPRECATED"]; + } @catch (NSException *exception) { + RCTLogError( + @"%@ has no setter or ivar for its module registry, which is not " + "permitted. You must either @synthesize the viewRegistry_DEPRECATED property, " + "or provide your own setter method.", + self.name); + } + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); + } +} + - (void)finishSetupForInstance { if (!_setupComplete && _instance) { diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 8a0d815a91cd98..7984501c80608d 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -233,6 +233,7 @@ @implementation RCTCxxBridge { id _turboModuleRegistry; RCTModuleRegistry *_objCModuleRegistry; + RCTViewRegistry *_viewRegistry_DEPRECATED; } @synthesize bridgeDescription = _bridgeDescription; @@ -282,6 +283,8 @@ - (instancetype)initWithParentBridge:(RCTBridge *)bridge _moduleDataByID = [NSMutableArray new]; _objCModuleRegistry = [RCTModuleRegistry new]; [_objCModuleRegistry setBridge:self]; + _viewRegistry_DEPRECATED = [RCTViewRegistry new]; + [_viewRegistry_DEPRECATED setBridge:self]; [RCTBridge setCurrentBridge:self]; @@ -750,7 +753,10 @@ - (void)updateModuleWithInstance:(id)instance // TODO #13258411: can we defer this until config generation? int32_t moduleDataId = getUniqueId(); BridgeNativeModulePerfLogger::moduleDataCreateStart([moduleName UTF8String], moduleDataId); - moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass bridge:self moduleRegistry:_objCModuleRegistry]; + moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass + bridge:self + moduleRegistry:_objCModuleRegistry + viewRegistry_DEPRECATED:_viewRegistry_DEPRECATED]; BridgeNativeModulePerfLogger::moduleDataCreateEnd([moduleName UTF8String], moduleDataId); _moduleDataByName[moduleName] = moduleData; @@ -815,7 +821,8 @@ - (void)registerExtraModules BridgeNativeModulePerfLogger::moduleDataCreateStart([moduleName UTF8String], moduleDataId); RCTModuleData *moduleData = [[RCTModuleData alloc] initWithModuleInstance:module bridge:self - moduleRegistry:_objCModuleRegistry]; + moduleRegistry:_objCModuleRegistry + viewRegistry_DEPRECATED:_viewRegistry_DEPRECATED]; BridgeNativeModulePerfLogger::moduleDataCreateEnd([moduleName UTF8String], moduleDataId); _moduleDataByName[moduleName] = moduleData; @@ -868,7 +875,8 @@ - (void)registerExtraLazyModules BridgeNativeModulePerfLogger::moduleDataCreateStart([moduleName UTF8String], moduleDataId); moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass bridge:self - moduleRegistry:_objCModuleRegistry]; + moduleRegistry:_objCModuleRegistry + viewRegistry_DEPRECATED:_viewRegistry_DEPRECATED]; BridgeNativeModulePerfLogger::moduleDataCreateEnd([moduleName UTF8String], moduleDataId); _moduleDataByName[moduleName] = moduleData; diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index b226b2bc7fad06..e1795bc213b375 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -653,7 +653,8 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName if (_bridge) { RCTModuleData *data = [[RCTModuleData alloc] initWithModuleInstance:(id)module bridge:_bridge - moduleRegistry:_moduleRegistry]; + moduleRegistry:_moduleRegistry + viewRegistry_DEPRECATED:_viewRegistry_DEPRECATED]; [_bridge registerModuleForFrameUpdates:(id)module withModuleData:data]; } From a26f20dc9af1eead2dd436510c1d0e1696dc609e Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 19 Dec 2020 05:59:22 -0800 Subject: [PATCH 0260/1810] Codemod away from RCTBridge uiManager viewForReactTag Summary: Changelog: [Internal] Reviewed By: fkgozali, mdvacca Differential Revision: D25648595 fbshipit-source-id: 7b338500e7d13ff12c9969663768408ede8e0ee3 --- React/CoreModules/RCTAccessibilityManager.mm | 3 ++- React/CoreModules/RCTActionSheetManager.mm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/React/CoreModules/RCTAccessibilityManager.mm b/React/CoreModules/RCTAccessibilityManager.mm index 7426794b9251d6..40241cdc31d18c 100644 --- a/React/CoreModules/RCTAccessibilityManager.mm +++ b/React/CoreModules/RCTAccessibilityManager.mm @@ -29,6 +29,7 @@ @interface RCTAccessibilityManager () @implementation RCTAccessibilityManager @synthesize bridge = _bridge; +@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED; @synthesize moduleRegistry = _moduleRegistry; @synthesize multipliers = _multipliers; @@ -285,7 +286,7 @@ static void setMultipliers( RCT_EXPORT_METHOD(setAccessibilityFocus : (double)reactTag) { dispatch_async(dispatch_get_main_queue(), ^{ - UIView *view = [self.bridge.uiManager viewForReactTag:@(reactTag)]; + UIView *view = [self.viewRegistry_DEPRECATED viewForReactTag:@(reactTag)]; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, view); }); } diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index 3c01cefa35c8bc..926431b54a64d8 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -32,6 +32,7 @@ @implementation RCTActionSheetManager { RCT_EXPORT_MODULE() @synthesize bridge = _bridge; +@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED; - (dispatch_queue_t)methodQueue { @@ -46,7 +47,7 @@ - (void)presentViewController:(UIViewController *)alertController UIView *sourceView = parentViewController.view; if (anchorViewTag) { - sourceView = [self.bridge.uiManager viewForReactTag:anchorViewTag]; + sourceView = [self.viewRegistry_DEPRECATED viewForReactTag:anchorViewTag]; } else { alertController.popoverPresentationController.permittedArrowDirections = 0; } From bccbf4d00a41679c8d3ed4db3964f4fa651cd702 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 19 Dec 2020 05:59:22 -0800 Subject: [PATCH 0261/1810] Round 3: Remove @synthesize bridge = _bridge from NativeModules Reviewed By: fkgozali, ejanzer, mdvacca Differential Revision: D25649765 fbshipit-source-id: 3ba6d977abce145039f6bdc581283c19445a1032 --- React/CoreModules/RCTAccessibilityManager.mm | 1 - React/CoreModules/RCTActionSheetManager.mm | 1 - 2 files changed, 2 deletions(-) diff --git a/React/CoreModules/RCTAccessibilityManager.mm b/React/CoreModules/RCTAccessibilityManager.mm index 40241cdc31d18c..3b15ec0e89a3c8 100644 --- a/React/CoreModules/RCTAccessibilityManager.mm +++ b/React/CoreModules/RCTAccessibilityManager.mm @@ -28,7 +28,6 @@ @interface RCTAccessibilityManager () @implementation RCTAccessibilityManager -@synthesize bridge = _bridge; @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED; @synthesize moduleRegistry = _moduleRegistry; @synthesize multipliers = _multipliers; diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index 926431b54a64d8..ac94189bf2ca0a 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -31,7 +31,6 @@ @implementation RCTActionSheetManager { RCT_EXPORT_MODULE() -@synthesize bridge = _bridge; @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED; - (dispatch_queue_t)methodQueue From db7b2760c120688734753cd2d7d240e23305772c Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sun, 20 Dec 2020 10:15:59 -0800 Subject: [PATCH 0262/1810] Make RCTEventEmitter synthesize RCTViewRegistry Summary: This will help us migrate our iOS EventEmitters off the bridge. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25656902 fbshipit-source-id: 2ca434e073383a1bf5b1d7366f1e1858c0c49aa6 --- React/Modules/RCTEventEmitter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/React/Modules/RCTEventEmitter.h b/React/Modules/RCTEventEmitter.h index bb1abd5f7d26f8..ea7b69c3d8804e 100644 --- a/React/Modules/RCTEventEmitter.h +++ b/React/Modules/RCTEventEmitter.h @@ -16,6 +16,7 @@ @property (nonatomic, weak) RCTBridge *bridge; @property (nonatomic, weak) RCTModuleRegistry *moduleRegistry; +@property (nonatomic, weak) RCTViewRegistry *viewRegistry_DEPRECATED; - (instancetype)initWithDisabledObservation; From e3d8a6b22245c15f49f72b78ba06bdefa7902355 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 21 Dec 2020 08:31:15 -0800 Subject: [PATCH 0263/1810] Fabric: Stacking Context test covering a sequence of changes Summary: This diff adds another complexity level for Stacking Context and zIndex tests: Now we test not only "noting-to-something" cases but also cases where we apply changes to an already non-empty tree, validating our assumption of each step. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25623176 fbshipit-source-id: 29a447d93522a2a4e7912351f907c46ac7b218bb --- .../mounting/tests/StackingContextTest.cpp | 219 +++++++++++++++++- .../rn-tester/js/examples/View/ViewExample.js | 1 + 2 files changed, 214 insertions(+), 6 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index a64ea7514c9eac..521d3135d1311f 100644 --- a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -38,6 +38,9 @@ class StackingContextTest : public ::testing::Test { std::shared_ptr nodeBC_; std::shared_ptr nodeBD_; + std::shared_ptr currentRootShadowNode_; + StubViewTree currentStubViewTree_; + StackingContextTest() : builder_(simpleComponentBuilder()) { // ┌────────────── (Root) ──────────────┐ // │ ┏━ A (tag: 2) ━━━━━━━━━━━━━━━━━━━┓ │ @@ -142,6 +145,11 @@ class StackingContextTest : public ::testing::Test { // clang-format on builder_.build(element); + + currentRootShadowNode_ = rootShadowNode_; + currentRootShadowNode_->layoutIfNeeded(); + currentStubViewTree_ = + buildStubViewTreeWithoutUsingDifferentiator(*currentRootShadowNode_); } void mutateViewShadowNodeProps_( @@ -156,17 +164,23 @@ class StackingContextTest : public ::testing::Test { })); } - void testViewTree( + void testViewTree_( std::function callback) { rootShadowNode_->layoutIfNeeded(); callback(buildStubViewTreeUsingDifferentiator(*rootShadowNode_)); callback(buildStubViewTreeWithoutUsingDifferentiator(*rootShadowNode_)); + + auto mutations = + calculateShadowViewMutations(*currentRootShadowNode_, *rootShadowNode_); + currentRootShadowNode_ = rootShadowNode_; + currentStubViewTree_.mutate(mutations); + callback(currentStubViewTree_); } }; TEST_F(StackingContextTest, defaultPropsMakeEverythingFlattened) { - testViewTree([](StubViewTree const &viewTree) { + testViewTree_([](StubViewTree const &viewTree) { // 1 view in total. EXPECT_EQ(viewTree.size(), 1); @@ -267,7 +281,7 @@ TEST_F(StackingContextTest, mostPropsDoNotForceViewsToMaterialize) { props.hitSlop = EdgeInsets{42, 42, 42, 42}; }); - testViewTree([](StubViewTree const &viewTree) { + testViewTree_([](StubViewTree const &viewTree) { // 1 view in total. EXPECT_EQ(viewTree.size(), 1); @@ -346,7 +360,7 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize1) { mutateViewShadowNodeProps_( nodeBBA_, [](ViewProps &props) { props.shadowColor = blackColor(); }); - testViewTree([](StubViewTree const &viewTree) { + testViewTree_([](StubViewTree const &viewTree) { // 4 views in total. EXPECT_EQ(viewTree.size(), 4); @@ -453,7 +467,7 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) { mutateViewShadowNodeProps_( nodeBD_, [](ViewProps &props) { props.opacity = 0.42; }); - testViewTree([](StubViewTree const &viewTree) { + testViewTree_([](StubViewTree const &viewTree) { // 10 views in total. EXPECT_EQ(viewTree.size(), 10); @@ -559,7 +573,7 @@ TEST_F(StackingContextTest, zIndexAndFlattenedNodes) { props.zIndex = 8996; }); - testViewTree([](StubViewTree const &viewTree) { + testViewTree_([](StubViewTree const &viewTree) { // 7 views in total. EXPECT_EQ(viewTree.size(), 7); @@ -574,6 +588,199 @@ TEST_F(StackingContextTest, zIndexAndFlattenedNodes) { EXPECT_EQ(viewTree.getRootStubView().children.at(4)->tag, 5); EXPECT_EQ(viewTree.getRootStubView().children.at(5)->tag, 3); }); + + // And now let's make BB to form a Stacking Context with small order-index. + + // ┌────────────── (Root) ──────────────┐ ┌────────── (Root) ──────────┐ + // │ ┌─ A (tag: 2) ───────────────────┐ │ │ ┏━ BB (tag: 6) ━━━━━━━━━━┓ │ + // │ │ │ │ │ ┃ #View ┃ │ + // │ │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ │ │ │ ┃ ┃ │ + // │ │ │ │ │ ┃ ┏━ BBB (tag: 8) ━━━━━┓ ┃ │ + // │ │ ┌─ AA (tag: 3) ──────────────┐ │ │ │ ┃ ┃ #View ┃ ┃ │ + // │ │ │ position: relative; │ │ │ │ ┃ ┃ #StackingContext ┃ ┃ │ + // │ │ │ zIndex: 9001; │ │ │ │ ┃ ┃ ┃ ┃ │ + // │ │ │ │ │ │ │ ┃ ┗━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ │ │ │ │ │ │ ┃ ┏━ BBA (tag: 7) ━━━━━┓ ┃ │ + // │ │ │ │ │ │ │ ┃ ┃ #View ┃ ┃ │ + // │ │ │ │ │ │ │ ┃ ┃ #StackingContext ┃ ┃ │ + // │ │ │ │ │ │ │ ┃ ┃ ┃ ┃ │ + // │ │ └────────────────────────────┘ │ │ │ ┃ ┗━━━━━━━━━━━━━━━━━━━━┛ ┃ │ + // │ └────────────────────────────────┘ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┌─ B (tag: 4) ───────────────────┐ │ │ ┏━ BD (tag: 10) ━━━━━━━━━┓ │ + // │ │ │ │ │ ┃ #View ┃ │ + // │ │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ │ │ │ ┃ ┃ │ + // │ │ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ ┌─ BA (tag: 5) ──────────────┐ │ │ │ ┏━ BC (tag: 9) ━━━━━━━━━━┓ │ + // │ │ │ position: relative; │ │ │ │ ┃ #View ┃ │ + // │ │ │ zIndex: 9000; │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ │ │ │ │ │ ┃ ┃ │ + // │ │ │ │ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ └────────────────────────────┘ │ │ │ ┏━ BA (tag: 5) ━━━━━━━━━━┓ │ + // │ │ ╔═ BB (tag: 6) ══════════════╗ │ │ │ ┃ #View ┃ │ + // │ │ ║ *** position: relative; ║ │ │ │ ┃ #StackingContext ┃ │ + // │ │ ║ *** zIndex: 42; ║ │ │━━━━▶│ ┃ ┃ │ + // │ │ ║ ║ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ ║ ║ │ │ │ ┏━ AA (tag: 3) ━━━━━━━━━━┓ │ + // │ │ ║ ┌─ BBA (tag: 7) ─────────┐ ║ │ │ │ ┃ #View ┃ │ + // │ │ ║ │ position: relative; │ ║ │ │ │ ┃ #StackingContext ┃ │ + // │ │ ║ │ zIndex: 8999; │ ║ │ │ │ ┃ ┃ │ + // │ │ ║ │ │ ║ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ └────────────────────────┘ ║ │ │ │ │ + // │ │ ║ ┌─ BBB (tag: 8) ─────────┐ ║ │ │ │ │ + // │ │ ║ │ position: relative; │ ║ │ │ │ │ + // │ │ ║ │ zIndex: 8998; │ ║ │ │ │ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ └────────────────────────┘ ║ │ │ │ │ + // │ │ ╚════════════════════════════╝ │ │ │ │ + // │ │ ┌─ BC (tag: 9) ──────────────┐ │ │ │ │ + // │ │ │ position: relative; │ │ │ │ │ + // │ │ │ zIndex: 8997; │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ └────────────────────────────┘ │ │ │ │ + // │ │ ┌─ BD (tag: 10) ─────────────┐ │ │ │ │ + // │ │ │ position: relative; │ │ │ │ │ + // │ │ │ zIndex: 8996; │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ └────────────────────────────┘ │ │ │ │ + // │ └────────────────────────────────┘ │ │ │ + // └────────────────────────────────────┘ └────────────────────────────┘ + + mutateViewShadowNodeProps_(nodeBB_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeRelative; + props.zIndex = 42; + }); + + testViewTree_([](StubViewTree const &viewTree) { + // 8 views in total. + EXPECT_EQ(viewTree.size(), 8); + + // The root view has 5 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 5); + + // The root view subviews are [6, 10, 9, 5, 3]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 6); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 10); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 9); + EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 5); + EXPECT_EQ(viewTree.getRootStubView().children.at(4)->tag, 3); + + auto &view6 = viewTree.getStubView(6); + EXPECT_EQ(view6.children.size(), 2); + EXPECT_EQ(view6.children.at(0)->tag, 8); + EXPECT_EQ(view6.children.at(1)->tag, 7); + }); + + // And now, let's revert it back. + + mutateViewShadowNodeProps_(nodeBB_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.positionType() = YGPositionTypeStatic; + props.zIndex = {}; + }); + + testViewTree_([](StubViewTree const &viewTree) { + // 7 views in total. + EXPECT_EQ(viewTree.size(), 7); + + // The root view has all 6 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 6); + + // The root view subviews are [10, 9, 8, 7, 5, 3]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 10); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 9); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 8); + EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 7); + EXPECT_EQ(viewTree.getRootStubView().children.at(4)->tag, 5); + EXPECT_EQ(viewTree.getRootStubView().children.at(5)->tag, 3); + }); + + // And now, let's hide BB completety. + + // ┌────────────── (Root) ──────────────┐ ┌────────── (Root) ──────────┐ + // │ ┌─ A (tag: 2) ───────────────────┐ │ │ ┏━ BD (tag: 10) ━━━━━━━━━┓ │ + // │ │ │ │ │ ┃ #View ┃ │ + // │ │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ │ │ │ ┃ ┃ │ + // │ │ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ ┌─ AA (tag: 3) ──────────────┐ │ │ │ ┏━ BC (tag: 9) ━━━━━━━━━━┓ │ + // │ │ │ position: relative; │ │ │ │ ┃ #View ┃ │ + // │ │ │ zIndex: 9001; │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ │ │ │ │ │ ┃ ┃ │ + // │ │ │ │ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ │ │ │ │ │ ┏━ BA (tag: 5) ━━━━━━━━━━┓ │ + // │ │ │ │ │ │ │ ┃ #View ┃ │ + // │ │ │ │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ └────────────────────────────┘ │ │ │ ┃ ┃ │ + // │ └────────────────────────────────┘ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ ┌─ B (tag: 4) ───────────────────┐ │ │ ┏━ AA (tag: 3) ━━━━━━━━━━┓ │ + // │ │ │ │ │ ┃ #View ┃ │ + // │ │ │ │ │ ┃ #StackingContext ┃ │ + // │ │ │ │ │ ┃ ┃ │ + // │ │ │ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━┛ │ + // │ │ ┌─ BA (tag: 5) ──────────────┐ │ │ │ │ + // │ │ │ position: relative; │ │ │ │ │ + // │ │ │ zIndex: 9000; │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ └────────────────────────────┘ │ │ │ │ + // │ │ ╔═ BB (tag: 6) ══════════════╗ │ │ │ │ + // │ │ ║ *** display: none; ║ │ │ │ │ + // │ │ ║ ║ │ │━━━━▶│ │ + // │ │ ║ ║ │ │ │ │ + // │ │ ║ ║ │ │ │ │ + // │ │ ║ ┌─ BBA (tag: 7) ─────────┐ ║ │ │ │ │ + // │ │ ║ │ position: relative; │ ║ │ │ │ │ + // │ │ ║ │ zIndex: 8999; │ ║ │ │ │ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ └────────────────────────┘ ║ │ │ │ │ + // │ │ ║ ┌─ BBB (tag: 8) ─────────┐ ║ │ │ │ │ + // │ │ ║ │ position: relative; │ ║ │ │ │ │ + // │ │ ║ │ zIndex: 8998; │ ║ │ │ │ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ │ │ ║ │ │ │ │ + // │ │ ║ └────────────────────────┘ ║ │ │ │ │ + // │ │ ╚════════════════════════════╝ │ │ │ │ + // │ │ ┌─ BC (tag: 9) ──────────────┐ │ │ │ │ + // │ │ │ position: relative; │ │ │ │ │ + // │ │ │ zIndex: 8997; │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ └────────────────────────────┘ │ │ │ │ + // │ │ ┌─ BD (tag: 10) ─────────────┐ │ │ │ │ + // │ │ │ position: relative; │ │ │ │ │ + // │ │ │ zIndex: 8996; │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ │ │ │ │ │ │ + // │ │ └────────────────────────────┘ │ │ │ │ + // │ └────────────────────────────────┘ │ │ │ + // └────────────────────────────────────┘ └────────────────────────────┘ + + mutateViewShadowNodeProps_(nodeBB_, [](ViewProps &props) { + auto &yogaStyle = props.yogaStyle; + yogaStyle.display() = YGDisplayNone; + }); + + testViewTree_([](StubViewTree const &viewTree) { + // 5 views in total. + EXPECT_EQ(viewTree.size(), 5); + + // The root view has all 4 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 4); + + // The root view subviews are [10, 9, 5, 3]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 10); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 9); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 5); + EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 3); + }); } } // namespace react diff --git a/packages/rn-tester/js/examples/View/ViewExample.js b/packages/rn-tester/js/examples/View/ViewExample.js index cea8eddf7ac750..dee2a5947b9a49 100644 --- a/packages/rn-tester/js/examples/View/ViewExample.js +++ b/packages/rn-tester/js/examples/View/ViewExample.js @@ -371,6 +371,7 @@ exports.examples = [ width: 100, height: 50, marginTop: -10, + position: 'relative', }, }); From a3918f4102bc7adcf0e512d92d9294cdece17686 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 21 Dec 2020 13:59:02 -0800 Subject: [PATCH 0264/1810] Cancel touches if surface touch handler can be prevented Summary: Changelog: [internal] If `otherGestureRecognizer` prevents Fabric's gesture recogniser, we need to manually reset the inner state. This cancels any currently active touches. Reviewed By: shergin Differential Revision: D25664384 fbshipit-source-id: 9e3cd41351381bcfed2836dad3e80d5f021f936c --- React/Fabric/RCTSurfaceTouchHandler.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index e556a3af6d1d72..6c06fa764b7a81 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -410,4 +410,14 @@ - (BOOL)gestureRecognizer:(__unused UIGestureRecognizer *)gestureRecognizer return [self canBePreventedByGestureRecognizer:otherGestureRecognizer]; } +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer + shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + BOOL canBePrevented = [self canBePreventedByGestureRecognizer:otherGestureRecognizer]; + if (canBePrevented) { + [self reset]; + } + return NO; +} + @end From f7c209cd54cf336a8c500077537f5f10f8eda360 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 21 Dec 2020 15:06:05 -0800 Subject: [PATCH 0265/1810] Fix racecondition in registration of event listeners Summary: This diff fixes a racecondition in registration of event listeners. mPostEventDispatchListeners is accessed from different threads, most of the times this variable is used to executed the listeners. It is only written during initialization and turn down of the renderer. changelog: [internal] Reviewed By: PeteTheHeat Differential Revision: D25667988 fbshipit-source-id: 1bf95f5193d55a737bad9403206cc3320185b8cb --- .../facebook/react/uimanager/events/EventDispatcherImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java index 9754b2de085471..6f1fd9730b2735 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; -import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; @@ -91,7 +90,8 @@ public int compare(Event lhs, Event rhs) { private final ArrayList mEventStaging = new ArrayList<>(); private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); - private final List mPostEventDispatchListeners = new ArrayList<>(); + private final CopyOnWriteArrayList mPostEventDispatchListeners = + new CopyOnWriteArrayList<>(); private final ScheduleDispatchFrameCallback mCurrentFrameCallback = new ScheduleDispatchFrameCallback(); private final AtomicInteger mHasDispatchScheduledCount = new AtomicInteger(); From 331dc2a998c0a2f43662efcf345f070bba01a1ed Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Mon, 21 Dec 2020 16:15:51 -0800 Subject: [PATCH 0266/1810] Default initialize RCTNetworking with observation disabled Summary: ## Context When you add/remove listeners from event emitters in JavaScript on iOS, we [call the NativeModule's addListener/removeListener methods](https://fburl.com/diffusion/4878jv6p). These addListener() and removeListener() methods [are implemented on the RCTEventEmitter class](https://fburl.com/diffusion/y913pqhy). All event emitters on iOS are subclasses of RCTEventEmitter. The only purpose of calling RCTEventEmitter's addListener() and removeListener() methods is to call the [subclasses' startObservation, and stopObservation methods](https://fburl.com/diffusion/rpzyfppk), and [increment/decrement a listenerCount member variable](https://fburl.com/diffusion/ktl8if26) in RCTEventEmitter, which helps catch memory leaks. RCTNetworking is a subclass of RCTEventEmitter, but it doesn't implement these startObserving/stopObserving methods. Since the [listenerCount is only used to show warnings](https://fburl.com/diffusion/i45lobil), in D24272560 (https://github.com/facebook/react-native/commit/82187bfb6b54fdffc5dadaa56e8bf97d2209708a), I disabled observation in RCTNetworking on the native side. Then in D24272663 (https://github.com/facebook/react-native/commit/dabca52f77799bcdedb6b0ec44b1f6297483a46d), I disabled RCTNetworking.addListener/removeListener NativeModule calls in JavaScript. This was gated via a QE/MC. ## Problem The default initializer of RCTNetworking doesn't initialize with observation disabled. This broke antwerp when we shipped the experiment in D24272663 (https://github.com/facebook/react-native/commit/dabca52f77799bcdedb6b0ec44b1f6297483a46d). This diff fixes that problem. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25671343 fbshipit-source-id: d9a8ba5324a23ade8f4b0bf2ec093f3e4fb494dc --- Libraries/Network/RCTNetworking.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/Network/RCTNetworking.mm b/Libraries/Network/RCTNetworking.mm index edbbe814e6e57f..1869ebc35badaa 100644 --- a/Libraries/Network/RCTNetworking.mm +++ b/Libraries/Network/RCTNetworking.mm @@ -157,6 +157,11 @@ @implementation RCTNetworking RCT_EXPORT_MODULE() +- (instancetype)init +{ + return [super initWithDisabledObservation]; +} + - (instancetype)initWithHandlersProvider:(NSArray> * (^)(void))getHandlers { if (self = [super initWithDisabledObservation]) { From 15a3a0108259770a436125663087050c79e8e47b Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 21 Dec 2020 22:41:06 -0800 Subject: [PATCH 0267/1810] Android: use Fabric component codegen output instead of checked in files Summary: For core components, we can start using the codegen output during build time instead of the checked in files in: https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/react/viewmanagers Note: Some files seemed to be handwritten, so this only removed those that use codegen. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25453157 fbshipit-source-id: f7eabddfd3fd668bef0c4aef3fddcb38c8b046a0 --- .../ActivityIndicatorViewManagerDelegate.java | 41 ----------- ...ActivityIndicatorViewManagerInterface.java | 20 ------ .../AndroidDrawerLayoutManagerDelegate.java | 60 ---------------- .../AndroidDrawerLayoutManagerInterface.java | 24 ------- .../AndroidProgressBarManagerDelegate.java | 50 ------------- .../AndroidProgressBarManagerInterface.java | 23 ------ ...roidSwipeRefreshLayoutManagerDelegate.java | 57 --------------- ...oidSwipeRefreshLayoutManagerInterface.java | 24 ------- .../AndroidSwitchManagerDelegate.java | 66 ----------------- .../AndroidSwitchManagerInterface.java | 26 ------- .../MaskedViewManagerDelegate.java | 25 ------- .../MaskedViewManagerInterface.java | 16 ----- .../ModalHostViewManagerDelegate.java | 53 -------------- .../ModalHostViewManagerInterface.java | 25 ------- .../ProgressViewManagerDelegate.java | 48 ------------- .../ProgressViewManagerInterface.java | 23 ------ .../SafeAreaViewManagerDelegate.java | 31 -------- .../SafeAreaViewManagerInterface.java | 16 ----- .../SegmentedControlManagerDelegate.java | 51 ------------- .../SegmentedControlManagerInterface.java | 24 ------- .../viewmanagers/SliderManagerDelegate.java | 72 ------------------- .../viewmanagers/SliderManagerInterface.java | 31 -------- ...nimplementedNativeViewManagerDelegate.java | 31 -------- ...implementedNativeViewManagerInterface.java | 17 ----- .../java/com/facebook/react/views/drawer/BUCK | 4 +- .../java/com/facebook/react/views/modal/BUCK | 4 +- .../com/facebook/react/views/progressbar/BUCK | 4 +- .../java/com/facebook/react/views/slider/BUCK | 4 +- .../facebook/react/views/swiperefresh/BUCK | 4 +- .../com/facebook/react/views/switchview/BUCK | 4 +- .../components/GeneratePropsJavaDelegate.js | 4 +- .../components/GeneratePropsJavaInterface.js | 4 +- 32 files changed, 14 insertions(+), 872 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerInterface.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerInterface.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java deleted file mode 100644 index 72b309e4f2e518..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate.java +++ /dev/null @@ -1,41 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class ActivityIndicatorViewManagerDelegate & ActivityIndicatorViewManagerInterface> extends BaseViewManagerDelegate { - public ActivityIndicatorViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "hidesWhenStopped": - mViewManager.setHidesWhenStopped(view, value == null ? false : (boolean) value); - break; - case "animating": - mViewManager.setAnimating(view, value == null ? false : (boolean) value); - break; - case "color": - mViewManager.setColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "size": - mViewManager.setSize(view, (String) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerInterface.java deleted file mode 100644 index d217b8bc2fdfbe..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ActivityIndicatorViewManagerInterface.java +++ /dev/null @@ -1,20 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface ActivityIndicatorViewManagerInterface { - void setHidesWhenStopped(T view, boolean value); - void setAnimating(T view, boolean value); - void setColor(T view, @Nullable Integer value); - void setSize(T view, @Nullable String value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java deleted file mode 100644 index 11af21261e73f9..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate.java +++ /dev/null @@ -1,60 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class AndroidDrawerLayoutManagerDelegate & AndroidDrawerLayoutManagerInterface> extends BaseViewManagerDelegate { - public AndroidDrawerLayoutManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "keyboardDismissMode": - mViewManager.setKeyboardDismissMode(view, (String) value); - break; - case "drawerBackgroundColor": - mViewManager.setDrawerBackgroundColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "drawerPosition": - mViewManager.setDrawerPosition(view, (String) value); - break; - case "drawerWidth": - mViewManager.setDrawerWidth(view, value == null ? null : ((Double) value).floatValue()); - break; - case "drawerLockMode": - mViewManager.setDrawerLockMode(view, (String) value); - break; - case "statusBarBackgroundColor": - mViewManager.setStatusBarBackgroundColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - default: - super.setProperty(view, propName, value); - } - } - - @Override - public void receiveCommand(T view, String commandName, ReadableArray args) { - switch (commandName) { - case "openDrawer": - mViewManager.openDrawer(view); - break; - case "closeDrawer": - mViewManager.closeDrawer(view); - break; - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerInterface.java deleted file mode 100644 index 7654b2d79297a5..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerInterface.java +++ /dev/null @@ -1,24 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface AndroidDrawerLayoutManagerInterface { - void setKeyboardDismissMode(T view, @Nullable String value); - void setDrawerBackgroundColor(T view, @Nullable Integer value); - void setDrawerPosition(T view, @Nullable String value); - void setDrawerWidth(T view, @Nullable Float value); - void setDrawerLockMode(T view, @Nullable String value); - void setStatusBarBackgroundColor(T view, @Nullable Integer value); - void openDrawer(T view); - void closeDrawer(T view); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java deleted file mode 100644 index 9a1554d885c4dd..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate.java +++ /dev/null @@ -1,50 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class AndroidProgressBarManagerDelegate & AndroidProgressBarManagerInterface> extends BaseViewManagerDelegate { - public AndroidProgressBarManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "styleAttr": - mViewManager.setStyleAttr(view, value == null ? null : (String) value); - break; - case "typeAttr": - mViewManager.setTypeAttr(view, value == null ? null : (String) value); - break; - case "indeterminate": - mViewManager.setIndeterminate(view, value == null ? false : (boolean) value); - break; - case "progress": - mViewManager.setProgress(view, value == null ? 0f : ((Double) value).doubleValue()); - break; - case "animating": - mViewManager.setAnimating(view, value == null ? true : (boolean) value); - break; - case "color": - mViewManager.setColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "testID": - mViewManager.setTestID(view, value == null ? "" : (String) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface.java deleted file mode 100644 index 814d8e7f7e14c9..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface.java +++ /dev/null @@ -1,23 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface AndroidProgressBarManagerInterface { - void setStyleAttr(T view, @Nullable String value); - void setTypeAttr(T view, @Nullable String value); - void setIndeterminate(T view, boolean value); - void setProgress(T view, double value); - void setAnimating(T view, boolean value); - void setColor(T view, @Nullable Integer value); - void setTestID(T view, @Nullable String value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java deleted file mode 100644 index 32a60194d43213..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate.java +++ /dev/null @@ -1,57 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class AndroidSwipeRefreshLayoutManagerDelegate & AndroidSwipeRefreshLayoutManagerInterface> extends BaseViewManagerDelegate { - public AndroidSwipeRefreshLayoutManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "enabled": - mViewManager.setEnabled(view, value == null ? true : (boolean) value); - break; - case "colors": - mViewManager.setColors(view, (ReadableArray) value); - break; - case "progressBackgroundColor": - mViewManager.setProgressBackgroundColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "size": - mViewManager.setSize(view, value == null ? 1 : ((Double) value).intValue()); - break; - case "progressViewOffset": - mViewManager.setProgressViewOffset(view, value == null ? 0f : ((Double) value).floatValue()); - break; - case "refreshing": - mViewManager.setRefreshing(view, value == null ? false : (boolean) value); - break; - default: - super.setProperty(view, propName, value); - } - } - - @Override - public void receiveCommand(T view, String commandName, ReadableArray args) { - switch (commandName) { - case "setNativeRefreshing": - mViewManager.setNativeRefreshing(view, args.getBoolean(0)); - break; - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerInterface.java deleted file mode 100644 index 3e81326b3e8ee0..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerInterface.java +++ /dev/null @@ -1,24 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableArray; - -public interface AndroidSwipeRefreshLayoutManagerInterface { - void setEnabled(T view, boolean value); - void setColors(T view, @Nullable ReadableArray value); - void setProgressBackgroundColor(T view, @Nullable Integer value); - void setSize(T view, int value); - void setProgressViewOffset(T view, float value); - void setRefreshing(T view, boolean value); - void setNativeRefreshing(T view, boolean value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java deleted file mode 100644 index 27505917f8855a..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate.java +++ /dev/null @@ -1,66 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class AndroidSwitchManagerDelegate & AndroidSwitchManagerInterface> extends BaseViewManagerDelegate { - public AndroidSwitchManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "disabled": - mViewManager.setDisabled(view, value == null ? false : (boolean) value); - break; - case "enabled": - mViewManager.setEnabled(view, value == null ? true : (boolean) value); - break; - case "thumbColor": - mViewManager.setThumbColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "trackColorForFalse": - mViewManager.setTrackColorForFalse(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "trackColorForTrue": - mViewManager.setTrackColorForTrue(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "value": - mViewManager.setValue(view, value == null ? false : (boolean) value); - break; - case "on": - mViewManager.setOn(view, value == null ? false : (boolean) value); - break; - case "thumbTintColor": - mViewManager.setThumbTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "trackTintColor": - mViewManager.setTrackTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - default: - super.setProperty(view, propName, value); - } - } - - @Override - public void receiveCommand(T view, String commandName, ReadableArray args) { - switch (commandName) { - case "setNativeValue": - mViewManager.setNativeValue(view, args.getBoolean(0)); - break; - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerInterface.java deleted file mode 100644 index 2ff293b3be663a..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidSwitchManagerInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface AndroidSwitchManagerInterface { - void setDisabled(T view, boolean value); - void setEnabled(T view, boolean value); - void setThumbColor(T view, @Nullable Integer value); - void setTrackColorForFalse(T view, @Nullable Integer value); - void setTrackColorForTrue(T view, @Nullable Integer value); - void setValue(T view, boolean value); - void setOn(T view, boolean value); - void setThumbTintColor(T view, @Nullable Integer value); - void setTrackTintColor(T view, @Nullable Integer value); - void setNativeValue(T view, boolean value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java deleted file mode 100644 index 0d95dd794afc50..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerDelegate.java +++ /dev/null @@ -1,25 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class MaskedViewManagerDelegate & MaskedViewManagerInterface> extends BaseViewManagerDelegate { - public MaskedViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - super.setProperty(view, propName, value); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerInterface.java deleted file mode 100644 index 0b930ee79c1be0..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/MaskedViewManagerInterface.java +++ /dev/null @@ -1,16 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; - -public interface MaskedViewManagerInterface { - // No props -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java deleted file mode 100644 index 52967876c20dbf..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerDelegate.java +++ /dev/null @@ -1,53 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class ModalHostViewManagerDelegate & ModalHostViewManagerInterface> extends BaseViewManagerDelegate { - public ModalHostViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "animationType": - mViewManager.setAnimationType(view, (String) value); - break; - case "presentationStyle": - mViewManager.setPresentationStyle(view, (String) value); - break; - case "transparent": - mViewManager.setTransparent(view, value == null ? false : (boolean) value); - break; - case "statusBarTranslucent": - mViewManager.setStatusBarTranslucent(view, value == null ? false : (boolean) value); - break; - case "hardwareAccelerated": - mViewManager.setHardwareAccelerated(view, value == null ? false : (boolean) value); - break; - case "animated": - mViewManager.setAnimated(view, value == null ? false : (boolean) value); - break; - case "supportedOrientations": - mViewManager.setSupportedOrientations(view, (ReadableArray) value); - break; - case "identifier": - mViewManager.setIdentifier(view, value == null ? 0 : ((Double) value).intValue()); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerInterface.java deleted file mode 100644 index bf60387d5180c8..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ModalHostViewManagerInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableArray; - -public interface ModalHostViewManagerInterface { - void setAnimationType(T view, @Nullable String value); - void setPresentationStyle(T view, @Nullable String value); - void setTransparent(T view, boolean value); - void setStatusBarTranslucent(T view, boolean value); - void setHardwareAccelerated(T view, boolean value); - void setAnimated(T view, boolean value); - void setSupportedOrientations(T view, @Nullable ReadableArray value); - void setIdentifier(T view, int value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java deleted file mode 100644 index 9a469c4f51233c..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerDelegate.java +++ /dev/null @@ -1,48 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class ProgressViewManagerDelegate & ProgressViewManagerInterface> extends BaseViewManagerDelegate { - public ProgressViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "progressViewStyle": - mViewManager.setProgressViewStyle(view, (String) value); - break; - case "progress": - mViewManager.setProgress(view, value == null ? 0f : ((Double) value).floatValue()); - break; - case "progressTintColor": - mViewManager.setProgressTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "trackTintColor": - mViewManager.setTrackTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "progressImage": - mViewManager.setProgressImage(view, (ReadableMap) value); - break; - case "trackImage": - mViewManager.setTrackImage(view, (ReadableMap) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerInterface.java deleted file mode 100644 index bbfbdf4e31bb02..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/ProgressViewManagerInterface.java +++ /dev/null @@ -1,23 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableMap; - -public interface ProgressViewManagerInterface { - void setProgressViewStyle(T view, @Nullable String value); - void setProgress(T view, float value); - void setProgressTintColor(T view, @Nullable Integer value); - void setTrackTintColor(T view, @Nullable Integer value); - void setProgressImage(T view, @Nullable ReadableMap value); - void setTrackImage(T view, @Nullable ReadableMap value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java deleted file mode 100644 index 586fed6ae83fa2..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate.java +++ /dev/null @@ -1,31 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class SafeAreaViewManagerDelegate & SafeAreaViewManagerInterface> extends BaseViewManagerDelegate { - public SafeAreaViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "emulateUnlessSupported": - mViewManager.setEmulateUnlessSupported(view, value == null ? false : (boolean) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerInterface.java deleted file mode 100644 index 073e2c01c76826..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SafeAreaViewManagerInterface.java +++ /dev/null @@ -1,16 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; - -public interface SafeAreaViewManagerInterface { - void setEmulateUnlessSupported(T view, boolean value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java deleted file mode 100644 index 64e5eadd6d887d..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java +++ /dev/null @@ -1,51 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class SegmentedControlManagerDelegate & SegmentedControlManagerInterface> extends BaseViewManagerDelegate { - public SegmentedControlManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "values": - mViewManager.setValues(view, (ReadableArray) value); - break; - case "selectedIndex": - mViewManager.setSelectedIndex(view, value == null ? 0 : ((Double) value).intValue()); - break; - case "enabled": - mViewManager.setEnabled(view, value == null ? true : (boolean) value); - break; - case "tintColor": - mViewManager.setTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "textColor": - mViewManager.setTextColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "backgroundColor": - mViewManager.setBackgroundColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "momentary": - mViewManager.setMomentary(view, value == null ? false : (boolean) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java deleted file mode 100644 index 0ee9d56850941d..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java +++ /dev/null @@ -1,24 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableArray; - -public interface SegmentedControlManagerInterface { - void setValues(T view, @Nullable ReadableArray value); - void setSelectedIndex(T view, int value); - void setEnabled(T view, boolean value); - void setTintColor(T view, @Nullable Integer value); - void setTextColor(T view, @Nullable Integer value); - void setBackgroundColor(T view, @Nullable Integer value); - void setMomentary(T view, boolean value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java deleted file mode 100644 index 017b209edb02e9..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerDelegate.java +++ /dev/null @@ -1,72 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ColorPropConverter; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class SliderManagerDelegate & SliderManagerInterface> extends BaseViewManagerDelegate { - public SliderManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "disabled": - mViewManager.setDisabled(view, value == null ? false : (boolean) value); - break; - case "enabled": - mViewManager.setEnabled(view, value == null ? true : (boolean) value); - break; - case "maximumTrackImage": - mViewManager.setMaximumTrackImage(view, (ReadableMap) value); - break; - case "maximumTrackTintColor": - mViewManager.setMaximumTrackTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "maximumValue": - mViewManager.setMaximumValue(view, value == null ? 1f : ((Double) value).doubleValue()); - break; - case "minimumTrackImage": - mViewManager.setMinimumTrackImage(view, (ReadableMap) value); - break; - case "minimumTrackTintColor": - mViewManager.setMinimumTrackTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "minimumValue": - mViewManager.setMinimumValue(view, value == null ? 0f : ((Double) value).doubleValue()); - break; - case "step": - mViewManager.setStep(view, value == null ? 0f : ((Double) value).doubleValue()); - break; - case "testID": - mViewManager.setTestID(view, value == null ? "" : (String) value); - break; - case "thumbImage": - mViewManager.setThumbImage(view, (ReadableMap) value); - break; - case "thumbTintColor": - mViewManager.setThumbTintColor(view, ColorPropConverter.getColor(value, view.getContext())); - break; - case "trackImage": - mViewManager.setTrackImage(view, (ReadableMap) value); - break; - case "value": - mViewManager.setValue(view, value == null ? 0f : ((Double) value).doubleValue()); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerInterface.java deleted file mode 100644 index 2d5c752f62cbba..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SliderManagerInterface.java +++ /dev/null @@ -1,31 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableMap; - -public interface SliderManagerInterface { - void setDisabled(T view, boolean value); - void setEnabled(T view, boolean value); - void setMaximumTrackImage(T view, @Nullable ReadableMap value); - void setMaximumTrackTintColor(T view, @Nullable Integer value); - void setMaximumValue(T view, double value); - void setMinimumTrackImage(T view, @Nullable ReadableMap value); - void setMinimumTrackTintColor(T view, @Nullable Integer value); - void setMinimumValue(T view, double value); - void setStep(T view, double value); - void setTestID(T view, @Nullable String value); - void setThumbImage(T view, @Nullable ReadableMap value); - void setThumbTintColor(T view, @Nullable Integer value); - void setTrackImage(T view, @Nullable ReadableMap value); - void setValue(T view, double value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java deleted file mode 100644 index 4dce46a5381445..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate.java +++ /dev/null @@ -1,31 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; - -public class UnimplementedNativeViewManagerDelegate & UnimplementedNativeViewManagerInterface> extends BaseViewManagerDelegate { - public UnimplementedNativeViewManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "name": - mViewManager.setName(view, value == null ? "" : (String) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerInterface.java deleted file mode 100644 index c76951e2225c1a..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/UnimplementedNativeViewManagerInterface.java +++ /dev/null @@ -1,17 +0,0 @@ -/** -* Copyright (c) Facebook, Inc. and its affiliates. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface UnimplementedNativeViewManagerInterface { - void setName(T view, @Nullable String value); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK index 4b8d23644be731..e500ae5c9c15d7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library") +load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") rn_android_library( name = "drawer", @@ -26,6 +26,6 @@ rn_android_library( react_native_target("java/com/facebook/react/uimanager:uimanager"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), react_native_target("java/com/facebook/react/views/scroll:scroll"), - react_native_target("java/com/facebook/react/viewmanagers:viewmanagers"), + react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK index 27c9e712a583d5..73cedfd484bba5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library") +load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") rn_android_library( name = "modal", @@ -17,6 +17,7 @@ rn_android_library( YOGA_TARGET, react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), + react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), @@ -25,7 +26,6 @@ rn_android_library( react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), react_native_target("java/com/facebook/react/views/common:common"), react_native_target("java/com/facebook/react/views/view:view"), - react_native_target("java/com/facebook/react/viewmanagers:viewmanagers"), react_native_target("res:modal"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK index 7cdbb3e964fa35..14f9498a4be8ae 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library") +load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") rn_android_library( name = "progressbar", @@ -19,6 +19,6 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/uimanager:uimanager"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), - react_native_target("java/com/facebook/react/viewmanagers:viewmanagers"), + react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK index 346c3512f352fc..8568b1101e6942 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/slider/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library") +load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") rn_android_library( name = "slider", @@ -22,6 +22,6 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/uimanager:uimanager"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), - react_native_target("java/com/facebook/react/viewmanagers:viewmanagers"), + react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK index a138ce884bd02c..1209f9a3f38ae0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_android_library") +load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") rn_android_library( name = "swiperefresh", @@ -26,6 +26,6 @@ rn_android_library( react_native_target("java/com/facebook/react/views/scroll:scroll"), ], exported_deps = [ - react_native_target("java/com/facebook/react/viewmanagers:viewmanagers"), + react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK index 166dc14a57fd19..9d6bbcad36a0da 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library") +load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") rn_android_library( name = "switchview", @@ -24,6 +24,6 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/uimanager:uimanager"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), - react_native_target("java/com/facebook/react/viewmanagers:viewmanagers"), + react_native_root_target("Libraries:generated_components_java-FBReactNativeComponentSpec"), ], ) diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index 6b3da0121392f3..e931e1fe125631 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -268,9 +268,7 @@ module.exports = { packageName?: string, ): FilesOutput { // TODO: This doesn't support custom package name yet. - // TODO: But it customizes the name here temporarily to prepare for Fabric RNTester support. - const normalizedPackageName = - packageName != null ? packageName : 'com.facebook.react.viewmanagers'; + const normalizedPackageName = 'com.facebook.react.viewmanagers'; const outputDir = `java/${normalizedPackageName.replace(/\./g, '/')}`; const files = new Map(); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index 040ec22dd81241..daa2afe92c3d64 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -216,9 +216,7 @@ module.exports = { packageName?: string, ): FilesOutput { // TODO: This doesn't support custom package name yet. - // TODO: But it customizes the name here temporarily to prepare for Fabric RNTester support. - const normalizedPackageName = - packageName != null ? packageName : 'com.facebook.react.viewmanagers'; + const normalizedPackageName = 'com.facebook.react.viewmanagers'; const outputDir = `java/${normalizedPackageName.replace(/\./g, '/')}`; const files = new Map(); From 1ce53e86ed244e61b27a17916f370ba78e0b78a5 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 21 Dec 2020 22:41:06 -0800 Subject: [PATCH 0268/1810] Codegen Android: rename "ReactAndroidSpec" to "rncore" for parity with Fabric Summary: The TM specs and Fabric files should be combined into the same .so. For short term parity with Fabric components and iOS, let's rename ReactAndroidSpec (default name based on project path) to "rncore". Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25674312 fbshipit-source-id: 3d71aa0cc945affecb06dcfc15e807dd48c76468 --- ReactAndroid/Android-prebuilt.mk | 6 +++--- ReactAndroid/build.gradle | 3 +++ packages/rn-tester/android/app/src/main/jni/Android.mk | 2 +- .../android/app/src/main/jni/RNTesterAppModuleProvider.cpp | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/Android-prebuilt.mk b/ReactAndroid/Android-prebuilt.mk index 6a921100744dca..11b770a06f8081 100644 --- a/ReactAndroid/Android-prebuilt.mk +++ b/ReactAndroid/Android-prebuilt.mk @@ -85,10 +85,10 @@ LOCAL_EXPORT_C_INCLUDES := \ $(REACT_ANDROID_SRC_DIR)/java/com/facebook/react/turbomodule/core/jni include $(PREBUILT_SHARED_LIBRARY) -# react_codegen_reactandroidspec +# react_codegen_rncore include $(CLEAR_VARS) -LOCAL_MODULE := react_codegen_reactandroidspec -LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_codegen_reactandroidspec.so +LOCAL_MODULE := react_codegen_rncore +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_codegen_rncore.so LOCAL_EXPORT_C_INCLUDES := \ $(REACT_GENERATED_SRC_DIR)/codegen/jni include $(PREBUILT_SHARED_LIBRARY) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 2b33e77be7157c..d5fa04ca000698 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -478,6 +478,9 @@ dependencies { apply(from: "release.gradle") react { + // TODO: The library name is chosen for parity with Fabric components & iOS + // This should be changed to a more generic name, e.g. `ReactCoreSpec`. + libraryName = "rncore" jsRootDir = file("../Libraries") reactNativeRootDir = file("$projectDir/..") useJavaGenerator = System.getenv("USE_CODEGEN_JAVAPOET") ?: false diff --git a/packages/rn-tester/android/app/src/main/jni/Android.mk b/packages/rn-tester/android/app/src/main/jni/Android.mk index 6e003cdb953721..09d4881d54fd66 100644 --- a/packages/rn-tester/android/app/src/main/jni/Android.mk +++ b/packages/rn-tester/android/app/src/main/jni/Android.mk @@ -18,7 +18,7 @@ LOCAL_MODULE := rntester_appmodules LOCAL_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni -LOCAL_SHARED_LIBRARIES := libfbjni libreact_nativemodule_core libturbomodulejsijni libreact_codegen_reactandroidspec +LOCAL_SHARED_LIBRARIES := libfbjni libreact_nativemodule_core libturbomodulejsijni libreact_codegen_rncore LOCAL_STATIC_LIBRARIES := libsampleturbomodule LOCAL_CFLAGS := \ -DLOG_TAG=\"ReactNative\" diff --git a/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp b/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp index 854775a6b1efc2..615cdc5d907265 100644 --- a/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp +++ b/packages/rn-tester/android/app/src/main/jni/RNTesterAppModuleProvider.cpp @@ -8,8 +8,8 @@ #include "RNTesterAppModuleProvider.h" #include -#include #include +#include namespace facebook { namespace react { @@ -25,7 +25,7 @@ std::shared_ptr RNTesterAppModuleProvider(const std::string moduleN return module; } - return ReactAndroidSpec_ModuleProvider(moduleName, params); + return rncore_ModuleProvider(moduleName, params); } } // namespace react From 8db181abfcd5449995afa0e770f03ef5b6b9178b Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 21 Dec 2020 22:41:06 -0800 Subject: [PATCH 0269/1810] RNTester Android: generate Fabric JNI files during build time Summary: Generate Fabric C++ files along side TM spec files for RNTester. The combined .so then has both TM and Fabric files. This commit also removed the checked-in JNI files. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25674313 fbshipit-source-id: 8091d5a00f42849a74cab50e8d24f4010d500e5b --- ReactAndroid/Android-prebuilt.mk | 63 +++ .../com/facebook/react/fabric/jni/Android.mk | 4 +- .../react/viewmanagers/jni/Android.mk | 29 - .../components/rncore/ComponentDescriptors.h | 31 - .../components/rncore/EventEmitters.cpp | 148 ----- .../components/rncore/EventEmitters.h | 229 -------- .../renderer/components/rncore/Props.cpp | 191 ------- .../react/renderer/components/rncore/Props.h | 529 ------------------ .../components/rncore/ShadowNodes.cpp | 28 - .../renderer/components/rncore/ShadowNodes.h | 117 ---- .../src/main/jni/react/jni/Android.mk | 1 - .../renderer/components/modal/Android.mk | 2 +- .../renderer/components/picker/Android.mk | 2 +- .../components/progressbar/Android.mk | 2 +- .../renderer/components/slider/Android.mk | 2 +- .../renderer/components/switch/Android.mk | 2 +- .../src/generators/RNCodegen.js | 17 +- .../generators/modules/GenerateModuleJniH.js | 11 +- .../GenerateModuleJniH-test.js.snap | 36 +- .../android/app/src/main/jni/Android.mk | 2 +- scripts/generate-native-modules-specs-cli.js | 15 + 21 files changed, 120 insertions(+), 1341 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/Android.mk delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ComponentDescriptors.h delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.cpp delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.h delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.cpp delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.h diff --git a/ReactAndroid/Android-prebuilt.mk b/ReactAndroid/Android-prebuilt.mk index 11b770a06f8081..6a704c2bc0855a 100644 --- a/ReactAndroid/Android-prebuilt.mk +++ b/ReactAndroid/Android-prebuilt.mk @@ -64,6 +64,18 @@ LOCAL_EXPORT_C_INCLUDES := $(THIRD_PARTY_NDK_DIR)/glog/exported LOCAL_SHARED_LIBRARIES := libglog include $(PREBUILT_SHARED_LIBRARY) +# yoga +include $(CLEAR_VARS) +LOCAL_MODULE := yoga +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libyoga.so +LOCAL_EXPORT_C_INCLUDES := \ + $(FIRST_PARTY_NDK_DIR)/yogajni/jni \ + $(REACT_COMMON_DIR)/yoga +# Note: Sync with yogajni/Android.mk +LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti -O3 +LOCAL_LDLIBS += -landroid -llog +include $(PREBUILT_SHARED_LIBRARY) + # react_nativemodule_core include $(CLEAR_VARS) LOCAL_MODULE := react_nativemodule_core @@ -85,6 +97,57 @@ LOCAL_EXPORT_C_INCLUDES := \ $(REACT_ANDROID_SRC_DIR)/java/com/facebook/react/turbomodule/core/jni include $(PREBUILT_SHARED_LIBRARY) +# react_render_core +include $(CLEAR_VARS) +LOCAL_MODULE := react_render_core +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_render_core.so +LOCAL_EXPORT_C_INCLUDES := \ + $(REACT_COMMON_DIR) \ + $(REACT_COMMON_DIR)/react/renderer/core +include $(PREBUILT_SHARED_LIBRARY) + +# react_render_debug +include $(CLEAR_VARS) +LOCAL_MODULE := react_render_debug +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_render_debug.so +LOCAL_EXPORT_C_INCLUDES := \ + $(REACT_COMMON_DIR)/react/renderer/debug +include $(PREBUILT_SHARED_LIBRARY) + +# react_render_graphics +include $(CLEAR_VARS) +LOCAL_MODULE := react_render_graphics +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_render_graphics.so +LOCAL_EXPORT_C_INCLUDES := \ + $(REACT_COMMON_DIR)/react/renderer/graphics \ + $(REACT_COMMON_DIR)/react/renderer/graphics/platform/cxx +include $(PREBUILT_SHARED_LIBRARY) + +# react_render_imagemanager +include $(CLEAR_VARS) +LOCAL_MODULE := react_render_imagemanager +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_render_imagemanager.so +LOCAL_EXPORT_C_INCLUDES := \ + $(REACT_COMMON_DIR)/react/renderer/imagemanager \ + $(REACT_COMMON_DIR)/react/renderer/imagemanager/platform/cxx +include $(PREBUILT_SHARED_LIBRARY) + +# react_render_mounting +include $(CLEAR_VARS) +LOCAL_MODULE := react_render_mounting +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_render_mounting.so +LOCAL_EXPORT_C_INCLUDES := \ + $(REACT_COMMON_DIR)/react/renderer/mounting +include $(PREBUILT_SHARED_LIBRARY) + +# react_render_components_view +include $(CLEAR_VARS) +LOCAL_MODULE := react_render_components_view +LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libreact_render_components_view.so +LOCAL_EXPORT_C_INCLUDES := \ + $(REACT_COMMON_DIR)/react/renderer/components/view +include $(PREBUILT_SHARED_LIBRARY) + # react_codegen_rncore include $(CLEAR_VARS) LOCAL_MODULE := react_codegen_rncore diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk index 593a8cf30815b3..793daed7427978 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := fabricjni LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SHARED_LIBRARIES := libreactconfig libreact_render_components_slider libreact_render_components_progressbar libreact_render_components_switch libreact_render_components_modal libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core libreact_render_mapbuffer react_render_componentregistry libreact_render_components_view libreact_render_components_unimplementedview libreact_render_components_root libreact_render_components_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libreact_render_viewmanagers react_render_components_text libreact_render_components_image react_render_components_textinput react_render_components_picker +LOCAL_SHARED_LIBRARIES := libreactconfig libreact_render_components_slider libreact_render_components_progressbar libreact_render_components_switch libreact_render_components_modal libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core libreact_render_mapbuffer react_render_componentregistry libreact_render_components_view libreact_render_components_unimplementedview libreact_render_components_root libreact_render_components_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libreact_codegen_rncore react_render_components_text libreact_render_components_image react_render_components_textinput react_render_components_picker LOCAL_STATIC_LIBRARIES := @@ -60,5 +60,3 @@ $(call import-module,react/renderer/scheduler) $(call import-module,react/renderer/templateprocessor) $(call import-module,react/renderer/textlayoutmanager) $(call import-module,react/renderer/uimanager) - -# $(call import-module,react/fabric/viewmanagers/jni) diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/Android.mk deleted file mode 100644 index cc37b42fdbe2e2..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_viewmanagers - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/react/renderer/components/rncore/*.cpp) - -LOCAL_SHARED_LIBRARIES := libreact_render_components_view libfolly_json libreact_render_core libreact_render_graphics - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/rncore/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,react/renderer/components/view) diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ComponentDescriptors.h b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ComponentDescriptors.h deleted file mode 100644 index cc3c195dd3a24f..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ComponentDescriptors.h +++ /dev/null @@ -1,31 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GenerateComponentDescriptorH.js - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -using ActivityIndicatorViewComponentDescriptor = ConcreteComponentDescriptor; -using DatePickerComponentDescriptor = ConcreteComponentDescriptor; -using AndroidDrawerLayoutComponentDescriptor = ConcreteComponentDescriptor; -using RCTMaskedViewComponentDescriptor = ConcreteComponentDescriptor; -using RCTProgressViewComponentDescriptor = ConcreteComponentDescriptor; -using AndroidSwipeRefreshLayoutComponentDescriptor = ConcreteComponentDescriptor; -using PullToRefreshViewComponentDescriptor = ConcreteComponentDescriptor; -using RCTSegmentedControlComponentDescriptor = ConcreteComponentDescriptor; -using SwitchComponentDescriptor = ConcreteComponentDescriptor; -using UnimplementedNativeViewComponentDescriptor = ConcreteComponentDescriptor; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp deleted file mode 100644 index ee226666fb4fd6..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.cpp +++ /dev/null @@ -1,148 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GenerateEventEmitterCpp.js - */ - -#include - -namespace facebook { -namespace react { - - -void DatePickerEventEmitter::onChange(OnChange event) const { - dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "timestamp", event.timestamp); - return payload; - }); -} -void AndroidDrawerLayoutEventEmitter::onDrawerSlide(OnDrawerSlide event) const { - dispatchEvent("drawerSlide", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "offset", event.offset); - return payload; - }); -} -void AndroidDrawerLayoutEventEmitter::onDrawerStateChanged(OnDrawerStateChanged event) const { - dispatchEvent("drawerStateChanged", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "drawerState", event.drawerState); - return payload; - }); -} -void AndroidDrawerLayoutEventEmitter::onDrawerOpen(OnDrawerOpen event) const { - dispatchEvent("drawerOpen", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void AndroidDrawerLayoutEventEmitter::onDrawerClose(OnDrawerClose event) const { - dispatchEvent("drawerClose", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} - - - -void AndroidSwipeRefreshLayoutEventEmitter::onRefresh(OnRefresh event) const { - dispatchEvent("refresh", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void PullToRefreshViewEventEmitter::onRefresh(OnRefresh event) const { - dispatchEvent("refresh", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} - -void RCTSegmentedControlEventEmitter::onChange(OnChange event) const { - dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "value", event.value); -payload.setProperty(runtime, "selectedSegmentIndex", event.selectedSegmentIndex); - return payload; - }); -} -void SliderEventEmitter::onChange(OnChange event) const { - dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "value", event.value); -payload.setProperty(runtime, "fromUser", event.fromUser); - return payload; - }); -} -void SliderEventEmitter::onValueChange(OnValueChange event) const { - dispatchEvent("valueChange", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "value", event.value); -payload.setProperty(runtime, "fromUser", event.fromUser); - return payload; - }); -} -void SliderEventEmitter::onSlidingComplete(OnSlidingComplete event) const { - dispatchEvent("slidingComplete", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "value", event.value); -payload.setProperty(runtime, "fromUser", event.fromUser); - return payload; - }); -} -void AndroidSwitchEventEmitter::onChange(OnChange event) const { - dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "value", event.value); - return payload; - }); -} -void SwitchEventEmitter::onChange(OnChange event) const { - dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "value", event.value); - return payload; - }); -} - - -void ModalHostViewEventEmitter::onRequestClose(OnRequestClose event) const { - dispatchEvent("requestClose", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void ModalHostViewEventEmitter::onShow(OnShow event) const { - dispatchEvent("show", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void ModalHostViewEventEmitter::onDismiss(OnDismiss event) const { - dispatchEvent("dismiss", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void ModalHostViewEventEmitter::onOrientationChange(OnOrientationChange event) const { - dispatchEvent("orientationChange", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "orientation", toString(event.orientation)); - return payload; - }); -} - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h deleted file mode 100644 index 16cc009e715739..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/EventEmitters.h +++ /dev/null @@ -1,229 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GenerateEventEmitterH.js - */ -#pragma once - -#include - -namespace facebook { -namespace react { - -class ActivityIndicatorViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class DatePickerEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnChange { - Float timestamp; - }; - - void onChange(OnChange value) const; -}; -class AndroidDrawerLayoutEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnDrawerSlide { - Float offset; - }; - - struct OnDrawerStateChanged { - int drawerState; - }; - - struct OnDrawerOpen { - - }; - - struct OnDrawerClose { - - }; - - void onDrawerSlide(OnDrawerSlide value) const; - - void onDrawerStateChanged(OnDrawerStateChanged value) const; - - void onDrawerOpen(OnDrawerOpen value) const; - - void onDrawerClose(OnDrawerClose value) const; -}; -class RCTMaskedViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class AndroidProgressBarEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class RCTProgressViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class AndroidSwipeRefreshLayoutEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnRefresh { - - }; - - void onRefresh(OnRefresh value) const; -}; -class PullToRefreshViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnRefresh { - - }; - - void onRefresh(OnRefresh value) const; -}; -class SafeAreaViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class RCTSegmentedControlEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnChange { - int value; - int selectedSegmentIndex; - }; - - void onChange(OnChange value) const; -}; -class SliderEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnChange { - double value; - bool fromUser; - }; - - struct OnValueChange { - double value; - bool fromUser; - }; - - struct OnSlidingComplete { - double value; - bool fromUser; - }; - - void onChange(OnChange value) const; - - void onValueChange(OnValueChange value) const; - - void onSlidingComplete(OnSlidingComplete value) const; -}; -class AndroidSwitchEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnChange { - bool value; - }; - - void onChange(OnChange value) const; -}; -class SwitchEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnChange { - bool value; - }; - - void onChange(OnChange value) const; -}; -class InputAccessoryEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class UnimplementedNativeViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - - - -}; -class ModalHostViewEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnRequestClose { - - }; - - struct OnShow { - - }; - - struct OnDismiss { - - }; - - enum class OnOrientationChangeOrientation { - Portrait, - Landscape - }; - - static char const *toString(const OnOrientationChangeOrientation value) { - switch (value) { - case OnOrientationChangeOrientation::Portrait: return "portrait"; - case OnOrientationChangeOrientation::Landscape: return "landscape"; - } - } - - struct OnOrientationChange { - OnOrientationChangeOrientation orientation; - }; - - void onRequestClose(OnRequestClose value) const; - - void onShow(OnShow value) const; - - void onDismiss(OnDismiss value) const; - - void onOrientationChange(OnOrientationChange value) const; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.cpp b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.cpp deleted file mode 100644 index fcce261612f836..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.cpp +++ /dev/null @@ -1,191 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GeneratePropsCpp.js - */ - -#include -#include -#include - -namespace facebook { -namespace react { - -ActivityIndicatorViewProps::ActivityIndicatorViewProps( - const ActivityIndicatorViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - hidesWhenStopped(convertRawProp(rawProps, "hidesWhenStopped", sourceProps.hidesWhenStopped, {false})), - animating(convertRawProp(rawProps, "animating", sourceProps.animating, {false})), - color(convertRawProp(rawProps, "color", sourceProps.color, {})), - size(convertRawProp(rawProps, "size", sourceProps.size, {ActivityIndicatorViewSize::Small})) - {} -DatePickerProps::DatePickerProps( - const DatePickerProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - date(convertRawProp(rawProps, "date", sourceProps.date, {0.0})), - initialDate(convertRawProp(rawProps, "initialDate", sourceProps.initialDate, {0.0})), - locale(convertRawProp(rawProps, "locale", sourceProps.locale, {})), - maximumDate(convertRawProp(rawProps, "maximumDate", sourceProps.maximumDate, {0.0})), - minimumDate(convertRawProp(rawProps, "minimumDate", sourceProps.minimumDate, {0.0})), - minuteInterval(convertRawProp(rawProps, "minuteInterval", sourceProps.minuteInterval, {DatePickerMinuteInterval::MinuteInterval1})), - mode(convertRawProp(rawProps, "mode", sourceProps.mode, {DatePickerMode::Date})), - timeZoneOffsetInMinutes(convertRawProp(rawProps, "timeZoneOffsetInMinutes", sourceProps.timeZoneOffsetInMinutes, {0.0})) - {} -AndroidDrawerLayoutProps::AndroidDrawerLayoutProps( - const AndroidDrawerLayoutProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - keyboardDismissMode(convertRawProp(rawProps, "keyboardDismissMode", sourceProps.keyboardDismissMode, {AndroidDrawerLayoutKeyboardDismissMode::None})), - drawerBackgroundColor(convertRawProp(rawProps, "drawerBackgroundColor", sourceProps.drawerBackgroundColor, {})), - drawerPosition(convertRawProp(rawProps, "drawerPosition", sourceProps.drawerPosition, {AndroidDrawerLayoutDrawerPosition::Left})), - drawerWidth(convertRawProp(rawProps, "drawerWidth", sourceProps.drawerWidth, {})), - drawerLockMode(convertRawProp(rawProps, "drawerLockMode", sourceProps.drawerLockMode, {AndroidDrawerLayoutDrawerLockMode::Unlocked})), - statusBarBackgroundColor(convertRawProp(rawProps, "statusBarBackgroundColor", sourceProps.statusBarBackgroundColor, {})) - {} -RCTMaskedViewProps::RCTMaskedViewProps( - const RCTMaskedViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps) - - - {} -AndroidProgressBarProps::AndroidProgressBarProps( - const AndroidProgressBarProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - styleAttr(convertRawProp(rawProps, "styleAttr", sourceProps.styleAttr, {})), - typeAttr(convertRawProp(rawProps, "typeAttr", sourceProps.typeAttr, {})), - indeterminate(convertRawProp(rawProps, "indeterminate", sourceProps.indeterminate, {false})), - progress(convertRawProp(rawProps, "progress", sourceProps.progress, {0.0})), - animating(convertRawProp(rawProps, "animating", sourceProps.animating, {true})), - color(convertRawProp(rawProps, "color", sourceProps.color, {})), - testID(convertRawProp(rawProps, "testID", sourceProps.testID, {""})) - {} -RCTProgressViewProps::RCTProgressViewProps( - const RCTProgressViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - progressViewStyle(convertRawProp(rawProps, "progressViewStyle", sourceProps.progressViewStyle, {RCTProgressViewProgressViewStyle::Default})), - progress(convertRawProp(rawProps, "progress", sourceProps.progress, {0.0})), - progressTintColor(convertRawProp(rawProps, "progressTintColor", sourceProps.progressTintColor, {})), - trackTintColor(convertRawProp(rawProps, "trackTintColor", sourceProps.trackTintColor, {})), - progressImage(convertRawProp(rawProps, "progressImage", sourceProps.progressImage, {})), - trackImage(convertRawProp(rawProps, "trackImage", sourceProps.trackImage, {})) - {} -AndroidSwipeRefreshLayoutProps::AndroidSwipeRefreshLayoutProps( - const AndroidSwipeRefreshLayoutProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - enabled(convertRawProp(rawProps, "enabled", sourceProps.enabled, {true})), - colors(convertRawProp(rawProps, "colors", sourceProps.colors, {})), - progressBackgroundColor(convertRawProp(rawProps, "progressBackgroundColor", sourceProps.progressBackgroundColor, {})), - size(convertRawProp(rawProps, "size", sourceProps.size, {1})), - progressViewOffset(convertRawProp(rawProps, "progressViewOffset", sourceProps.progressViewOffset, {0.0})), - refreshing(convertRawProp(rawProps, "refreshing", sourceProps.refreshing, {false})) - {} -PullToRefreshViewProps::PullToRefreshViewProps( - const PullToRefreshViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - tintColor(convertRawProp(rawProps, "tintColor", sourceProps.tintColor, {})), - titleColor(convertRawProp(rawProps, "titleColor", sourceProps.titleColor, {})), - title(convertRawProp(rawProps, "title", sourceProps.title, {})), - refreshing(convertRawProp(rawProps, "refreshing", sourceProps.refreshing, {false})) - {} -SafeAreaViewProps::SafeAreaViewProps( - const SafeAreaViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - emulateUnlessSupported(convertRawProp(rawProps, "emulateUnlessSupported", sourceProps.emulateUnlessSupported, {false})) - {} -RCTSegmentedControlProps::RCTSegmentedControlProps( - const RCTSegmentedControlProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - values(convertRawProp(rawProps, "values", sourceProps.values, {})), - selectedIndex(convertRawProp(rawProps, "selectedIndex", sourceProps.selectedIndex, {0})), - enabled(convertRawProp(rawProps, "enabled", sourceProps.enabled, {true})), - tintColor(convertRawProp(rawProps, "tintColor", sourceProps.tintColor, {})), - textColor(convertRawProp(rawProps, "textColor", sourceProps.textColor, {})), - backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor, {})), - momentary(convertRawProp(rawProps, "momentary", sourceProps.momentary, {false})) - {} -SliderProps::SliderProps( - const SliderProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - disabled(convertRawProp(rawProps, "disabled", sourceProps.disabled, {false})), - enabled(convertRawProp(rawProps, "enabled", sourceProps.enabled, {true})), - maximumTrackImage(convertRawProp(rawProps, "maximumTrackImage", sourceProps.maximumTrackImage, {})), - maximumTrackTintColor(convertRawProp(rawProps, "maximumTrackTintColor", sourceProps.maximumTrackTintColor, {})), - maximumValue(convertRawProp(rawProps, "maximumValue", sourceProps.maximumValue, {1.0})), - minimumTrackImage(convertRawProp(rawProps, "minimumTrackImage", sourceProps.minimumTrackImage, {})), - minimumTrackTintColor(convertRawProp(rawProps, "minimumTrackTintColor", sourceProps.minimumTrackTintColor, {})), - minimumValue(convertRawProp(rawProps, "minimumValue", sourceProps.minimumValue, {0.0})), - step(convertRawProp(rawProps, "step", sourceProps.step, {0.0})), - testID(convertRawProp(rawProps, "testID", sourceProps.testID, {""})), - thumbImage(convertRawProp(rawProps, "thumbImage", sourceProps.thumbImage, {})), - thumbTintColor(convertRawProp(rawProps, "thumbTintColor", sourceProps.thumbTintColor, {})), - trackImage(convertRawProp(rawProps, "trackImage", sourceProps.trackImage, {})), - value(convertRawProp(rawProps, "value", sourceProps.value, {0.0})) - {} -AndroidSwitchProps::AndroidSwitchProps( - const AndroidSwitchProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - disabled(convertRawProp(rawProps, "disabled", sourceProps.disabled, {false})), - enabled(convertRawProp(rawProps, "enabled", sourceProps.enabled, {true})), - thumbColor(convertRawProp(rawProps, "thumbColor", sourceProps.thumbColor, {})), - trackColorForFalse(convertRawProp(rawProps, "trackColorForFalse", sourceProps.trackColorForFalse, {})), - trackColorForTrue(convertRawProp(rawProps, "trackColorForTrue", sourceProps.trackColorForTrue, {})), - value(convertRawProp(rawProps, "value", sourceProps.value, {false})), - on(convertRawProp(rawProps, "on", sourceProps.on, {false})), - thumbTintColor(convertRawProp(rawProps, "thumbTintColor", sourceProps.thumbTintColor, {})), - trackTintColor(convertRawProp(rawProps, "trackTintColor", sourceProps.trackTintColor, {})) - {} -SwitchProps::SwitchProps( - const SwitchProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - disabled(convertRawProp(rawProps, "disabled", sourceProps.disabled, {false})), - value(convertRawProp(rawProps, "value", sourceProps.value, {false})), - tintColor(convertRawProp(rawProps, "tintColor", sourceProps.tintColor, {})), - onTintColor(convertRawProp(rawProps, "onTintColor", sourceProps.onTintColor, {})), - thumbTintColor(convertRawProp(rawProps, "thumbTintColor", sourceProps.thumbTintColor, {})), - thumbColor(convertRawProp(rawProps, "thumbColor", sourceProps.thumbColor, {})), - trackColorForFalse(convertRawProp(rawProps, "trackColorForFalse", sourceProps.trackColorForFalse, {})), - trackColorForTrue(convertRawProp(rawProps, "trackColorForTrue", sourceProps.trackColorForTrue, {})) - {} -InputAccessoryProps::InputAccessoryProps( - const InputAccessoryProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor, {})) - {} -UnimplementedNativeViewProps::UnimplementedNativeViewProps( - const UnimplementedNativeViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - name(convertRawProp(rawProps, "name", sourceProps.name, {""})) - {} -ModalHostViewProps::ModalHostViewProps( - const ModalHostViewProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - animationType(convertRawProp(rawProps, "animationType", sourceProps.animationType, {ModalHostViewAnimationType::None})), - presentationStyle(convertRawProp(rawProps, "presentationStyle", sourceProps.presentationStyle, {ModalHostViewPresentationStyle::FullScreen})), - transparent(convertRawProp(rawProps, "transparent", sourceProps.transparent, {false})), - statusBarTranslucent(convertRawProp(rawProps, "statusBarTranslucent", sourceProps.statusBarTranslucent, {false})), - hardwareAccelerated(convertRawProp(rawProps, "hardwareAccelerated", sourceProps.hardwareAccelerated, {false})), - animated(convertRawProp(rawProps, "animated", sourceProps.animated, {false})), - supportedOrientations(convertRawProp(rawProps, "supportedOrientations", sourceProps.supportedOrientations, {static_cast(ModalHostViewSupportedOrientations::Portrait)})), - identifier(convertRawProp(rawProps, "identifier", sourceProps.identifier, {0})) - {} - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.h b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.h deleted file mode 100644 index b968f7e266817e..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/Props.h +++ /dev/null @@ -1,529 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GeneratePropsH.js - */ -#pragma once - -#include -#include -#include -#include -#include - -namespace facebook { -namespace react { - -enum class ActivityIndicatorViewSize { Small, Large }; - -static inline void fromRawValue(const RawValue &value, ActivityIndicatorViewSize &result) { - auto string = (std::string)value; - if (string == "small") { result = ActivityIndicatorViewSize::Small; return; } - if (string == "large") { result = ActivityIndicatorViewSize::Large; return; } - abort(); -} - -static inline std::string toString(const ActivityIndicatorViewSize &value) { - switch (value) { - case ActivityIndicatorViewSize::Small: return "small"; - case ActivityIndicatorViewSize::Large: return "large"; - } -} - -class ActivityIndicatorViewProps final : public ViewProps { - public: - ActivityIndicatorViewProps() = default; - ActivityIndicatorViewProps(const ActivityIndicatorViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool hidesWhenStopped{false}; - bool animating{false}; - SharedColor color{}; - ActivityIndicatorViewSize size{ActivityIndicatorViewSize::Small}; -}; - -enum class DatePickerMinuteInterval { MinuteInterval1 = 1, MinuteInterval2 = 2, MinuteInterval3 = 3, MinuteInterval4 = 4, MinuteInterval5 = 5, MinuteInterval6 = 6, MinuteInterval10 = 10, MinuteInterval12 = 12, MinuteInterval15 = 15, MinuteInterval20 = 20, MinuteInterval30 = 30 }; - -static inline void fromRawValue(const RawValue &value, DatePickerMinuteInterval &result) { - assert(value.hasType()); - auto integerValue = (int)value; - switch (integerValue) { - case 1: - result = DatePickerMinuteInterval::MinuteInterval1; - return; - case 2: - result = DatePickerMinuteInterval::MinuteInterval2; - return; - case 3: - result = DatePickerMinuteInterval::MinuteInterval3; - return; - case 4: - result = DatePickerMinuteInterval::MinuteInterval4; - return; - case 5: - result = DatePickerMinuteInterval::MinuteInterval5; - return; - case 6: - result = DatePickerMinuteInterval::MinuteInterval6; - return; - case 10: - result = DatePickerMinuteInterval::MinuteInterval10; - return; - case 12: - result = DatePickerMinuteInterval::MinuteInterval12; - return; - case 15: - result = DatePickerMinuteInterval::MinuteInterval15; - return; - case 20: - result = DatePickerMinuteInterval::MinuteInterval20; - return; - case 30: - result = DatePickerMinuteInterval::MinuteInterval30; - return; - } - abort(); -} - -static inline std::string toString(const DatePickerMinuteInterval &value) { - switch (value) { - case DatePickerMinuteInterval::MinuteInterval1: return "1"; - case DatePickerMinuteInterval::MinuteInterval2: return "2"; - case DatePickerMinuteInterval::MinuteInterval3: return "3"; - case DatePickerMinuteInterval::MinuteInterval4: return "4"; - case DatePickerMinuteInterval::MinuteInterval5: return "5"; - case DatePickerMinuteInterval::MinuteInterval6: return "6"; - case DatePickerMinuteInterval::MinuteInterval10: return "10"; - case DatePickerMinuteInterval::MinuteInterval12: return "12"; - case DatePickerMinuteInterval::MinuteInterval15: return "15"; - case DatePickerMinuteInterval::MinuteInterval20: return "20"; - case DatePickerMinuteInterval::MinuteInterval30: return "30"; - } -} -enum class DatePickerMode { Date, Time, Datetime }; - -static inline void fromRawValue(const RawValue &value, DatePickerMode &result) { - auto string = (std::string)value; - if (string == "date") { result = DatePickerMode::Date; return; } - if (string == "time") { result = DatePickerMode::Time; return; } - if (string == "datetime") { result = DatePickerMode::Datetime; return; } - abort(); -} - -static inline std::string toString(const DatePickerMode &value) { - switch (value) { - case DatePickerMode::Date: return "date"; - case DatePickerMode::Time: return "time"; - case DatePickerMode::Datetime: return "datetime"; - } -} - -class DatePickerProps final : public ViewProps { - public: - DatePickerProps() = default; - DatePickerProps(const DatePickerProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - Float date{0.0}; - Float initialDate{0.0}; - std::string locale{}; - Float maximumDate{0.0}; - Float minimumDate{0.0}; - DatePickerMinuteInterval minuteInterval{DatePickerMinuteInterval::MinuteInterval1}; - DatePickerMode mode{DatePickerMode::Date}; - Float timeZoneOffsetInMinutes{0.0}; -}; - -enum class AndroidDrawerLayoutKeyboardDismissMode { None, OnDrag }; - -static inline void fromRawValue(const RawValue &value, AndroidDrawerLayoutKeyboardDismissMode &result) { - auto string = (std::string)value; - if (string == "none") { result = AndroidDrawerLayoutKeyboardDismissMode::None; return; } - if (string == "on-drag") { result = AndroidDrawerLayoutKeyboardDismissMode::OnDrag; return; } - abort(); -} - -static inline std::string toString(const AndroidDrawerLayoutKeyboardDismissMode &value) { - switch (value) { - case AndroidDrawerLayoutKeyboardDismissMode::None: return "none"; - case AndroidDrawerLayoutKeyboardDismissMode::OnDrag: return "on-drag"; - } -} -enum class AndroidDrawerLayoutDrawerPosition { Left, Right }; - -static inline void fromRawValue(const RawValue &value, AndroidDrawerLayoutDrawerPosition &result) { - auto string = (std::string)value; - if (string == "left") { result = AndroidDrawerLayoutDrawerPosition::Left; return; } - if (string == "right") { result = AndroidDrawerLayoutDrawerPosition::Right; return; } - abort(); -} - -static inline std::string toString(const AndroidDrawerLayoutDrawerPosition &value) { - switch (value) { - case AndroidDrawerLayoutDrawerPosition::Left: return "left"; - case AndroidDrawerLayoutDrawerPosition::Right: return "right"; - } -} -enum class AndroidDrawerLayoutDrawerLockMode { Unlocked, LockedClosed, LockedOpen }; - -static inline void fromRawValue(const RawValue &value, AndroidDrawerLayoutDrawerLockMode &result) { - auto string = (std::string)value; - if (string == "unlocked") { result = AndroidDrawerLayoutDrawerLockMode::Unlocked; return; } - if (string == "locked-closed") { result = AndroidDrawerLayoutDrawerLockMode::LockedClosed; return; } - if (string == "locked-open") { result = AndroidDrawerLayoutDrawerLockMode::LockedOpen; return; } - abort(); -} - -static inline std::string toString(const AndroidDrawerLayoutDrawerLockMode &value) { - switch (value) { - case AndroidDrawerLayoutDrawerLockMode::Unlocked: return "unlocked"; - case AndroidDrawerLayoutDrawerLockMode::LockedClosed: return "locked-closed"; - case AndroidDrawerLayoutDrawerLockMode::LockedOpen: return "locked-open"; - } -} - -class AndroidDrawerLayoutProps final : public ViewProps { - public: - AndroidDrawerLayoutProps() = default; - AndroidDrawerLayoutProps(const AndroidDrawerLayoutProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - AndroidDrawerLayoutKeyboardDismissMode keyboardDismissMode{AndroidDrawerLayoutKeyboardDismissMode::None}; - SharedColor drawerBackgroundColor{}; - AndroidDrawerLayoutDrawerPosition drawerPosition{AndroidDrawerLayoutDrawerPosition::Left}; - Float drawerWidth{}; - AndroidDrawerLayoutDrawerLockMode drawerLockMode{AndroidDrawerLayoutDrawerLockMode::Unlocked}; - SharedColor statusBarBackgroundColor{}; -}; - -class RCTMaskedViewProps final : public ViewProps { - public: - RCTMaskedViewProps() = default; - RCTMaskedViewProps(const RCTMaskedViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - -}; - -class AndroidProgressBarProps final : public ViewProps { - public: - AndroidProgressBarProps() = default; - AndroidProgressBarProps(const AndroidProgressBarProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - std::string styleAttr{}; - std::string typeAttr{}; - bool indeterminate{false}; - double progress{0.0}; - bool animating{true}; - SharedColor color{}; - std::string testID{""}; -}; - -enum class RCTProgressViewProgressViewStyle { Default, Bar }; - -static inline void fromRawValue(const RawValue &value, RCTProgressViewProgressViewStyle &result) { - auto string = (std::string)value; - if (string == "default") { result = RCTProgressViewProgressViewStyle::Default; return; } - if (string == "bar") { result = RCTProgressViewProgressViewStyle::Bar; return; } - abort(); -} - -static inline std::string toString(const RCTProgressViewProgressViewStyle &value) { - switch (value) { - case RCTProgressViewProgressViewStyle::Default: return "default"; - case RCTProgressViewProgressViewStyle::Bar: return "bar"; - } -} - -class RCTProgressViewProps final : public ViewProps { - public: - RCTProgressViewProps() = default; - RCTProgressViewProps(const RCTProgressViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - RCTProgressViewProgressViewStyle progressViewStyle{RCTProgressViewProgressViewStyle::Default}; - Float progress{0.0}; - SharedColor progressTintColor{}; - SharedColor trackTintColor{}; - ImageSource progressImage{}; - ImageSource trackImage{}; -}; - -class AndroidSwipeRefreshLayoutProps final : public ViewProps { - public: - AndroidSwipeRefreshLayoutProps() = default; - AndroidSwipeRefreshLayoutProps(const AndroidSwipeRefreshLayoutProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool enabled{true}; - std::vector colors{}; - SharedColor progressBackgroundColor{}; - int size{1}; - Float progressViewOffset{0.0}; - bool refreshing{false}; -}; - -class PullToRefreshViewProps final : public ViewProps { - public: - PullToRefreshViewProps() = default; - PullToRefreshViewProps(const PullToRefreshViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - SharedColor tintColor{}; - SharedColor titleColor{}; - std::string title{}; - bool refreshing{false}; -}; - -class SafeAreaViewProps final : public ViewProps { - public: - SafeAreaViewProps() = default; - SafeAreaViewProps(const SafeAreaViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool emulateUnlessSupported{false}; -}; - -class RCTSegmentedControlProps final : public ViewProps { - public: - RCTSegmentedControlProps() = default; - RCTSegmentedControlProps(const RCTSegmentedControlProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - std::vector values{}; - int selectedIndex{0}; - bool enabled{true}; - SharedColor tintColor{}; - SharedColor textColor{}; - SharedColor backgroundColor{}; - bool momentary{false}; -}; - -class SliderProps final : public ViewProps { - public: - SliderProps() = default; - SliderProps(const SliderProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool disabled{false}; - bool enabled{true}; - ImageSource maximumTrackImage{}; - SharedColor maximumTrackTintColor{}; - double maximumValue{1.0}; - ImageSource minimumTrackImage{}; - SharedColor minimumTrackTintColor{}; - double minimumValue{0.0}; - double step{0.0}; - std::string testID{""}; - ImageSource thumbImage{}; - SharedColor thumbTintColor{}; - ImageSource trackImage{}; - double value{0.0}; -}; - -class AndroidSwitchProps final : public ViewProps { - public: - AndroidSwitchProps() = default; - AndroidSwitchProps(const AndroidSwitchProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool disabled{false}; - bool enabled{true}; - SharedColor thumbColor{}; - SharedColor trackColorForFalse{}; - SharedColor trackColorForTrue{}; - bool value{false}; - bool on{false}; - SharedColor thumbTintColor{}; - SharedColor trackTintColor{}; -}; - -class SwitchProps final : public ViewProps { - public: - SwitchProps() = default; - SwitchProps(const SwitchProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool disabled{false}; - bool value{false}; - SharedColor tintColor{}; - SharedColor onTintColor{}; - SharedColor thumbTintColor{}; - SharedColor thumbColor{}; - SharedColor trackColorForFalse{}; - SharedColor trackColorForTrue{}; -}; - -class InputAccessoryProps final : public ViewProps { - public: - InputAccessoryProps() = default; - InputAccessoryProps(const InputAccessoryProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - SharedColor backgroundColor{}; -}; - -class UnimplementedNativeViewProps final : public ViewProps { - public: - UnimplementedNativeViewProps() = default; - UnimplementedNativeViewProps(const UnimplementedNativeViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - std::string name{""}; -}; - -enum class ModalHostViewAnimationType { None, Slide, Fade }; - -static inline void fromRawValue(const RawValue &value, ModalHostViewAnimationType &result) { - auto string = (std::string)value; - if (string == "none") { result = ModalHostViewAnimationType::None; return; } - if (string == "slide") { result = ModalHostViewAnimationType::Slide; return; } - if (string == "fade") { result = ModalHostViewAnimationType::Fade; return; } - abort(); -} - -static inline std::string toString(const ModalHostViewAnimationType &value) { - switch (value) { - case ModalHostViewAnimationType::None: return "none"; - case ModalHostViewAnimationType::Slide: return "slide"; - case ModalHostViewAnimationType::Fade: return "fade"; - } -} -enum class ModalHostViewPresentationStyle { FullScreen, PageSheet, FormSheet, OverFullScreen }; - -static inline void fromRawValue(const RawValue &value, ModalHostViewPresentationStyle &result) { - auto string = (std::string)value; - if (string == "fullScreen") { result = ModalHostViewPresentationStyle::FullScreen; return; } - if (string == "pageSheet") { result = ModalHostViewPresentationStyle::PageSheet; return; } - if (string == "formSheet") { result = ModalHostViewPresentationStyle::FormSheet; return; } - if (string == "overFullScreen") { result = ModalHostViewPresentationStyle::OverFullScreen; return; } - abort(); -} - -static inline std::string toString(const ModalHostViewPresentationStyle &value) { - switch (value) { - case ModalHostViewPresentationStyle::FullScreen: return "fullScreen"; - case ModalHostViewPresentationStyle::PageSheet: return "pageSheet"; - case ModalHostViewPresentationStyle::FormSheet: return "formSheet"; - case ModalHostViewPresentationStyle::OverFullScreen: return "overFullScreen"; - } -} -using ModalHostViewSupportedOrientationsMask = uint32_t; - -enum class ModalHostViewSupportedOrientations: ModalHostViewSupportedOrientationsMask { - Portrait = 1 << 0, - PortraitUpsideDown = 1 << 1, - Landscape = 1 << 2, - LandscapeLeft = 1 << 3, - LandscapeRight = 1 << 4 -}; - -constexpr bool operator&( - ModalHostViewSupportedOrientationsMask const lhs, - enum ModalHostViewSupportedOrientations const rhs) { - return lhs & static_cast(rhs); -} - -constexpr ModalHostViewSupportedOrientationsMask operator|( - ModalHostViewSupportedOrientationsMask const lhs, - enum ModalHostViewSupportedOrientations const rhs) { - return lhs | static_cast(rhs); -} - -constexpr void operator|=( - ModalHostViewSupportedOrientationsMask &lhs, - enum ModalHostViewSupportedOrientations const rhs) { - lhs = lhs | static_cast(rhs); -} - -static inline void fromRawValue(const RawValue &value, ModalHostViewSupportedOrientationsMask &result) { - auto items = std::vector{value}; - for (const auto &item : items) { - if (item == "portrait") { - result |= ModalHostViewSupportedOrientations::Portrait; - continue; - } - if (item == "portrait-upside-down") { - result |= ModalHostViewSupportedOrientations::PortraitUpsideDown; - continue; - } - if (item == "landscape") { - result |= ModalHostViewSupportedOrientations::Landscape; - continue; - } - if (item == "landscape-left") { - result |= ModalHostViewSupportedOrientations::LandscapeLeft; - continue; - } - if (item == "landscape-right") { - result |= ModalHostViewSupportedOrientations::LandscapeRight; - continue; - } - abort(); - } -} - -static inline std::string toString(const ModalHostViewSupportedOrientationsMask &value) { - auto result = std::string{}; - auto separator = std::string{", "}; - - if (value & ModalHostViewSupportedOrientations::Portrait) { - result += "portrait" + separator; - } - if (value & ModalHostViewSupportedOrientations::PortraitUpsideDown) { - result += "portrait-upside-down" + separator; - } - if (value & ModalHostViewSupportedOrientations::Landscape) { - result += "landscape" + separator; - } - if (value & ModalHostViewSupportedOrientations::LandscapeLeft) { - result += "landscape-left" + separator; - } - if (value & ModalHostViewSupportedOrientations::LandscapeRight) { - result += "landscape-right" + separator; - } - if (!result.empty()) { - result.erase(result.length() - separator.length()); - } - return result; -} - -class ModalHostViewProps final : public ViewProps { - public: - ModalHostViewProps() = default; - ModalHostViewProps(const ModalHostViewProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - ModalHostViewAnimationType animationType{ModalHostViewAnimationType::None}; - ModalHostViewPresentationStyle presentationStyle{ModalHostViewPresentationStyle::FullScreen}; - bool transparent{false}; - bool statusBarTranslucent{false}; - bool hardwareAccelerated{false}; - bool animated{false}; - ModalHostViewSupportedOrientationsMask supportedOrientations{static_cast(ModalHostViewSupportedOrientations::Portrait)}; - int identifier{0}; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.cpp b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.cpp deleted file mode 100644 index befdb19c30df35..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GenerateShadowNodeCpp.js - */ - -#include - -namespace facebook { -namespace react { - -extern const char ActivityIndicatorViewComponentName[] = "ActivityIndicatorView"; -extern const char DatePickerComponentName[] = "DatePicker"; -extern const char AndroidDrawerLayoutComponentName[] = "AndroidDrawerLayout"; -extern const char RCTMaskedViewComponentName[] = "RCTMaskedView"; -extern const char RCTProgressViewComponentName[] = "RCTProgressView"; -extern const char AndroidSwipeRefreshLayoutComponentName[] = "AndroidSwipeRefreshLayout"; -extern const char PullToRefreshViewComponentName[] = "PullToRefreshView"; -extern const char RCTSegmentedControlComponentName[] = "RCTSegmentedControl"; -extern const char SwitchComponentName[] = "Switch"; -extern const char UnimplementedNativeViewComponentName[] = "UnimplementedNativeView"; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.h b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.h deleted file mode 100644 index f8a84f5836b01b..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/jni/react/renderer/components/rncore/ShadowNodes.h +++ /dev/null @@ -1,117 +0,0 @@ - -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @generated by codegen project: GenerateShadowNodeH.js - */ - -#pragma once - -#include -#include -#include - -namespace facebook { -namespace react { - -extern const char ActivityIndicatorViewComponentName[]; - -/* - * `ShadowNode` for component. - */ -using ActivityIndicatorViewShadowNode = ConcreteViewShadowNode< - ActivityIndicatorViewComponentName, - ActivityIndicatorViewProps>; - -extern const char DatePickerComponentName[]; - -/* - * `ShadowNode` for component. - */ -using DatePickerShadowNode = ConcreteViewShadowNode< - DatePickerComponentName, - DatePickerProps, -DatePickerEventEmitter>; - -extern const char AndroidDrawerLayoutComponentName[]; - -/* - * `ShadowNode` for component. - */ -using AndroidDrawerLayoutShadowNode = ConcreteViewShadowNode< - AndroidDrawerLayoutComponentName, - AndroidDrawerLayoutProps, -AndroidDrawerLayoutEventEmitter>; - -extern const char RCTMaskedViewComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RCTMaskedViewShadowNode = ConcreteViewShadowNode< - RCTMaskedViewComponentName, - RCTMaskedViewProps>; - -extern const char RCTProgressViewComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RCTProgressViewShadowNode = ConcreteViewShadowNode< - RCTProgressViewComponentName, - RCTProgressViewProps>; - -extern const char AndroidSwipeRefreshLayoutComponentName[]; - -/* - * `ShadowNode` for component. - */ -using AndroidSwipeRefreshLayoutShadowNode = ConcreteViewShadowNode< - AndroidSwipeRefreshLayoutComponentName, - AndroidSwipeRefreshLayoutProps, -AndroidSwipeRefreshLayoutEventEmitter>; - -extern const char PullToRefreshViewComponentName[]; - -/* - * `ShadowNode` for component. - */ -using PullToRefreshViewShadowNode = ConcreteViewShadowNode< - PullToRefreshViewComponentName, - PullToRefreshViewProps, -PullToRefreshViewEventEmitter>; - -extern const char RCTSegmentedControlComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RCTSegmentedControlShadowNode = ConcreteViewShadowNode< - RCTSegmentedControlComponentName, - RCTSegmentedControlProps, -RCTSegmentedControlEventEmitter>; - -extern const char SwitchComponentName[]; - -/* - * `ShadowNode` for component. - */ -using SwitchShadowNode = ConcreteViewShadowNode< - SwitchComponentName, - SwitchProps, -SwitchEventEmitter>; - -extern const char UnimplementedNativeViewComponentName[]; - -/* - * `ShadowNode` for component. - */ -using UnimplementedNativeViewShadowNode = ConcreteViewShadowNode< - UnimplementedNativeViewComponentName, - UnimplementedNativeViewProps>; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index 76c613b0f466e7..8340d30515c536 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -136,7 +136,6 @@ include $(REACT_SRC_DIR)/reactperflogger/jni/Android.mk include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk ifeq ($(BUILD_FABRIC),true) - include $(REACT_SRC_DIR)/viewmanagers/jni/Android.mk include $(REACT_SRC_DIR)/fabric/jni/Android.mk endif diff --git a/ReactCommon/react/renderer/components/modal/Android.mk b/ReactCommon/react/renderer/components/modal/Android.mk index dd404e8dbda309..fd6e0ab65527d4 100644 --- a/ReactCommon/react/renderer/components/modal/Android.mk +++ b/ReactCommon/react/renderer/components/modal/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_image libreact_render_uimanager libreact_render_imagemanager libreact_render_components_view libreact_render_componentregistry libreact_render_viewmanagers +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_image libreact_render_uimanager libreact_render_imagemanager libreact_render_components_view libreact_render_componentregistry libreact_codegen_rncore include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/picker/Android.mk b/ReactCommon/react/renderer/components/picker/Android.mk index be55965cece467..a00db4ffb35bfc 100644 --- a/ReactCommon/react/renderer/components/picker/Android.mk +++ b/ReactCommon/react/renderer/components/picker/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_components_view libreact_render_componentregistry libreact_render_viewmanagers +LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_components_view libreact_render_componentregistry libreact_codegen_rncore include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/progressbar/Android.mk b/ReactCommon/react/renderer/components/progressbar/Android.mk index f17cb34c809c55..ad9a268c434986 100644 --- a/ReactCommon/react/renderer/components/progressbar/Android.mk +++ b/ReactCommon/react/renderer/components/progressbar/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libfbjni libreact_render_viewmanagers libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_view +LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_view include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/slider/Android.mk b/ReactCommon/react/renderer/components/slider/Android.mk index 23e58023b81d81..a687de48bd0632 100644 --- a/ReactCommon/react/renderer/components/slider/Android.mk +++ b/ReactCommon/react/renderer/components/slider/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libfbjni libreact_render_viewmanagers libreact_render_imagemanager libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libreact_render_components_image libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_view +LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreact_render_imagemanager libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libreact_render_components_image libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_view include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/renderer/components/switch/Android.mk b/ReactCommon/react/renderer/components/switch/Android.mk index 65be95635a04d8..4805dc1292fdd6 100644 --- a/ReactCommon/react/renderer/components/switch/Android.mk +++ b/ReactCommon/react/renderer/components/switch/Android.mk @@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libfbjni libreact_render_viewmanagers libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_view +LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_components_view include $(BUILD_SHARED_LIBRARY) diff --git a/packages/react-native-codegen/src/generators/RNCodegen.js b/packages/react-native-codegen/src/generators/RNCodegen.js index b4da4132056410..06cf6f07845623 100644 --- a/packages/react-native-codegen/src/generators/RNCodegen.js +++ b/packages/react-native-codegen/src/generators/RNCodegen.js @@ -77,12 +77,15 @@ const GENERATORS = { ], // TODO: Refactor this to consolidate various C++ output variation instead of forking per platform. componentsAndroid: [ - // TODO: enable C++ output below: - // generateComponentDescriptorH.generate, - // generateEventEmitterCpp.generate, - // generateEventEmitterH.generate, - // generatePropsCpp.generate, - // generatePropsH.generate, + // JNI/C++ files + generateComponentDescriptorH.generate, + generateEventEmitterCpp.generate, + generateEventEmitterH.generate, + generatePropsCpp.generate, + generatePropsH.generate, + generateShadowNodeCpp.generate, + generateShadowNodeH.generate, + // Java files generatePropsJavaInterface.generate, generatePropsJavaDelegate.generate, ], @@ -93,6 +96,8 @@ const GENERATORS = { generateComponentHObjCpp.generate, generatePropsCpp.generate, generatePropsH.generate, + generateShadowNodeCpp.generate, + generateShadowNodeH.generate, ], modulesAndroid: [ GenerateModuleJniCpp.generate, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js index d611a6be20bd0a..a83207961bf120 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js @@ -61,6 +61,7 @@ std::shared_ptr ${libraryName}_ModuleProvider(const std::string mod `; }; +// Note: this Android.mk template includes dependencies for both NativeModule and components. const AndroidMkTemplate = ({libraryName}: $ReadOnly<{libraryName: string}>) => { return `# Copyright (c) Facebook, Inc. and its affiliates. # @@ -71,15 +72,15 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := ${libraryName} +LOCAL_MODULE := react_codegen_${libraryName} LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/${libraryName}/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/${libraryName} -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi @@ -122,7 +123,7 @@ module.exports = { [ 'jni/Android.mk', AndroidMkTemplate({ - libraryName: `react_codegen_${libraryName.toLowerCase()}`, + libraryName: `${libraryName.toLowerCase()}`, }), ], ]); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap index ac403bf8d4b3fb..412b15cb456707 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap @@ -48,11 +48,11 @@ LOCAL_MODULE := react_codegen_complex_objects LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/complex_objects/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/complex_objects -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi @@ -114,11 +114,11 @@ LOCAL_MODULE := react_codegen_empty_native_modules LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/empty_native_modules/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/empty_native_modules -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi @@ -180,11 +180,11 @@ LOCAL_MODULE := react_codegen_native_modules_with_type_aliases LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/native_modules_with_type_aliases/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/native_modules_with_type_aliases -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi @@ -254,11 +254,11 @@ LOCAL_MODULE := react_codegen_real_module_example LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/real_module_example/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/real_module_example -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi @@ -320,11 +320,11 @@ LOCAL_MODULE := react_codegen_simple_native_modules LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/simple_native_modules/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/simple_native_modules -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi @@ -394,11 +394,11 @@ LOCAL_MODULE := react_codegen_two_modules_different_files LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/two_modules_different_files/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/two_modules_different_files -LOCAL_SHARED_LIBRARIES := libreact_nativemodule_core +LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core libreact_render_components_view libreact_render_core libreact_render_graphics LOCAL_STATIC_LIBRARIES := libjsi diff --git a/packages/rn-tester/android/app/src/main/jni/Android.mk b/packages/rn-tester/android/app/src/main/jni/Android.mk index 09d4881d54fd66..e11ca0b62fbb6f 100644 --- a/packages/rn-tester/android/app/src/main/jni/Android.mk +++ b/packages/rn-tester/android/app/src/main/jni/Android.mk @@ -18,7 +18,7 @@ LOCAL_MODULE := rntester_appmodules LOCAL_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni -LOCAL_SHARED_LIBRARIES := libfbjni libreact_nativemodule_core libturbomodulejsijni libreact_codegen_rncore +LOCAL_SHARED_LIBRARIES := libfbjni libglog libfolly_json libyoga libreact_nativemodule_core libturbomodulejsijni libreact_render_components_view libreact_render_core libreact_render_graphics libreact_codegen_rncore LOCAL_STATIC_LIBRARIES := libsampleturbomodule LOCAL_CFLAGS := \ -DLOG_TAG=\"ReactNative\" diff --git a/scripts/generate-native-modules-specs-cli.js b/scripts/generate-native-modules-specs-cli.js index 81c645e9ec29c1..0412be9340d937 100644 --- a/scripts/generate-native-modules-specs-cli.js +++ b/scripts/generate-native-modules-specs-cli.js @@ -76,6 +76,21 @@ function generateSpec( generators: GENERATORS[platform], }, ); + + if (platform === 'android') { + // Move all components C++ files to a structured jni folder for now. + // Note: this should've been done by RNCodegen's generators, but: + // * the generators don't support platform option yet + // * this subdir structure is Android-only, not applicable to iOS + const files = fs.readdirSync(outputDirectory); + const jniOutputDirectory = `${outputDirectory}/jni/react/renderer/components/${libraryName}`; + mkdirp.sync(jniOutputDirectory); + files + .filter(f => f.endsWith('.h') || f.endsWith('.cpp')) + .forEach(f => { + fs.renameSync(`${outputDirectory}/${f}`, `${jniOutputDirectory}/${f}`); + }); + } } function main() { From 86ffbd0a272703bc143aa2e40d4ffbbccad6dc32 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 21 Dec 2020 22:41:06 -0800 Subject: [PATCH 0270/1810] RNTester Android: always compile Fabric files Summary: This commit makes both `:ReactAndroid` and `:rn-tester:android:app` always compile in Fabric codegen outputs. However, one may still enable/disable Fabric at runtime by setting `USE_FABRIC` env var (set to 1 or 0, default is 0). Note that we can't register custom components specific to the app, yet, so only the components in react-native github repo is covered by this commit. RNTester doesn't enable Fabric by default yet due to known UI bugs that haven't been addressed yet. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25674311 fbshipit-source-id: 8db660c959319250ebc683c84076677cf6489e94 --- ReactAndroid/build.gradle | 6 ------ ReactAndroid/src/main/jni/react/jni/Android.mk | 5 +---- ReactCommon/jsi/Android.mk | 6 +++--- packages/rn-tester/android/app/build.gradle | 4 ++-- scripts/generate-native-modules-specs-cli.js | 4 +--- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index d5fa04ca000698..3b3f973ade27a0 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -33,11 +33,6 @@ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") // - glog-0.3.5 def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES") -// The 'USE_FABRIC' environment variable will build Fabric C++ code into the bundle -// USE_FABRIC=0 will build RN excluding fabric -// USE_FABRIC=1 will build RN including fabric -def enableFabric = (System.getenv('USE_FABRIC') ?: '0').toBoolean() - // The Boost library is a very large download (>100MB). // If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable // and the build will use that. @@ -318,7 +313,6 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) { "REACT_COMMON_DIR=$projectDir/../ReactCommon", "REACT_GENERATED_SRC_DIR=$buildDir/generated/source", "REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react", - "BUILD_FABRIC=$enableFabric", "-C", file("src/main/jni/react/jni").absolutePath, "--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors() ) diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index 8340d30515c536..9831c1aeef2c0e 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -134,10 +134,7 @@ include $(REACT_SRC_DIR)/reactperflogger/jni/Android.mk # TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..." # Note: Update this only when ready to minimize breaking changes. include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk - -ifeq ($(BUILD_FABRIC),true) - include $(REACT_SRC_DIR)/fabric/jni/Android.mk -endif +include $(REACT_SRC_DIR)/fabric/jni/Android.mk # TODO(ramanpreet): # Why doesn't this import-module call generate a jscexecutor.so file? diff --git a/ReactCommon/jsi/Android.mk b/ReactCommon/jsi/Android.mk index 40c7042c16e375..6bc98f1b35fcc9 100644 --- a/ReactCommon/jsi/Android.mk +++ b/ReactCommon/jsi/Android.mk @@ -32,8 +32,8 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_CFLAGS := -fexceptions -frtti -O3 LOCAL_SHARED_LIBRARIES := libfolly_json libjsc glog -ifeq ($(BUILD_FABRIC),true) - LOCAL_CFLAGS += -DRN_FABRIC_ENABLED -endif +# TODO: Remove this flag when ready. +# Android has this enabled by default, but the flag is still needed for iOS. +LOCAL_CFLAGS += -DRN_FABRIC_ENABLED include $(BUILD_STATIC_LIBRARY) diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 13c150cb30dfc0..8855fff3fd2b9c 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -66,7 +66,7 @@ plugins { * // Root dir for all JS files for the app. Defaults to `root` above. * jsRootDir: "../..", * - * // Enable Fabric at build time and runtime. + * // Enable Fabric at runtime. * enableFabric: true, * * // Java package name to use for any codegen artifacts produced during build time. @@ -113,7 +113,7 @@ def enableProguardInReleaseBuilds = true def enableCodegen = project.ext.react.enableCodegen /** - * Build and enable Fabric in RN Tester app. + * Enable Fabric in RN Tester app. */ def enableFabric = project.ext.react.enableFabric diff --git a/scripts/generate-native-modules-specs-cli.js b/scripts/generate-native-modules-specs-cli.js index 0412be9340d937..600412f3399ea1 100644 --- a/scripts/generate-native-modules-specs-cli.js +++ b/scripts/generate-native-modules-specs-cli.js @@ -26,9 +26,7 @@ const path = require('path'); const USE_FABRIC = process.env.USE_FABRIC != null && !!process.env.USE_FABRIC; const GENERATORS = { - android: USE_FABRIC - ? ['componentsAndroid', 'modulesAndroid'] - : ['modulesAndroid'], + android: ['componentsAndroid', 'modulesAndroid'], ios: ['modulesIOS'], }; From f312e5ba84afcddaac326ed62eaf4e00c00cf480 Mon Sep 17 00:00:00 2001 From: empyrical Date: Tue, 22 Dec 2020 08:33:56 -0800 Subject: [PATCH 0271/1810] Update iOS Fabric-related files to compile on OSS (#29810) Summary: Original PR contents: This pull request updates the Podspecs and associated build scripts, and some source files so they build on OSS. RNTester now compiles with `fabric_enabled` again. The following changes have been made: * Various spots that were pointing to the old `ReactCommon/fabric` location have now been updated to `ReactCommon/react/renderer` * Files that were attempting to use internal FB header `FBRCTFabricComponentsPlugins.h` were changed to use `RCTFabricComponentsPlugins.h` * `RCTFabricComponentsPlugins` in OSS was updated to include the `Image` fabric component (thanks tsapeta) * Replaced old `generate-rncore.sh` build script with new `generate-rncore.js` script which does not require `flow-node` and uses the `react-native-codegen` API directly, so there is no longer any need for an interim `schema-rncore.json` file. * Updated Yoga podspec which wasn't fully synced with changes from the main Yoga repo * Updated Fabric podspec with additional needed subspecs Additions to PR by hramos: * Replaced use of generate-rncore scripts with the original generate-native-modules-specs.sh script, which is now generate-specs.sh and supports both codegen for Native Modules and Components now (TurboModules/Fabric). * Codegen now runs at build time as part of the Xcode build pipeline instead of as part of `pod install`. The build script is injected by the FBReactNativeSpec pod, as the pod is part of both Fabric and non-Fabric builds. ## Changelog [General] [Fixed] - RNTester compiles with `fabric_enabled` again Pull Request resolved: https://github.com/facebook/react-native/pull/29810 Test Plan: RNTester now compiles and runs in the simulator again when `fabric_enabled` is set to `true`. ``` cd xplat/js/react-native-github/packages/rn-tester USE_FABRIC=1 pod install open RNTesterPods.xcworkspace # Build and run ``` Reviewed By: fkgozali Differential Revision: D24058507 Pulled By: hramos fbshipit-source-id: 8b2ea3694e6cb9aa23f83f087e2995fd4320e2bb --- .gitignore | 3 +- .../FBReactNativeSpec.podspec | 29 ++- .../RCTActivityIndicatorViewComponentView.mm | 2 +- .../Picker/RCTPickerComponentView.mm | 2 +- .../RCTFabricComponentsPlugins.h | 1 + .../RCTFabricComponentsPlugins.mm | 1 + .../RCTSafeAreaViewComponentView.mm | 1 - .../RCTPullToRefreshViewComponentView.mm | 2 +- .../Slider/RCTSliderComponentView.mm | 2 +- .../Switch/RCTSwitchComponentView.mm | 2 +- .../RCTUnimplementedViewComponentView.mm | 2 +- React/React-RCTFabric.podspec | 10 +- ReactCommon/React-Fabric.podspec | 195 +++++++++++------- .../renderer/graphics/React-graphics.podspec | 14 +- ReactCommon/yoga/Yoga.podspec | 2 +- package.json | 4 +- .../plugin/CodegenPluginExtension.java | 2 +- packages/rn-tester/Podfile | 18 +- packages/rn-tester/Podfile.lock | 6 +- scripts/generate-rncore.sh | 14 -- ...les-specs-cli.js => generate-specs-cli.js} | 4 +- ...ive-modules-specs.sh => generate-specs.sh} | 41 ++-- scripts/react_native_pods.rb | 2 +- 23 files changed, 209 insertions(+), 150 deletions(-) delete mode 100755 scripts/generate-rncore.sh rename scripts/{generate-native-modules-specs-cli.js => generate-specs-cli.js} (96%) rename scripts/{generate-native-modules-specs.sh => generate-specs.sh} (65%) diff --git a/.gitignore b/.gitignore index 7dd758b61058ae..e71831ae100198 100644 --- a/.gitignore +++ b/.gitignore @@ -102,8 +102,7 @@ package-lock.json # react-native-codegen /Libraries/FBReactNativeSpec/FBReactNativeSpec /packages/react-native-codegen/lib -/ReactCommon/fabric/components/rncore/ -/schema-rncore.json +/ReactCommon/react/renderer/components/rncore/ # Visual studio .vscode diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec index 70e90d54ea439e..79493bdca4ebec 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -20,11 +20,27 @@ end react_native_path = File.join(__dir__, "..", "..") srcs_dir = File.join(__dir__, "..") -codegen_script_path = File.join(react_native_path, "scripts", "generate-native-modules-specs.sh") +codegen_script_path = File.join(react_native_path, "scripts", "generate-specs.sh") codegen_path = File.join(react_native_path, codegen_path_prefix, "react-native-codegen") -output_dir = File.join(__dir__, "FBReactNativeSpec") -generated_files = [File.join(output_dir, "FBReactNativeSpec.h"), File.join(output_dir, "FBReactNativeSpec-generated.mm")] codegen_command = "CODEGEN_PATH=#{codegen_path} sh '#{codegen_script_path}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"" +modules_output_dir = File.join(__dir__, "FBReactNativeSpec") +components_output_dir = File.join(react_native_path, "ReactCommon", "react", "renderer", "components", "rncore") +generated_filenames = [ "FBReactNativeSpec.h", "FBReactNativeSpec-generated.mm" ] +generated_files = generated_filenames.map { |filename| File.join(modules_output_dir, filename) } + +if ENV['USE_FABRIC'] == '1' + components_generated_filenames = [ + "ComponentDescriptors.h", + "EventEmitters.cpp", + "EventEmitters.h", + "Props.cpp", + "Props.h", + "RCTComponentViewHelpers.h", + "ShadowNodes.cpp", + "ShadowNodes.h" + ] + generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(components_output_dir, filename) }) +end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' folly_version = '2020.01.13.00' @@ -40,6 +56,7 @@ Pod::Spec.new do |s| s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.source = source s.source_files = "**/*.{c,h,m,mm,cpp}" + s.exclude_files = "jni" s.header_dir = "FBReactNativeSpec" s.pod_target_xcconfig = { @@ -55,11 +72,11 @@ Pod::Spec.new do |s| s.dependency "React-jsi", version s.dependency "ReactCommon/turbomodule/core", version - s.prepare_command = "mkdir -p #{output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}" + s.prepare_command = "mkdir -p #{modules_output_dir} #{components_output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}" s.script_phase = { - :name => 'Generate Native Modules Code', + :name => 'Generate Specs', :input_files => [srcs_dir], - :output_files => ["$(DERIVED_FILE_DIR)/FBReactNativeSpec-codegen.log"], + :output_files => ["$(DERIVED_FILE_DIR)/codegen.log"], :script => codegen_command, :execution_position => :before_compile } diff --git a/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm index 7b5a56999ed8be..f5c0a1e421deb8 100644 --- a/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ActivityIndicator/RCTActivityIndicatorViewComponentView.mm @@ -13,7 +13,7 @@ #import #import -#import "FBRCTFabricComponentsPlugins.h" +#import "RCTFabricComponentsPlugins.h" using namespace facebook::react; diff --git a/React/Fabric/Mounting/ComponentViews/Picker/RCTPickerComponentView.mm b/React/Fabric/Mounting/ComponentViews/Picker/RCTPickerComponentView.mm index d1a2037473a78d..d318e34984199c 100644 --- a/React/Fabric/Mounting/ComponentViews/Picker/RCTPickerComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Picker/RCTPickerComponentView.mm @@ -15,8 +15,8 @@ #import #import -#import "FBRCTFabricComponentsPlugins.h" #import "RCTConversions.h" +#import "RCTFabricComponentsPlugins.h" using namespace facebook::react; diff --git a/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h b/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h index 47cd8759fab861..b0b82ba221b55a 100644 --- a/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h +++ b/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h @@ -41,6 +41,7 @@ Class RCTParagraphCls(void) __attribute__((used)); Class RCTTextInputCls(void) __attribute__((used)); Class RCTInputAccessoryCls(void) __attribute__((used)); Class RCTViewCls(void) __attribute__((used)); +Class RCTImageCls(void) __attribute__((used)); #ifdef __cplusplus } diff --git a/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm b/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm index e5ed57f33af978..bad4843193a66c 100644 --- a/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm +++ b/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm @@ -30,6 +30,7 @@ {"TextInput", RCTTextInputCls}, {"InputAccessoryView", RCTInputAccessoryCls}, {"View", RCTViewCls}, + {"Image", RCTImageCls}, }; auto p = sFabricComponentsClassMap.find(name); diff --git a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm index ddc2cc5bccf251..1180a898cb03c4 100644 --- a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm @@ -10,7 +10,6 @@ #import #import #import -#import "FBRCTFabricComponentsPlugins.h" #import "RCTConversions.h" #import "RCTFabricComponentsPlugins.h" diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index afcec45afa68cc..6d89e699307df8 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -16,7 +16,7 @@ #import #import -#import "FBRCTFabricComponentsPlugins.h" +#import "RCTFabricComponentsPlugins.h" using namespace facebook::react; diff --git a/React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm b/React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm index af62366caa3be3..f9c4d89f9b10d9 100644 --- a/React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm @@ -15,7 +15,7 @@ #import #import -#import "FBRCTFabricComponentsPlugins.h" +#import "RCTFabricComponentsPlugins.h" using namespace facebook::react; diff --git a/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm b/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm index e680a25ba2827f..970414806e1cd9 100644 --- a/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm @@ -14,7 +14,7 @@ #import #import -#import "FBRCTFabricComponentsPlugins.h" +#import "RCTFabricComponentsPlugins.h" using namespace facebook::react; diff --git a/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm index d7eaa6c62a54fc..04e426d7ab9e5b 100644 --- a/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm @@ -16,7 +16,7 @@ #import -#import "FBRCTFabricComponentsPlugins.h" +#import "RCTFabricComponentsPlugins.h" using namespace facebook::react; diff --git a/React/React-RCTFabric.podspec b/React/React-RCTFabric.podspec index bca122846f75b0..833d67cd364e56 100644 --- a/React/React-RCTFabric.podspec +++ b/React/React-RCTFabric.podspec @@ -30,8 +30,7 @@ Pod::Spec.new do |s| s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "10.0" } s.source = source - s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}", - "Tests/**/*.{mm}" + s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}" s.exclude_files = "**/tests/*", "**/android/*", s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags @@ -45,5 +44,10 @@ Pod::Spec.new do |s| s.dependency "React-Core", version s.dependency "React-Fabric", version s.dependency "React-RCTImage", version - s.dependency "Folly/Fabric", folly_version + s.dependency "RCT-Folly/Fabric", folly_version + + s.test_spec 'Tests' do |test_spec| + test_spec.source_files = "Tests/**/*.{mm}" + test_spec.framework = "XCTest" + end end diff --git a/ReactCommon/React-Fabric.podspec b/ReactCommon/React-Fabric.podspec index 0bf38ed0c2f62a..5ffcdd2153741f 100644 --- a/ReactCommon/React-Fabric.podspec +++ b/ReactCommon/React-Fabric.podspec @@ -18,7 +18,7 @@ end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' folly_version = '2020.01.13.00' -folly_dep_name = 'Folly/Fabric' +folly_dep_name = 'RCT-Folly/Fabric' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -30,7 +30,6 @@ Pod::Spec.new do |s| s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "10.0" } s.source = source - s.prepare_command = File.read("../scripts/generate-rncore.sh") s.source_files = "dummyFile.cpp" s.library = "stdc++" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", @@ -44,12 +43,21 @@ Pod::Spec.new do |s| s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.subspec "animations" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "react/renderer/animations/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/animations/tests" + ss.header_dir = "react/renderer/animations" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + end + s.subspec "attributedstring" do |ss| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags - ss.source_files = "fabric/attributedstring/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*" - ss.header_dir = "react/attributedstring" + ss.source_files = "react/renderer/attributedstring/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/attributedstring/tests" + ss.header_dir = "react/renderer/attributedstring" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end @@ -57,13 +65,13 @@ Pod::Spec.new do |s| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags ss.source_files = "better/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*" + ss.exclude_files = "better/tests" ss.header_dir = "better" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end s.subspec "config" do |ss| - ss.source_files = "config/*.{m,mm,cpp,h}" + ss.source_files = "react/config/*.{m,mm,cpp,h}" ss.header_dir = "react/config" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" } end @@ -71,121 +79,145 @@ Pod::Spec.new do |s| s.subspec "core" do |ss| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags - ss.source_files = "fabric/core/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/**/*" - ss.header_dir = "react/core" + ss.source_files = "react/renderer/core/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/core/tests" + ss.header_dir = "react/renderer/core" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end + s.subspec "componentregistry" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "react/renderer/componentregistry/**/*.{m,mm,cpp,h}" + ss.header_dir = "react/renderer/componentregistry" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + end + s.subspec "components" do |ss| ss.subspec "activityindicator" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/activityindicator/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/activityindicator" + sss.source_files = "react/renderer/components/activityindicator/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/activityindicator/tests" + sss.header_dir = "react/renderer/components/activityindicator" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "image" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/image/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/image" + sss.source_files = "react/renderer/components/image/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/image/tests" + sss.header_dir = "react/renderer/components/image" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + end + + ss.subspec "inputaccessory" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "react/renderer/components/inputaccessory/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/inputaccessory/tests" + sss.header_dir = "react/renderer/components/inputaccessory" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "legacyviewmanagerinterop" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/legacyviewmanagerinterop/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/legacyviewmanagerinterop" + sss.source_files = "react/renderer/components/legacyviewmanagerinterop/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/legacyviewmanagerinterop/tests" + sss.header_dir = "react/renderer/components/legacyviewmanagerinterop" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/Headers/Private/React-Core\"" } end ss.subspec "modal" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/modal/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/modal" + sss.source_files = "react/renderer/components/modal/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/modal/tests" + sss.header_dir = "react/renderer/components/modal" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + end + + ss.subspec "picker" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "react/renderer/components/picker/iospicker/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/picker/iospicker/tests" + sss.header_dir = "react/renderer/components/iospicker" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "rncore" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/rncore/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*", "fabric/components/rncore/*Tests.{h,cpp}", - # TODO: These should be re-enabled later when Codegen Native Module support is needed. - "fabric/components/rncore/rncore-generated.mm", "fabric/components/rncore/NativeModules.{h,cpp}" - sss.header_dir = "react/components/rncore" + sss.source_files = "react/renderer/components/rncore/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/rncore/tests" + sss.header_dir = "react/renderer/components/rncore" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "root" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/root/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/root" + sss.source_files = "react/renderer/components/root/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/root/tests" + sss.header_dir = "react/renderer/components/root" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "safeareaview" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/safeareaview/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/safeareaview" + sss.source_files = "react/renderer/components/safeareaview/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/safeareaview/tests" + sss.header_dir = "react/renderer/components/safeareaview" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "scrollview" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/scrollview/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/scrollview" + sss.source_files = "react/renderer/components/scrollview/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/scrollview/tests" + sss.header_dir = "react/renderer/components/scrollview" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "slider" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/slider/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*", - "**/android/*" - sss.header_dir = "react/components/slider" + sss.source_files = "react/renderer/components/slider/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/slider/tests/**/*", + "react/renderer/components/slider/platform/android" + sss.header_dir = "react/renderer/components/slider" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "text" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/text/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/text" + sss.source_files = "react/renderer/components/text/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/text/tests" + sss.header_dir = "react/renderer/components/text" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "textinput" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/textinput/iostextinput/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/iostextinput" + sss.source_files = "react/renderer/components/textinput/iostextinput/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/textinput/iostextinput/tests" + sss.header_dir = "react/renderer/components/iostextinput" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end ss.subspec "unimplementedview" do |sss| sss.dependency folly_dep_name, folly_version sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/unimplementedview/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/unimplementedview" + sss.source_files = "react/renderer/components/unimplementedview/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/unimplementedview/tests" + sss.header_dir = "react/renderer/components/unimplementedview" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end @@ -193,9 +225,9 @@ Pod::Spec.new do |s| sss.dependency folly_dep_name, folly_version sss.dependency "Yoga" sss.compiler_flags = folly_compiler_flags - sss.source_files = "fabric/components/view/**/*.{m,mm,cpp,h}" - sss.exclude_files = "**/tests/*" - sss.header_dir = "react/components/view" + sss.source_files = "react/renderer/components/view/**/*.{m,mm,cpp,h}" + sss.exclude_files = "react/renderer/components/view/tests" + sss.header_dir = "react/renderer/components/view" sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end end @@ -203,9 +235,9 @@ Pod::Spec.new do |s| s.subspec "debug" do |ss| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags - ss.source_files = "fabric/debug/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*" - ss.header_dir = "react/debug" + ss.source_files = "react/renderer/debug/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/debug/tests" + ss.header_dir = "react/renderer/debug" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end @@ -213,45 +245,64 @@ Pod::Spec.new do |s| ss.dependency "React-RCTImage", version ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags - ss.source_files = "fabric/imagemanager/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*", - "**/android/*", - "**/cxx/*" - ss.header_dir = "react/imagemanager" + ss.source_files = "react/renderer/imagemanager/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/imagemanager/tests", + "react/renderer/imagemanager/platform/android", + "react/renderer/imagemanager/platform/cxx" + ss.header_dir = "react/renderer/imagemanager" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end s.subspec "mounting" do |ss| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags - ss.source_files = "fabric/mounting/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*" - ss.header_dir = "react/mounting" + ss.source_files = "react/renderer/mounting/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/mounting/tests" + ss.header_dir = "react/renderer/mounting" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + end + + s.subspec "scheduler" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "react/renderer/scheduler/**/*.{m,mm,cpp,h}" + ss.header_dir = "react/renderer/scheduler" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + end + + s.subspec "templateprocessor" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "react/renderer/templateprocessor/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/templateprocessor/tests" + ss.header_dir = "react/renderer/templateprocessor" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end s.subspec "textlayoutmanager" do |ss| ss.dependency folly_dep_name, folly_version + ss.dependency "React-Fabric/uimanager" ss.compiler_flags = folly_compiler_flags - ss.source_files = "fabric/textlayoutmanager/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*", - "**/android/*", - "**/cxx/*" - ss.header_dir = "react/textlayoutmanager" + ss.source_files = "react/renderer/textlayoutmanager/platform/ios/**/*.{m,mm,cpp,h}", + "react/renderer/textlayoutmanager/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/textlayoutmanager/tests", + "react/renderer/textlayoutmanager/platform/android", + "react/renderer/textlayoutmanager/platform/cxx" + ss.header_dir = "react/renderer/textlayoutmanager" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end s.subspec "uimanager" do |ss| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags - ss.source_files = "fabric/uimanager/**/*.{m,mm,cpp,h}" - ss.exclude_files = "**/tests/*", - ss.header_dir = "react/uimanager" + ss.source_files = "react/renderer/uimanager/**/*.{m,mm,cpp,h}" + ss.exclude_files = "react/renderer/uimanager/tests" + ss.header_dir = "react/renderer/uimanager" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end s.subspec "utils" do |ss| - ss.source_files = "utils/*.{m,mm,cpp,h}" + ss.source_files = "react/utils/*.{m,mm,cpp,h}" ss.header_dir = "react/utils" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end diff --git a/ReactCommon/react/renderer/graphics/React-graphics.podspec b/ReactCommon/react/renderer/graphics/React-graphics.podspec index 30bffb22f09d7b..aebbc2cd293267 100644 --- a/ReactCommon/react/renderer/graphics/React-graphics.podspec +++ b/ReactCommon/react/renderer/graphics/React-graphics.podspec @@ -5,7 +5,7 @@ require "json" -package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json"))) +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "package.json"))) version = package['version'] source = { :git => 'https://github.com/facebook/react-native.git' } @@ -32,11 +32,11 @@ Pod::Spec.new do |s| s.library = "stdc++" s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.source_files = "**/*.{m,mm,cpp,h}" - s.exclude_files = "**/tests/*", - "**/android/*", - "**/cxx/*" - s.header_dir = "react/graphics" - s.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } + s.exclude_files = "tests", + "platform/android", + "platform/cxx" + s.header_dir = "react/renderer/graphics" + s.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_TARGET_SRCROOT)/../../../\" \"$(PODS_ROOT)/RCT-Folly\"" } - s.dependency "Folly/Fabric", folly_version + s.dependency "RCT-Folly/Fabric", folly_version end diff --git a/ReactCommon/yoga/Yoga.podspec b/ReactCommon/yoga/Yoga.podspec index 500dfee8e47ac5..b723a3410018da 100644 --- a/ReactCommon/yoga/Yoga.podspec +++ b/ReactCommon/yoga/Yoga.podspec @@ -51,7 +51,7 @@ Pod::Spec.new do |spec| source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.source_files = source_files - header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h' + header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGNode,YGStyle,YGValue}.h' header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.public_header_files = header_files end diff --git a/package.json b/package.json index 1f18019bde367d..5bd66383837161 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "README.md", "rn-get-polyfills.js", "scripts/compose-source-maps.js", - "scripts/generate-native-modules-specs.sh", - "scripts/generate-native-modules-specs-cli.js", + "scripts/generate-specs.sh", + "scripts/generate-specs-cli.js", "scripts/ios-configure-glog.sh", "scripts/launchPackager.bat", "scripts/launchPackager.command", diff --git a/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/plugin/CodegenPluginExtension.java b/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/plugin/CodegenPluginExtension.java index eecb4b88f861f9..4d734a1da7decc 100644 --- a/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/plugin/CodegenPluginExtension.java +++ b/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/plugin/CodegenPluginExtension.java @@ -34,7 +34,7 @@ public File codegenGenerateSchemaCLI() { } public File codegenGenerateNativeModuleSpecsCLI() { - return new File(this.reactNativeRootDir, "scripts/generate-native-modules-specs-cli.js"); + return new File(this.reactNativeRootDir, "scripts/generate-specs-cli.js"); } private String projectPathToLibraryName(final String projectPath) { diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index db37edcc38f3f2..26ef7308a49665 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -17,18 +17,26 @@ end def pods() project 'RNTesterPods.xcodeproj' - # Enable TurboModule + fabric_enabled = false + + # To use fabric: set the environment variable `USE_FABRIC` to 1, like below + # $ USE_FABRIC=1 bundle exec pod install + # or + # $ export USE_FABRIC=1 + # $ bundle exec pod install + if ENV['USE_FABRIC'] == '1' + puts "Building RNTester with Fabric enabled." + fabric_enabled = true + end + prefix_path = "../.." - use_react_native!(path: prefix_path, hermes_enabled: ENV['USE_HERMES'] == '1') + use_react_native!(path: prefix_path, fabric_enabled: fabric_enabled, hermes_enabled: ENV['USE_HERMES'] == '1') pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon" # Additional Pods which aren't included in the default Podfile pod 'React-RCTPushNotification', :path => "#{prefix_path}/Libraries/PushNotificationIOS" pod 'Yoga', :path => "#{prefix_path}/ReactCommon/yoga", :modular_headers => true # Additional Pods which are classed as unstable - # - # To use fabric: add `fabric_enabled` option to the use_react_native method above, like below - # use_react_native!(path: "..", fabric_enabled: true) end target 'RNTester' do diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index dca3e8b99c3fbd..61a95d29b96d37 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -490,7 +490,7 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 765701e4018375c2e423d955806400a39bdb9c63 + FBReactNativeSpec: 8e8b4f540947580f2a9ef54a443453c562d439cd Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a @@ -525,9 +525,9 @@ SPEC CHECKSUMS: React-RCTVibration: a1cce36dd452eb88296d99d80d66f2c5bd50aad4 React-runtimeexecutor: 53867815d0a01e53a2c901cb7f01076216c5c799 ReactCommon: d101410fc55088c91dc24595715c7b26ec760adf - Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 + Yoga: e37ade282f73232191786671781d052c84d0faa8 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: a36cc754d464f1cc28efaac3a4065fd58419f79d +PODFILE CHECKSUM: 486f12ff39a0c690fe414d7ffbbdaa371d51590b COCOAPODS: 1.10.0 diff --git a/scripts/generate-rncore.sh b/scripts/generate-rncore.sh deleted file mode 100755 index 5e67d91c812302..00000000000000 --- a/scripts/generate-rncore.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -# This script collects the "core" component schemas used by fabric -# then uses react-native-codegen to generate the component headers -# to a location that the podspecs expect. - -# shellcheck disable=SC2038 - -find "$PWD/../Libraries" -name "*NativeComponent.js" -print | xargs yarn flow-node packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js schema-rncore.json -yarn flow-node packages/react-native-codegen/buck_tests/generate-tests.js schema-rncore.json rncore ReactCommon/fabric/components/rncore rncore diff --git a/scripts/generate-native-modules-specs-cli.js b/scripts/generate-specs-cli.js similarity index 96% rename from scripts/generate-native-modules-specs-cli.js rename to scripts/generate-specs-cli.js index 600412f3399ea1..72310cb54b7414 100644 --- a/scripts/generate-native-modules-specs-cli.js +++ b/scripts/generate-specs-cli.js @@ -23,11 +23,9 @@ const fs = require('fs'); const mkdirp = require('mkdirp'); const path = require('path'); -const USE_FABRIC = process.env.USE_FABRIC != null && !!process.env.USE_FABRIC; - const GENERATORS = { android: ['componentsAndroid', 'modulesAndroid'], - ios: ['modulesIOS'], + ios: ['componentsIOS', 'modulesIOS'], }; function generateSpec( diff --git a/scripts/generate-native-modules-specs.sh b/scripts/generate-specs.sh similarity index 65% rename from scripts/generate-native-modules-specs.sh rename to scripts/generate-specs.sh index b9b71b33134743..69de08b3dcc3e3 100755 --- a/scripts/generate-native-modules-specs.sh +++ b/scripts/generate-specs.sh @@ -5,18 +5,18 @@ # LICENSE file in the root directory of this source tree. # This script collects the JavaScript spec definitions for core -# native modules, then uses react-native-codegen to generate -# native code. +# native modules and components, then uses react-native-codegen +# to generate native code. # The script will use the local react-native-codegen package by # default. Optionally, set the CODEGEN_PATH to point to the # desired codegen library (e.g. when using react-native-codegen # from npm). # # Usage: -# ./scripts/generate-native-modules-specs.sh +# ./scripts/generate-specs.sh # -# Example: -# CODEGEN_PATH=.. ./scripts/generate-native-modules-specs.sh +# Examples: +# CODEGEN_PATH=.. ./scripts/generate-specs.sh # shellcheck disable=SC2038 @@ -27,6 +27,7 @@ TEMP_DIR=$(mktemp -d /tmp/react-native-codegen-XXXXXXXX) RN_DIR=$(cd "$THIS_DIR/.." && pwd) CODEGEN_PATH="${CODEGEN_PATH:-$(cd "$RN_DIR/packages/react-native-codegen" && pwd)}" YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" +USE_FABRIC="${USE_FABRIC:-0}" cleanup () { set +e @@ -38,12 +39,14 @@ describe () { printf "\\n\\n>>>>> %s\\n\\n\\n" "$1" } -run_codegen () { - SRCS_DIR=$1 - LIBRARY_NAME=$2 - OUTPUT_DIR=$3 +main() { + SRCS_DIR=$(cd "$RN_DIR/Libraries" && pwd) + + OUTPUT_DIR="$TEMP_DIR/out" + COMPONENTS_DIR="$RN_DIR/ReactCommon/react/renderer/components/rncore" + MODULES_DIR="$RN_DIR/Libraries/FBReactNativeSpec/FBReactNativeSpec" - SCHEMA_FILE="$TEMP_DIR/schema-$LIBRARY_NAME.json" + SCHEMA_FILE="$TEMP_DIR/schema.json" if [ ! -d "$CODEGEN_PATH/lib" ]; then describe "Building react-native-codegen package" @@ -58,21 +61,13 @@ run_codegen () { describe "Generating native code from schema (iOS)" pushd "$RN_DIR" >/dev/null || exit - "$YARN_BINARY" --silent node scripts/generate-native-modules-specs-cli.js ios "$SCHEMA_FILE" "$OUTPUT_DIR" + USE_FABRIC="$USE_FABRIC" "$YARN_BINARY" --silent node scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$OUTPUT_DIR" popd >/dev/null || exit -} -# Handle Core Modules -run_codegen_core_modules () { - LIBRARY_NAME="FBReactNativeSpec" - SRCS_DIR=$(cd "$RN_DIR/Libraries" && pwd) - OUTPUT_DIR="$SRCS_DIR/$LIBRARY_NAME/$LIBRARY_NAME" - - run_codegen "$SRCS_DIR" "$LIBRARY_NAME" "$OUTPUT_DIR" -} - -main() { - run_codegen_core_modules + mkdir -p "$COMPONENTS_DIR" "$MODULES_DIR" + mv "$OUTPUT_DIR/FBReactNativeSpec.h" "$OUTPUT_DIR/FBReactNativeSpec-generated.mm" "$MODULES_DIR" + find "$OUTPUT_DIR" -type f | xargs sed -i '' 's/FBReactNativeSpec/rncore/g' + cp -R "$OUTPUT_DIR/." "$COMPONENTS_DIR" } trap cleanup EXIT diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index b07641ffb6093d..1e28bee9e59468 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -55,7 +55,7 @@ def use_react_native! (options={}) if fabric_enabled pod 'React-Fabric', :path => "#{prefix}/ReactCommon" - pod 'React-graphics', :path => "#{prefix}/ReactCommon/fabric/graphics" + pod 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics" pod 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi" pod 'React-RCTFabric', :path => "#{prefix}/React" pod 'RCT-Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec" From bc0c5c98bbdfa34e0287cb664effceb79534ac00 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 22 Dec 2020 09:04:20 -0800 Subject: [PATCH 0272/1810] Move react-native-codegen/e2e/__tests__/modules/BUCK Reviewed By: PeteTheHeat Differential Revision: D25675408 fbshipit-source-id: 97f8070611f7f7707af9bd7dd9c9a59e8ad96125 --- packages/react-native-codegen/e2e/{__tests__/modules => }/BUCK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename packages/react-native-codegen/e2e/{__tests__/modules => }/BUCK (85%) diff --git a/packages/react-native-codegen/e2e/__tests__/modules/BUCK b/packages/react-native-codegen/e2e/BUCK similarity index 85% rename from packages/react-native-codegen/e2e/__tests__/modules/BUCK rename to packages/react-native-codegen/e2e/BUCK index 29df252313e6ea..d3d39491480b8e 100644 --- a/packages/react-native-codegen/e2e/__tests__/modules/BUCK +++ b/packages/react-native-codegen/e2e/BUCK @@ -5,7 +5,7 @@ react_native_module_flow_types_library( android_package_name = "com.facebook.fbreact.specs", js_srcs = glob( [ - "../../__test_fixtures__/modules/*.js", + "./__test_fixtures__/modules/*.js", ], ), ) From e5ecca39a8117f1b5503379bda146b9267eeeaee Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 22 Dec 2020 12:16:25 -0800 Subject: [PATCH 0273/1810] Prevent crash when blurring an image Summary: Changelog: [internal] Return original image instead of calling `abort()` when malloc fails. Should we show a redbox? I don't think so, the redbox wouldn't be actionable for product engineer. Reviewed By: PeteTheHeat Differential Revision: D25678532 fbshipit-source-id: dd44d5e87198a0f76767ea40fe111ed347a7669a --- Libraries/Image/RCTImageBlurUtils.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Libraries/Image/RCTImageBlurUtils.m b/Libraries/Image/RCTImageBlurUtils.m index 592f0239ed60fc..3ba8c64eac85d6 100644 --- a/Libraries/Image/RCTImageBlurUtils.m +++ b/Libraries/Image/RCTImageBlurUtils.m @@ -34,12 +34,13 @@ buffer1.rowBytes = buffer2.rowBytes = CGImageGetBytesPerRow(imageRef); size_t bytes = buffer1.rowBytes * buffer1.height; buffer1.data = malloc(bytes); + if (!buffer1.data) { + return inputImage; + } buffer2.data = malloc(bytes); - if (!buffer1.data || !buffer2.data) { - // CWE - 391 : Unchecked error condition - // https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html - // https://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c - abort(); + if (!buffer2.data) { + free(buffer1.data); + return inputImage; } // A description of how to compute the box kernel width from the Gaussian @@ -58,10 +59,9 @@ } void *tempBuffer = malloc(tempBufferSize); if (!tempBuffer) { - // CWE - 391 : Unchecked error condition - // https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html - // https://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c - abort(); + free(buffer1.data); + free(buffer2.data); + return inputImage; } //copy image data From eba31d285847ef70cf22ce83fe013efa95416e3c Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 22 Dec 2020 13:56:53 -0800 Subject: [PATCH 0274/1810] Back out "Cancel touches if surface touch handler can be prevented" Summary: Changelog: [internal] Causes assert in `_updateTouches` to be fired. Original commit changeset: 9e3cd4135138 Reviewed By: motiz88 Differential Revision: D25684453 fbshipit-source-id: a5394c622712e7b1c1c57cd663c2bba9161da333 --- React/Fabric/RCTSurfaceTouchHandler.mm | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index 6c06fa764b7a81..e556a3af6d1d72 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -410,14 +410,4 @@ - (BOOL)gestureRecognizer:(__unused UIGestureRecognizer *)gestureRecognizer return [self canBePreventedByGestureRecognizer:otherGestureRecognizer]; } -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer - shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer -{ - BOOL canBePrevented = [self canBePreventedByGestureRecognizer:otherGestureRecognizer]; - if (canBePrevented) { - [self reset]; - } - return NO; -} - @end From 1c895678cf13dda727f6c8cadd03c76db05d85dd Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Wed, 23 Dec 2020 01:11:00 -0800 Subject: [PATCH 0275/1810] Separate out pickScale Summary: Changelog: [Internal][Changed] - Separate `pickScale` implementation from AssetSourceResolver Reviewed By: motiz88 Differential Revision: D25520686 fbshipit-source-id: 7c5845d5e6f130e719cf8725224589031037a61d --- Libraries/Image/AssetSourcePickScale.js | 33 +++++++++++++++++++++++++ Libraries/Image/AssetSourceResolver.js | 27 ++++++-------------- Libraries/Image/resolveAssetSource.js | 3 ++- 3 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 Libraries/Image/AssetSourcePickScale.js diff --git a/Libraries/Image/AssetSourcePickScale.js b/Libraries/Image/AssetSourcePickScale.js new file mode 100644 index 00000000000000..70c35f3bcf34f8 --- /dev/null +++ b/Libraries/Image/AssetSourcePickScale.js @@ -0,0 +1,33 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +const PixelRatio = require('../Utilities/PixelRatio'); +function AssetSourcePickScale( + scales: Array, + deviceScale?: number, +): number { + if (deviceScale == null) { + deviceScale = PixelRatio.get(); + } + // Packager guarantees that `scales` array is sorted + for (let i = 0; i < scales.length; i++) { + if (scales[i] >= deviceScale) { + return scales[i]; + } + } + + // If nothing matches, device scale is larger than any available + // scales, so we return the biggest one. Unless the array is empty, + // in which case we default to 1 + return scales[scales.length - 1] || 1; +} +module.exports = AssetSourcePickScale; diff --git a/Libraries/Image/AssetSourceResolver.js b/Libraries/Image/AssetSourceResolver.js index 6c97f008e1bb21..4ddc2bf123050d 100644 --- a/Libraries/Image/AssetSourceResolver.js +++ b/Libraries/Image/AssetSourceResolver.js @@ -21,6 +21,7 @@ export type ResolvedAssetSource = {| import type {PackagerAsset} from '@react-native/assets/registry'; const PixelRatio = require('../Utilities/PixelRatio'); +const pickScale = require('./AssetSourcePickScale'); const Platform = require('../Utilities/Platform'); const invariant = require('invariant'); @@ -35,7 +36,7 @@ const { * Returns a path like 'assets/AwesomeModule/icon@2x.png' */ function getScaledAssetPath(asset): string { - const scale = AssetSourceResolver.pickScale(asset.scales, PixelRatio.get()); + const scale = pickScale(asset.scales, PixelRatio.get()); const scaleSuffix = scale === 1 ? '' : '@' + scale + 'x'; const assetDir = getBasePath(asset); return assetDir + '/' + asset.name + scaleSuffix + '.' + asset.type; @@ -45,7 +46,7 @@ function getScaledAssetPath(asset): string { * Returns a path like 'drawable-mdpi/icon.png' */ function getAssetPathInDrawableFolder(asset): string { - const scale = AssetSourceResolver.pickScale(asset.scales, PixelRatio.get()); + const scale = pickScale(asset.scales, PixelRatio.get()); const drawbleFolder = getAndroidResourceFolderName(asset, scale); const fileName = getAndroidResourceIdentifier(asset); return drawbleFolder + '/' + fileName + '.' + asset.type; @@ -154,26 +155,14 @@ class AssetSourceResolver { width: this.asset.width, height: this.asset.height, uri: source, - scale: AssetSourceResolver.pickScale(this.asset.scales, PixelRatio.get()), + scale: pickScale(this.asset.scales, PixelRatio.get()), }; } - static pickScale(scales: Array, deviceScale?: number): number { - if (deviceScale == null) { - deviceScale = PixelRatio.get(); - } - // Packager guarantees that `scales` array is sorted - for (let i = 0; i < scales.length; i++) { - if (scales[i] >= deviceScale) { - return scales[i]; - } - } - - // If nothing matches, device scale is larger than any available - // scales, so we return the biggest one. Unless the array is empty, - // in which case we default to 1 - return scales[scales.length - 1] || 1; - } + static pickScale: ( + scales: Array, + deviceScale?: number, + ) => number = pickScale; } module.exports = AssetSourceResolver; diff --git a/Libraries/Image/resolveAssetSource.js b/Libraries/Image/resolveAssetSource.js index 71df2005163baa..19e9607ace5585 100644 --- a/Libraries/Image/resolveAssetSource.js +++ b/Libraries/Image/resolveAssetSource.js @@ -14,6 +14,7 @@ const AssetRegistry = require('@react-native/assets/registry'); const AssetSourceResolver = require('./AssetSourceResolver'); +const AssetSourcePickScale = require('./AssetSourcePickScale'); import type {ResolvedAssetSource} from './AssetSourceResolver'; @@ -105,5 +106,5 @@ function resolveAssetSource(source: any): ?ResolvedAssetSource { } module.exports = resolveAssetSource; -module.exports.pickScale = AssetSourceResolver.pickScale; +module.exports.pickScale = AssetSourcePickScale; module.exports.setCustomSourceTransformer = setCustomSourceTransformer; From 369b3d2983c85d91aa7a8269b0d0bb9ecf90c573 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 23 Dec 2020 04:43:55 -0800 Subject: [PATCH 0276/1810] Remove unused methods from LayoutableShadowNode Summary: Changelog: [internal] These methods were not used, removing them. Reviewed By: shergin Differential Revision: D25680765 fbshipit-source-id: 7e44aa5b9c4ffa9d0264b573dcb7edc2ad2a74c3 --- .../renderer/core/LayoutableShadowNode.cpp | 7 ---- .../renderer/core/LayoutableShadowNode.h | 15 --------- .../core/tests/LayoutableShadowNodeTest.cpp | 33 ++++++++++++------- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index 3809740c83e72d..1b49fd9eb3627d 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -159,13 +159,6 @@ Point LayoutableShadowNode::getContentOriginOffset() const { return {0, 0}; } -LayoutMetrics LayoutableShadowNode::getRelativeLayoutMetrics( - LayoutableShadowNode const &ancestorLayoutableShadowNode, - LayoutInspectingPolicy policy) const { - return computeRelativeLayoutMetrics( - getFamily(), ancestorLayoutableShadowNode, policy); -} - LayoutableShadowNode::UnsharedList LayoutableShadowNode::getLayoutableChildNodes() const { LayoutableShadowNode::UnsharedList layoutableChildren; diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.h b/ReactCommon/react/renderer/core/LayoutableShadowNode.h index 83ad3273a1397b..b30f1d2124213a 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.h +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.h @@ -122,21 +122,6 @@ class LayoutableShadowNode : public ShadowNode { */ virtual Point getContentOriginOffset() const; - /* - * Returns layout metrics relatively to the given ancestor node. - * Uses `computeRelativeLayoutMetrics()` under the hood. - */ - LayoutMetrics getRelativeLayoutMetrics( - ShadowNodeFamily const &descendantNodeFamily, - LayoutInspectingPolicy policy) const; - - /* - * Returns layout metrics relatively to the given ancestor node. - */ - LayoutMetrics getRelativeLayoutMetrics( - LayoutableShadowNode const &ancestorLayoutableShadowNode, - LayoutInspectingPolicy policy) const; - /* * Sets layout metrics for the shadow node. */ diff --git a/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp b/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp index 8e02861ae79c97..c6dc5f68b5bfac 100644 --- a/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp +++ b/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp @@ -52,7 +52,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetrics) { auto parentShadowNode = builder.build(element); auto relativeLayoutMetrics = - childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + childShadowNode->getFamily(), *parentShadowNode, {}); // A is a parent to B, A has origin {10, 10}, B has origin {10, 10}. // B's relative origin to A should be {10, 10}. @@ -104,13 +105,14 @@ TEST(LayoutableShadowNodeTest, contentOriginOffset) { auto parentShadowNode = builder.build(element); auto relativeLayoutMetrics = - childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + childShadowNode->getFamily(), *parentShadowNode, {}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 0); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 10); - relativeLayoutMetrics = - childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {false}); + relativeLayoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics( + childShadowNode->getFamily(), *parentShadowNode, {false}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 10); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 20); @@ -157,7 +159,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedNode) { auto parentShadowNode = builder.build(element); auto relativeLayoutMetrics = - childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + childShadowNode->getFamily(), *parentShadowNode, {}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 35); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 70); @@ -222,7 +225,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedParent) { auto parentShadowNode = builder.build(element); auto relativeLayoutMetrics = - childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + childShadowNode->getFamily(), *parentShadowNode, {}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 45); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 45); @@ -254,7 +258,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnSameNode) { auto shadowNode = builder.build(element); auto relativeLayoutMetrics = - shadowNode->getRelativeLayoutMetrics(*shadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + shadowNode->getFamily(), *shadowNode, {}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 0); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 0); @@ -290,7 +295,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnSameTransformedNode) { auto shadowNode = builder.build(element); auto relativeLayoutMetrics = - shadowNode->getRelativeLayoutMetrics(*shadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + shadowNode->getFamily(), *shadowNode, {}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 0); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 0); @@ -332,7 +338,8 @@ TEST(LayoutableShadowNodeTest, relativeLayourMetricsOnClonedNode) { parentShadowNode->replaceChild(*childShadowNode, clonedChildShadowNode); auto newRelativeLayoutMetrics = - childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {}); + LayoutableShadowNode::computeRelativeLayoutMetrics( + childShadowNode->getFamily(), *parentShadowNode, {}); EXPECT_EQ(newRelativeLayoutMetrics.frame.size.width, 50); EXPECT_EQ(newRelativeLayoutMetrics.frame.size.height, 60); } @@ -379,7 +386,7 @@ TEST( auto parentShadowNode = builder.build(element); - auto relativeLayoutMetrics = childShadowNode->getRelativeLayoutMetrics(*parentShadowNode, {}); + auto relativeLayoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics(childShadowNode->getFamily(), *parentShadowNode, {}); // relativeLayoutMetrics do not include offsset of nodeAA_ because it is a // RootKindNode. @@ -410,13 +417,15 @@ TEST(LayoutableShadowNodeTest, includeViewportOffset) { // `includeViewportOffset` has to work with `includeTransform` enabled and // disabled. - auto layoutMetrics = viewShadowNode->getRelativeLayoutMetrics( + auto layoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics( + viewShadowNode->getFamily(), *rootShadowNode, {/* includeTransform = */ false, /* includeViewportOffset = */ true}); EXPECT_EQ(layoutMetrics.frame.origin.x, 10); EXPECT_EQ(layoutMetrics.frame.origin.y, 20); - layoutMetrics = viewShadowNode->getRelativeLayoutMetrics( + layoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics( + viewShadowNode->getFamily(), *rootShadowNode, {/* includeTransform = */ true, /* includeViewportOffset = */ true}); EXPECT_EQ(layoutMetrics.frame.origin.x, 10); From a1e9a2d81e6ac57ca68e79c8025b928f17d5413b Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 23 Dec 2020 04:43:55 -0800 Subject: [PATCH 0277/1810] Avoid for loop in UIManager::getNewestCloneOfShadowNode Summary: Changelog: [internal] The loop inside `UIManager::getNewestCloneOfShadowNode` is unnecessary as ancestorList already has index of the children. Reviewed By: shergin Differential Revision: D25681296 fbshipit-source-id: e8fab6c6d945064b0a7e63b6fd22697054fb7ea2 --- ReactCommon/react/renderer/uimanager/UIManager.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index 2ff70c92659550..3da07b811a7cca 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -128,16 +128,6 @@ void UIManager::clearJSResponder() const { ShadowNode::Shared UIManager::getNewestCloneOfShadowNode( ShadowNode const &shadowNode) const { - auto findNewestChildInParent = - [&](auto const &parentNode) -> ShadowNode::Shared { - for (auto const &child : parentNode.getChildren()) { - if (ShadowNode::sameFamily(*child, shadowNode)) { - return child; - } - } - return nullptr; - }; - auto ancestorShadowNode = ShadowNode::Shared{}; shadowTreeRegistry_.visit( shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) { @@ -154,7 +144,8 @@ ShadowNode::Shared UIManager::getNewestCloneOfShadowNode( return nullptr; } - return findNewestChildInParent(ancestors.rbegin()->first.get()); + auto pair = ancestors.rbegin(); + return pair->first.get().getChildren().at(pair->second); } ShadowNode::Shared UIManager::findNodeAtPoint( From da10179238f394a101a5698db015d3cfcf6a6ac2 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 23 Dec 2020 04:43:55 -0800 Subject: [PATCH 0278/1810] Pass x and y to measure callback Summary: Changelog: [internal] Previous implementation of "measure" in UIManagerBinding returned 0, 0 for x and y coordinates. Reviewed By: shergin Differential Revision: D25681586 fbshipit-source-id: fa69b6d4803f083a8299e00cae8bb59932c8bf78 --- .../react/renderer/uimanager/UIManager.h | 6 +++--- .../renderer/uimanager/UIManagerBinding.cpp | 21 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index e138a6ec6e6d72..62f3e6ba5dbdf8 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -74,6 +74,9 @@ class UIManager final : public ShadowTreeDelegate { void registerCommitHook(UIManagerCommitHook const &commitHook) const; void unregisterCommitHook(UIManagerCommitHook const &commitHook) const; + ShadowNode::Shared getNewestCloneOfShadowNode( + ShadowNode const &shadowNode) const; + #pragma mark - ShadowTreeDelegate void shadowTreeDidFinishTransaction( @@ -125,9 +128,6 @@ class UIManager final : public ShadowTreeDelegate { ShadowNode::Shared const &shadowNode, Point point) const; - ShadowNode::Shared getNewestCloneOfShadowNode( - ShadowNode const &shadowNode) const; - /* * Returns layout metrics of given `shadowNode` relative to * `ancestorShadowNode` (relative to the root node in case if provided diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index e772a888e2dc32..6dbd55137db562 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -7,10 +7,10 @@ #include "UIManagerBinding.h" -#include - #include #include +#include +#include namespace facebook { namespace react { @@ -594,10 +594,9 @@ jsi::Value UIManagerBinding::get( jsi::Value const &thisValue, jsi::Value const *arguments, size_t count) noexcept->jsi::Value { + auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); auto layoutMetrics = uiManager->getRelativeLayoutMetrics( - *shadowNodeFromValue(runtime, arguments[0]), - nullptr, - {/* .includeTransform = */ true}); + *shadowNode, nullptr, {/* .includeTransform = */ true}); auto onSuccessFunction = arguments[1].getObject(runtime).getFunction(runtime); @@ -605,12 +604,20 @@ jsi::Value UIManagerBinding::get( onSuccessFunction.call(runtime, {0, 0, 0, 0, 0, 0}); return jsi::Value::undefined(); } + auto newestCloneOfShadowNode = + uiManager->getNewestCloneOfShadowNode(*shadowNode); + + auto layoutableShadowNode = traitCast( + newestCloneOfShadowNode.get()); + Point originRelativeToParent = layoutableShadowNode + ? layoutableShadowNode->getLayoutMetrics().frame.origin + : Point(); auto frame = layoutMetrics.frame; onSuccessFunction.call( runtime, - {0, - 0, + {jsi::Value{runtime, (double)originRelativeToParent.x}, + jsi::Value{runtime, (double)originRelativeToParent.y}, jsi::Value{runtime, (double)frame.size.width}, jsi::Value{runtime, (double)frame.size.height}, jsi::Value{runtime, (double)frame.origin.x}, From 016905333a0ffe2321c1f81f0999b066bdf85509 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH 0279/1810] Back out "Use ConcreteStateTeller in RCTScrollViewComponentView" Summary: ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Original commit changeset: 8c777ae1264c Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687695 fbshipit-source-id: 334cb6c7497270c040e4aec262a30441bc7529ce --- .../ScrollView/RCTScrollViewComponentView.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 453312d85cde08..889452e5d16b9c 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -64,7 +64,7 @@ @interface RCTScrollViewComponentView () < @end @implementation RCTScrollViewComponentView { - ScrollViewShadowNode::ConcreteStateTeller _stateTeller; + ScrollViewShadowNode::ConcreteState::Shared _state; CGSize _contentSize; NSTimeInterval _lastScrollEventDispatchTime; NSTimeInterval _scrollEventThrottle; @@ -247,8 +247,8 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { assert(std::dynamic_pointer_cast(state)); - _stateTeller.setConcreteState(state); - auto data = _stateTeller.getData().value(); + _state = std::static_pointer_cast(state); + auto &data = _state->getData(); auto contentOffset = RCTCGPointFromPoint(data.contentOffset); if (!oldState && !CGPointEqualToPoint(contentOffset, CGPointZero)) { @@ -304,8 +304,11 @@ - (ScrollViewMetrics)_scrollViewMetrics - (void)_updateStateWithContentOffset { + if (!_state) { + return; + } auto contentOffset = RCTPointFromCGPoint(_scrollView.contentOffset); - _stateTeller.updateState([contentOffset](ScrollViewShadowNode::ConcreteState::Data const &data) { + _state->updateState([contentOffset](ScrollViewShadowNode::ConcreteState::Data const &data) { auto newData = data; newData.contentOffset = contentOffset; return newData; @@ -316,7 +319,7 @@ - (void)prepareForRecycle { const auto &props = *std::static_pointer_cast(_props); _scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset); - _stateTeller.invalidate(); + _state.reset(); _isUserTriggeredScrolling = NO; [super prepareForRecycle]; } From b426cbccb4c3f92c194be5b2243ccce1068f5f91 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH 0280/1810] Back out "Use ConcreteStateTeller in RCTTextInputComponentView" Summary: Original commit changeset: 2b82e2d43cc6 ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687699 fbshipit-source-id: d318155509b00064e29fc32efe893151a9723fd5 --- .../TextInput/RCTTextInputComponentView.mm | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index deb8c9304878f1..f5d280a59e9206 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -29,7 +29,7 @@ @interface RCTTextInputComponentView () *_backedTextInputView; NSUInteger _mostRecentEventCount; NSAttributedString *_lastStringStateWasUpdatedWith; @@ -216,21 +216,21 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); - if (!_stateTeller.isValid()) { + if (!_state) { assert(false && "State is `null` for component."); _backedTextInputView.attributedText = nil; return; } - auto data = _stateTeller.getData().value(); + auto data = _state->getData(); if (!oldState) { - _mostRecentEventCount = data.mostRecentEventCount; + _mostRecentEventCount = _state->getData().mostRecentEventCount; } - if (_mostRecentEventCount == data.mostRecentEventCount) { + if (_mostRecentEventCount == _state->getData().mostRecentEventCount) { _comingFromJS = YES; [self _setAttributedString:RCTNSAttributedStringFromAttributedStringBox(data.attributedStringBox)]; _comingFromJS = NO; @@ -251,7 +251,7 @@ - (void)updateLayoutMetrics:(LayoutMetrics const &)layoutMetrics - (void)prepareForRecycle { [super prepareForRecycle]; - _stateTeller.invalidate(); + _state.reset(); _backedTextInputView.attributedText = nil; _mostRecentEventCount = 0; _comingFromJS = NO; @@ -488,17 +488,16 @@ - (TextInputMetrics)_textInputMetrics - (void)_updateState { - if (!_stateTeller.isValid()) { + if (!_state) { return; } - NSAttributedString *attributedString = _backedTextInputView.attributedText; - auto data = _stateTeller.getData().value(); + auto data = _state->getData(); _lastStringStateWasUpdatedWith = attributedString; data.attributedStringBox = RCTAttributedStringBoxFromNSAttributedString(attributedString); _mostRecentEventCount += _comingFromJS ? 0 : 1; data.mostRecentEventCount = _mostRecentEventCount; - _stateTeller.updateState(std::move(data)); + _state->updateState(std::move(data)); } - (AttributedString::Range)_selectionRange From a0beb3a437a19693aa25a1acfc2ae59c1e97e131 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH 0281/1810] Back out "Use ConcreteStateTeller in RCTModalHostViewComponentView" Summary: Original commit changeset: b82301e5db48 ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687694 fbshipit-source-id: 17a737d394cb7f460b239be421466981bc46f995 --- .../Modal/RCTModalHostViewComponentView.mm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index 01648dd2f423d9..cdbb147bba359e 100644 --- a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -98,7 +98,7 @@ @interface RCTModalHostViewComponentView () onOrientationChange(onOrientationChangeStruct(newBounds)); } - auto newState = ModalHostViewState{RCTSizeFromCGSize(newBounds.size)}; - _stateTeller.updateState(std::move(newState)); + if (_state != nullptr) { + auto newState = ModalHostViewState{RCTSizeFromCGSize(newBounds.size)}; + _state->updateState(std::move(newState)); + } } #pragma mark - RCTComponentViewProtocol @@ -215,7 +217,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider - (void)prepareForRecycle { [super prepareForRecycle]; - _stateTeller.invalidate(); + _state.reset(); _viewController = nil; _isPresented = NO; } @@ -237,9 +239,10 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & [super updateProps:props oldProps:oldProps]; } -- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState +- (void)updateState:(facebook::react::State::Shared const &)state + oldState:(facebook::react::State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); } - (void)mountChildComponentView:(UIView *)childComponentView index:(NSInteger)index From 6675b614040b9a0e172c3c81666e6010660d096b Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH 0282/1810] Back out "Use ConcreteStateTeller in RCTLegacyViewManagerInteropComponentView" Summary: Original commit changeset: 4c0d7b249175 ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687698 fbshipit-source-id: b7eac808db1acdc7ef3297313ac352162bdccd5b --- .../RCTLegacyViewManagerInteropComponentView.mm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm b/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm index 3262418b17832c..661b53ee7b8bf3 100644 --- a/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm @@ -22,7 +22,7 @@ @implementation RCTLegacyViewManagerInteropComponentView { NSMutableArray *_viewsToBeMounted; NSMutableArray *_viewsToBeUnmounted; RCTLegacyViewManagerInteropCoordinatorAdapter *_adapter; - LegacyViewManagerInteropShadowNode::ConcreteStateTeller _stateTeller; + LegacyViewManagerInteropShadowNode::ConcreteState::Shared _state; } - (instancetype)initWithFrame:(CGRect)frame @@ -75,9 +75,9 @@ + (void)supportLegacyViewManagerWithName:(NSString *)componentName - (RCTLegacyViewManagerInteropCoordinator *)coordinator { - auto data = _stateTeller.getData(); - if (data.hasValue()) { - return unwrapManagedObject(data.value().coordinator); + if (_state != nullptr) { + const auto &state = _state->getData(); + return unwrapManagedObject(state.coordinator); } else { return nil; } @@ -85,7 +85,9 @@ - (RCTLegacyViewManagerInteropCoordinator *)coordinator - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN { - return self.coordinator.componentViewName; + const auto &state = _state->getData(); + RCTLegacyViewManagerInteropCoordinator *coordinator = unwrapManagedObject(state.coordinator); + return coordinator.componentViewName; } #pragma mark - RCTComponentViewProtocol @@ -95,7 +97,7 @@ - (void)prepareForRecycle _adapter = nil; [_viewsToBeMounted removeAllObjects]; [_viewsToBeUnmounted removeAllObjects]; - _stateTeller.invalidate(); + _state.reset(); self.contentView = nil; [super prepareForRecycle]; } @@ -124,7 +126,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); } - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask From e7c41ec5fb4d7c778749efcda8d450ecc6cdfa18 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH 0283/1810] Back out "Use ConcreteStateTeller in RCTInputAccessoryComponentView" Summary: Original commit changeset: a3324b5df6e6 ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687697 fbshipit-source-id: 849bb8b6c244b17a49b5fe140346d90a9a7e52ff --- .../RCTInputAccessoryComponentView.mm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm b/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm index d151d1c0c3a421..e53c8570d95cc6 100644 --- a/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm @@ -41,7 +41,7 @@ } @implementation RCTInputAccessoryComponentView { - InputAccessoryShadowNode::ConcreteStateTeller _stateTeller; + InputAccessoryShadowNode::ConcreteState::Shared _state; RCTInputAccessoryContentView *_contentView; RCTSurfaceTouchHandler *_touchHandler; UIView __weak *_textInput; @@ -118,15 +118,16 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & self.hidden = true; } -- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState +- (void)updateState:(const facebook::react::State::Shared &)state + oldState:(const facebook::react::State::Shared &)oldState { - _stateTeller.setConcreteState(state); - CGSize oldViewportSize = RCTCGSizeFromSize(_stateTeller.getData().value().viewportSize); + _state = std::static_pointer_cast(state); + CGSize oldScreenSize = RCTCGSizeFromSize(_state->getData().viewportSize); CGSize viewportSize = RCTViewportSize(); viewportSize.height = std::nan(""); - if (oldViewportSize.width != viewportSize.width) { + if (oldScreenSize.width != viewportSize.width) { auto stateData = InputAccessoryState{RCTSizeFromCGSize(viewportSize)}; - _stateTeller.updateState(std::move(stateData)); + _state->updateState(std::move(stateData)); } } @@ -141,7 +142,7 @@ - (void)updateLayoutMetrics:(LayoutMetrics const &)layoutMetrics - (void)prepareForRecycle { [super prepareForRecycle]; - _stateTeller.invalidate(); + _state.reset(); _textInput = nil; } From fba0631ba79c6b2b61ebf6e3ec6e0b337524591c Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH 0284/1810] Fabric: Farewell ConcreteStateTeller Summary: ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687692 fbshipit-source-id: a89d0a4d63b9c97775a312afa3df43f26b5ecc08 --- .../react/renderer/core/ConcreteShadowNode.h | 2 - .../react/renderer/core/ConcreteStateTeller.h | 152 ------------------ 2 files changed, 154 deletions(-) delete mode 100644 ReactCommon/react/renderer/core/ConcreteStateTeller.h diff --git a/ReactCommon/react/renderer/core/ConcreteShadowNode.h b/ReactCommon/react/renderer/core/ConcreteShadowNode.h index e6b842f3c820b9..bafe8e23946120 100644 --- a/ReactCommon/react/renderer/core/ConcreteShadowNode.h +++ b/ReactCommon/react/renderer/core/ConcreteShadowNode.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include #include @@ -49,7 +48,6 @@ class ConcreteShadowNode : public BaseShadowNodeT { using SharedConcreteEventEmitter = std::shared_ptr; using SharedConcreteShadowNode = std::shared_ptr; using ConcreteState = ConcreteState; - using ConcreteStateTeller = ConcreteStateTeller; using ConcreteStateData = StateDataT; static ComponentName Name() { diff --git a/ReactCommon/react/renderer/core/ConcreteStateTeller.h b/ReactCommon/react/renderer/core/ConcreteStateTeller.h deleted file mode 100644 index 2354ae0daaf7ee..00000000000000 --- a/ReactCommon/react/renderer/core/ConcreteStateTeller.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include -#include - -namespace facebook { -namespace react { - -/* - * Wrapper for `ConreteState` class designed to make interactions with - * ConcreteState easier. - */ -template -class ConcreteStateTeller { - public: - using Data = typename ConcreteStateT::Data; - - /* - * Sets backing `ConcreteState` on which all the methods will be called. - * Can be called from any thread. - */ - void setConcreteState(State::Shared const &state) { - std::lock_guard lock(mutex_); - concreteState_ = std::static_pointer_cast(state); - } - - /* - * Removes reference to `ConcreteState` previously set in `setConcreteState`. - * Can be called from any thread. - */ - void invalidate() { - std::lock_guard lock(mutex_); - concreteState_ = nullptr; - } - - /* - * Returns data if state isn't nullptr. - * Can be called from any thread. - */ - better::optional getData() const { - std::lock_guard lock(mutex_); - if (concreteState_) { - return concreteState_->getData(); - } else { - return {}; - } - } - - /* - * Returns true if backing state isn't nullptr, false otherwise. - * Can be called from any thread. - */ - bool isValid() const { - std::lock_guard lock(mutex_); - return concreteState_ != nullptr; - } - - /* - * Initiate a state update process with given new data and priority. - * This is a simplified convenience version of the method that receives a - * function for cases where a new value of data does not depend on an old - * value. - */ - void updateState( - Data &&newData, - EventPriority priority = EventPriority::AsynchronousUnbatched) const { - updateState( - [data = std::move(newData)](Data const &oldData) -> Data { - return std::move(data); - }, - priority); - } - - /* - * Initiate a state update process with a given function (that transforms an - * old data value to a new one) and priority. The update function can be - * called from any thread any moment later. The function can be called only - * once or not called at all (in the case where the node was already unmounted - * and updating makes no sense). The state update operation might fail in case - * of conflict. - */ - void updateState( - std::function callback, - EventPriority priority = EventPriority::AsynchronousBatched) const { - std::shared_ptr concreteState; - { - std::lock_guard lock(mutex_); - if (!concreteState_) { - return; - } - concreteState = concreteState_; - } - - concreteState->updateState( - callback, - [=]() { - updateStateRetryIfNecesarry_(concreteState, callback, priority, 1); - }, - priority); - } - - private: - /* - * Protected by `mutex_`. - */ - std::shared_ptr concreteState_; - - /* - * Protects `concreteState_`. - */ - std::mutex mutable mutex_; - - void updateStateRetryIfNecesarry_( - std::shared_ptr concreteState, - std::function callback, - EventPriority priority, - int retryCount) const { - { - std::lock_guard lock(mutex_); - - if (concreteState != concreteState_) { - LOG(WARNING) << "ConcreteState_ changed while retrying"; - return; - } - } - - if (retryCount > 60) { - LOG(ERROR) << "Exceeded 60 retries"; - assert(false); - return; - } - - concreteState->updateState( - callback, - [=] { - updateStateRetryIfNecesarry_( - concreteState, callback, priority, retryCount + 1); - }, - priority); - } -}; - -} // namespace react -} // namespace facebook From 3ade096f02191b3f978fec71c3dff3cffa676f66 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Wed, 23 Dec 2020 19:47:10 -0800 Subject: [PATCH 0285/1810] Add cachebreaker to remote assets Summary: Changelog: [Internal][Added] - Create a general utils for assets and add a cache breaker utility to set/get a urlparam for remote assets. Reviewed By: motiz88 Differential Revision: D25521331 fbshipit-source-id: 042e52a27e826bc9993e80bc68cc6fc68abaf224 --- Libraries/Image/AssetSourceResolver.js | 2 +- ...{AssetSourcePickScale.js => AssetUtils.js} | 25 ++++++++++++++----- Libraries/Image/resolveAssetSource.js | 4 +-- 3 files changed, 22 insertions(+), 9 deletions(-) rename Libraries/Image/{AssetSourcePickScale.js => AssetUtils.js} (55%) diff --git a/Libraries/Image/AssetSourceResolver.js b/Libraries/Image/AssetSourceResolver.js index 4ddc2bf123050d..ee81537631cc14 100644 --- a/Libraries/Image/AssetSourceResolver.js +++ b/Libraries/Image/AssetSourceResolver.js @@ -21,7 +21,7 @@ export type ResolvedAssetSource = {| import type {PackagerAsset} from '@react-native/assets/registry'; const PixelRatio = require('../Utilities/PixelRatio'); -const pickScale = require('./AssetSourcePickScale'); +const {pickScale} = require('./AssetUtils'); const Platform = require('../Utilities/Platform'); const invariant = require('invariant'); diff --git a/Libraries/Image/AssetSourcePickScale.js b/Libraries/Image/AssetUtils.js similarity index 55% rename from Libraries/Image/AssetSourcePickScale.js rename to Libraries/Image/AssetUtils.js index 70c35f3bcf34f8..519a8cdb1eb7d1 100644 --- a/Libraries/Image/AssetSourcePickScale.js +++ b/Libraries/Image/AssetUtils.js @@ -10,11 +10,12 @@ 'use strict'; -const PixelRatio = require('../Utilities/PixelRatio'); -function AssetSourcePickScale( - scales: Array, - deviceScale?: number, -): number { +import PixelRatio from '../Utilities/PixelRatio'; + +let cacheBreaker; +let warnIfCacheBreakerUnset = true; + +export function pickScale(scales: Array, deviceScale?: number): number { if (deviceScale == null) { deviceScale = PixelRatio.get(); } @@ -30,4 +31,16 @@ function AssetSourcePickScale( // in which case we default to 1 return scales[scales.length - 1] || 1; } -module.exports = AssetSourcePickScale; + +export function setUrlCacheBreaker(appendage: string) { + cacheBreaker = appendage; +} + +export function getUrlCacheBreaker(): string { + if (__DEV__ && warnIfCacheBreakerUnset && cacheBreaker == null) { + warnIfCacheBreakerUnset = false; + console.warn('AssetUtils.getUrlCacheBreaker: Cache breaker value is unset'); + return ''; + } + return cacheBreaker; +} diff --git a/Libraries/Image/resolveAssetSource.js b/Libraries/Image/resolveAssetSource.js index 19e9607ace5585..fe8e543e1ff91e 100644 --- a/Libraries/Image/resolveAssetSource.js +++ b/Libraries/Image/resolveAssetSource.js @@ -14,7 +14,7 @@ const AssetRegistry = require('@react-native/assets/registry'); const AssetSourceResolver = require('./AssetSourceResolver'); -const AssetSourcePickScale = require('./AssetSourcePickScale'); +const {pickScale} = require('./AssetUtils'); import type {ResolvedAssetSource} from './AssetSourceResolver'; @@ -106,5 +106,5 @@ function resolveAssetSource(source: any): ?ResolvedAssetSource { } module.exports = resolveAssetSource; -module.exports.pickScale = AssetSourcePickScale; +module.exports.pickScale = pickScale; module.exports.setCustomSourceTransformer = setCustomSourceTransformer; From f379b1e583ffeac54619e196bbc2dd368ff7b62b Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 21:46:56 -0800 Subject: [PATCH 0286/1810] Fabric: Shipping `updateStateWithAutorepeat` as the only way to update a state Summary: This replaces the internal core implementation of `setState` with the new `updateStateWithAutorepeat` which is now the only option. In short, `updateStateWithAutorepeat` works as `setState` with the following features: * The state update might be performed several times until it succeeds. * The callback is being called on every retry with actual previous data provided (can be different on every call). * In case of a static value is provided (simple case, not lambda, the only case on Android for now), the same *new*/provided value will be used for all state updates. In this case, the state update cannot fail. * If a callback is provided, the update operation can be canceled via returning `nullptr` from the callback. This diff removes all mentions of the previous state update approach from the core; some other leftovers will be removed separatly. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25695600 fbshipit-source-id: 14b3d4bad7ee69e024a9b0b9fc018f7d58bf060c --- .../RCTSafeAreaViewComponentView.mm | 4 +- .../ScrollView/RCTScrollViewComponentView.mm | 2 +- .../react/fabric/StateWrapperImpl.java | 30 +--------- .../react/fabric/jni/StateWrapperImpl.cpp | 29 +-------- .../uimanager/FabricViewStateManager.java | 7 +-- .../react/uimanager/StateWrapper.java | 6 +- .../react/renderer/core/ConcreteState.h | 59 ++++--------------- ReactCommon/react/renderer/core/State.h | 4 +- ReactCommon/react/renderer/core/StateUpdate.h | 2 - .../react/renderer/scheduler/Scheduler.cpp | 6 -- .../react/renderer/uimanager/UIManager.cpp | 40 +------------ .../react/renderer/uimanager/UIManager.h | 6 -- 12 files changed, 25 insertions(+), 170 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm index 1180a898cb03c4..fa362f134a4b6f 100644 --- a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm @@ -61,7 +61,7 @@ - (void)_updateStateIfNecessary auto newPadding = RCTEdgeInsetsFromUIEdgeInsets(insets); auto threshold = 1.0 / RCTScreenScale() + 0.01; // Size of a pixel plus some small threshold. - _state->updateStateWithAutorepeat( + _state->updateState( [=](SafeAreaViewShadowNode::ConcreteState::Data const &oldData) -> SafeAreaViewShadowNode::ConcreteState::SharedData { auto oldPadding = oldData.padding; @@ -74,7 +74,7 @@ - (void)_updateStateIfNecessary auto newData = oldData; newData.padding = newPadding; - return std::make_shared(newData); + return std::make_shared(newData); }); } diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 889452e5d16b9c..8ff8770a97a405 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -311,7 +311,7 @@ - (void)_updateStateWithContentOffset _state->updateState([contentOffset](ScrollViewShadowNode::ConcreteState::Data const &data) { auto newData = data; newData.contentOffset = contentOffset; - return newData; + return std::make_shared(newData); }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/StateWrapperImpl.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/StateWrapperImpl.java index 6a461623e99aca..2d96776f882ea0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/StateWrapperImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/StateWrapperImpl.java @@ -8,13 +8,11 @@ package com.facebook.react.fabric; import android.annotation.SuppressLint; -import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.NativeMap; import com.facebook.react.bridge.ReadableNativeMap; -import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.StateWrapper; @@ -30,9 +28,6 @@ public class StateWrapperImpl implements StateWrapper { @DoNotStrip private final HybridData mHybridData; - private Runnable mFailureCallback = null; - private int mUpdateStateId = 0; - private static native HybridData initHybrid(); private StateWrapperImpl() { @@ -44,29 +39,8 @@ private StateWrapperImpl() { public native void updateStateImpl(@NonNull NativeMap map); - public native void updateStateWithFailureCallbackImpl( - @NonNull NativeMap map, Object self, int updateStateId); - @Override - public void updateState(@NonNull WritableMap map, Runnable failureCallback) { - mUpdateStateId++; - mFailureCallback = failureCallback; - updateStateWithFailureCallbackImpl((NativeMap) map, this, mUpdateStateId); - } - - @DoNotStrip - @AnyThread - public void updateStateFailed(int callbackRefId) { - // If the callback ref ID doesn't match the ID of the most-recent updateState call, - // then it's an outdated failure callback and we ignore it. - if (callbackRefId != mUpdateStateId) { - return; - } - - final Runnable failureCallback = mFailureCallback; - mFailureCallback = null; - if (failureCallback != null) { - UiThreadUtil.runOnUiThread(failureCallback); - } + public void updateState(@NonNull WritableMap map) { + updateStateImpl((NativeMap) map); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/StateWrapperImpl.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/StateWrapperImpl.cpp index afbe9c7155232e..9a5b929e9af10f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/StateWrapperImpl.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/StateWrapperImpl.cpp @@ -33,31 +33,7 @@ void StateWrapperImpl::updateStateImpl(NativeMap *map) { // Get folly::dynamic from map auto dynamicMap = map->consume(); // Set state - state_->updateState(dynamicMap, nullptr); -} - -void StateWrapperImpl::updateStateWithFailureCallbackImpl( - NativeMap *map, - jni::alias_ref self, - int callbackRefId) { - // Get folly::dynamic from map - auto dynamicMap = map->consume(); - // Turn the alias into a global_ref - // Note: this whole thing feels really janky, making StateWrapperImpl.java - // pass "this" into a function it's calling on "this". But after struggling - // for a while I couldn't figure out how to get a reference to the Java side - // of "this" in C++ in a way that's reasonably safe, and it maybe is even - // discouraged. Anyway, it might be weird, but this seems to work and be safe. - jni::global_ref globalSelf = make_global(self); - // Set state - state_->updateState( - dynamicMap, [globalSelf = std::move(globalSelf), callbackRefId]() { - static auto method = - jni::findClassStatic( - StateWrapperImpl::StateWrapperImplJavaDescriptor) - ->getMethod("updateStateFailed"); - method(globalSelf, callbackRefId); - }); + state_->updateState(dynamicMap); } void StateWrapperImpl::registerNatives() { @@ -65,9 +41,6 @@ void StateWrapperImpl::registerNatives() { makeNativeMethod("initHybrid", StateWrapperImpl::initHybrid), makeNativeMethod("getState", StateWrapperImpl::getState), makeNativeMethod("updateStateImpl", StateWrapperImpl::updateStateImpl), - makeNativeMethod( - "updateStateWithFailureCallbackImpl", - StateWrapperImpl::updateStateWithFailureCallbackImpl), }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java index f6bdd767801e88..f0b7cfb8ff6682 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java @@ -79,10 +79,9 @@ public void run() { if (stateUpdate == null) { return; } - stateWrapper.updateState( - stateUpdate, - // Failure callback - this is run if the updateState call fails - failureRunnable); + + // TODO: State update cannot fail; remove `failureRunnable` and custom retrying logic. + stateWrapper.updateState(stateUpdate); } public void setState(final StateUpdateCallback stateUpdateCallback) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/StateWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/StateWrapper.java index 51bbc14349a446..c21d2414d0b3a6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/StateWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/StateWrapper.java @@ -22,8 +22,8 @@ public interface StateWrapper { ReadableNativeMap getState(); /** - * Pass a map of values back to the C++ layer. /Last/ runnable passed into updateState is called - * if an updateState call fails. + * Pass a map of values back to the C++ layer. The operation is performed synchronously and cannot + * fail. */ - void updateState(WritableMap map, Runnable failureCallback); + void updateState(WritableMap map); } diff --git a/ReactCommon/react/renderer/core/ConcreteState.h b/ReactCommon/react/renderer/core/ConcreteState.h index 33fa5dac788398..9ee3b21ec518c6 100644 --- a/ReactCommon/react/renderer/core/ConcreteState.h +++ b/ReactCommon/react/renderer/core/ConcreteState.h @@ -60,55 +60,23 @@ class ConcreteState : public State { */ void updateState( Data &&newData, - std::function failureCallback = nullptr, EventPriority priority = EventPriority::AsynchronousUnbatched) const { updateState( - [data = std::move(newData)](Data const &oldData) mutable -> Data && { - return std::move(data); + [data = std::move(newData)](Data const &oldData) mutable -> SharedData { + return std::make_shared(std::move(data)); }, - failureCallback, priority); } /* * Initiate a state update process with a given function (that transforms an - * old data value to a new one) and priority. The update function can be - * called from any thread any moment later. The function can be called only - * once or not called at all (in the case where the node was already unmounted - * and updating makes no sense). The state update operation might fail in case - * of conflict. + * old data value to a new one) and priority. The callback function can be + * called from any thread any moment later. + * In case of a conflict, the `callback` might be called several times until + * it succeeded. To cancel the state update operation, the callback needs to + * return `nullptr`. */ void updateState( - std::function callback, - std::function failureCallback = nullptr, - EventPriority priority = EventPriority::AsynchronousBatched) const { - auto family = family_.lock(); - - if (!family) { - // No more nodes of this family exist anymore, - // updating state is impossible. - return; - } - - auto stateUpdate = StateUpdate{ - family, - [=](StateData::Shared const &oldData) -> StateData::Shared { - assert(oldData); - return std::make_shared( - callback(*std::static_pointer_cast(oldData))); - }, - failureCallback, - false}; - - family->dispatchRawState(std::move(stateUpdate), priority); - } - - /* - * An experimental version of `updateState` function that re-commit the state - * update over and over again until it succeeded. To cancel the state update - * operation, the state update lambda needs to return `nullptr`. - */ - void updateStateWithAutorepeat( std::function callback, EventPriority priority = EventPriority::AsynchronousBatched) const { auto family = family_.lock(); @@ -120,14 +88,10 @@ class ConcreteState : public State { } auto stateUpdate = StateUpdate{ - family, - [=](StateData::Shared const &oldData) -> StateData::Shared { + family, [=](StateData::Shared const &oldData) -> StateData::Shared { assert(oldData); return callback(*std::static_pointer_cast(oldData)); - }, - nullptr, - true, - }; + }}; family->dispatchRawState(std::move(stateUpdate), priority); } @@ -137,9 +101,8 @@ class ConcreteState : public State { return getData().getDynamic(); } - void updateState(folly::dynamic data, std::function failureCallback) - const override { - updateState(std::move(Data(getData(), data)), failureCallback); + void updateState(folly::dynamic data) const override { + updateState(std::move(Data(getData(), data))); } #endif }; diff --git a/ReactCommon/react/renderer/core/State.h b/ReactCommon/react/renderer/core/State.h index ae636f37e421cd..c0472fec057bf5 100644 --- a/ReactCommon/react/renderer/core/State.h +++ b/ReactCommon/react/renderer/core/State.h @@ -65,9 +65,7 @@ class State { #ifdef ANDROID virtual folly::dynamic getDynamic() const = 0; - virtual void updateState( - folly::dynamic data, - std::function failureCallback) const = 0; + virtual void updateState(folly::dynamic data) const = 0; #endif protected: diff --git a/ReactCommon/react/renderer/core/StateUpdate.h b/ReactCommon/react/renderer/core/StateUpdate.h index 7931f5e080066f..890e56d141092b 100644 --- a/ReactCommon/react/renderer/core/StateUpdate.h +++ b/ReactCommon/react/renderer/core/StateUpdate.h @@ -25,8 +25,6 @@ class StateUpdate { SharedShadowNodeFamily family; Callback callback; - FailureCallback failureCallback; - bool autorepeat; }; } // namespace react diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 9fe70284e2f309..313b4e201ec656 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -109,15 +109,9 @@ Scheduler::Scheduler( #ifdef ANDROID removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( "react_fabric:remove_outstanding_surfaces_on_destruction_android"); - uiManager_->experimentEnableStateUpdateWithAutorepeat = - reactNativeConfig_->getBool( - "react_fabric:enable_state_update_with_autorepeat_android"); #else removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( "react_fabric:remove_outstanding_surfaces_on_destruction_ios"); - uiManager_->experimentEnableStateUpdateWithAutorepeat = - reactNativeConfig_->getBool( - "react_fabric:enable_state_update_with_autorepeat_ios"); #endif } diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index 3da07b811a7cca..de353321bf278f 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -191,8 +191,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics( shadowNode.getFamily(), *layoutableAncestorShadowNode, policy); } -void UIManager::updateStateWithAutorepeat( - StateUpdate const &stateUpdate) const { +void UIManager::updateState(StateUpdate const &stateUpdate) const { auto &callback = stateUpdate.callback; auto &family = stateUpdate.family; auto &componentDescriptor = family->getComponentDescriptor(); @@ -230,43 +229,6 @@ void UIManager::updateStateWithAutorepeat( }); } -void UIManager::updateState(StateUpdate const &stateUpdate) const { - if (stateUpdate.autorepeat || experimentEnableStateUpdateWithAutorepeat) { - updateStateWithAutorepeat(stateUpdate); - return; - } - - auto &callback = stateUpdate.callback; - auto &family = stateUpdate.family; - auto &componentDescriptor = family->getComponentDescriptor(); - - shadowTreeRegistry_.visit( - family->getSurfaceId(), [&](ShadowTree const &shadowTree) { - auto status = shadowTree.tryCommit([&](RootShadowNode const - &oldRootShadowNode) { - return std::static_pointer_cast( - oldRootShadowNode.cloneTree( - *family, [&](ShadowNode const &oldShadowNode) { - auto newData = - callback(oldShadowNode.getState()->getDataPointer()); - auto newState = - componentDescriptor.createState(*family, newData); - - return oldShadowNode.clone({ - /* .props = */ ShadowNodeFragment::propsPlaceholder(), - /* .children = */ - ShadowNodeFragment::childrenPlaceholder(), - /* .state = */ newState, - }); - })); - }); - if (status != ShadowTree::CommitStatus::Succeeded && - stateUpdate.failureCallback) { - stateUpdate.failureCallback(); - } - }); -} - void UIManager::dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index 62f3e6ba5dbdf8..c2c76cc03b54af 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -83,11 +83,6 @@ class UIManager final : public ShadowTreeDelegate { ShadowTree const &shadowTree, MountingCoordinator::Shared const &mountingCoordinator) const override; - /* - * Temporary flags. - */ - bool experimentEnableStateUpdateWithAutorepeat{false}; - RootShadowNode::Unshared shadowTreeWillCommit( ShadowTree const &shadowTree, RootShadowNode::Shared const &oldRootShadowNode, @@ -143,7 +138,6 @@ class UIManager final : public ShadowTreeDelegate { * and performs a commit. */ void updateState(StateUpdate const &stateUpdate) const; - void updateStateWithAutorepeat(StateUpdate const &stateUpdate) const; void dispatchCommand( const ShadowNode::Shared &shadowNode, From f45cb60e560d21be134aa808bd105e0394ba1fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 23 Dec 2020 22:22:59 -0800 Subject: [PATCH 0287/1810] Use Fabric builds in iOS tests (#30639) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/30639 # Changelog: [Internal] Enable Fabric builds in iOS tests on Circle CI and Sandcastle. Reviewed By: fkgozali Differential Revision: D25700257 fbshipit-source-id: a250dbc9904efec9ded130912a993638f0992373 --- .circleci/config.yml | 2 +- packages/rn-tester/Podfile.lock | 315 +++++++++++++++++++++++++++++++- 2 files changed, 314 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9d1ada2052cb22..a9ed245dc5c5e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -428,7 +428,7 @@ jobs: steps: - run: name: Generate RNTesterPods Workspace - command: cd packages/rn-tester && bundle exec pod install --verbose + command: cd packages/rn-tester && USE_FABRIC=1 bundle exec pod install --verbose # ------------------------- # Runs iOS unit tests diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 61a95d29b96d37..f3ddbec6b86801 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -70,6 +70,10 @@ PODS: - boost-for-react-native - DoubleConversion - glog + - RCT-Folly/Fabric (2020.01.13.00): + - boost-for-react-native + - DoubleConversion + - glog - RCTRequired (1000.0.0) - RCTTypeSafety (1000.0.0): - FBLazyVector (= 1000.0.0) @@ -244,6 +248,289 @@ PODS: - React-jsinspector (= 1000.0.0) - React-perflogger (= 1000.0.0) - React-runtimeexecutor (= 1000.0.0) + - React-Fabric (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-Fabric/animations (= 1000.0.0) + - React-Fabric/attributedstring (= 1000.0.0) + - React-Fabric/better (= 1000.0.0) + - React-Fabric/componentregistry (= 1000.0.0) + - React-Fabric/components (= 1000.0.0) + - React-Fabric/config (= 1000.0.0) + - React-Fabric/core (= 1000.0.0) + - React-Fabric/debug (= 1000.0.0) + - React-Fabric/imagemanager (= 1000.0.0) + - React-Fabric/mounting (= 1000.0.0) + - React-Fabric/scheduler (= 1000.0.0) + - React-Fabric/templateprocessor (= 1000.0.0) + - React-Fabric/textlayoutmanager (= 1000.0.0) + - React-Fabric/uimanager (= 1000.0.0) + - React-Fabric/utils (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/animations (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/attributedstring (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/better (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/componentregistry (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-Fabric/components/activityindicator (= 1000.0.0) + - React-Fabric/components/image (= 1000.0.0) + - React-Fabric/components/inputaccessory (= 1000.0.0) + - React-Fabric/components/legacyviewmanagerinterop (= 1000.0.0) + - React-Fabric/components/modal (= 1000.0.0) + - React-Fabric/components/picker (= 1000.0.0) + - React-Fabric/components/rncore (= 1000.0.0) + - React-Fabric/components/root (= 1000.0.0) + - React-Fabric/components/safeareaview (= 1000.0.0) + - React-Fabric/components/scrollview (= 1000.0.0) + - React-Fabric/components/slider (= 1000.0.0) + - React-Fabric/components/text (= 1000.0.0) + - React-Fabric/components/textinput (= 1000.0.0) + - React-Fabric/components/unimplementedview (= 1000.0.0) + - React-Fabric/components/view (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/activityindicator (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/image (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/inputaccessory (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/legacyviewmanagerinterop (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/modal (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/picker (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/rncore (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/root (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/safeareaview (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/scrollview (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/slider (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/text (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/textinput (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/unimplementedview (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/components/view (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - Yoga + - React-Fabric/config (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/core (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/debug (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/imagemanager (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - React-RCTImage (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/mounting (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/scheduler (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/templateprocessor (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/textlayoutmanager (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-Fabric/uimanager + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/uimanager (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-Fabric/utils (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - RCTRequired (= 1000.0.0) + - RCTTypeSafety (= 1000.0.0) + - React-graphics (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) + - React-graphics (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) - React-jsi (1000.0.0): - boost-for-react-native (= 1.63.0) - DoubleConversion @@ -255,6 +542,11 @@ PODS: - DoubleConversion - glog - RCT-Folly (= 2020.01.13.00) + - React-jsi/Fabric (1000.0.0): + - boost-for-react-native (= 1.63.0) + - DoubleConversion + - glog + - RCT-Folly (= 2020.01.13.00) - React-jsiexecutor (1000.0.0): - DoubleConversion - glog @@ -281,6 +573,11 @@ PODS: - React-jsi (= 1000.0.0) - React-RCTNetwork (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) + - React-RCTFabric (1000.0.0): + - RCT-Folly/Fabric (= 2020.01.13.00) + - React-Core (= 1000.0.0) + - React-Fabric (= 1000.0.0) + - React-RCTImage (= 1000.0.0) - React-RCTImage (1000.0.0): - FBReactNativeSpec (= 1000.0.0) - RCT-Folly (= 2020.01.13.00) @@ -378,6 +675,7 @@ DEPENDENCIES: - FlipperKit/SKIOSNetworkPlugin (~> 0.54.0) - glog (from `../../third-party-podspecs/glog.podspec`) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) + - RCT-Folly/Fabric (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../Libraries/RCTRequired`) - RCTTypeSafety (from `../../Libraries/TypeSafety`) - React (from `../../`) @@ -387,13 +685,17 @@ DEPENDENCIES: - React-Core/RCTWebSocket (from `../../`) - React-CoreModules (from `../../React/CoreModules`) - React-cxxreact (from `../../ReactCommon/cxxreact`) + - React-Fabric (from `../../ReactCommon`) + - React-graphics (from `../../ReactCommon/react/renderer/graphics`) - React-jsi (from `../../ReactCommon/jsi`) + - React-jsi/Fabric (from `../../ReactCommon/jsi`) - React-jsiexecutor (from `../../ReactCommon/jsiexecutor`) - React-jsinspector (from `../../ReactCommon/jsinspector`) - React-perflogger (from `../../ReactCommon/reactperflogger`) - React-RCTActionSheet (from `../../Libraries/ActionSheetIOS`) - React-RCTAnimation (from `../../Libraries/NativeAnimation`) - React-RCTBlob (from `../../Libraries/Blob`) + - React-RCTFabric (from `../../React`) - React-RCTImage (from `../../Libraries/Image`) - React-RCTLinking (from `../../Libraries/LinkingIOS`) - React-RCTNetwork (from `../../Libraries/Network`) @@ -447,6 +749,10 @@ EXTERNAL SOURCES: :path: "../../React/CoreModules" React-cxxreact: :path: "../../ReactCommon/cxxreact" + React-Fabric: + :path: "../../ReactCommon" + React-graphics: + :path: "../../ReactCommon/react/renderer/graphics" React-jsi: :path: "../../ReactCommon/jsi" React-jsiexecutor: @@ -461,6 +767,8 @@ EXTERNAL SOURCES: :path: "../../Libraries/NativeAnimation" React-RCTBlob: :path: "../../Libraries/Blob" + React-RCTFabric: + :path: "../../React" React-RCTImage: :path: "../../Libraries/Image" React-RCTLinking: @@ -490,7 +798,7 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 8e8b4f540947580f2a9ef54a443453c562d439cd + FBReactNativeSpec: 259a715466e53b411664fdfbe166dbde93ece5b6 Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a @@ -500,7 +808,7 @@ SPEC CHECKSUMS: FlipperKit: ab353d41aea8aae2ea6daaf813e67496642f3d7d glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 OpenSSL-Universal: ff34003318d5e1163e9529b08470708e389ffcdd - RCT-Folly: b39288cedafe50da43317ec7d91bcc8cc0abbf33 + RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c RCTRequired: d3d4ce60e1e2282864d7560340690a3c8c646de1 RCTTypeSafety: 4da4f9f218727257c50fd3bf2683a06cdb4fede3 React: 87b3271d925336a94620915db5845c67c5dbbd77 @@ -508,6 +816,8 @@ SPEC CHECKSUMS: React-Core: 2b2a8ac8bfb65779965456570a871f4cf5e5e03a React-CoreModules: 87f011fa87190ffe979e443ce578ec93ec6ff4d4 React-cxxreact: de6de17eac6bbaa4f9fad46b66e7f0c4aaaf863d + React-Fabric: 911e4b13fbffce46820f18c3a3b7a2a966e9e425 + React-graphics: 996d77a11e944cb0b3a5c67aefda1de5cb848e28 React-jsi: 790da16b69a61adc36829eed43c44187c1488d10 React-jsiexecutor: 17a3e26806bc19d8be7b6c83792bffc46df796be React-jsinspector: 01db8cd098c7ab72bd09abdda522a08c9acd3af9 @@ -515,6 +825,7 @@ SPEC CHECKSUMS: React-RCTActionSheet: e6562ea4df7099af4023d1bd0e9716e43b45a5c9 React-RCTAnimation: fc2f655a64f0791879ab03843cca90c53737d1cb React-RCTBlob: 5f82467e5d3bef65d05cdd900df6e12b0849744a + React-RCTFabric: 7a25f04616e0bcdcda4279a93b42e80ee69b46be React-RCTImage: f3a98834281555ce1bbbe1af0306aaf40ac70fc7 React-RCTLinking: 801d05ad5e6d1636e977f4dfeab21f87358a02a5 React-RCTNetwork: b5e2f27a098ca52d98426328640314a499da6d00 From a68415270c92396f00d027e9e4090d6381edb35a Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 24 Dec 2020 00:47:38 -0800 Subject: [PATCH 0288/1810] Delete codegen_rn_modules_tests Summary: This test was used to compare the old codegen output with the new codegen output. It was written predominately to test the ObjC++ generator. A few reasons why we should delete this: 1. We do not want the old and the new codegen targets co-existing because it will slow down buck query. 2. The new ObjC++ codegen output is different from the old. In the new ObjC++ generator, we aren't generating dead structs. Therefore, this test simply won't work on the most sophisticated generator (i.e: the generator it was designed to run on). The other generators are really simple. We've also been running the ObjC++ and the Java generators in production for over a month for react-native-github specs. These are arguably the most complicated specs we maintain, so generator correctness isn't too much of a concern. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25683069 fbshipit-source-id: b2175f34f50a078d80ef738e59024f546628219a --- packages/react-native-codegen/BUCK | 16 ------ .../verify_all_modules_with_old_codegen.sh | 10 ---- .../src/cli/verify_with_old_codegen.js | 52 ------------------- .../src/cli/verify_with_old_codegen.sh | 19 ------- 4 files changed, 97 deletions(-) delete mode 100755 packages/react-native-codegen/src/cli/verify_all_modules_with_old_codegen.sh delete mode 100755 packages/react-native-codegen/src/cli/verify_with_old_codegen.js delete mode 100755 packages/react-native-codegen/src/cli/verify_with_old_codegen.sh diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index c058291e1b7cbc..07fb2bfeb96fad 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -9,22 +9,6 @@ SETUP_ENV_DEPS = [] if IS_OSS_BUILD else [ "//xplat/js:setup_env", ] -fb_native.sh_binary( - name = "codegen_rn_modules_tests", - main = "src/cli/verify_with_old_codegen.sh", - visibility = ["PUBLIC"], - resources = [ - "src/cli/verify_with_old_codegen.js", - "src/cli/verify_with_old_codegen.sh", - ] + SETUP_ENV_DEPS, -) - -fb_native.sh_test( - name = "verify_all_modules_with_old_codegen", - test = "src/cli/verify_all_modules_with_old_codegen.sh", - visibility = ["PUBLIC"], -) - fb_native.genrule( name = "codegen_tests_schema", srcs = glob( diff --git a/packages/react-native-codegen/src/cli/verify_all_modules_with_old_codegen.sh b/packages/react-native-codegen/src/cli/verify_all_modules_with_old_codegen.sh deleted file mode 100755 index a46079351aaf8c..00000000000000 --- a/packages/react-native-codegen/src/cli/verify_all_modules_with_old_codegen.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -e -set -u - -exec buck query "filter('generated_objcpp_modules_tests_', '//xplat/js/...')" | xargs buck build diff --git a/packages/react-native-codegen/src/cli/verify_with_old_codegen.js b/packages/react-native-codegen/src/cli/verify_with_old_codegen.js deleted file mode 100755 index 60192bfab7d852..00000000000000 --- a/packages/react-native-codegen/src/cli/verify_with_old_codegen.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -'use strict'; - -const fs = require('fs'); -const [first, second] = process.argv.slice(2); - -const contents1 = fs.readFileSync(first, 'utf8'); -const contents2 = fs.readFileSync(second, 'utf8'); - -function traverse(t) { - return t - .replace(/\).invoke/g, ')\n.invoke') // in old codegen it was in one line - .split('\n') - .map(l => l.trim()) // no whitespaces - .filter(Boolean) // no empty lines - .filter( - l => - !l.startsWith('namespace') && // no namespaces - !l.startsWith('}') && // after removing openign namespaces we need to remove all closings - !l.startsWith('/**') && // all comments - !l.startsWith('#') && // imports - !l.startsWith('//') && // comments - !l.startsWith('importing it, you must change') && // comment in old codegen - !l.startsWith('*'), //comments - ) - .map(l => l.replace(/ /g, '')) // remove rest whitespaces - .sort(); // sort alphabetically lines -} - -const t1 = traverse(contents1); -const t2 = traverse(contents2); - -if (t1.length !== t2.length) { - throw new Error('Old and new codegen produces output of different size'); -} else { - for (let i = 0; i < t1.length; i++) { - if (t1[i] !== t2[i]) { - throw new Error( - `Old and new codegen does not produce similar output! ${i} ${t1[i]} | ${t2[i]}`, - ); - } - } -} diff --git a/packages/react-native-codegen/src/cli/verify_with_old_codegen.sh b/packages/react-native-codegen/src/cli/verify_with_old_codegen.sh deleted file mode 100755 index 7399c20dcb6294..00000000000000 --- a/packages/react-native-codegen/src/cli/verify_with_old_codegen.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -e -set -u - -THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) - -# shellcheck source=xplat/js/env-utils/setup_env_vars.sh -source "$THIS_DIR/../../../../../env-utils/setup_env_vars.sh" - -pushd "$JS_DIR" >/dev/null - "$INSTALL_NODE_MODULES" -popd >/dev/null - -exec "$FLOW_NODE_BINARY" "$THIS_DIR/verify_with_old_codegen.js" "$@" From fb34fba01c568180ecbff04a05d82c6df7e011ce Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 24 Dec 2020 00:47:38 -0800 Subject: [PATCH 0289/1810] Use native_module_spec_name to name codegen targets Summary: ## Description Suppose this was the codegen declaration before: ``` rn_library( name = "FooModule", native_module_spec_name = "FBReactNativeSpec", codegen_modules = True, # ... ) ``` Previously, this would generate the following BUCK targets: - generated_objcpp_modules-FooModuleApple - generated_java_modules-FooModuleAndroid - generated_java_modules-FooModule-jniAndroid ## Changes We will now generate: - FBReactNativeSpecApple - FBReactNativeSpecAndroid - FBReactNativeSpec-jniAndroid This matches the naming scheme of the old codegen. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25680224 fbshipit-source-id: 617ac18fd915f3277f6bd98072d147f20fb193e5 --- React/CoreModules/BUCK | 2 +- .../src/main/java/com/facebook/react/animated/BUCK | 2 +- .../src/main/java/com/facebook/react/devsupport/BUCK | 2 +- .../com/facebook/react/modules/accessibilityinfo/BUCK | 2 +- .../main/java/com/facebook/react/modules/appearance/BUCK | 2 +- .../main/java/com/facebook/react/modules/appstate/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/blob/BUCK | 2 +- .../java/com/facebook/react/modules/bundleloader/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/camera/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/core/BUCK | 2 +- .../main/java/com/facebook/react/modules/datepicker/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/debug/BUCK | 2 +- .../main/java/com/facebook/react/modules/deviceinfo/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/dialog/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/image/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/intent/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/network/BUCK | 2 +- .../main/java/com/facebook/react/modules/permissions/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/share/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/sound/BUCK | 2 +- .../main/java/com/facebook/react/modules/statusbar/BUCK | 2 +- .../src/main/java/com/facebook/react/modules/storage/BUCK | 2 +- .../main/java/com/facebook/react/modules/systeminfo/BUCK | 4 ++-- .../src/main/java/com/facebook/react/modules/toast/BUCK | 2 +- .../main/java/com/facebook/react/modules/vibration/BUCK | 2 +- .../main/java/com/facebook/react/modules/websocket/BUCK | 2 +- packages/react-native-codegen/BUCK | 2 +- packages/react-native-codegen/DEFS.bzl | 8 ++++---- 28 files changed, 32 insertions(+), 32 deletions(-) diff --git a/React/CoreModules/BUCK b/React/CoreModules/BUCK index e07b6ff6f12e56..d9475c86bb52c3 100644 --- a/React/CoreModules/BUCK +++ b/React/CoreModules/BUCK @@ -131,6 +131,6 @@ rn_apple_library( "//xplat/js:RCTLinkingApple", "//xplat/js:RCTPushNotificationApple", "//xplat/js/react-native-github:ReactInternalApple", - "//xplat/js/react-native-github/Libraries:generated_objcpp_modules-FBReactNativeSpecApple", + "//xplat/js/react-native-github/Libraries:FBReactNativeSpecApple", ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK b/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK index 81527da4f69178..da22b9787c38f2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/BUCK @@ -29,5 +29,5 @@ rn_android_library( react_native_target("java/com/facebook/react/uimanager:uimanager"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK index 0240a2666fa622..2c919248ab83d8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK @@ -40,7 +40,7 @@ rn_android_library( react_native_target("res:devsupport"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK index d032844ae7bc56..b8c3a1b9b31131 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/BUCK @@ -19,5 +19,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK index ee8429aa991239..640c535e0a0de1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/BUCK @@ -17,5 +17,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK index 295c630477ad5d..cacb0a3ca2c04c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/BUCK @@ -17,5 +17,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK index 95b880422d10f0..df5de6afb47ae9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BUCK @@ -32,6 +32,6 @@ rn_android_library( react_native_target("java/com/facebook/react/modules/websocket:websocket"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK index 0a129c6c7a61f9..b16ad7c7570d36 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/bundleloader/BUCK @@ -18,5 +18,5 @@ rn_android_library( react_native_target("java/com/facebook/react/devsupport:interfaces"), react_native_target("java/com/facebook/react/module/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK index f679963f07467f..e516ebe6638852 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/BUCK @@ -19,6 +19,6 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK index 118339191a1282..31207dd63156b6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/BUCK @@ -22,6 +22,6 @@ rn_android_library( react_native_target("java/com/facebook/react/util:util"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK index 02bc5fbc3ebe0d..e1c276c6757c6b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK @@ -23,5 +23,5 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK index 034c8e312bcbfe..525683f3596eef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK @@ -24,7 +24,7 @@ rn_android_library( react_native_target("java/com/facebook/react/uimanager:uimanager"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK index da57d4876626c8..46f482370c3cd1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/BUCK @@ -20,6 +20,6 @@ rn_android_library( react_native_target("java/com/facebook/react/uimanager:uimanager"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK index 40a7d8c6e998f8..e80e77f2aa3e32 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/BUCK @@ -24,5 +24,5 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK index 4fba41ae0fd81c..bc4e575b2be95a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/image/BUCK @@ -25,6 +25,6 @@ rn_android_library( react_native_target("java/com/facebook/react/views/image:image"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK index d89eb671861503..fb94f3fb365c64 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/BUCK @@ -17,5 +17,5 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK index 0d7020d1a9fa2a..703d1b7b72a31b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/BUCK @@ -29,5 +29,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK index 54e9a48eab1168..14d1f89fa2b651 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/BUCK @@ -16,5 +16,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK index d3ead4b3ae47c3..d3e98217f6e61d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/share/BUCK @@ -16,5 +16,5 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK index 411ade4a0efd1b..dc76a82b932c1a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/sound/BUCK @@ -20,5 +20,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/uimanager:uimanager"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK index 2b6cf951aef714..21e2ecf7700065 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/BUCK @@ -25,5 +25,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/uimanager:uimanager"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK index ed16e94bb9b3ff..c74d5354d7e64d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/BUCK @@ -19,5 +19,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/common:common"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK index 695140160c82bc..efda55325a7405 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/BUCK @@ -22,7 +22,7 @@ rn_android_library( react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ":systeminfo-moduleless", ], ) @@ -45,5 +45,5 @@ rn_android_library( react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_target("res:systeminfo"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK index f0c2b1dae8a5de..79edb9b7dc43d0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/toast/BUCK @@ -15,5 +15,5 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK index e80dbb0ce5d619..bcf7ea3376f42a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/BUCK @@ -17,5 +17,5 @@ rn_android_library( react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/modules/core:core"), ], - exported_deps = [react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec")], + exported_deps = [react_native_root_target("Libraries:FBReactNativeSpec")], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK index 9bf4b604c8ae3c..18879f21d4a9b8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/BUCK @@ -23,6 +23,6 @@ rn_android_library( react_native_target("java/com/facebook/react/modules/network:network"), ], exported_deps = [ - react_native_root_target("Libraries:generated_java_modules-FBReactNativeSpec"), + react_native_root_target("Libraries:FBReactNativeSpec"), ], ) diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index 07fb2bfeb96fad..07b517fc2f71d0 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -94,8 +94,8 @@ rn_xplat_cxx_library( "PUBLIC", ], deps = [ + ":FBReactNativeTestSpec", ":generated_components-codegen_tests", - ":generated_objcpp_modules-codegen_tests", ], ) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 0e71c3e37f17ac..06a9ef6c937160 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -103,8 +103,8 @@ def rn_codegen_cli(): ) def rn_codegen_modules( + name, native_module_spec_name, - name = "", library_labels = [], schema_target = ""): generate_fixtures_rule_name = "generate_fixtures_modules-{}".format(name) @@ -157,7 +157,7 @@ def rn_codegen_modules( ) rn_android_library( - name = "generated_java_modules-{}".format(name), + name = "{}".format(native_module_spec_name), srcs = [ ":{}".format(generate_module_java_zip_name), ], @@ -176,7 +176,7 @@ def rn_codegen_modules( ) rn_xplat_cxx_library( - name = "generated_java_modules-{}-jni".format(name), + name = "{}-jni".format(native_module_spec_name), srcs = [ ":{}".format(generate_module_jni_cpp_name), ], @@ -229,7 +229,7 @@ def rn_codegen_modules( ) rn_apple_library( - name = "generated_objcpp_modules-{}Apple".format(name), + name = "{}Apple".format(native_module_spec_name), extension_api_only = True, header_namespace = "", sdks = (IOS), From a9bc3853f0cf2bb32999335c0aaf90194ea9084d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Sun, 27 Dec 2020 03:22:59 -0800 Subject: [PATCH 0290/1810] Cancel touches if surface touch handler can be prevented | second try Summary: Changelog: [internal] Previous implementation, (D25684453 (https://github.com/facebook/react-native/commit/eba31d285847ef70cf22ce83fe013efa95416e3c)) which was backed out, had a bug that caused assert to fail. It was restarting internal state `RCTSurfaceTouchHandler` and lead to inconsistency. This is because touch event is a state machine and before "moved" is called, touch event had to "began". With internal state being restarted, that wasn't the case. In the previous implementation the internal state was incorrectly restarted because I thought touches would not longer receive touch events after declaring that UIGestureRecogniser shouldn't be recognised simultaneously. In this diff I take a different approach. Instead of restarting the internal state, the recogniser is first disabled and then enabled again. This cancels any ongoing touches instead of manual cleanup. ### Other approaches In the UIViewController, we could listen to `viewWillDisappear` message and cancel any ongoing touches on the surface. This would work as well (it would prevent Pressable components from being highlighted during interactive view controller dismissal) however we would need to expose existence of `RCTTouchHandler` to the view controller. This approach is also discouraged in D15734129 (https://github.com/facebook/react-native/commit/36307d87e1974aff1abac598da2fd11c4e8e23c1). Reviewed By: shergin Differential Revision: D25685536 fbshipit-source-id: ad226c82e73f841c1ebd9b92738847cc5cdc21d1 --- React/Fabric/RCTSurfaceTouchHandler.mm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index e556a3af6d1d72..eb5d126eda3370 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -410,4 +410,22 @@ - (BOOL)gestureRecognizer:(__unused UIGestureRecognizer *)gestureRecognizer return [self canBePreventedByGestureRecognizer:otherGestureRecognizer]; } +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer + shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + BOOL canBePrevented = [self canBePreventedByGestureRecognizer:otherGestureRecognizer]; + if (canBePrevented) { + [self _cancelTouches]; + } + return NO; +} + +#pragma mark - + +- (void)_cancelTouches +{ + [self setEnabled:NO]; + [self setEnabled:YES]; +} + @end From 5a3e13ad8f39be077919ce8c35a0fb793455c179 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Mon, 28 Dec 2020 13:47:53 -0800 Subject: [PATCH 0291/1810] fix Android CI - autoglob (#30652) Summary: This PR is fixing Android CI by ignoring autoglob configuration. ## Changelog [Internal] [Changed] - fix Android CI Pull Request resolved: https://github.com/facebook/react-native/pull/30652 Test Plan: Android CI is green again Reviewed By: d16r Differential Revision: D25715153 Pulled By: fkgozali fbshipit-source-id: 6fb44bb4078735ea83132fcff2559ef6b27405da --- tools/build_defs/oss/rn_defs.bzl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/build_defs/oss/rn_defs.bzl b/tools/build_defs/oss/rn_defs.bzl index 30b911c2ec4276..23fb85c5eb1516 100644 --- a/tools/build_defs/oss/rn_defs.bzl +++ b/tools/build_defs/oss/rn_defs.bzl @@ -122,6 +122,7 @@ def rn_extra_build_flags(): # React property preprocessor def rn_android_library(name, deps = [], plugins = [], *args, **kwargs): + _ = kwargs.pop("autoglob", False) _ = kwargs.pop("is_androidx", False) if react_native_target( "java/com/facebook/react/uimanager/annotations:annotations", @@ -165,6 +166,7 @@ def rn_apple_library(*args, **kwargs): kwargs.setdefault("target_sdk_version", "10.0") # Unsupported kwargs + _ = kwargs.pop("autoglob", False) _ = kwargs.pop("plugins_only", False) _ = kwargs.pop("enable_exceptions", False) _ = kwargs.pop("extension_api_only", False) @@ -191,7 +193,8 @@ def rn_genrule(*args, **kwargs): def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs): vm_args = vm_args or [] - is_androidx = kwargs.pop("is_androidx", False) + _ = kwargs.pop("autoglob", False) + _ = kwargs.pop("is_androidx", False) kwargs["deps"] = kwargs.pop("deps", []) + [ react_native_android_toplevel_dep("third-party/java/mockito2:mockito2"), From f002a5710f9dc678b33850b87f2c65814939f34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Mon, 28 Dec 2020 14:26:55 -0800 Subject: [PATCH 0292/1810] Disable tests with USE_FRAMEWORKS=1 (#30655) Summary: Tests that set USE_FRAMEWORKS=1 will fail because Flipper does not currently support the use of frameworks. These tests should be re-enabled once this issue is addressed. ## Changelog [Internal] - Disable USE_FRAMEWORKS=1 tests Pull Request resolved: https://github.com/facebook/react-native/pull/30655 Test Plan: CI Reviewed By: fkgozali Differential Revision: D25718040 Pulled By: hramos fbshipit-source-id: 1db1fc59b2d47922c3329e9f438e571bde370ecc --- .circleci/config.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a9ed245dc5c5e7..025669fdb324ff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -781,30 +781,34 @@ workflows: run_unit_tests: true requires: - setup_ios - - test_ios: - name: test_ios_unit_frameworks_jsc - use_frameworks: true - run_unit_tests: true - requires: - - setup_ios + # DISABLED: USE_FRAMEWORKS=1 not supported by Flipper + # - test_ios: + # name: test_ios_unit_frameworks_jsc + # use_frameworks: true + # run_unit_tests: true + # requires: + # - setup_ios - test_ios: name: test_ios_unit_hermes use_hermes: true run_unit_tests: true requires: - setup_ios - - test_ios: - name: test_ios_unit_frameworks_hermes - use_hermes: true - use_frameworks: true - run_unit_tests: true - requires: - - setup_ios + # DISABLED: USE_FRAMEWORKS=1 not supported by Flipper + # - test_ios: + # name: test_ios_unit_frameworks_hermes + # use_hermes: true + # use_frameworks: true + # run_unit_tests: true + # requires: + # - setup_ios + # DISABLED: Detox tests need to be fixed # - test_ios: # name: test_ios_detox # run_detox_tests: true # requires: # - setup_ios + # DISABLED: USE_FRAMEWORKS=1 not supported by Flipper # - test_ios: # name: test_ios_detox_frameworks # use_frameworks: true From b8ca59cd745ffc74a669603875e368d16fd93465 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 28 Dec 2020 22:33:01 -0800 Subject: [PATCH 0293/1810] Reduce re-rendering of Animated components in Fabric Summary: The `isFabric` method used in createAnimatedComponent is unreliable (another reason in a long list of reasons why you should not duplicate this code elsewhere, and why we want to delete it ASAP). In particular, during the first render, the ref component has not been set yet, so we /cannot/ detect if the component is Fabric or non-Fabric and assume it's non-Fabric. In Fabric, this causes `collapsable` and `nativeID` values to change after the first render. To reduce this re-rendering, but not eliminate it for all components, I've introduced a flag that indicates if a component will /never/ be flattened. In particular, Image components, ScrollViews, Text cannot ever be flattened, so we should always pass `collapsable:false` and the same nativeID prop for those components. For Animated s and other components, the re-rendering issue is still a problem in Fabric for now. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25720322 fbshipit-source-id: fe3234d8ae974911a2b5f82e4f6a093216f43d4b --- .../Animated/components/AnimatedImage.js | 6 ++-- .../Animated/components/AnimatedScrollView.js | 6 ++-- Libraries/Animated/components/AnimatedText.js | 6 ++-- Libraries/Animated/components/AnimatedView.js | 4 ++- Libraries/Animated/createAnimatedComponent.js | 35 +++++++++++++------ 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Libraries/Animated/components/AnimatedImage.js b/Libraries/Animated/components/AnimatedImage.js index 56cdb7d18f7908..5aae7d90056442 100644 --- a/Libraries/Animated/components/AnimatedImage.js +++ b/Libraries/Animated/components/AnimatedImage.js @@ -17,9 +17,9 @@ const createAnimatedComponent = require('../createAnimatedComponent'); import type {AnimatedComponentType} from '../createAnimatedComponent'; -module.exports = (createAnimatedComponent( - (Image: $FlowFixMe), -): AnimatedComponentType< +module.exports = (createAnimatedComponent((Image: $FlowFixMe), { + collapsable: false, +}): AnimatedComponentType< React.ElementConfig, React.ElementRef, >); diff --git a/Libraries/Animated/components/AnimatedScrollView.js b/Libraries/Animated/components/AnimatedScrollView.js index 259cbb81b0ee2f..bfa75b7167b6d3 100644 --- a/Libraries/Animated/components/AnimatedScrollView.js +++ b/Libraries/Animated/components/AnimatedScrollView.js @@ -24,9 +24,9 @@ const ScrollViewWithEventThrottle = React.forwardRef((props, ref) => ( )); -module.exports = (createAnimatedComponent( - ScrollViewWithEventThrottle, -): AnimatedComponentType< +module.exports = (createAnimatedComponent(ScrollViewWithEventThrottle, { + collapsable: false, +}): AnimatedComponentType< React.ElementConfig, React.ElementRef, >); diff --git a/Libraries/Animated/components/AnimatedText.js b/Libraries/Animated/components/AnimatedText.js index 5a184e0626fe17..7a940093aadd08 100644 --- a/Libraries/Animated/components/AnimatedText.js +++ b/Libraries/Animated/components/AnimatedText.js @@ -17,9 +17,9 @@ const createAnimatedComponent = require('../createAnimatedComponent'); import type {AnimatedComponentType} from '../createAnimatedComponent'; -module.exports = (createAnimatedComponent( - (Text: $FlowFixMe), -): AnimatedComponentType< +module.exports = (createAnimatedComponent((Text: $FlowFixMe), { + collapsable: false, +}): AnimatedComponentType< React.ElementConfig, React.ElementRef, >); diff --git a/Libraries/Animated/components/AnimatedView.js b/Libraries/Animated/components/AnimatedView.js index 0ce54601fe9990..d2a87807b02b7f 100644 --- a/Libraries/Animated/components/AnimatedView.js +++ b/Libraries/Animated/components/AnimatedView.js @@ -17,7 +17,9 @@ const createAnimatedComponent = require('../createAnimatedComponent'); import type {AnimatedComponentType} from '../createAnimatedComponent'; -module.exports = (createAnimatedComponent(View): AnimatedComponentType< +module.exports = (createAnimatedComponent(View, { + collapsable: true, +}): AnimatedComponentType< React.ElementConfig, React.ElementRef, >); diff --git a/Libraries/Animated/createAnimatedComponent.js b/Libraries/Animated/createAnimatedComponent.js index 230aa164203606..8e8638edb63d58 100644 --- a/Libraries/Animated/createAnimatedComponent.js +++ b/Libraries/Animated/createAnimatedComponent.js @@ -37,8 +37,13 @@ export type AnimatedComponentType< Instance, >; +type AnimatedComponentOptions = { + collapsable?: boolean, +}; + function createAnimatedComponent( Component: React.AbstractComponent, + options?: AnimatedComponentOptions, ): AnimatedComponentType { invariant( typeof Component !== 'function' || @@ -79,6 +84,9 @@ function createAnimatedComponent( } _isFabric = (): boolean => { + // When called during the first render, `_component` is always null. + // Therefore, even if a component is rendered in Fabric, we can't detect + // that until ref is set, which happens sometime after the first render. if (this._component == null) { return false; } @@ -213,23 +221,28 @@ function createAnimatedComponent( const {style: passthruStyle = {}, ...passthruProps} = this.props.passthroughAnimatedPropExplicitValues || {}; const mergedStyle = {...style, ...passthruStyle}; + const forceNativeId = + props.collapsable ?? + (this._propsAnimated.__isNative || + this._isFabric() || + options?.collapsable === false); + // The native driver updates views directly through the UI thread so we + // have to make sure the view doesn't get optimized away because it cannot + // go through the NativeViewHierarchyManager since it operates on the shadow + // thread. TODO: T68258846 + const collapsableProps = forceNativeId + ? { + nativeID: props.nativeID ?? 'animatedComponent', + collapsable: false, + } + : {}; return ( ); } From 59f8b6adbb37dbc31fc7ac28210a6ddfd6b79814 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 28 Dec 2020 23:22:54 -0800 Subject: [PATCH 0294/1810] Extract measure() Android function into an utility method Summary: This diff extracts the measure() Android function into an utility method. As part of this diff I'm also refactoring one of the usages of this method (Text) Additional refactors will be done as part of other diffs changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25721046 fbshipit-source-id: 76cc6a8088607aaae5055c675076a0c18fc322ec --- .../textlayoutmanager/TextLayoutManager.cpp | 93 +++--------------- ReactCommon/react/utils/LayoutManager.h | 94 +++++++++++++++++++ 2 files changed, 107 insertions(+), 80 deletions(-) create mode 100644 ReactCommon/react/utils/LayoutManager.h diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index 56a72d3881fed0..18b1aaa34e4618 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using namespace facebook::jni; @@ -40,65 +41,31 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById( int64_t cacheId, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { - const jni::global_ref &fabricUIManager = - contextContainer_->at>("FabricUIManager"); - auto env = Environment::current(); auto attachmentPositions = env->NewFloatArray(0); - - static auto measure = - jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") - ->getMethod("measure"); - auto minimumSize = layoutConstraints.minimumSize; auto maximumSize = layoutConstraints.maximumSize; - local_ref componentName = make_jstring("RCTText"); folly::dynamic cacheIdMap = folly::dynamic::object; cacheIdMap["cacheId"] = cacheId; - local_ref attributedStringRNM = - ReadableNativeMap::newObjectCxxArgs(cacheIdMap); - local_ref paragraphAttributesRNM = - ReadableNativeMap::newObjectCxxArgs(toDynamic(paragraphAttributes)); - local_ref attributedStringRM = make_local( - reinterpret_cast(attributedStringRNM.get())); - local_ref paragraphAttributesRM = make_local( - reinterpret_cast(paragraphAttributesRNM.get())); - auto size = yogaMeassureToSize(measure( - fabricUIManager, + auto size = measureAndroidComponent( + contextContainer_, -1, // TODO: we should pass rootTag in - componentName.get(), - attributedStringRM.get(), - paragraphAttributesRM.get(), + "RCTText", + cacheIdMap, + toDynamic(paragraphAttributes), nullptr, minimumSize.width, maximumSize.width, minimumSize.height, maximumSize.height, - attachmentPositions)); + attachmentPositions); // Clean up allocated ref - it still takes up space in the JNI ref table even // though it's 0 length env->DeleteLocalRef(attachmentPositions); - // Explicitly release smart pointers to free up space faster in JNI tables - componentName.reset(); - attributedStringRM.reset(); - attributedStringRNM.reset(); - paragraphAttributesRM.reset(); - paragraphAttributesRNM.reset(); - // TODO: currently we do not support attachments for cached IDs - should we? auto attachments = TextMeasurement::Attachments{}; @@ -159,9 +126,6 @@ TextMeasurement TextLayoutManager::doMeasure( AttributedString attributedString, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { - const jni::global_ref &fabricUIManager = - contextContainer_->at>("FabricUIManager"); - int attachmentsCount = 0; for (auto fragment : attributedString.getFragments()) { if (fragment.isAttachment()) { @@ -171,46 +135,22 @@ TextMeasurement TextLayoutManager::doMeasure( auto env = Environment::current(); auto attachmentPositions = env->NewFloatArray(attachmentsCount * 2); - static auto measure = - jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") - ->getMethod("measure"); - auto minimumSize = layoutConstraints.minimumSize; auto maximumSize = layoutConstraints.maximumSize; auto serializedAttributedString = toDynamic(attributedString); - local_ref componentName = make_jstring("RCTText"); - local_ref attributedStringRNM = - ReadableNativeMap::newObjectCxxArgs(serializedAttributedString); - local_ref paragraphAttributesRNM = - ReadableNativeMap::newObjectCxxArgs(toDynamic(paragraphAttributes)); - - local_ref attributedStringRM = make_local( - reinterpret_cast(attributedStringRNM.get())); - local_ref paragraphAttributesRM = make_local( - reinterpret_cast(paragraphAttributesRNM.get())); - auto size = yogaMeassureToSize(measure( - fabricUIManager, + auto size = measureAndroidComponent( + contextContainer_, -1, // TODO: we should pass rootTag in - componentName.get(), - attributedStringRM.get(), - paragraphAttributesRM.get(), + "RCTText", + serializedAttributedString, + toDynamic(paragraphAttributes), nullptr, minimumSize.width, maximumSize.width, minimumSize.height, maximumSize.height, - attachmentPositions)); + attachmentPositions); jfloat *attachmentData = env->GetFloatArrayElements(attachmentPositions, 0); @@ -239,13 +179,6 @@ TextMeasurement TextLayoutManager::doMeasure( attachmentPositions, attachmentData, JNI_ABORT); env->DeleteLocalRef(attachmentPositions); - // Explicitly release smart pointers to free up space faster in JNI tables - componentName.reset(); - attributedStringRM.reset(); - attributedStringRNM.reset(); - paragraphAttributesRM.reset(); - paragraphAttributesRNM.reset(); - return TextMeasurement{size, attachments}; } diff --git a/ReactCommon/react/utils/LayoutManager.h b/ReactCommon/react/utils/LayoutManager.h new file mode 100644 index 00000000000000..9789fc87d997ce --- /dev/null +++ b/ReactCommon/react/utils/LayoutManager.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include +#include +#include + +namespace facebook { +namespace react { + +#ifdef ANDROID + +using namespace facebook::jni; + +Size measureAndroidComponent( + const ContextContainer::Shared &contextContainer, + Tag rootTag, + std::string componentName, + folly::dynamic localData, + folly::dynamic props, + folly::dynamic state, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight, + jfloatArray attachmentPositions) { + const jni::global_ref &fabricUIManager = + contextContainer->at>("FabricUIManager"); + + static auto measure = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod("measure"); + + auto componentNameRef = make_jstring(componentName); + local_ref localDataRNM = + ReadableNativeMap::newObjectCxxArgs(localData); + local_ref propsRNM = + ReadableNativeMap::newObjectCxxArgs(props); + local_ref stateRNM = + ReadableNativeMap::newObjectCxxArgs(state); + + local_ref localDataRM = + make_local(reinterpret_cast(localDataRNM.get())); + local_ref propsRM = + make_local(reinterpret_cast(propsRNM.get())); + local_ref stateRM = + make_local(reinterpret_cast(stateRNM.get())); + + auto size = yogaMeassureToSize(measure( + fabricUIManager, + rootTag, + componentNameRef.get(), + localDataRM.get(), + propsRM.get(), + stateRM.get(), + minWidth, + maxWidth, + minHeight, + maxHeight, + attachmentPositions)); + + // Explicitly release smart pointers to free up space faster in JNI tables + componentNameRef.reset(); + localDataRM.reset(); + localDataRNM.reset(); + propsRM.reset(); + propsRNM.reset(); + stateRM.reset(); + stateRNM.reset(); + + return size; +} + +#endif + +} // namespace react +} // namespace facebook From 72ddd692228de55e4a7abb274c615be436e9dc15 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 29 Dec 2020 00:58:03 -0800 Subject: [PATCH 0295/1810] Remove deleted parameter from javadoc Summary: ez javadoc changelog: [internal] Reviewed By: fkgozali Differential Revision: D25468185 fbshipit-source-id: bba614df552b3c8431e77aaa51a29e08fae5ea7f --- .../java/com/facebook/react/uimanager/UIManagerModule.java | 3 ++- .../main/java/com/facebook/react/uimanager/ViewManager.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 9d982ee29d5afd..c54cf11316af5e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -15,6 +15,7 @@ import android.content.ComponentCallbacks2; import android.content.res.Configuration; import android.view.View; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.collection.ArrayMap; import com.facebook.common.logging.FLog; @@ -208,7 +209,7 @@ public UIImplementation getUIImplementation() { } @Override - public String getName() { + public @NonNull String getName() { return NAME; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index a806b87a380a34..5401620f715751 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -39,7 +39,6 @@ public abstract class ViewManager * * @param viewToUpdate * @param props - * @param stateWrapper */ public void updateProperties(@NonNull T viewToUpdate, ReactStylesDiffMap props) { final ViewManagerDelegate delegate; From c776f09e5f8be53a7d9196d6497b4780eb051703 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 29 Dec 2020 10:39:54 -0800 Subject: [PATCH 0296/1810] Refactor initialization of Fabric to avoid loading UIManagerModule Summary: This diff refactors the intialization of Fabric in order to avoid loading UIManagerModule as part of the creation of FabricJSIModuleProvider. One caveat is that now we are not taking into consideration the flag mLazyViewManagersEnabled https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java?commit=4fb6c5ae79bb8e78e852a811128f03cf6fbed9aa&lines=177 As a side effect of this diff view managers will be initialized twice if the user has fabric and paper enabled changelog: [internal] internal Reviewed By: shergin Differential Revision: D25468183 fbshipit-source-id: 78d8069007c5a98f9a6825eaa0c174603c8b9b4f --- .../react/fabric/FabricJSIModuleProvider.java | 18 ++++++++---------- .../react/uiapp/RNTesterApplication.java | 11 ++++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index 91fe11b20cd55e..e36f851b3002ce 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -8,7 +8,6 @@ package com.facebook.react.fabric; import androidx.annotation.NonNull; -import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSIModuleProvider; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UIManager; @@ -34,9 +33,10 @@ import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem; import com.facebook.react.fabric.mounting.mountitems.UpdateStateMountItem; import com.facebook.react.uimanager.StateWrapper; -import com.facebook.react.uimanager.UIManagerModule; +import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.uimanager.events.BatchEventDispatchedListener; import com.facebook.react.uimanager.events.EventDispatcher; +import com.facebook.react.uimanager.events.EventDispatcherImpl; import com.facebook.systrace.Systrace; public class FabricJSIModuleProvider implements JSIModuleProvider { @@ -44,14 +44,17 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { @NonNull private final ReactApplicationContext mReactApplicationContext; @NonNull private final ComponentFactory mComponentFactory; @NonNull private final ReactNativeConfig mConfig; + @NonNull private final ViewManagerRegistry mViewManagerRegistry; public FabricJSIModuleProvider( @NonNull ReactApplicationContext reactApplicationContext, @NonNull ComponentFactory componentFactory, - @NonNull ReactNativeConfig config) { + @NonNull ReactNativeConfig config, + @NonNull ViewManagerRegistry viewManagerRegistry) { mReactApplicationContext = reactApplicationContext; mComponentFactory = componentFactory; mConfig = config; + mViewManagerRegistry = viewManagerRegistry; } @Override @@ -87,15 +90,10 @@ public UIManager get() { private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager"); - UIManagerModule nativeModule = - Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class)); - EventDispatcher eventDispatcher = nativeModule.getEventDispatcher(); + EventDispatcher eventDispatcher = new EventDispatcherImpl(mReactApplicationContext); FabricUIManager fabricUIManager = new FabricUIManager( - mReactApplicationContext, - nativeModule.getViewManagerRegistry_DO_NOT_USE(), - eventDispatcher, - eventBeatManager); + mReactApplicationContext, mViewManagerRegistry, eventDispatcher, eventBeatManager); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); return fabricUIManager; diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index b892f527c0e4a9..e8eec3ae80b7a3 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -34,6 +34,7 @@ import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.shell.MainReactPackage; import com.facebook.react.turbomodule.core.TurboModuleManager; +import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.views.text.ReactFontManager; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; @@ -168,6 +169,13 @@ public JSIModuleType getJSIModuleType() { public JSIModuleProvider getJSIModuleProvider() { final ComponentFactory ComponentFactory = new ComponentFactory(); CoreComponentsRegistry.register(ComponentFactory); + final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); + + ViewManagerRegistry viewManagerRegistry = + new ViewManagerRegistry( + reactInstanceManager.getOrCreateViewManagers( + reactApplicationContext)); + return new FabricJSIModuleProvider( reactApplicationContext, ComponentFactory, @@ -192,7 +200,8 @@ public String getString(final String s) { public double getDouble(final String s) { return 0; } - }); + }, + viewManagerRegistry); } }); } From 6740b22ab081bd0cd9204b9127c7a68666e13cc0 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 29 Dec 2020 13:01:55 -0800 Subject: [PATCH 0297/1810] Add @DoNotStrip to exported methods in NativeModule specs Summary: NativeModule methods are meant to be called from JavaScript. As such, they may not necessarily have call-sites in Java. This means that they're succeptible to being stripped by proguard. This diff annotates all exported NativeModule methods with DoNotStrip, so that proguard doesn't strip them. We already do this in the legacy codegen. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25723801 fbshipit-source-id: a7c8701e0a5d03a970f5f19cc6ae6b320a2e99a1 --- .../resolver/FunctionResolvedType.java | 2 ++ .../modules/GenerateModuleJavaSpec.js | 3 +- .../GenerateModuleJavaSpec-test.js.snap | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java b/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java index 2a7468ce11e242..7896494eebb2f4 100644 --- a/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java +++ b/packages/react-native-codegen/android/gradlePlugin-build/gradlePlugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java @@ -103,6 +103,8 @@ public MethodSpec getGeneratedMethodWithReactAnnotation(String methodName) { // React methods need special `@ReactMethod` annotation for now. methodBuilder.addAnnotation(annotationBuilder.build()); + // TODO(T82242829) Add @DoNotStrip annotation + return methodBuilder.build(); } diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index b8238cf4786d52..34334426418d58 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -395,6 +395,7 @@ module.exports = { 'com.facebook.react.bridge.ReactMethod', 'com.facebook.react.bridge.ReactModuleWithSpec', 'com.facebook.react.turbomodule.core.interfaces.TurboModule', + 'com.facebook.proguard.annotations.DoNotStrip', ]); const methods = properties.map(method => { @@ -443,7 +444,7 @@ module.exports = { const methodJavaAnnotation = `@ReactMethod${ isSyncMethod ? '(isBlockingSynchronousMethod = true)' : '' - }`; + }\n @DoNotStrip`; const methodBody = method.optional ? getFalsyReturnStatementFromReturnType( methodTypeAnnotation.returnTypeAnnotation, diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap index a5564d2fbaa10d..5e314758e47c21 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap @@ -16,6 +16,7 @@ Map { package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -32,15 +33,19 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract WritableMap difficult(ReadableMap A); @ReactMethod + @DoNotStrip public abstract void optionals(ReadableMap A); @ReactMethod + @DoNotStrip public void optionalMethod(ReadableMap options, Callback callback, ReadableArray extras) {} @ReactMethod + @DoNotStrip public abstract void getArrays(ReadableMap options); } ", @@ -63,6 +68,7 @@ Map { package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -96,6 +102,7 @@ Map { package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -109,6 +116,7 @@ public abstract class AliasTurboModuleSpec extends ReactContextBaseJavaModule im } @ReactMethod + @DoNotStrip public abstract void cropImage(ReadableMap cropData); } ", @@ -131,6 +139,7 @@ Map { package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -146,12 +155,15 @@ public abstract class NativeCameraRollManagerSpec extends ReactContextBaseJavaMo } @ReactMethod + @DoNotStrip public abstract void getPhotos(ReadableMap params, Promise promise); @ReactMethod + @DoNotStrip public abstract void saveToCameraRoll(String uri, String type, Promise promise); @ReactMethod + @DoNotStrip public abstract void deletePhotos(ReadableArray assets, Promise promise); } ", @@ -169,6 +181,7 @@ public abstract class NativeCameraRollManagerSpec extends ReactContextBaseJavaMo package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -183,18 +196,23 @@ public abstract class NativeExceptionsManagerSpec extends ReactContextBaseJavaMo } @ReactMethod + @DoNotStrip public abstract void reportFatalException(String message, ReadableArray stack, double exceptionId); @ReactMethod + @DoNotStrip public abstract void reportSoftException(String message, ReadableArray stack, double exceptionId); @ReactMethod + @DoNotStrip public void reportException(ReadableMap data) {} @ReactMethod + @DoNotStrip public abstract void updateExceptionMessage(String message, ReadableArray stack, double exceptionId); @ReactMethod + @DoNotStrip public void dismissRedbox() {} } ", @@ -217,6 +235,7 @@ Map { package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; @@ -268,33 +287,43 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } @ReactMethod + @DoNotStrip public abstract void voidFunc(); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract boolean getBool(boolean arg); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract double getNumber(double arg); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract String getString(String arg); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract WritableArray getArray(ReadableArray arg); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract WritableMap getObject(ReadableMap arg); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract double getRootTag(double arg); @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip public abstract WritableMap getValue(double x, String y, ReadableMap z); @ReactMethod + @DoNotStrip public abstract void getValueWithCallback(Callback callback); @ReactMethod + @DoNotStrip public abstract void getValueWithPromise(boolean error, Promise promise); } ", @@ -317,6 +346,7 @@ Map { package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -329,6 +359,7 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } @ReactMethod + @DoNotStrip public abstract void voidFunc(); } ", @@ -346,6 +377,7 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo package com.facebook.fbreact.specs; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -358,6 +390,7 @@ public abstract class NativeSampleTurboModule2Spec extends ReactContextBaseJavaM } @ReactMethod + @DoNotStrip public abstract void voidFunc(); } ", From 4c734d1e8d9626b1426dd398cd4d6a4cd2126619 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 29 Dec 2020 13:01:55 -0800 Subject: [PATCH 0298/1810] Support custom android_package_name in module codegen Summary: ## Changes All `rn_library(codegen_modules = True)` must now also specify native_module_android_package_name, like so: ``` rn_library( name = "FBAuth" codegen_modules = True, native_module_spec_name = "Foo", native_module_android_package_name = "com.facebook.fbreact.specs", ) ``` This will generate the FBAuth Java spec files under the appropriate directory: "com/facebook/fbreact/specs". It will also make the code-generated specs have the appropriate package name: "com.facebook.fbreact.specs". Changelog: [Internal] Reviewed By: shergin Differential Revision: D25723176 fbshipit-source-id: 6efec1cbee43d70110c0ef23e2422e08609b61d4 --- Libraries/BUCK | 1 + packages/react-native-codegen/BUCK | 1 + packages/react-native-codegen/DEFS.bzl | 16 ++++++++++++---- .../src/cli/generators/generate-all.js | 2 +- .../generators/modules/GenerateModuleJavaSpec.js | 5 +++-- .../modules/__tests__/GenerateModuleCpp-test.js | 7 ++++++- .../modules/__tests__/GenerateModuleH-test.js | 7 ++++++- .../__tests__/GenerateModuleHObjCpp-test.js | 7 ++++++- .../__tests__/GenerateModuleJavaSpec-test.js | 7 ++++++- .../__tests__/GenerateModuleJniCpp-test.js | 7 ++++++- .../modules/__tests__/GenerateModuleJniH-test.js | 7 ++++++- .../modules/__tests__/GenerateModuleMm-test.js | 7 ++++++- 12 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Libraries/BUCK b/Libraries/BUCK index 2f64ec0bbd5ad1..cef11f41005d73 100644 --- a/Libraries/BUCK +++ b/Libraries/BUCK @@ -31,6 +31,7 @@ fb_native.genrule( rn_codegen_modules( name = "FBReactNativeSpec", + android_package_name = "com.facebook.fbreact.specs", library_labels = ["supermodule:xplat/default/public.react_native.infra"], native_module_spec_name = "FBReactNativeSpec", schema_target = ":react_native_codegen_schema", diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index 07b517fc2f71d0..d9da90a41f0ea3 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -28,6 +28,7 @@ rn_codegen_components( rn_codegen_modules( name = "codegen_tests", + android_package_name = "com.facebook.fbreact.specs", native_module_spec_name = "FBReactNativeTestSpec", schema_target = ":codegen_tests_schema", ) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 06a9ef6c937160..7cd02e2c0e2e79 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -105,6 +105,7 @@ def rn_codegen_cli(): def rn_codegen_modules( name, native_module_spec_name, + android_package_name, library_labels = [], schema_target = ""): generate_fixtures_rule_name = "generate_fixtures_modules-{}".format(name) @@ -118,7 +119,13 @@ def rn_codegen_modules( fb_native.genrule( name = generate_fixtures_rule_name, srcs = native.glob(["src/generators/**/*.js"]), - cmd = "$(exe {}) $(location {}) {} $OUT {}".format(react_native_root_target("packages/react-native-codegen:generate_all_from_schema"), schema_target, name, native_module_spec_name), + cmd = "$(exe {generator_script}) $(location {schema_target}) {library_name} $OUT {native_module_spec_name} {android_package_name}".format( + generator_script = react_native_root_target("packages/react-native-codegen:generate_all_from_schema"), + schema_target = schema_target, + library_name = name, + native_module_spec_name = native_module_spec_name, + android_package_name = android_package_name, + ), out = "codegenfiles-{}".format(name), labels = ["codegen_rule"], ) @@ -128,9 +135,10 @@ def rn_codegen_modules( ################## fb_native.genrule( name = generate_module_java_name, - # TODO: support different package name internally. - # Right now, it's hardcoded to `com.facebook.fbreact.specs`. - cmd = "mkdir -p $OUT/com/facebook/fbreact/specs && cp -r $(location :{})/java/com/facebook/fbreact/specs/* $OUT/com/facebook/fbreact/specs/".format(generate_fixtures_rule_name), + cmd = "mkdir -p $OUT/{spec_path} && cp -r $(location {generator_target})/java/{spec_path}/* $OUT/{spec_path}/".format( + spec_path = android_package_name.replace(".", "/"), + generator_target = ":" + generate_fixtures_rule_name, + ), out = "src", labels = ["codegen_rule"], ) diff --git a/packages/react-native-codegen/src/cli/generators/generate-all.js b/packages/react-native-codegen/src/cli/generators/generate-all.js index 613eec58c0bf48..6b7e8509e9589c 100644 --- a/packages/react-native-codegen/src/cli/generators/generate-all.js +++ b/packages/react-native-codegen/src/cli/generators/generate-all.js @@ -19,7 +19,7 @@ const fs = require('fs'); const mkdirp = require('mkdirp'); const args = process.argv.slice(2); -if (args.length !== 4) { +if (args.length < 4) { throw new Error( `Expected to receive path to schema, library name, output directory and module spec name. Received ${args.join( ', ', diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index 34334426418d58..8739e09bafad58 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -371,10 +371,11 @@ module.exports = { packageName?: string, ): FilesOutput { const files = new Map(); + const nativeModules = getModules(schema); + const normalizedPackageName = - packageName != null ? packageName : 'com.facebook.fbreact.specs'; + packageName == null ? 'com.facebook.fbreact.specs' : packageName; const outputDir = `java/${normalizedPackageName.replace(/\./g, '/')}`; - const nativeModules = getModules(schema); Object.keys(nativeModules).forEach(hasteModuleName => { const { diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js index 6dbe02f952f13a..6904c804baf900 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js @@ -22,7 +22,12 @@ describe('GenerateModuleCpp', () => { it(`can generate fixture ${fixtureName}`, () => { expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), + generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ), ).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js index 658221b56298f4..ffe05d6880de5a 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js @@ -22,7 +22,12 @@ describe('GenerateModuleH', () => { it(`can generate fixture ${fixtureName}`, () => { expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), + generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ), ).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js index 3c4943971857b0..fc148e2efc47ff 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js @@ -21,7 +21,12 @@ describe('GenerateModuleHObjCpp', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - const output = generator.generate(fixtureName, fixture, 'SampleSpec'); + const output = generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ); expect( new Map([['SampleSpec.h', output.get('SampleSpec.h')]]), ).toMatchSnapshot(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js index 5ccb87d2d4b672..e7c77457dd7eba 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js @@ -22,7 +22,12 @@ describe('GenerateModuleJavaSpec', () => { it(`can generate fixture ${fixtureName}`, () => { expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), + generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ), ).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js index e6030bca0fc2d1..d3dae278440717 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js @@ -22,7 +22,12 @@ describe('GenerateModuleJniCpp', () => { it(`can generate fixture ${fixtureName}`, () => { expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), + generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ), ).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js index dcbd78a42c604d..d5ac7ecfb32858 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js @@ -22,7 +22,12 @@ describe('GenerateModuleJniH', () => { it(`can generate fixture ${fixtureName}`, () => { expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), + generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ), ).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js index ec8f4842a106bf..3c0e5686585416 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js @@ -21,7 +21,12 @@ describe('GenerateModuleMm', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - const output = generator.generate(fixtureName, fixture, 'SampleSpec'); + const output = generator.generate( + fixtureName, + fixture, + 'SampleSpec', + 'com.facebook.fbreact.specs', + ); expect( new Map([ ['SampleSpec-generated.mm', output.get('SampleSpec-generated.mm')], From b3defc887239d5edbcb8559ae3a021cf2775be95 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 29 Dec 2020 15:06:15 -0800 Subject: [PATCH 0299/1810] Refactor preComputeConstantsForViewManager to avoid loading UIManagerModule in Fabric Summary: This method refactors the preComputeConstantsForViewManager to avoid loading UIManagerModule when using Fabric + Static View configs changelog: [internal] internal Reviewed By: shergin Differential Revision: D25468182 fbshipit-source-id: e95b0e7d013e832792fb77fc0b6e5705d7f04868 --- .../com/facebook/react/bridge/UIManager.java | 12 ++++++++++++ .../facebook/react/fabric/FabricUIManager.java | 7 +++++++ .../react/fabric/mounting/MountingManager.java | 4 ++++ .../react/uimanager/UIManagerModule.java | 16 ++++++---------- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java index 74af261f5b47c3..f07ec720b98ffa 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java @@ -14,6 +14,7 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; import com.facebook.infer.annotation.ThreadConfined; +import java.util.List; public interface UIManager extends JSIModule, PerformanceCounter { @@ -129,4 +130,15 @@ void updateRootLayoutSpecs( @Deprecated @Nullable String resolveCustomDirectEventName(@Nullable String eventName); + + /** + * Helper method to pre-initialize view managers. When using Native ViewConfigs this method will + * also pre-compute the constants for a view manager. The purpose is to ensure that we don't block + * for getting the constants for view managers during initial rendering of a surface. + * + * @deprecated this method will be removed in the future + * @param viewManagerNames {@link List } names of ViewManagers + */ + @Deprecated + void preInitializeViewManagers(List viewManagerNames); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 8948750319465a..82f743be08536f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -229,6 +229,13 @@ public int addRootView( return rootTag; } + @Override + public void preInitializeViewManagers(List viewManagerNames) { + for (String viewManagerName : viewManagerNames) { + mMountingManager.initializeViewManager(viewManagerName); + } + } + @Override @AnyThread @ThreadConfined(ANY) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index be91c29c23ebe9..2ea54f35e42bb3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -782,6 +782,10 @@ public long measure( return viewState == null ? null : viewState.mEventEmitter; } + public void initializeViewManager(String componentName) { + mViewManagerRegistry.get(componentName); + } + /** * This class holds view state for react tags. Objects of this class are stored into the {@link * #mTagToViewState}, and they should be updated in the same thread. diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index c54cf11316af5e..51f84ebc9400e8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -294,14 +294,16 @@ private static Map createConstants( * Helper method to pre-compute the constants for a view manager. This method ensures that we * don't block for getting the constants for view managers during TTI * - * @deprecated this method will not be available in FabricUIManager class. + * @deprecated this method will be removed in the future * @param viewManagerNames {@link List} names of ViewManagers */ @Deprecated - public void preComputeConstantsForViewManager(List viewManagerNames) { - // TODO T81145457 - Implement pre-initialization of ViewManagers in Fabric Android + @Override + public void preInitializeViewManagers(List viewManagerNames) { if (ReactFeatureFlags.enableExperimentalStaticViewConfigs) { - preInitializeViewManagers(viewManagerNames); + for (String viewManagerName : viewManagerNames) { + mUIImplementation.resolveViewManager(viewManagerName); + } // When Static view configs are enabled it is not necessary to pre-compute the constants for // viewManagers, although the pre-initialization of viewManager objects is still necessary // for performance reasons. @@ -326,12 +328,6 @@ public void preComputeConstantsForViewManager(List viewManagerNames) { mViewManagerConstantsCache = Collections.unmodifiableMap(constantsMap); } - private void preInitializeViewManagers(List viewManagerNames) { - for (String viewManagerName : viewManagerNames) { - mUIImplementation.resolveViewManager(viewManagerName); - } - } - @ReactMethod(isBlockingSynchronousMethod = true) public @Nullable WritableMap getConstantsForViewManager(@Nullable String viewManagerName) { if (mViewManagerConstantsCache != null From 249b341a414ecab6bf43c120b42ccf72d2758765 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 29 Dec 2020 15:52:10 -0800 Subject: [PATCH 0300/1810] Don't redraw images when props don't change Summary: Right now we assume in the Image component that any prop changes requires a redraw of the image, even if the props set are identical. Noop prop updates can be caused in Fabric by LayoutAnimations. This may go away in the future, but only when we have a new animations system. I don't think most other components need to be concerned with this, and many other components already guard against unnecessary redraws. Since the image "flashes" when it is loaded, unlike most other native components, this issue is more noticeable for images. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25727482 fbshipit-source-id: 75ffa456bddc1208900733140ce4ff19f7e2c11e --- .../react/views/image/ReactImageView.java | 82 ++++++++++++++----- .../react/views/imagehelper/ImageSource.java | 17 ++++ 2 files changed, 77 insertions(+), 22 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java index 68ada3dfc70627..9869fe878ded27 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java @@ -23,6 +23,7 @@ import android.net.Uri; import android.widget.Toast; import androidx.annotation.Nullable; +import com.facebook.common.internal.Objects; import com.facebook.common.references.CloseableReference; import com.facebook.common.util.UriUtil; import com.facebook.drawee.controller.AbstractDraweeControllerBuilder; @@ -90,8 +91,10 @@ public class ReactImageView extends GenericDraweeView { private ImageResizeMethod mResizeMethod = ImageResizeMethod.AUTO; public void updateCallerContext(@Nullable Object callerContext) { - mCallerContext = callerContext; - mIsDirty = true; + if (!Objects.equal(mCallerContext, callerContext)) { + mCallerContext = callerContext; + mIsDirty = true; + } } private class RoundedCornerPostprocessor extends BasePostprocessor { @@ -229,6 +232,11 @@ public ReactImageView( } public void setShouldNotifyLoadEvents(boolean shouldNotify) { + // Skip update if shouldNotify is already in sync with the download listener + if (shouldNotify == (mDownloadListener != null)) { + return; + } + if (!shouldNotify) { mDownloadListener = null; } else { @@ -295,18 +303,25 @@ public void setBackgroundColor(int backgroundColor) { } public void setBorderColor(int borderColor) { - mBorderColor = borderColor; - mIsDirty = true; + if (mBorderColor != borderColor) { + mBorderColor = borderColor; + mIsDirty = true; + } } public void setOverlayColor(int overlayColor) { - mOverlayColor = overlayColor; - mIsDirty = true; + if (mOverlayColor != overlayColor) { + mOverlayColor = overlayColor; + mIsDirty = true; + } } public void setBorderWidth(float borderWidth) { - mBorderWidth = PixelUtil.toPixelFromDIP(borderWidth); - mIsDirty = true; + float newBorderWidth = PixelUtil.toPixelFromDIP(borderWidth); + if (!FloatUtil.floatsEqual(mBorderWidth, newBorderWidth)) { + mBorderWidth = newBorderWidth; + mIsDirty = true; + } } public void setBorderRadius(float borderRadius) { @@ -329,32 +344,39 @@ public void setBorderRadius(float borderRadius, int position) { } public void setScaleType(ScalingUtils.ScaleType scaleType) { - mScaleType = scaleType; - mIsDirty = true; + if (mScaleType != scaleType) { + mScaleType = scaleType; + mIsDirty = true; + } } public void setTileMode(Shader.TileMode tileMode) { - mTileMode = tileMode; - mIsDirty = true; + if (mTileMode != tileMode) { + mTileMode = tileMode; + mIsDirty = true; + } } public void setResizeMethod(ImageResizeMethod resizeMethod) { - mResizeMethod = resizeMethod; - mIsDirty = true; + if (mResizeMethod != resizeMethod) { + mResizeMethod = resizeMethod; + mIsDirty = true; + } } public void setSource(@Nullable ReadableArray sources) { - mSources.clear(); + List tmpSources = new LinkedList<>(); + if (sources == null || sources.size() == 0) { ImageSource imageSource = new ImageSource(getContext(), REMOTE_TRANSPARENT_BITMAP_URI); - mSources.add(imageSource); + tmpSources.add(imageSource); } else { // Optimize for the case where we have just one uri, case in which we don't need the sizes if (sources.size() == 1) { ReadableMap source = sources.getMap(0); String uri = source.getString("uri"); ImageSource imageSource = new ImageSource(getContext(), uri); - mSources.add(imageSource); + tmpSources.add(imageSource); if (Uri.EMPTY.equals(imageSource.getUri())) { warnImageSource(uri); } @@ -365,28 +387,44 @@ public void setSource(@Nullable ReadableArray sources) { ImageSource imageSource = new ImageSource( getContext(), uri, source.getDouble("width"), source.getDouble("height")); - mSources.add(imageSource); + tmpSources.add(imageSource); if (Uri.EMPTY.equals(imageSource.getUri())) { warnImageSource(uri); } } } } + + // Don't reset sources and dirty node if sources haven't changed + if (mSources.equals(tmpSources)) { + return; + } + + mSources.clear(); + for (ImageSource src : tmpSources) { + mSources.add(src); + } mIsDirty = true; } public void setDefaultSource(@Nullable String name) { - mDefaultImageDrawable = + Drawable newDefaultDrawable = ResourceDrawableIdHelper.getInstance().getResourceDrawable(getContext(), name); - mIsDirty = true; + if (!Objects.equal(mDefaultImageDrawable, newDefaultDrawable)) { + mDefaultImageDrawable = newDefaultDrawable; + mIsDirty = true; + } } public void setLoadingIndicatorSource(@Nullable String name) { Drawable drawable = ResourceDrawableIdHelper.getInstance().getResourceDrawable(getContext(), name); - mLoadingImageDrawable = + Drawable newLoadingIndicatorSource = drawable != null ? (Drawable) new AutoRotateDrawable(drawable, 1000) : null; - mIsDirty = true; + if (!Objects.equal(mLoadingImageDrawable, newLoadingIndicatorSource)) { + mLoadingImageDrawable = newLoadingIndicatorSource; + mIsDirty = true; + } } public void setProgressiveRenderingEnabled(boolean enabled) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.java b/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.java index 9f95b5bae9af05..065ebbe636682f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.java @@ -11,6 +11,7 @@ import android.net.Uri; import androidx.annotation.Nullable; import com.facebook.infer.annotation.Assertions; +import java.util.Objects; /** Class describing an image source (network URI or resource) and size. */ public class ImageSource { @@ -29,6 +30,22 @@ public ImageSource(Context context, String source, double width, double height) mUri = computeUri(context); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ImageSource that = (ImageSource) o; + return Double.compare(that.mSize, mSize) == 0 + && isResource == that.isResource + && Objects.equals(mUri, that.mUri) + && Objects.equals(mSource, that.mSource); + } + + @Override + public int hashCode() { + return Objects.hash(mUri, mSource, mSize, isResource); + } + public ImageSource(Context context, String source) { this(context, source, 0.0d, 0.0d); } From 907b574cf6bca6809d49ba49fff8d91f8c62be10 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 29 Dec 2020 15:52:10 -0800 Subject: [PATCH 0301/1810] LayoutAnimations: change default prop interpolation on Android: set new non-interpolated prop values at beginning of animation, not end Summary: In Android, only changed prop values are sent to the mounting layer via folly::dynamic maps. In the LayoutAnimation system, before this, we only sent that map at the /end/ of the animation for any non-interpolated values (for example, image source is not interpolated so it was not updated until the end of the animation). However, what we probably expect is that all non-interpolated values change immediately, and interpolated values smoothly transition. This diff makes that change on Android by using the final RawProps as the /initial/ value that interpolations are stacked on. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25727483 fbshipit-source-id: e692d37b9965fedcdf429a81d60b7cb7f0c6abe1 --- .../renderer/components/view/ViewComponentDescriptor.h | 8 ++++++++ .../react/renderer/core/ConcreteComponentDescriptor.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h b/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h index fd078e656c89b1..4ec013c7fb5bdb 100644 --- a/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h @@ -25,7 +25,15 @@ class ViewComponentDescriptor float animationProgress, const SharedProps &props, const SharedProps &newProps) const override { +#ifdef ANDROID + // On Android only, the merged props should have the same RawProps as the + // final props struct + SharedProps interpolatedPropsShared = + (newProps != nullptr ? cloneProps(newProps, newProps->rawProps) + : cloneProps(newProps, {})); +#else SharedProps interpolatedPropsShared = cloneProps(newProps, {}); +#endif interpolateViewProps( animationProgress, props, newProps, interpolatedPropsShared); diff --git a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index 497cf561e3d8ca..18217e60e1e532 100644 --- a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -127,6 +127,14 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { const SharedProps &props, const SharedProps &newProps) const override { // By default, this does nothing. +#ifdef ANDROID + // On Android only, the merged props should have the same RawProps as the + // final props struct + if (newProps != nullptr) { + return cloneProps(newProps, newProps->rawProps); + } +#endif + return cloneProps(newProps, {}); }; From 266108d7d8b3f69088ca27c94f639135c55c3791 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 29 Dec 2020 15:52:10 -0800 Subject: [PATCH 0302/1810] LayoutAnimations: use the final view as the baseline for animations, instead of the initial view Summary: To ensure that we're not sending old eventEmitters or State objects to the mounting layer, or potentially out-of-date Props objects, base animated interpolations on the final ShadowNode instead of the initial. Changelog: [Internal] Reviewed By: shergin Differential Revision: D25727481 fbshipit-source-id: 560ae8d25c7cec4c2137e70b4571b762f461edff --- .../animations/LayoutAnimationKeyFrameManager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 48d652328d81c1..ba068284c4ccbb 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1623,7 +1623,15 @@ ShadowView LayoutAnimationKeyFrameManager::createInterpolatedShadowView( } ComponentDescriptor const &componentDescriptor = getComponentDescriptorForShadowView(startingView); - auto mutatedShadowView = ShadowView(startingView); + + // Base the mutated view on the finalView, so that the following stay + // consistent: + // - state + // - eventEmitter + // For now, we do not allow interpolation of state. And we probably never + // will, so make sure we always keep the mounting layer consistent with the + // "final" state. + auto mutatedShadowView = ShadowView(finalView); if (startingView.props == nullptr || finalView.props == nullptr) { return finalView; From ee5a27b759a1a480bec17ff8c758ef755c768909 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 29 Dec 2020 15:52:10 -0800 Subject: [PATCH 0303/1810] Remove temporary Litho-interop feature flag Summary: Remove temporary Litho-interop feature flag. Changelog: [Internal] Differential Revision: D25445364 fbshipit-source-id: c0fa3e6e5e55c0997e4a5ddd6c1cc5695878c7d2 --- .../main/java/com/facebook/react/config/ReactFeatureFlags.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index c0e8f35cd0011a..d1318d9237d469 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -60,9 +60,6 @@ public class ReactFeatureFlags { /** Use lock-free data structures for Fabric MountItems. */ public static boolean enableLockFreeMountInstructions = false; - /** Temporary flag for FB-internal workaround for RN:Litho interop in non-Fabric RN. */ - public static boolean enableNonFabricRNLithoForceLayout = true; - /** Disable UI update operations in non-Fabric renderer after catalyst instance was destroyed */ public static boolean disableNonFabricViewOperationsOnCatalystDestroy = false; From 00e038689db6c31a33603f6431afbefb197ebdd5 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 29 Dec 2020 15:56:52 -0800 Subject: [PATCH 0304/1810] TextInput measuring error in ScrollResponder downgraded to a warning Summary: Even though replacing an error with a warning does not look like a future-proof solution here are the reasons for this: * The measuring operation might just fail because of the async nature of React Native. And here, from my understanding, we don't even have a good reason for measuring. Auto-scrolling to selected textinput (which is the reason for this code, AFAIK) is a standard feature that OS does for all text input. I suspect that this (very old) feature was built in a timeframe where this system feature was originally broken (sometime before 2016). * This product-facing API does not have an error-callback, so just loggin an error here is as (not) actionable as logging a warning. * The error callback was never implemented in the pre-Fabric world, so it *never* got called for years, and now when Fabric is starting calling in some cases, it is being "punished" for this. In the next diff, I will try to retrofit this feature back to Paper to reach parity with Paper. Changelog: [Internal] Differential Revision: D25700156 fbshipit-source-id: 319a146b17cc2130848148ad11adbde16e86c5d5 --- Libraries/Components/ScrollResponder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 55571c86e08f60..c0be65511536b3 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -678,8 +678,8 @@ const ScrollResponderMixin = { this.preventNegativeScrollOffset = false; }, - scrollResponderTextInputFocusError: function(msg: string) { - console.error('Error measuring text field: ', msg); + scrollResponderTextInputFocusError: function() { + console.warn('Error measuring text field.'); }, /** From 811ccec74e5b898e9304f86f85f390908f8d317f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Tue, 29 Dec 2020 16:08:29 -0800 Subject: [PATCH 0305/1810] Add use_react_native_codegen! Summary: Consolidate CocoaPods codegen scripts under a single `use_react_native_codegen!` method in `react_native_pods.rb`. This is the first step towards making the codegen scripts library-agnostic. There are still a handful of hardcoded assumptions in place (e.g. the output directory structure, the use of a separate directory for components), but with some work one would be able to add codegen support to arbitrary CocoaPods podspecs. The codegen script no longer takes a CODEGEN_PATH argument, and will instead attempt to use the local react-native-codegen package if available, and fallback to using the node_modules/react-native-codegen package if not. ## Usage The `use_react_native_codegen!` method has two arguments: - `spec`, a pod [Specification](https://www.rubydoc.info/github/CocoaPods/Core/Pod/Specification) object. - `options`, an optional object. Supported keys: - `:srcs_dir`, the path to your JavaScript sources. Your native module or component specs should be located somewhere in this directory. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25728053 fbshipit-source-id: feec587b656d5b220598ce6196ea6bb34a9580a9 --- .../FBReactNativeSpec.podspec | 36 +------------ packages/rn-tester/Podfile.lock | 2 +- scripts/generate-specs.sh | 21 +++++--- scripts/react_native_pods.rb | 50 ++++++++++++++++++- 4 files changed, 65 insertions(+), 44 deletions(-) diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec index 79493bdca4ebec..0be878326215b2 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -4,44 +4,19 @@ # LICENSE file in the root directory of this source tree. require "json" +require_relative "../../scripts/react_native_pods.rb" package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) version = package['version'] source = { :git => 'https://github.com/facebook/react-native.git' } -codegen_path_prefix = ".." if version == '1000.0.0' # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. source[:commit] = `git rev-parse HEAD`.strip - codegen_path_prefix = "packages" else source[:tag] = "v#{version}" end -react_native_path = File.join(__dir__, "..", "..") -srcs_dir = File.join(__dir__, "..") -codegen_script_path = File.join(react_native_path, "scripts", "generate-specs.sh") -codegen_path = File.join(react_native_path, codegen_path_prefix, "react-native-codegen") -codegen_command = "CODEGEN_PATH=#{codegen_path} sh '#{codegen_script_path}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"" -modules_output_dir = File.join(__dir__, "FBReactNativeSpec") -components_output_dir = File.join(react_native_path, "ReactCommon", "react", "renderer", "components", "rncore") -generated_filenames = [ "FBReactNativeSpec.h", "FBReactNativeSpec-generated.mm" ] -generated_files = generated_filenames.map { |filename| File.join(modules_output_dir, filename) } - -if ENV['USE_FABRIC'] == '1' - components_generated_filenames = [ - "ComponentDescriptors.h", - "EventEmitters.cpp", - "EventEmitters.h", - "Props.cpp", - "Props.h", - "RCTComponentViewHelpers.h", - "ShadowNodes.cpp", - "ShadowNodes.h" - ] - generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(components_output_dir, filename) }) -end - folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' folly_version = '2020.01.13.00' @@ -72,12 +47,5 @@ Pod::Spec.new do |s| s.dependency "React-jsi", version s.dependency "ReactCommon/turbomodule/core", version - s.prepare_command = "mkdir -p #{modules_output_dir} #{components_output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}" - s.script_phase = { - :name => 'Generate Specs', - :input_files => [srcs_dir], - :output_files => ["$(DERIVED_FILE_DIR)/codegen.log"], - :script => codegen_command, - :execution_position => :before_compile - } + use_react_native_codegen! (s) end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index f3ddbec6b86801..9af165313093d9 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -798,7 +798,7 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 259a715466e53b411664fdfbe166dbde93ece5b6 + FBReactNativeSpec: cc83b1f9c1a764577c37a7009d002b8afb36f192 Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a diff --git a/scripts/generate-specs.sh b/scripts/generate-specs.sh index 69de08b3dcc3e3..25cf8d255118ff 100755 --- a/scripts/generate-specs.sh +++ b/scripts/generate-specs.sh @@ -7,16 +7,10 @@ # This script collects the JavaScript spec definitions for core # native modules and components, then uses react-native-codegen # to generate native code. -# The script will use the local react-native-codegen package by -# default. Optionally, set the CODEGEN_PATH to point to the -# desired codegen library (e.g. when using react-native-codegen -# from npm). # # Usage: # ./scripts/generate-specs.sh # -# Examples: -# CODEGEN_PATH=.. ./scripts/generate-specs.sh # shellcheck disable=SC2038 @@ -25,7 +19,6 @@ set -e THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) TEMP_DIR=$(mktemp -d /tmp/react-native-codegen-XXXXXXXX) RN_DIR=$(cd "$THIS_DIR/.." && pwd) -CODEGEN_PATH="${CODEGEN_PATH:-$(cd "$RN_DIR/packages/react-native-codegen" && pwd)}" YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}" USE_FABRIC="${USE_FABRIC:-0}" @@ -48,6 +41,18 @@ main() { SCHEMA_FILE="$TEMP_DIR/schema.json" + CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen" + CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen" + + if [ -d "$CODEGEN_REPO_PATH" ]; then + CODEGEN_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd) + elif [ -d "$CODEGEN_NPM_PATH" ]; then + CODEGEN_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd) + else + echo "Error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." 1>&2 + exit 1 + fi + if [ ! -d "$CODEGEN_PATH/lib" ]; then describe "Building react-native-codegen package" pushd "$CODEGEN_PATH" >/dev/null || exit @@ -61,7 +66,7 @@ main() { describe "Generating native code from schema (iOS)" pushd "$RN_DIR" >/dev/null || exit - USE_FABRIC="$USE_FABRIC" "$YARN_BINARY" --silent node scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$OUTPUT_DIR" + "$YARN_BINARY" --silent node scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$OUTPUT_DIR" popd >/dev/null || exit mkdir -p "$COMPONENTS_DIR" "$MODULES_DIR" diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 1e28bee9e59468..f26f587e109def 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. def use_react_native! (options={}) - # The prefix to the react-native + # The prefix to react-native prefix = options[:path] ||= "../node_modules/react-native" # Include Fabric dependencies @@ -144,3 +144,51 @@ def react_native_post_install(installer) exclude_architectures(installer) end + +def use_react_native_codegen!(spec, options={}) + # The path to react-native (e.g. react_native_path) + prefix = options[:path] ||= File.join(__dir__, "..") + + # The path to JavaScript files + srcs_dir = options[:srcs_dir] ||= File.join(prefix, "Libraries") + + # Library name (e.g. FBReactNativeSpec) + library_name = spec.name + modules_output_dir = File.join(prefix, "Libraries/#{library_name}/#{library_name}") + + # Run the codegen as part of the Xcode build pipeline. + spec.script_phase = { + :name => 'Generate Specs', + :input_files => [srcs_dir], + :output_files => ["$(DERIVED_FILE_DIR)/codegen.log"], + :script => "sh '#{File.join(__dir__, "generate-specs.sh")}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"", + :execution_position => :before_compile + } + + # Since the generated files are not guaranteed to exist when CocoaPods is run, we need to create + # empty files to ensure the references are included in the resulting Pods Xcode project. + mkdir_command = "mkdir -p #{modules_output_dir}" + generated_filenames = [ "#{library_name}.h", "#{library_name}-generated.mm" ] + generated_files = generated_filenames.map { |filename| File.join(modules_output_dir, filename) } + + if ENV['USE_FABRIC'] == '1' + # We use a different library name for components, as well as an additional set of files. + # Eventually, we want these to be part of the same library as #{library_name} above. + components_library_name = "rncore" + components_output_dir = File.join(prefix, "ReactCommon/react/renderer/components/#{components_library_name}") + mkdir_command += " #{components_output_dir}" + components_generated_filenames = [ + "ComponentDescriptors.h", + "EventEmitters.cpp", + "EventEmitters.h", + "Props.cpp", + "Props.h", + "RCTComponentViewHelpers.h", + "ShadowNodes.cpp", + "ShadowNodes.h" + ] + generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(components_output_dir, filename) }) + end + + spec.prepare_command = "#{mkdir_command} && touch #{generated_files.reduce() { |str, file| str + " " + file }}" +end From 053b8f6c9377fdef294d11088ff5d7ed2c311a2f Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 30 Dec 2020 12:16:53 -0800 Subject: [PATCH 0306/1810] Fix typo in ReactNativeTypes Summary: Faric -> Fabric Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25734126 fbshipit-source-id: 5d0bb02482fd713601de0a22477c5b5c39daf522 --- Libraries/Renderer/shims/ReactNativeTypes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 86cb8908473859..4510551f7da690 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -197,7 +197,7 @@ export type ReactNativeEventTarget = { ... }; -export type ReactFaricEventTouch = { +export type ReactFabricEventTouch = { identifier: number, locationX: number, locationY: number, @@ -211,10 +211,10 @@ export type ReactFaricEventTouch = { ... }; -export type ReactFaricEvent = { - touches: Array, - changedTouches: Array, - targetTouches: Array, +export type ReactFabricEvent = { + touches: Array, + changedTouches: Array, + targetTouches: Array, target: number, ... }; From 4984c1e525e310f15c7d89230fdb2fa8fea91f05 Mon Sep 17 00:00:00 2001 From: Kacie Bawiec Date: Wed, 30 Dec 2020 19:32:44 -0800 Subject: [PATCH 0307/1810] Back out "Refactor initialization of Fabric to avoid loading UIManagerModule" Summary: This diff D25468183 (https://github.com/facebook/react-native/commit/c776f09e5f8be53a7d9196d6497b4780eb051703) is causing TetraFormTextInput's onChange not to fire. See https://fb.workplace.com/groups/rn.support/permalink/4918163014898941/ I confirmed this was the bad diff via mobile bisect. changelog: [internal] internal Reviewed By: rickhanlonii, mdvacca, nadiia Differential Revision: D25739854 fbshipit-source-id: efdfb1e464dd5d990d5c9ea291dde9895736817a --- .../react/fabric/FabricJSIModuleProvider.java | 18 ++++++++++-------- .../react/uiapp/RNTesterApplication.java | 11 +---------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index e36f851b3002ce..91fe11b20cd55e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -8,6 +8,7 @@ package com.facebook.react.fabric; import androidx.annotation.NonNull; +import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSIModuleProvider; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UIManager; @@ -33,10 +34,9 @@ import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem; import com.facebook.react.fabric.mounting.mountitems.UpdateStateMountItem; import com.facebook.react.uimanager.StateWrapper; -import com.facebook.react.uimanager.ViewManagerRegistry; +import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.events.BatchEventDispatchedListener; import com.facebook.react.uimanager.events.EventDispatcher; -import com.facebook.react.uimanager.events.EventDispatcherImpl; import com.facebook.systrace.Systrace; public class FabricJSIModuleProvider implements JSIModuleProvider { @@ -44,17 +44,14 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { @NonNull private final ReactApplicationContext mReactApplicationContext; @NonNull private final ComponentFactory mComponentFactory; @NonNull private final ReactNativeConfig mConfig; - @NonNull private final ViewManagerRegistry mViewManagerRegistry; public FabricJSIModuleProvider( @NonNull ReactApplicationContext reactApplicationContext, @NonNull ComponentFactory componentFactory, - @NonNull ReactNativeConfig config, - @NonNull ViewManagerRegistry viewManagerRegistry) { + @NonNull ReactNativeConfig config) { mReactApplicationContext = reactApplicationContext; mComponentFactory = componentFactory; mConfig = config; - mViewManagerRegistry = viewManagerRegistry; } @Override @@ -90,10 +87,15 @@ public UIManager get() { private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager"); - EventDispatcher eventDispatcher = new EventDispatcherImpl(mReactApplicationContext); + UIManagerModule nativeModule = + Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class)); + EventDispatcher eventDispatcher = nativeModule.getEventDispatcher(); FabricUIManager fabricUIManager = new FabricUIManager( - mReactApplicationContext, mViewManagerRegistry, eventDispatcher, eventBeatManager); + mReactApplicationContext, + nativeModule.getViewManagerRegistry_DO_NOT_USE(), + eventDispatcher, + eventBeatManager); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); return fabricUIManager; diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index e8eec3ae80b7a3..b892f527c0e4a9 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -34,7 +34,6 @@ import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.shell.MainReactPackage; import com.facebook.react.turbomodule.core.TurboModuleManager; -import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.views.text.ReactFontManager; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; @@ -169,13 +168,6 @@ public JSIModuleType getJSIModuleType() { public JSIModuleProvider getJSIModuleProvider() { final ComponentFactory ComponentFactory = new ComponentFactory(); CoreComponentsRegistry.register(ComponentFactory); - final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); - - ViewManagerRegistry viewManagerRegistry = - new ViewManagerRegistry( - reactInstanceManager.getOrCreateViewManagers( - reactApplicationContext)); - return new FabricJSIModuleProvider( reactApplicationContext, ComponentFactory, @@ -200,8 +192,7 @@ public String getString(final String s) { public double getDouble(final String s) { return 0; } - }, - viewManagerRegistry); + }); } }); } From b9ad5a706d698de16ddd9b9d5c2a1684ced7bda2 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 1 Jan 2021 15:43:24 -0800 Subject: [PATCH 0308/1810] Micro-optimization in ReadableNativeMaps Summary: This is just a micro-optimization in ReadableNativeMaps. It wont change much in perf.. changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25733948 fbshipit-source-id: b01109acdf5b2eb532801469ef5cb845010c6ed0 --- .../src/main/jni/react/jni/ReadableNativeMap.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/jni/ReadableNativeMap.cpp b/ReactAndroid/src/main/jni/react/jni/ReadableNativeMap.cpp index c1ad15082bebf5..61f686c4404466 100644 --- a/ReactAndroid/src/main/jni/react/jni/ReadableNativeMap.cpp +++ b/ReactAndroid/src/main/jni/react/jni/ReadableNativeMap.cpp @@ -64,14 +64,15 @@ local_ref> ReadableNativeMap::importKeys() { return JArrayClass::newArray(0); } auto pairs = map_.items(); - for (auto &pair : pairs) { - keys_.value().push_back(pair.first.asString()); - } - jint size = keys_.value().size(); + jint size = map_.size(); auto jarray = JArrayClass::newArray(size); - for (jint ii = 0; ii < size; ii++) { - (*jarray)[ii] = make_jstring(keys_.value()[ii].getString()); + jint i = 0; + for (auto &pair : pairs) { + auto value = pair.first.asString(); + keys_.value().push_back(value); + (*jarray)[i++] = make_jstring(value); } + return jarray; } From 89beefaefb6ef39b278b36d57ec17189254ce1c3 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 1 Jan 2021 15:43:24 -0800 Subject: [PATCH 0309/1810] Setup test infra into mapBuffer project Summary: Setup test infra into mapBuffer project changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25733949 fbshipit-source-id: bcfc89d87e28dc5a6ed28bc6b56893aa6f191e71 --- ReactCommon/react/renderer/mapbuffer/BUCK | 3 ++- ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp | 4 ++++ ReactCommon/react/renderer/mapbuffer/MapBuffer.h | 2 ++ .../react/renderer/mapbuffer/tests/MapBufferTest.cpp | 10 ++++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/mapbuffer/BUCK b/ReactCommon/react/renderer/mapbuffer/BUCK index 5bd4038921efe8..dc246215845732 100644 --- a/ReactCommon/react/renderer/mapbuffer/BUCK +++ b/ReactCommon/react/renderer/mapbuffer/BUCK @@ -22,7 +22,7 @@ rn_xplat_cxx_library( [ ("", "*.h"), ], - prefix = "react", + prefix = "react/renderer/mapbuffer", ), compiler_flags = [ "-fexceptions", @@ -63,5 +63,6 @@ fb_xplat_cxx_test( deps = [ "//xplat/folly:molly", "//xplat/third-party/gmock:gtest", + react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), ], ) diff --git a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp index 085ccae66c975d..2113ecf41e0a3d 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp +++ b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp @@ -14,5 +14,9 @@ MapBuffer::MapBuffer() {} MapBuffer::~MapBuffer() {} +int MapBuffer::getSize() { + return 0; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/mapbuffer/MapBuffer.h b/ReactCommon/react/renderer/mapbuffer/MapBuffer.h index 3ce365990d5250..1a3e5b12e3b401 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBuffer.h +++ b/ReactCommon/react/renderer/mapbuffer/MapBuffer.h @@ -31,6 +31,8 @@ class MapBuffer { public: MapBuffer(); virtual ~MapBuffer(); + + int getSize(); }; } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp index 4785f09ae7e498..eba9018f90971d 100644 --- a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp +++ b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp @@ -7,8 +7,14 @@ #include +#include #include +#include -TEST(MapBufferTest, testSomething) { - // TODO +using namespace facebook::react; + +// Dummy test to create setup of tests +TEST(MapBufferTest, testMapCreation) { + auto buffer = MapBuffer(); + assert(buffer.getSize() == 0); } From e088a4fe9c15a89db82b8c9c6220d6ddeb1f811a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 4 Jan 2021 03:52:18 -0800 Subject: [PATCH 0310/1810] Add support for UnsafeObject to allow using Flow strict in native modules Summary: This new type will be valid in Flow strict mode and can be used by native modules and components to replace `Object`, with the same semantics. This unblocks the migration of the most modules in the React Native package to Flow strict. Changelog: [Internal] Add UnsafeObject type compatible with Flow strict mode to use in native modules and components Reviewed By: RSNara Differential Revision: D25540631 fbshipit-source-id: 60b80bbc84a53aecc747e3a1799cdf551e1859cd --- .../samples/NativeSampleTurboModule.js | 2 + Libraries/Types/CodegenTypes.js | 1 + .../android/NativeSampleTurboModuleSpec.java | 3 ++ .../platform/android/SampleTurboModule.java | 10 +++++ .../ios/RCTNativeSampleTurboModuleSpec.h | 1 + .../ios/RCTNativeSampleTurboModuleSpec.mm | 11 ++++++ .../platform/ios/RCTSampleTurboModule.mm | 5 +++ .../ios/SampleTurboCxxModuleLegacyImpl.cpp | 11 ++++++ .../ios/SampleTurboCxxModuleLegacyImpl.h | 1 + .../__tests__/react-native-modules-test.js | 15 +++++++- .../modules/__test_fixtures__/fixtures.js | 26 +++++++++++++ .../module-parser-snapshot-test.js.snap | 37 +++++++++++++++++++ .../src/parsers/flow/modules/index.js | 1 + .../TurboModule/SampleTurboModuleExample.js | 2 + 14 files changed, 125 insertions(+), 1 deletion(-) diff --git a/Libraries/TurboModule/samples/NativeSampleTurboModule.js b/Libraries/TurboModule/samples/NativeSampleTurboModule.js index f9c4c6ef53e393..d240c4ad3ab4a4 100644 --- a/Libraries/TurboModule/samples/NativeSampleTurboModule.js +++ b/Libraries/TurboModule/samples/NativeSampleTurboModule.js @@ -10,6 +10,7 @@ 'use strict'; +import type {UnsafeObject} from '../../Types/CodegenTypes'; import type {RootTag, TurboModule} from '../RCTExport'; import * as TurboModuleRegistry from '../TurboModuleRegistry'; @@ -26,6 +27,7 @@ export interface Spec extends TurboModule { +getString: (arg: string) => string; +getArray: (arg: Array) => Array; +getObject: (arg: Object) => Object; + +getUnsafeObject: (arg: UnsafeObject) => UnsafeObject; +getRootTag: (arg: RootTag) => RootTag; +getValue: (x: number, y: string, z: Object) => Object; +getValueWithCallback: (callback: (value: string) => void) => void; diff --git a/Libraries/Types/CodegenTypes.js b/Libraries/Types/CodegenTypes.js index 9e33919fdd845f..457ef2f39028c9 100644 --- a/Libraries/Types/CodegenTypes.js +++ b/Libraries/Types/CodegenTypes.js @@ -28,6 +28,7 @@ export type DirectEventHandler< export type Double = number; export type Float = number; export type Int32 = number; +export type UnsafeObject = $FlowFixMe; // Object is forbidden in strict mode type DefaultTypes = number | boolean | string | $ReadOnlyArray; // Default handling, ignore the unused value diff --git a/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java b/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java index 8475fbc4711299..f992e5d6ae1c67 100644 --- a/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java +++ b/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java @@ -42,6 +42,9 @@ public NativeSampleTurboModuleSpec(ReactApplicationContext reactContext) { @ReactMethod(isBlockingSynchronousMethod = true) public abstract WritableMap getObject(ReadableMap arg); + @ReactMethod(isBlockingSynchronousMethod = true) + public abstract WritableMap getUnsafeObject(ReadableMap arg); + @ReactMethod public abstract void voidFunc(); diff --git a/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java b/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java index bc357d2baa3d9b..f919eb5bd2dd07 100644 --- a/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java +++ b/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java @@ -109,6 +109,16 @@ public WritableMap getObject(ReadableMap arg) { return map; } + @DoNotStrip + @Override + @SuppressWarnings("unused") + public WritableMap getUnsafeObject(ReadableMap arg) { + WritableNativeMap map = new WritableNativeMap(); + map.merge(arg); + log("getUnsafeObject", arg, map); + return map; + } + @DoNotStrip @SuppressWarnings("unused") @Override diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h index 4738cff8d10ad5..b14289e1cd1baa 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h @@ -26,6 +26,7 @@ - (NSString *)getString:(NSString *)arg; - (NSArray> *)getArray:(NSArray *)arg; - (NSDictionary *)getObject:(NSDictionary *)arg; +- (NSDictionary *)getUnsafeObject:(NSDictionary *)arg; - (NSNumber *)getRootTag:(double)arg; - (NSDictionary *)getValue:(double)x y:(NSString *)y z:(NSDictionary *)z; - (void)getValueWithCallback:(RCTResponseSenderBlock)callback; diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm index 70f69b107babb3..7337f63d51814f 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm @@ -70,6 +70,16 @@ .invokeObjCMethod(rt, ObjectKind, "getObject", @selector(getObject:), args, count); } +static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getUnsafeObject( + facebook::jsi::Runtime &rt, + TurboModule &turboModule, + const facebook::jsi::Value *args, + size_t count) +{ + return static_cast(turboModule) + .invokeObjCMethod(rt, ObjectKind, "getUnsafeObject", @selector(getUnsafeObject:), args, count); +} + static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag( facebook::jsi::Runtime &rt, TurboModule &turboModule, @@ -130,6 +140,7 @@ methodMap_["getString"] = MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getString}; methodMap_["getArray"] = MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getArray}; methodMap_["getObject"] = MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getObject}; + methodMap_["getUnsafeObject"] = MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getUnsafeObject}; methodMap_["getRootTag"] = MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag}; methodMap_["getValue"] = MethodMetadata{3, __hostFunction_NativeSampleTurboModuleSpecJSI_getValue}; methodMap_["getValueWithCallback"] = diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm index 3e019c791eaba5..ac1d236ed7dc2d 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm @@ -96,6 +96,11 @@ - (NSDictionary *)constantsToExport return arg; } +RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, getUnsafeObject : (NSDictionary *)arg) +{ + return arg; +} + RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSNumber *, getRootTag : (double)arg) { return @(arg); diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp index 5eea42c3d8058a..a66b01ef2c16b2 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp +++ b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp @@ -69,6 +69,12 @@ std::vector SampleTurboCxxModuleLegacyImpl::getMethods() { return getObject(xplat::jsArgAsObject(args, 0)); }, CxxModule::SyncTag), + CxxModule::Method( + "getUnsafeObject", + [this](folly::dynamic args) { + return getUnsafeObject(xplat::jsArgAsObject(args, 0)); + }, + CxxModule::SyncTag), CxxModule::Method( "getRootTag", [this](folly::dynamic args) { @@ -126,6 +132,11 @@ folly::dynamic SampleTurboCxxModuleLegacyImpl::getObject( return arg; } +folly::dynamic SampleTurboCxxModuleLegacyImpl::getUnsafeObject( + const folly::dynamic &arg) { + return arg; +} + double SampleTurboCxxModuleLegacyImpl::getRootTag(double arg) { return arg; } diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h index 72d0e3b4adbf49..a3aa44062f5728 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h +++ b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h @@ -31,6 +31,7 @@ class SampleTurboCxxModuleLegacyImpl std::string getString(const std::string &arg); folly::dynamic getArray(const folly::dynamic &arg); folly::dynamic getObject(const folly::dynamic &arg); + folly::dynamic getUnsafeObject(const folly::dynamic &arg); double getRootTag(double arg); folly::dynamic getValue(double x, const std::string &y, const folly::dynamic &z); diff --git a/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js b/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js index 18880a57eac5b2..7591ffb86a8d82 100644 --- a/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js +++ b/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js @@ -18,7 +18,20 @@ const NATIVE_MODULES_DIR = __dirname; const eslintTester = new ESLintTester(); -const VALID_SPECS = []; +const VALID_SPECS = [ + { + code: ` +import {TurboModuleRegistry, type TurboModule} from 'react-native'; +import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes'; + +export interface Spec extends TurboModule { + func1(a: string): UnsafeObject, +} +export default TurboModuleRegistry.get('XYZ'); + `, + filename: `${NATIVE_MODULES_DIR}/NativeXYZ.js`, + }, +]; const INVALID_SPECS = [ // Untyped NativeModule require diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js index 9ef58d4d097333..e05e185232ca59 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js @@ -257,6 +257,31 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); `; +const NATIVE_MODULE_WITH_UNSAFE_OBJECT = ` +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +'use strict'; + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes'; + +export interface Spec extends TurboModule { + +getUnsafeObject: (o: UnsafeObject) => UnsafeObject, +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); + +`; + const NATIVE_MODULE_WITH_ROOT_TAG = ` /** * Copyright (c) Facebook, Inc. and its affiliates. @@ -555,6 +580,7 @@ module.exports = { NATIVE_MODULE_WITH_COMPLEX_OBJECTS, NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY, NATIVE_MODULE_WITH_SIMPLE_OBJECT, + NATIVE_MODULE_WITH_UNSAFE_OBJECT, NATIVE_MODULE_WITH_ROOT_TAG, NATIVE_MODULE_WITH_NULLABLE_PARAM, NATIVE_MODULE_WITH_BASIC_ARRAY, diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap index 1ce7e4797ddad4..2527921cea9f79 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap @@ -1297,3 +1297,40 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_SIMPLE_O } }" `; + +exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_UNSAFE_OBJECT 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getUnsafeObject', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + }, + 'params': [ + { + 'name': 'o', + 'optional': false, + 'typeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 955f8358d5ab5f..e00d157743a129 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -197,6 +197,7 @@ function translateTypeAnnotation( type: 'FloatTypeAnnotation', }); } + case 'UnsafeObject': case 'Object': { return wrapNullable(nullable, { type: 'GenericObjectTypeAnnotation', diff --git a/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js b/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js index bc227cdc94c357..09fdd06f9af7b2 100644 --- a/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js +++ b/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js @@ -68,6 +68,8 @@ class SampleTurboModuleExample extends React.Component<{||}, State> { ]), getObject: () => NativeSampleTurboModule.getObject({a: 1, b: 'foo', c: null}), + getUnsafeObject: () => + NativeSampleTurboModule.getObject({a: 1, b: 'foo', c: null}), getRootTag: () => NativeSampleTurboModule.getRootTag(this.context), getValue: () => NativeSampleTurboModule.getValue(5, 'test', {a: 1, b: 'foo'}), From 1e7536a0700702914e520959f57fe0859b62b1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 4 Jan 2021 03:52:18 -0800 Subject: [PATCH 0311/1810] Migrate CodegenTypes and dependencies to Flow strict Summary: Migrates `CodegenTypes` and its transitive dependencies to Flow strict to unblock this mode in Native Modules and Native Components. Changelog: [Internal] Reviewed By: TheSavior Differential Revision: D25540629 fbshipit-source-id: 7bed2ee58af7a789b50932734c7a86cf1719e2c5 --- Libraries/Renderer/shims/ReactNativeTypes.js | 98 +++++++++++++------- Libraries/Types/CodegenTypes.js | 2 +- Libraries/Types/CoreEventTypes.js | 2 +- Libraries/Utilities/DebugEnvironment.js | 2 +- 4 files changed, 66 insertions(+), 38 deletions(-) diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 4510551f7da690..a38eaaf1141754 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -5,10 +5,15 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict */ -import type {ElementRef, AbstractComponent} from 'react'; +import type { + ElementRef, + ElementType, + MixedElement, + AbstractComponent, +} from 'react'; export type MeasureOnSuccessCallback = ( x: number, @@ -33,22 +38,32 @@ export type MeasureLayoutOnSuccessCallback = ( height: number, ) => void; -type AttributeType = +type AttributeType = | true | $ReadOnly<{| diff?: (arg1: T, arg2: T) => boolean, - process?: (arg1: any) => any, + process?: (arg1: V) => T, |}>; +// We either force that `diff` and `process` always use mixed, +// or we allow them to define specific types and use this hack +type AnyAttributeType = AttributeType<$FlowFixMe, $FlowFixMe>; + type AttributeConfiguration = $ReadOnly<{ - [propName: string]: AttributeType, - style: $ReadOnly<{[propName: string]: AttributeType, ...}>, + [propName: string]: AnyAttributeType, + style: $ReadOnly<{ + [propName: string]: AnyAttributeType, + ..., + }>, ... }>; type PartialAttributeConfiguration = $ReadOnly<{ - [propName: string]: AttributeType, - style?: $ReadOnly<{[propName: string]: AttributeType, ...}>, + [propName: string]: AnyAttributeType, + style?: $ReadOnly<{ + [propName: string]: AnyAttributeType, + ..., + }>, ... }>; @@ -94,7 +109,7 @@ export type NativeMethods = { onSuccess: MeasureLayoutOnSuccessCallback, onFail?: () => void, ): void, - setNativeProps(nativeProps: Object): void, + setNativeProps(nativeProps: {...}): void, ... }; @@ -118,9 +133,11 @@ type InspectorDataSource = $ReadOnly<{| |}>; type InspectorDataGetter = ( - (componentOrHandle: any) => ?number, + ( + componentOrHandle: ElementRef | number, + ) => ?number, ) => $ReadOnly<{| - measure: Function, + measure: (callback: MeasureOnSuccessCallback) => void, props: InspectorDataProps, source: InspectorDataSource, |}>; @@ -152,46 +169,57 @@ export type TouchedViewDataAtPoint = $ReadOnly<{| * Provide minimal Flow typing for the high-level RN API and call it a day. */ export type ReactNativeType = { - findHostInstance_DEPRECATED( - componentOrHandle: any, + findHostInstance_DEPRECATED( + componentOrHandle: ?(ElementRef | number), ): ?ElementRef>, - findNodeHandle(componentOrHandle: any): ?number, - dispatchCommand(handle: any, command: string, args: Array): void, + findNodeHandle( + componentOrHandle: ?(ElementRef | number), + ): ?number, + dispatchCommand( + handle: ElementRef>, + command: string, + args: Array, + ): void, render( - element: React$Element, - containerTag: any, - callback: ?Function, - ): any, - unmountComponentAtNode(containerTag: number): any, - unmountComponentAtNodeAndRemoveContainer(containerTag: number): any, - // TODO (bvaughn) Add types - unstable_batchedUpdates: any, + element: MixedElement, + containerTag: number, + callback: ?() => void, + ): ?ElementRef, + unmountComponentAtNode(containerTag: number): void, + unmountComponentAtNodeAndRemoveContainer(containerTag: number): void, + unstable_batchedUpdates: (fn: (T) => void, bookkeeping: T) => void, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsType, ... }; export type ReactFabricType = { - findHostInstance_DEPRECATED( - componentOrHandle: any, + findHostInstance_DEPRECATED( + componentOrHandle: ?(ElementRef | number), ): ?ElementRef>, - findNodeHandle(componentOrHandle: any): ?number, - dispatchCommand(handle: any, command: string, args: Array): void, + findNodeHandle( + componentOrHandle: ?(ElementRef | number), + ): ?number, + dispatchCommand( + handle: ElementRef>, + command: string, + args: Array, + ): void, render( - element: React$Element, - containerTag: any, - callback: ?Function, - ): any, - unmountComponentAtNode(containerTag: number): any, + element: MixedElement, + containerTag: number, + callback: ?() => void, + ): ?ElementRef, + unmountComponentAtNode(containerTag: number): void, ... }; export type ReactNativeEventTarget = { - node: Object, + node: {...}, canonical: { _nativeTag: number, viewConfig: ViewConfig, - currentProps: Object, - _internalInstanceHandle: Object, + currentProps: {...}, + _internalInstanceHandle: {...}, ... }, ... diff --git a/Libraries/Types/CodegenTypes.js b/Libraries/Types/CodegenTypes.js index 457ef2f39028c9..458cfe80ba88ba 100644 --- a/Libraries/Types/CodegenTypes.js +++ b/Libraries/Types/CodegenTypes.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow strict-local + * @flow strict */ 'use strict'; diff --git a/Libraries/Types/CoreEventTypes.js b/Libraries/Types/CoreEventTypes.js index 6bf13e0aa7cded..906219cd75dde1 100644 --- a/Libraries/Types/CoreEventTypes.js +++ b/Libraries/Types/CoreEventTypes.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow strict-local + * @flow strict * @format */ diff --git a/Libraries/Utilities/DebugEnvironment.js b/Libraries/Utilities/DebugEnvironment.js index c2b3e8ff57ef2c..3ec4eeaa491926 100644 --- a/Libraries/Utilities/DebugEnvironment.js +++ b/Libraries/Utilities/DebugEnvironment.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow strict-local + * @flow strict */ 'use strict'; From c7463f0059d106d8ce4dc6eedc165617d9011ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 4 Jan 2021 03:52:18 -0800 Subject: [PATCH 0312/1810] Add FlowFixMes for future violations of typed NativeEventEmitter Summary: Migrates all usages of `NativeEventEmitter` to `NativeEventEmitter<$FlowFixMe>`. This prevents having to modify a very large number of files in the same change that adds support for typed events. It adds an unused typed parameter to `NativeEventEmitter` so we can change all usages to add `$FlowFixMe`. Changelog: [Internal] Reviewed By: nadiia Differential Revision: D25575774 fbshipit-source-id: c7979e1502e980401d9c03456282eba333c1606d --- Libraries/AppState/AppState.js | 2 +- Libraries/Components/Keyboard/Keyboard.js | 2 +- Libraries/Components/StatusBar/StatusBarIOS.js | 2 +- Libraries/EventEmitter/NativeEventEmitter.js | 4 +++- Libraries/Linking/Linking.js | 2 +- Libraries/Modal/Modal.js | 2 +- Libraries/Network/RCTNetworking.android.js | 2 +- Libraries/Network/RCTNetworking.ios.js | 2 +- Libraries/PushNotificationIOS/PushNotificationIOS.js | 2 +- Libraries/Utilities/Appearance.js | 4 +++- Libraries/Utilities/DevSettings.js | 3 ++- Libraries/WebSocket/WebSocket.js | 2 +- 12 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index cc8a62a381ff8e..8a342d01f03dcf 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -22,7 +22,7 @@ import invariant from 'invariant'; * * See https://reactnative.dev/docs/appstate.html */ -class AppState extends NativeEventEmitter { +class AppState extends NativeEventEmitter<$FlowFixMe> { _eventHandlers: Object; _supportedEvents = ['change', 'memoryWarning', 'blur', 'focus']; currentState: ?string; diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index a9e0a29771ddfd..3c445e04e887b1 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -15,7 +15,7 @@ import LayoutAnimation from '../../LayoutAnimation/LayoutAnimation'; import dismissKeyboard from '../../Utilities/dismissKeyboard'; import NativeKeyboardObserver from './NativeKeyboardObserver'; import invariant from 'invariant'; -const KeyboardEventEmitter: NativeEventEmitter = new NativeEventEmitter( +const KeyboardEventEmitter: NativeEventEmitter<$FlowFixMe> = new NativeEventEmitter( NativeKeyboardObserver, ); diff --git a/Libraries/Components/StatusBar/StatusBarIOS.js b/Libraries/Components/StatusBar/StatusBarIOS.js index ccc561103f187c..8a166cd36e63b7 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.js @@ -16,6 +16,6 @@ import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS'; /** * Use `StatusBar` for mutating the status bar. */ -class StatusBarIOS extends NativeEventEmitter {} +class StatusBarIOS extends NativeEventEmitter<$FlowFixMe> {} module.exports = (new StatusBarIOS(NativeStatusBarManagerIOS): StatusBarIOS); diff --git a/Libraries/EventEmitter/NativeEventEmitter.js b/Libraries/EventEmitter/NativeEventEmitter.js index 298a3eea2f8831..3dfa20071198b2 100644 --- a/Libraries/EventEmitter/NativeEventEmitter.js +++ b/Libraries/EventEmitter/NativeEventEmitter.js @@ -34,7 +34,9 @@ const DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS = { * Abstract base class for implementing event-emitting modules. This implements * a subset of the standard EventEmitter node module API. */ -export default class NativeEventEmitter extends EventEmitter { +export default class NativeEventEmitter< + _GenericArgumentPlaceholder, +> extends EventEmitter { _nativeModule: ?NativeModule; _disableCallsIntoModule: boolean; diff --git a/Libraries/Linking/Linking.js b/Libraries/Linking/Linking.js index 27998010171828..de4172d388d1d9 100644 --- a/Libraries/Linking/Linking.js +++ b/Libraries/Linking/Linking.js @@ -24,7 +24,7 @@ import nullthrows from 'nullthrows'; * * See https://reactnative.dev/docs/linking.html */ -class Linking extends NativeEventEmitter { +class Linking extends NativeEventEmitter<$FlowFixMe> { constructor() { super(Platform.OS === 'ios' ? nullthrows(NativeLinkingManager) : undefined); } diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index f5d3556453b2c0..858886c3816c52 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -31,7 +31,7 @@ import RCTModalHostView from './RCTModalHostViewNativeComponent'; const ModalEventEmitter = Platform.OS === 'ios' && NativeModalManager != null - ? new NativeEventEmitter(NativeModalManager) + ? new NativeEventEmitter<$FlowFixMe>(NativeModalManager) : null; /** diff --git a/Libraries/Network/RCTNetworking.android.js b/Libraries/Network/RCTNetworking.android.js index 12864c9c9af7da..45c7141db4a87c 100644 --- a/Libraries/Network/RCTNetworking.android.js +++ b/Libraries/Network/RCTNetworking.android.js @@ -38,7 +38,7 @@ function generateRequestId(): number { * This class is a wrapper around the native RCTNetworking module. It adds a necessary unique * requestId to each network request that can be used to abort that request later on. */ -class RCTNetworking extends NativeEventEmitter { +class RCTNetworking extends NativeEventEmitter<$FlowFixMe> { constructor() { super(NativeNetworkingAndroid); } diff --git a/Libraries/Network/RCTNetworking.ios.js b/Libraries/Network/RCTNetworking.ios.js index bc1081aab357d6..5992cf84cf6df9 100644 --- a/Libraries/Network/RCTNetworking.ios.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -16,7 +16,7 @@ import type {NativeResponseType} from './XMLHttpRequest'; import convertRequestBody from './convertRequestBody'; import type {RequestBody} from './convertRequestBody'; -class RCTNetworking extends NativeEventEmitter { +class RCTNetworking extends NativeEventEmitter<$FlowFixMe> { constructor() { const disableCallsIntoModule = typeof global.__disableRCTNetworkingExtraneousModuleCalls === 'function' diff --git a/Libraries/PushNotificationIOS/PushNotificationIOS.js b/Libraries/PushNotificationIOS/PushNotificationIOS.js index 99d2d92c975a5b..d033f26422b01d 100644 --- a/Libraries/PushNotificationIOS/PushNotificationIOS.js +++ b/Libraries/PushNotificationIOS/PushNotificationIOS.js @@ -14,7 +14,7 @@ import NativeEventEmitter from '../EventEmitter/NativeEventEmitter'; import NativePushNotificationManagerIOS from './NativePushNotificationManagerIOS'; import invariant from 'invariant'; -const PushNotificationEmitter = new NativeEventEmitter( +const PushNotificationEmitter = new NativeEventEmitter<$FlowFixMe>( NativePushNotificationManagerIOS, ); diff --git a/Libraries/Utilities/Appearance.js b/Libraries/Utilities/Appearance.js index 314b3eaaad649c..3ab9ada2803c71 100644 --- a/Libraries/Utilities/Appearance.js +++ b/Libraries/Utilities/Appearance.js @@ -23,7 +23,9 @@ type AppearanceListener = (preferences: AppearancePreferences) => void; const eventEmitter = new EventEmitter(); if (NativeAppearance) { - const nativeEventEmitter = new NativeEventEmitter(NativeAppearance); + const nativeEventEmitter = new NativeEventEmitter<$FlowFixMe>( + NativeAppearance, + ); nativeEventEmitter.addListener( 'appearanceChanged', (newAppearance: AppearancePreferences) => { diff --git a/Libraries/Utilities/DevSettings.js b/Libraries/Utilities/DevSettings.js index 58494938ec6536..58054b3553b850 100644 --- a/Libraries/Utilities/DevSettings.js +++ b/Libraries/Utilities/DevSettings.js @@ -17,7 +17,8 @@ interface IDevSettings { onFastRefresh(): void; } -class DevSettings extends NativeEventEmitter implements IDevSettings { +class DevSettings extends NativeEventEmitter<$FlowFixMe> + implements IDevSettings { _menuItems: Map mixed>; constructor() { diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index 65cfd09c52c335..dc47f9ffc141a7 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -64,7 +64,7 @@ class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS): any) { CLOSED: number = CLOSED; _socketId: number; - _eventEmitter: NativeEventEmitter; + _eventEmitter: NativeEventEmitter<$FlowFixMe>; _subscriptions: Array; _binaryType: ?BinaryType; From e2033c5b7ba90066317ffbf75c6209c2ce1867bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 4 Jan 2021 03:52:18 -0800 Subject: [PATCH 0313/1810] Add FlowFixMes for future violations of typed EventEmitter Summary: This prevents having to modify too many files when we add the proper typing for that module Changelog: [Internal] Reviewed By: nadiia Differential Revision: D25586848 fbshipit-source-id: 16001ada4a37a58f83b6e5a4400daebf9257be72 --- Libraries/AppState/AppState.js | 4 ++-- .../Components/AccessibilityInfo/AccessibilityInfo.ios.js | 2 ++ Libraries/Interaction/InteractionManager.js | 2 +- Libraries/Utilities/Appearance.js | 2 +- Libraries/Utilities/Dimensions.js | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index 8a342d01f03dcf..280247634303a5 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -142,7 +142,7 @@ function throwMissingNativeModule() { ); } -class MissingNativeAppStateShim extends EventEmitter { +class MissingNativeAppStateShim extends EventEmitter<$FlowFixMe> { // AppState isAvailable: boolean = false; currentState: ?string = null; @@ -156,7 +156,7 @@ class MissingNativeAppStateShim extends EventEmitter { } // EventEmitter - addListener() { + addListener(): any { throwMissingNativeModule(); } diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js index 9ce8427f0dcaa4..8ae146272de650 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js @@ -211,9 +211,11 @@ const AccessibilityInfo = { if (eventName === 'change') { listener = RCTDeviceEventEmitter.addListener( CHANGE_EVENT_NAME.screenReaderChanged, + // $FlowFixMe[incompatible-call] handler, ); } else if (CHANGE_EVENT_NAME[eventName]) { + // $FlowFixMe[incompatible-call] listener = RCTDeviceEventEmitter.addListener(eventName, handler); } diff --git a/Libraries/Interaction/InteractionManager.js b/Libraries/Interaction/InteractionManager.js index 8aec6727e33c8d..0ba50eae35e4af 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -21,7 +21,7 @@ import EventEmitter from '../vendor/emitter/EventEmitter'; export type Handle = number; import type {Task} from './TaskQueue'; -const _emitter = new EventEmitter(); +const _emitter = new EventEmitter<$FlowFixMe>(); const DEBUG_DELAY: 0 = 0; const DEBUG: false = false; diff --git a/Libraries/Utilities/Appearance.js b/Libraries/Utilities/Appearance.js index 3ab9ada2803c71..e898c0b1896ac4 100644 --- a/Libraries/Utilities/Appearance.js +++ b/Libraries/Utilities/Appearance.js @@ -20,7 +20,7 @@ import invariant from 'invariant'; import {isAsyncDebugging} from './DebugEnvironment'; type AppearanceListener = (preferences: AppearancePreferences) => void; -const eventEmitter = new EventEmitter(); +const eventEmitter = new EventEmitter<$FlowFixMe>(); if (NativeAppearance) { const nativeEventEmitter = new NativeEventEmitter<$FlowFixMe>( diff --git a/Libraries/Utilities/Dimensions.js b/Libraries/Utilities/Dimensions.js index b3e5822c401bb3..4ac8c17f6c26ca 100644 --- a/Libraries/Utilities/Dimensions.js +++ b/Libraries/Utilities/Dimensions.js @@ -24,7 +24,7 @@ type DimensionsValue = { ... }; -const eventEmitter = new EventEmitter(); +const eventEmitter = new EventEmitter<$FlowFixMe>(); let dimensionsInitialized = false; let dimensions: DimensionsValue; From 1bafd0086fe1775bbeb98627ea065e52c895376e Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 4 Jan 2021 04:09:49 -0800 Subject: [PATCH 0314/1810] Remove v1 event coalescing Summary: Changelog: [internal] Old event coalescing isn't used anymore and there haven't been any problems with the new one. Reviewed By: shergin Differential Revision: D25701311 fbshipit-source-id: 359f0361edffa22130cfa8322038acdbe26fd599 --- .../react/renderer/core/BatchedEventQueue.cpp | 52 +++++++------------ .../react/renderer/core/BatchedEventQueue.h | 6 +-- .../react/renderer/core/EventDispatcher.cpp | 9 ++-- .../react/renderer/core/EventDispatcher.h | 3 +- .../react/renderer/scheduler/Scheduler.cpp | 3 +- 5 files changed, 25 insertions(+), 48 deletions(-) diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp index 055e9c59ec41f5..55bc9c7b0aabeb 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp @@ -13,10 +13,8 @@ namespace react { BatchedEventQueue::BatchedEventQueue( EventPipe eventPipe, StatePipe statePipe, - std::unique_ptr eventBeat, - bool enableV2EventCoalescing) - : EventQueue(eventPipe, statePipe, std::move(eventBeat)), - enableV2EventCoalescing_(enableV2EventCoalescing) {} + std::unique_ptr eventBeat) + : EventQueue(eventPipe, statePipe, std::move(eventBeat)) {} void BatchedEventQueue::onEnqueue() const { EventQueue::onEnqueue(); @@ -28,38 +26,26 @@ void BatchedEventQueue::enqueueUniqueEvent(RawEvent const &rawEvent) const { { std::lock_guard lock(queueMutex_); - if (enableV2EventCoalescing_) { - auto repeatedEvent = eventQueue_.rend(); - - for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) { - if (it->type == rawEvent.type && - it->eventTarget == rawEvent.eventTarget) { - repeatedEvent = it; - break; - } else if (it->eventTarget == rawEvent.eventTarget) { - // It is necessary to maintain order of different event types - // for the same target. If the same target has event types A1, B1 - // in the event queue and event A2 occurs. A1 has to stay in the - // queue. - break; - } - } - - if (repeatedEvent == eventQueue_.rend()) { - eventQueue_.push_back(rawEvent); - } else { - *repeatedEvent = std::move(rawEvent); - } - } else { - if (!eventQueue_.empty()) { - auto const position = eventQueue_.back(); - if (position.type == rawEvent.type && - position.eventTarget == rawEvent.eventTarget) { - eventQueue_.pop_back(); - } + auto repeatedEvent = eventQueue_.rend(); + + for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) { + if (it->type == rawEvent.type && + it->eventTarget == rawEvent.eventTarget) { + repeatedEvent = it; + break; + } else if (it->eventTarget == rawEvent.eventTarget) { + // It is necessary to maintain order of different event types + // for the same target. If the same target has event types A1, B1 + // in the event queue and event A2 occurs. A1 has to stay in the + // queue. + break; } + } + if (repeatedEvent == eventQueue_.rend()) { eventQueue_.push_back(rawEvent); + } else { + *repeatedEvent = std::move(rawEvent); } } diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.h b/ReactCommon/react/renderer/core/BatchedEventQueue.h index 85f7c8bca45951..827ef87886ef4a 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.h +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.h @@ -21,8 +21,7 @@ class BatchedEventQueue final : public EventQueue { BatchedEventQueue( EventPipe eventPipe, StatePipe statePipe, - std::unique_ptr eventBeat, - bool enableV2EventCoalescing); + std::unique_ptr eventBeat); void onEnqueue() const override; @@ -32,9 +31,6 @@ class BatchedEventQueue final : public EventQueue { * Can be called on any thread. */ void enqueueUniqueEvent(const RawEvent &rawEvent) const; - - private: - bool const enableV2EventCoalescing_; }; } // namespace react diff --git a/ReactCommon/react/renderer/core/EventDispatcher.cpp b/ReactCommon/react/renderer/core/EventDispatcher.cpp index 75d04608287142..8ece2ab3a07aff 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -21,8 +21,7 @@ EventDispatcher::EventDispatcher( StatePipe const &statePipe, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, - EventBeat::SharedOwnerBox const &ownerBox, - bool enableV2EventCoalescing) + EventBeat::SharedOwnerBox const &ownerBox) : synchronousUnbatchedQueue_(std::make_unique( eventPipe, statePipe, @@ -30,8 +29,7 @@ EventDispatcher::EventDispatcher( synchronousBatchedQueue_(std::make_unique( eventPipe, statePipe, - synchonousEventBeatFactory(ownerBox), - enableV2EventCoalescing)), + synchonousEventBeatFactory(ownerBox))), asynchronousUnbatchedQueue_(std::make_unique( eventPipe, statePipe, @@ -39,8 +37,7 @@ EventDispatcher::EventDispatcher( asynchronousBatchedQueue_(std::make_unique( eventPipe, statePipe, - asynchonousEventBeatFactory(ownerBox), - enableV2EventCoalescing)) {} + asynchonousEventBeatFactory(ownerBox))) {} void EventDispatcher::dispatchEvent( RawEvent const &rawEvent, diff --git a/ReactCommon/react/renderer/core/EventDispatcher.h b/ReactCommon/react/renderer/core/EventDispatcher.h index eb0abf52eba76b..d3fb37c132754f 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/ReactCommon/react/renderer/core/EventDispatcher.h @@ -37,8 +37,7 @@ class EventDispatcher { StatePipe const &statePipe, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, - EventBeat::SharedOwnerBox const &ownerBox, - bool enableV2EventCoalescing); + EventBeat::SharedOwnerBox const &ownerBox); /* * Dispatches a raw event with given priority using event-delivery pipe. diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 313b4e201ec656..648b1116844d21 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -67,8 +67,7 @@ Scheduler::Scheduler( statePipe, schedulerToolbox.synchronousEventBeatFactory, schedulerToolbox.asynchronousEventBeatFactory, - eventOwnerBox, - reactNativeConfig_->getBool("react_fabric:enable_v2_event_coalescing")); + eventOwnerBox); // Casting to `std::shared_ptr`. auto eventDispatcher = From 306edff62c5af8997a9760c2b7b7f600ced5510e Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Mon, 4 Jan 2021 07:37:56 -0800 Subject: [PATCH 0315/1810] Pass Systrace and Refresh as globals Summary: The `Systrace` and `Refresh` dependencies are injected into the `metroRequire` implementation by assigning the values to e.g. `require.Systrace = ...`. The issue with this approach is that some `require` implementations might not support extending the `require` object or doing so results in a degraded performance. An example where this is the case is Hermes where changing the `require` object forces Hermes to opt out of the static require optimization. This diff extends Metro so that the `Systrace` and `Refresh` implementation can either be injected by assigning to `require.Systrace` or by exposing the implementation in the global scope. It further changes the `Systrace` and `Refresh` modules to inject the instances using the global scope instead of extending `require`. Changelog: [Internal][Changed] - Expose Systrace and ReactRefresh as globals instead of extending require. Reviewed By: motiz88 Differential Revision: D25693381 fbshipit-source-id: 254d66d43e7a56d3310cf1a17d5146b8d1307562 --- Libraries/Core/setUpReactRefresh.js | 4 +++- Libraries/Performance/Systrace.js | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/Core/setUpReactRefresh.js b/Libraries/Core/setUpReactRefresh.js index 4ee10acf086ffa..ccc67ca22398b5 100644 --- a/Libraries/Core/setUpReactRefresh.js +++ b/Libraries/Core/setUpReactRefresh.js @@ -45,5 +45,7 @@ if (__DEV__) { }, }; - (require: any).Refresh = Refresh; + // The metro require polyfill can not have dependencies (applies for all polyfills). + // Expose `Refresh` by assigning it to global to make it available in the polyfill. + global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__ReactRefresh'] = Refresh; } diff --git a/Libraries/Performance/Systrace.js b/Libraries/Performance/Systrace.js index 048c3d404271ad..6089016521b862 100644 --- a/Libraries/Performance/Systrace.js +++ b/Libraries/Performance/Systrace.js @@ -209,11 +209,9 @@ const Systrace = { }; if (__DEV__) { - // This is needed, because require callis in polyfills are not processed as - // other files. Therefore, calls to `require('moduleId')` are not replaced - // with numeric IDs - // TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686) - (require: $FlowFixMe).Systrace = Systrace; + // The metro require polyfill can not have dependencies (true for all polyfills). + // Ensure that `Systrace` is available in polyfill by exposing it globally. + global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__SYSTRACE'] = Systrace; } module.exports = Systrace; From 5b34c98fa21d592c02c0fee7a7d67fe080233fdf Mon Sep 17 00:00:00 2001 From: Agastya Darma Date: Mon, 4 Jan 2021 09:12:53 -0800 Subject: [PATCH 0316/1810] WIP: Add an explicit NDK version to RNTester and ReactAndroid (#29987) Summary: When I try to run RNTester with Gradle the RNTester Required me to use **NDK 20.0.5594570**. I can't seem to find an explicit NDK version anywhere in ReactAndroid and RNTester. This PR Aims to add an explicit NDK version to RNTester and ReactAndroid. ![Screenshot from 2020-09-19 21-13-17](https://user-images.githubusercontent.com/8868908/93669563-444fcf00-fabf-11ea-8822-93264c5bb736.png) ## Changelog [Android] [Added] - Add an explicit NDK version to RNTester and ReactAndroid. Pull Request resolved: https://github.com/facebook/react-native/pull/29987 Test Plan: Build manually from RNTester Reviewed By: fkgozali Differential Revision: D23911371 Pulled By: ShikaSD fbshipit-source-id: 2f297c73890c0eb0bfec0e2ba7ec5755b4d84243 --- .circleci/config.yml | 4 ++-- ReactAndroid/build.gradle | 18 ++++++++++-------- build.gradle.kts | 5 +++++ gradle.properties | 2 ++ packages/rn-tester/android/app/build.gradle | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 025669fdb324ff..49c0c6603f4051 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -611,11 +611,11 @@ jobs: default: false environment: - ANDROID_HOME: "C:\\Android\\android-sdk" - - ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\19.2.5345600" + - ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944" - ANDROID_BUILD_VERSION: 28 - ANDROID_TOOLS_VERSION: 29.0.3 - GRADLE_OPTS: -Dorg.gradle.daemon=false - - NDK_VERSION: 19.2.5345600 + - NDK_VERSION: 20.1.5948944 steps: - checkout diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 3b3f973ade27a0..1ed98bed6eb40b 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -242,26 +242,28 @@ def getNdkBuildName() { } def findNdkBuildFullPath() { + // android.ndkDirectory should return project.android.ndkVersion ndkDirectory + def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null + if (ndkDir) { + return new File(ndkDir, getNdkBuildName()).getAbsolutePath() + } + // we allow to provide full path to ndk-build tool if (hasProperty("ndk.command")) { return property("ndk.command") } // or just a path to the containing directory if (hasProperty("ndk.path")) { - def ndkDir = property("ndk.path") + ndkDir = property("ndk.path") return new File(ndkDir, getNdkBuildName()).getAbsolutePath() } + // @TODO ANDROID_NDK && ndk.dir is deprecated and will be removed in the future. if (System.getenv("ANDROID_NDK") != null) { - def ndkDir = System.getenv("ANDROID_NDK") + ndkDir = System.getenv("ANDROID_NDK") return new File(ndkDir, getNdkBuildName()).getAbsolutePath() } - def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null - - if (ndkDir) { - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } return null } @@ -377,7 +379,7 @@ task extractJNIFiles { android { compileSdkVersion 29 - + ndkVersion ANDROID_NDK_VERSION compileOptions { sourceCompatibility(JavaVersion.VERSION_1_8) targetCompatibility(JavaVersion.VERSION_1_8) diff --git a/build.gradle.kts b/build.gradle.kts index 4d2c53b0189eb3..532c996c131dc4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,4 +34,9 @@ allprojects { google() jcenter() } + + // used to override ndk path on CI + if (System.getenv("LOCAL_ANDROID_NDK_VERSION") != null) { + setProperty("ANDROID_NDK_VERSION", System.getenv("LOCAL_ANDROID_NDK_VERSION")) + } } diff --git a/gradle.properties b/gradle.properties index f0a3fdf5d79fed..dd6698ad75bd27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,3 +3,5 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true + +ANDROID_NDK_VERSION=20.1.5948944 diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 8855fff3fd2b9c..59a2e64275a35c 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -127,7 +127,7 @@ def useIntlJsc = false android { compileSdkVersion 29 - + ndkVersion ANDROID_NDK_VERSION compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 From 8aea93022bad4ed57ff6b738528a43f26fc335ac Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Mon, 4 Jan 2021 12:02:05 -0800 Subject: [PATCH 0317/1810] Remove dependency on Folly in TurboModuleUtils.h (#30672) Summary: The TurboModuleUtils.h includes "folly/Optional.h" which is not used and creates an unnecessary dependency on Folly. In this PR we remove this unnecessary include. It is required for the https://github.com/microsoft/react-native-windows/pull/6804 where we add an experimental support for the C++ TurboModules. While the C++ TurboModules use the same JSI and TurboModule code defined in react-native, we provide a layer that let them to work over the ABI-safe Microsoft.ReactNative.dll boundary. The RNW Nuget distribution with DLL files includes a few source files to create native/turbo modules that work through the ABI-safe API. The TurboModuleUtils.h is one of such files. By removing the dependency on Folly we reduce requirements for the native module code. After this PR is merged we will remove the fork of the TurboModuleUtils.h added in https://github.com/microsoft/react-native-windows/pull/6804. ## Changelog [Internal] [Fixed] - Remove dependency on Folly in TurboModuleUtils.h Pull Request resolved: https://github.com/facebook/react-native/pull/30672 Test Plan: The change does not bring any functional changes. It may only affect code compilation where some code may depend on TurboModuleUtils.h when it needs the "folly/Optional.h". The fix is add the `#include ` there explicitly. I had run the iOS tests and they passed: ``` yarn pod install in packages\rn-tester ./scripts/objc-test.sh test ``` Reviewed By: mdvacca Differential Revision: D25758927 Pulled By: fkgozali fbshipit-source-id: 347d8f6bc333a3df67095ea0dc7221c818432fab --- .../react/nativemodule/core/ReactCommon/TurboModuleUtils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h index 030d3fac9783de..30add1d265baae 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h @@ -10,7 +10,6 @@ #include #include -#include #include #include From 7a9e4ba4e9ae02ab8a0fe0f67ceefd5d675b9dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Mon, 4 Jan 2021 13:32:03 -0800 Subject: [PATCH 0318/1810] Optionally override codegen script defaults via envvars Summary: The codegen helper script, `generate-specs.sh`, is being used to generate code for the FBReactNativeSpec and React-Fabric/rncore pods. The script now supports overriding several defaults by setting the following environment variables: - SRCS_DIR: Path to JavaScript sources, defaults to $RN_DIR/Libraries/ - LIBRARY_NAME: Defaults to FBReactNativeSpec - MODULES_OUTPUT_DIR: Defaults to Libraries/$LIBRARY_NAME/$LIBRARY_NAME - COMPONENTS_LIBRARY_NAME: Defaults to rncore - COMPONENTS_OUTPUT_DIR: Defaults to ReactCommon/react/renderer/components/$COMPONENTS_LIBRARY_NAME The CocoaPods codegen integration has been updated to take advantage of these. **Example CocoaPods usage:** ``` # packages/rn-tester/NativeModuleExample/RNTesterSpecs.podspec Pod::Spec.new do |s| s.name = "RNTesterSpec" # ... use_react_native_codegen!(s, { :srcs_dir => __dir__, :modules_output_dir => __dir__ }) end ``` Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25738466 fbshipit-source-id: c68f5a3cd0996283a7af287e992e2f973024f44c --- packages/rn-tester/Podfile.lock | 2 +- scripts/generate-specs.sh | 30 ++++++++++++++++++++--------- scripts/react_native_pods.rb | 34 +++++++++++++++++++-------------- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 9af165313093d9..35822c377965e2 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -798,7 +798,7 @@ SPEC CHECKSUMS: CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: cc83b1f9c1a764577c37a7009d002b8afb36f192 + FBReactNativeSpec: d0504078deb2ffa0fbee5032382f4ef165a1c8a8 Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a diff --git a/scripts/generate-specs.sh b/scripts/generate-specs.sh index 25cf8d255118ff..cd4ef2902d2bdf 100755 --- a/scripts/generate-specs.sh +++ b/scripts/generate-specs.sh @@ -8,8 +8,16 @@ # native modules and components, then uses react-native-codegen # to generate native code. # +# Optionally, set these envvars to override defaults: +# - SRCS_DIR: Path to JavaScript sources +# - CODEGEN_MODULES_LIBRARY_NAME: Defaults to FBReactNativeSpec +# - CODEGEN_MODULES_OUTPUT_DIR: Defaults to Libraries/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_MODULES_LIBRARY_NAME +# - CODEGEN_COMPONENTS_LIBRARY_NAME: Defaults to rncore +# - CODEGEN_COMPONENTS_OUTPUT_DIR: Defaults to ReactCommon/react/renderer/components/$CODEGEN_COMPONENTS_LIBRARY_NAME +# # Usage: # ./scripts/generate-specs.sh +# SRCS_DIR=myapp/js CODEGEN_MODULES_LIBRARY_NAME=MySpecs CODEGEN_MODULES_OUTPUT_DIR=myapp/MySpecs ./scripts/generate-specs.sh # # shellcheck disable=SC2038 @@ -33,12 +41,16 @@ describe () { } main() { - SRCS_DIR=$(cd "$RN_DIR/Libraries" && pwd) + SRCS_DIR=${SRCS_DIR:-$(cd "$RN_DIR/Libraries" && pwd)} + CODEGEN_MODULES_LIBRARY_NAME=${CODEGEN_MODULES_LIBRARY_NAME:-FBReactNativeSpec} - OUTPUT_DIR="$TEMP_DIR/out" - COMPONENTS_DIR="$RN_DIR/ReactCommon/react/renderer/components/rncore" - MODULES_DIR="$RN_DIR/Libraries/FBReactNativeSpec/FBReactNativeSpec" + CODEGEN_COMPONENTS_LIBRARY_NAME=${CODEGEN_COMPONENTS_LIBRARY_NAME:-rncore} + CODEGEN_MODULES_OUTPUT_DIR=${CODEGEN_MODULES_OUTPUT_DIR:-"$RN_DIR/Libraries/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_MODULES_LIBRARY_NAME"} + # TODO: $CODEGEN_COMPONENTS_PATH should be programmatically specified, and may change with use_frameworks! support. + CODEGEN_COMPONENTS_PATH="ReactCommon/react/renderer/components" + CODEGEN_COMPONENTS_OUTPUT_DIR=${CODEGEN_COMPONENTS_OUTPUT_DIR:-"$RN_DIR/$CODEGEN_COMPONENTS_PATH/$CODEGEN_COMPONENTS_LIBRARY_NAME"} + TEMP_OUTPUT_DIR="$TEMP_DIR/out" SCHEMA_FILE="$TEMP_DIR/schema.json" CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen" @@ -66,13 +78,13 @@ main() { describe "Generating native code from schema (iOS)" pushd "$RN_DIR" >/dev/null || exit - "$YARN_BINARY" --silent node scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$OUTPUT_DIR" + "$YARN_BINARY" --silent node scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$CODEGEN_MODULES_LIBRARY_NAME" popd >/dev/null || exit - mkdir -p "$COMPONENTS_DIR" "$MODULES_DIR" - mv "$OUTPUT_DIR/FBReactNativeSpec.h" "$OUTPUT_DIR/FBReactNativeSpec-generated.mm" "$MODULES_DIR" - find "$OUTPUT_DIR" -type f | xargs sed -i '' 's/FBReactNativeSpec/rncore/g' - cp -R "$OUTPUT_DIR/." "$COMPONENTS_DIR" + mkdir -p "$CODEGEN_COMPONENTS_OUTPUT_DIR" "$CODEGEN_MODULES_OUTPUT_DIR" + mv "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME.h" "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME-generated.mm" "$CODEGEN_MODULES_OUTPUT_DIR" + find "$TEMP_OUTPUT_DIR" -type f | xargs sed -i '' "s/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_COMPONENTS_LIBRARY_NAME/g" + cp -R "$TEMP_OUTPUT_DIR/." "$CODEGEN_COMPONENTS_OUTPUT_DIR" } trap cleanup EXIT diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index f26f587e109def..2e01cfaebfae46 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -153,30 +153,36 @@ def use_react_native_codegen!(spec, options={}) srcs_dir = options[:srcs_dir] ||= File.join(prefix, "Libraries") # Library name (e.g. FBReactNativeSpec) - library_name = spec.name - modules_output_dir = File.join(prefix, "Libraries/#{library_name}/#{library_name}") + codegen_modules_library_name = spec.name + codegen_modules_output_dir = options[:codegen_modules_output_dir] ||= File.join(prefix, "Libraries/#{codegen_modules_library_name}/#{codegen_modules_library_name}") # Run the codegen as part of the Xcode build pipeline. + env_vars = "SRCS_DIR=#{srcs_dir}" + env_vars += " CODEGEN_MODULES_OUTPUT_DIR=#{codegen_modules_output_dir}" + if ENV['USE_FABRIC'] == '1' + # We use a different library name for components, as well as an additional set of files. + # Eventually, we want these to be part of the same library as #{codegen_modules_library_name} above. + codegen_components_library_name = "rncore" + codegen_components_output_dir = File.join(prefix, "ReactCommon/react/renderer/components/#{codegen_components_library_name}") + env_vars += " CODEGEN_COMPONENTS_OUTPUT_DIR=#{codegen_components_output_dir}" + end spec.script_phase = { :name => 'Generate Specs', :input_files => [srcs_dir], - :output_files => ["$(DERIVED_FILE_DIR)/codegen.log"], - :script => "sh '#{File.join(__dir__, "generate-specs.sh")}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"", - :execution_position => :before_compile + :output_files => ["$(DERIVED_FILE_DIR)/codegen-#{codegen_modules_library_name}.log"], + :script => "bash -c '#{env_vars} CODEGEN_MODULES_LIBRARY_NAME=#{codegen_modules_library_name} #{File.join(__dir__, "generate-specs.sh")}' | tee \"${SCRIPT_OUTPUT_FILE_0}\"", + :execution_position => :before_compile, + :show_env_vars_in_log => true } # Since the generated files are not guaranteed to exist when CocoaPods is run, we need to create # empty files to ensure the references are included in the resulting Pods Xcode project. - mkdir_command = "mkdir -p #{modules_output_dir}" - generated_filenames = [ "#{library_name}.h", "#{library_name}-generated.mm" ] - generated_files = generated_filenames.map { |filename| File.join(modules_output_dir, filename) } + mkdir_command = "mkdir -p #{codegen_modules_output_dir}" + generated_filenames = [ "#{codegen_modules_library_name}.h", "#{codegen_modules_library_name}-generated.mm" ] + generated_files = generated_filenames.map { |filename| File.join(codegen_modules_output_dir, filename) } if ENV['USE_FABRIC'] == '1' - # We use a different library name for components, as well as an additional set of files. - # Eventually, we want these to be part of the same library as #{library_name} above. - components_library_name = "rncore" - components_output_dir = File.join(prefix, "ReactCommon/react/renderer/components/#{components_library_name}") - mkdir_command += " #{components_output_dir}" + mkdir_command += " #{codegen_components_output_dir}" components_generated_filenames = [ "ComponentDescriptors.h", "EventEmitters.cpp", @@ -187,7 +193,7 @@ def use_react_native_codegen!(spec, options={}) "ShadowNodes.cpp", "ShadowNodes.h" ] - generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(components_output_dir, filename) }) + generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(codegen_components_output_dir, filename) }) end spec.prepare_command = "#{mkdir_command} && touch #{generated_files.reduce() { |str, file| str + " " + file }}" From 934275f9315c80c860d98db13baca0d49e91b335 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 4 Jan 2021 15:00:04 -0800 Subject: [PATCH 0319/1810] Fabric: Changeing debouncing logic of onLayout event Summary: This changes the way we throttle `onLayout` events in Fabric. The approach we used before has several issues: * Every event-dispatching action initiated a lambda scheduled on JavaScript thread (which is a bit inefficient). * If an event had {0,0,0,0} frame, it might be skipped because this is the default frame value. * An event was always delivered by the exact block scheduled at the moment of the event initiation (even though some other blocks might be called before). In case of events being initiated rapidly, it can delay actual event delivery and maybe even overwhelm the JavaScript thread. The new implementation uses a different approach: we maintain the shared storage with recent frame value and use the very first opportunity to deliver it. Alse see comments in the code. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25676336 fbshipit-source-id: 275b08990f7c5cf1f05a8f954ebc795a14e10ec2 --- .../components/view/ViewEventEmitter.cpp | 101 ++++++++++++------ .../components/view/ViewEventEmitter.h | 32 +++++- 2 files changed, 98 insertions(+), 35 deletions(-) diff --git a/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp b/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp index a81f85af595cac..fd2e83420b6ba9 100644 --- a/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp @@ -35,42 +35,81 @@ void ViewEventEmitter::onAccessibilityEscape() const { #pragma mark - Layout void ViewEventEmitter::onLayout(const LayoutMetrics &layoutMetrics) const { - // Due to State Reconciliation, `onLayout` can be called potentially many - // times with identical layoutMetrics. Ensure that the JS event is only - // dispatched when the value changes. + // A copy of a shared pointer (`layoutEventState_`) establishes shared + // ownership that will be captured by lambda. + auto layoutEventState = layoutEventState_; + + // Dispatched `frame` values to JavaScript thread are throttled here. + // Basic ideas: + // - Scheduling a lambda with some value that already was dispatched, does + // nothing. + // - If some lambda is already in flight, we don't schedule another; + // - When a lambda is being executed on the JavaScript thread, the *most + // recent* `frame` value is used (not the value that was current at the + // moment of scheduling the lambda). + // + // This implies the following caveats: + // - Some events can be skipped; + // - When values change rapidly, even events with different values + // can be skipped (only the very last will be delivered). + // - Ordering is preserved. + { - std::lock_guard guard(layoutMetricsMutex_); - if (lastLayoutMetrics_ == layoutMetrics) { + std::lock_guard guard(layoutEventState->mutex); + + // If a *particular* `frame` was already dispatched to the JavaScript side, + // no other work is required. + if (layoutEventState->frame == layoutMetrics.frame && + layoutEventState->wasDispatched) { return; } - lastLayoutMetrics_ = layoutMetrics; + + // If the *particular* `frame` was not already dispatched *or* + // some *other* `frame` was dispatched before, + // we need to schedule the dispatching. + layoutEventState->wasDispatched = false; + layoutEventState->frame = layoutMetrics.frame; + + // Something is already in flight, dispatching another event is not + // required. + if (layoutEventState->isDispatching) { + return; + } + + layoutEventState->isDispatching = true; } - auto expectedEventCount = ++*eventCounter_; - - // dispatchUniqueEvent only drops consecutive onLayout events to the same - // node. We want to drop *any* unprocessed onLayout events when there's a - // newer one. - dispatchEvent( - "layout", - [frame = layoutMetrics.frame, - expectedEventCount, - eventCounter = eventCounter_](jsi::Runtime &runtime) { - auto actualEventCount = eventCounter->load(); - if (expectedEventCount != actualEventCount) { - // Drop stale events - return jsi::Value::null(); - } - - auto layout = jsi::Object(runtime); - layout.setProperty(runtime, "x", frame.origin.x); - layout.setProperty(runtime, "y", frame.origin.y); - layout.setProperty(runtime, "width", frame.size.width); - layout.setProperty(runtime, "height", frame.size.height); - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "layout", std::move(layout)); - return jsi::Value(std::move(payload)); - }); + dispatchEvent("layout", [layoutEventState](jsi::Runtime &runtime) { + auto frame = Rect{}; + + { + std::lock_guard guard(layoutEventState->mutex); + + layoutEventState->isDispatching = false; + + // If some *particular* `frame` was already dispatched before, + // and since then there were no other new values of the `frame` observed, + // do nothing. + if (layoutEventState->wasDispatched) { + return jsi::Value::null(); + } + + frame = layoutEventState->frame; + + // If some *particular* `frame` was *not* already dispatched before, + // it's time to dispatch it and mark as dispatched. + layoutEventState->wasDispatched = true; + } + + auto layout = jsi::Object(runtime); + layout.setProperty(runtime, "x", frame.origin.x); + layout.setProperty(runtime, "y", frame.origin.y); + layout.setProperty(runtime, "width", frame.size.width); + layout.setProperty(runtime, "height", frame.size.height); + auto payload = jsi::Object(runtime); + payload.setProperty(runtime, "layout", std::move(layout)); + return jsi::Value(std::move(payload)); + }); } } // namespace react diff --git a/ReactCommon/react/renderer/components/view/ViewEventEmitter.h b/ReactCommon/react/renderer/components/view/ViewEventEmitter.h index c00802431a18c9..1a4e17e84e5151 100644 --- a/ReactCommon/react/renderer/components/view/ViewEventEmitter.h +++ b/ReactCommon/react/renderer/components/view/ViewEventEmitter.h @@ -38,11 +38,35 @@ class ViewEventEmitter : public TouchEventEmitter { void onLayout(const LayoutMetrics &layoutMetrics) const; private: - mutable std::mutex layoutMetricsMutex_; - mutable LayoutMetrics lastLayoutMetrics_; + /* + * Contains the most recent `frame` and a `mutex` protecting access to it. + */ + struct LayoutEventState { + /* + * Protects an access to other fields of the struct. + */ + std::mutex mutex; - mutable std::shared_ptr eventCounter_{ - std::make_shared(0)}; + /* + * Last dispatched `frame` value or value that's being dispatched right now. + */ + Rect frame{}; + + /* + * Indicates that the `frame` value was already dispatched (and dispatching + * of the *same* value is not needed). + */ + bool wasDispatched{false}; + + /* + * Indicates that some lambda is already being dispatching (and dispatching + * another one is not needed). + */ + bool isDispatching{false}; + }; + + mutable std::shared_ptr layoutEventState_{ + std::make_shared()}; }; } // namespace react From a2164f429a91682f4494f8be22aa52606d68b9f3 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 5 Jan 2021 10:42:38 -0800 Subject: [PATCH 0320/1810] Ship lockfree mountitems Summary: Ship lockfree mountitems experiment. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25775521 fbshipit-source-id: 15811b15a9dc7d463a6d46d7fefd0d433ba86280 --- .../react/config/ReactFeatureFlags.java | 3 - .../react/fabric/FabricUIManager.java | 96 ++----------------- 2 files changed, 8 insertions(+), 91 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index d1318d9237d469..f233da7d48c8e6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -57,9 +57,6 @@ public class ReactFeatureFlags { /** Feature flag to configure eager initialization of Fabric */ public static boolean eagerInitializeFabric = false; - /** Use lock-free data structures for Fabric MountItems. */ - public static boolean enableLockFreeMountInstructions = false; - /** Disable UI update operations in non-Fabric renderer after catalyst instance was destroyed */ public static boolean disableNonFabricViewOperationsOnCatalystDestroy = false; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 82f743be08536f..78e4ace3e60768 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -26,7 +26,6 @@ import android.os.SystemClock; import android.view.View; import androidx.annotation.AnyThread; -import androidx.annotation.GuardedBy; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; @@ -87,7 +86,6 @@ import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.views.text.TextLayoutManager; import com.facebook.systrace.Systrace; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -133,7 +131,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { @NonNull private final CopyOnWriteArrayList mListeners = new CopyOnWriteArrayList<>(); - // Concurrent MountItem data-structures, experimental. TODO: T79662803 @NonNull private final ConcurrentLinkedQueue mViewCommandMountItemsConcurrent = new ConcurrentLinkedQueue<>(); @@ -146,24 +143,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { private final ConcurrentLinkedQueue mPreMountItemsConcurrent = new ConcurrentLinkedQueue<>(); - // Non-concurrent MountItem data-structures - @NonNull private final Object mViewCommandMountItemsLock = new Object(); - @NonNull private final Object mMountItemsLock = new Object(); - @NonNull private final Object mPreMountItemsLock = new Object(); - - @GuardedBy("mViewCommandMountItemsLock") - @NonNull - private List mViewCommandMountItems = new ArrayList<>(); - - @GuardedBy("mMountItemsLock") - @NonNull - private List mMountItems = new ArrayList<>(); - - @GuardedBy("mPreMountItemsLock") - @NonNull - private ArrayDeque mPreMountItems = - new ArrayDeque<>(PRE_MOUNT_ITEMS_INITIAL_SIZE_ARRAY); - @ThreadConfined(UI) @NonNull private final DispatchUIFrameCallback mDispatchUIFrameCallback; @@ -807,50 +786,17 @@ private List drainConcurrentItemQueue(ConcurrentLinkedQ @UiThread @ThreadConfined(UI) private List getAndResetViewCommandMountItems() { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - return drainConcurrentItemQueue(mViewCommandMountItemsConcurrent); - } - - synchronized (mViewCommandMountItemsLock) { - List result = mViewCommandMountItems; - if (result.isEmpty()) { - return null; - } - mViewCommandMountItems = new ArrayList<>(); - return result; - } + return drainConcurrentItemQueue(mViewCommandMountItemsConcurrent); } @UiThread @ThreadConfined(UI) private List getAndResetMountItems() { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - return drainConcurrentItemQueue(mMountItemsConcurrent); - } - - synchronized (mMountItemsLock) { - List result = mMountItems; - if (result.isEmpty()) { - return null; - } - mMountItems = new ArrayList<>(); - return result; - } + return drainConcurrentItemQueue(mMountItemsConcurrent); } private Collection getAndResetPreMountItems() { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - return drainConcurrentItemQueue(mPreMountItemsConcurrent); - } - - synchronized (mPreMountItemsLock) { - ArrayDeque result = mPreMountItems; - if (result.isEmpty()) { - return null; - } - mPreMountItems = new ArrayDeque<>(PRE_MOUNT_ITEMS_INITIAL_SIZE_ARRAY); - return result; - } + return drainConcurrentItemQueue(mPreMountItemsConcurrent); } /** @@ -1051,16 +997,8 @@ private void dispatchPreMountItems(long frameTimeNanos) { break; } - PreAllocateViewMountItem preMountItemToDispatch = null; - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - preMountItemToDispatch = mPreMountItemsConcurrent.poll(); - } else { - synchronized (mPreMountItemsLock) { - if (!mPreMountItems.isEmpty()) { - preMountItemToDispatch = mPreMountItems.pollFirst(); - } - } - } + PreAllocateViewMountItem preMountItemToDispatch = mPreMountItemsConcurrent.poll(); + // If list is empty, `poll` will return null, or var will never be set if (preMountItemToDispatch == null) { break; @@ -1268,13 +1206,7 @@ public Map getPerformanceCounters() { * @param mountItem */ private void addMountItem(MountItem mountItem) { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - mMountItemsConcurrent.add(mountItem); - } else { - synchronized (mMountItemsLock) { - mMountItems.add(mountItem); - } - } + mMountItemsConcurrent.add(mountItem); } /** @@ -1283,13 +1215,7 @@ private void addMountItem(MountItem mountItem) { * @param mountItem */ private void addPreAllocateMountItem(PreAllocateViewMountItem mountItem) { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - mPreMountItemsConcurrent.add(mountItem); - } else { - synchronized (mPreMountItemsLock) { - mPreMountItems.add(mountItem); - } - } + mPreMountItemsConcurrent.add(mountItem); } /** @@ -1298,13 +1224,7 @@ private void addPreAllocateMountItem(PreAllocateViewMountItem mountItem) { * @param mountItem */ private void addViewCommandMountItem(DispatchCommandMountItem mountItem) { - if (ReactFeatureFlags.enableLockFreeMountInstructions) { - mViewCommandMountItemsConcurrent.add(mountItem); - } else { - synchronized (mViewCommandMountItemsLock) { - mViewCommandMountItems.add(mountItem); - } - } + mViewCommandMountItemsConcurrent.add(mountItem); } private class DispatchUIFrameCallback extends GuardedFrameCallback { From 0db56f1888093eaa2595f9efff7088498743b9cc Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 5 Jan 2021 10:42:38 -0800 Subject: [PATCH 0321/1810] Ship IntBufferBatchMountItem experiment Summary: This experiment has been successfully running for several weeks and show small but statsig perf improvements. Delete the old code and ship this 100% in code to simplify Fabric code. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25775668 fbshipit-source-id: d2b41dfe691775e52b1e89c2fb6790a6500e560e --- .../react/fabric/FabricJSIModuleProvider.java | 20 +- .../react/fabric/FabricUIManager.java | 122 +---- .../com/facebook/react/fabric/jni/Binding.cpp | 469 +----------------- .../com/facebook/react/fabric/jni/Binding.h | 5 - .../mounting/mountitems/BatchMountItem.java | 117 ----- .../mounting/mountitems/CreateMountItem.java | 68 --- .../mounting/mountitems/InsertMountItem.java | 47 -- .../RemoveDeleteMultiMountItem.java | 90 ---- .../UpdateEventEmitterMountItem.java | 33 -- .../mountitems/UpdateLayoutMountItem.java | 90 ---- .../mountitems/UpdatePaddingMountItem.java | 53 -- .../mountitems/UpdatePropsMountItem.java | 42 -- .../mountitems/UpdateStateMountItem.java | 43 -- 13 files changed, 6 insertions(+), 1193 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/CreateMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/InsertMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveDeleteMultiMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateEventEmitterMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateLayoutMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePaddingMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePropsMountItem.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateStateMountItem.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index 91fe11b20cd55e..86e5cf383739be 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -18,21 +18,13 @@ import com.facebook.react.fabric.events.FabricEventEmitter; import com.facebook.react.fabric.mounting.LayoutMetricsConversions; import com.facebook.react.fabric.mounting.MountingManager; -import com.facebook.react.fabric.mounting.mountitems.BatchMountItem; -import com.facebook.react.fabric.mounting.mountitems.CreateMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchIntCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchStringCommandMountItem; -import com.facebook.react.fabric.mounting.mountitems.InsertMountItem; +import com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem; import com.facebook.react.fabric.mounting.mountitems.MountItem; import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem; -import com.facebook.react.fabric.mounting.mountitems.RemoveDeleteMultiMountItem; import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent; -import com.facebook.react.fabric.mounting.mountitems.UpdateEventEmitterMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdatePaddingMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdateStateMountItem; import com.facebook.react.uimanager.StateWrapper; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.events.BatchEventDispatchedListener; @@ -107,21 +99,12 @@ private static void loadClasses() { EventBeatManager.class.getClass(); EventEmitterWrapper.class.getClass(); FabricEventEmitter.class.getClass(); - BatchMountItem.class.getClass(); - CreateMountItem.class.getClass(); DispatchCommandMountItem.class.getClass(); DispatchIntCommandMountItem.class.getClass(); DispatchStringCommandMountItem.class.getClass(); - InsertMountItem.class.getClass(); MountItem.class.getClass(); PreAllocateViewMountItem.class.getClass(); - RemoveDeleteMultiMountItem.class.getClass(); SendAccessibilityEvent.class.getClass(); - UpdateEventEmitterMountItem.class.getClass(); - UpdateLayoutMountItem.class.getClass(); - UpdatePaddingMountItem.class.getClass(); - UpdatePropsMountItem.class.getClass(); - UpdateStateMountItem.class.getClass(); LayoutMetricsConversions.class.getClass(); MountingManager.class.getClass(); Binding.class.getClass(); @@ -134,5 +117,6 @@ private static void loadClasses() { StateWrapperImpl.class.getClass(); BatchEventDispatchedListener.class.getClass(); ReactNativeConfig.class.getClass(); + IntBufferBatchMountItem.class.getClass(); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 78e4ace3e60768..60aca9feefb7d2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -57,22 +57,13 @@ import com.facebook.react.fabric.events.EventEmitterWrapper; import com.facebook.react.fabric.events.FabricEventEmitter; import com.facebook.react.fabric.mounting.MountingManager; -import com.facebook.react.fabric.mounting.mountitems.BatchMountItem; -import com.facebook.react.fabric.mounting.mountitems.CreateMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchIntCommandMountItem; import com.facebook.react.fabric.mounting.mountitems.DispatchStringCommandMountItem; -import com.facebook.react.fabric.mounting.mountitems.InsertMountItem; import com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem; import com.facebook.react.fabric.mounting.mountitems.MountItem; import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem; -import com.facebook.react.fabric.mounting.mountitems.RemoveDeleteMultiMountItem; import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent; -import com.facebook.react.fabric.mounting.mountitems.UpdateEventEmitterMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdatePaddingMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem; -import com.facebook.react.fabric.mounting.mountitems.UpdateStateMountItem; import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.modules.i18nmanager.I18nUtil; import com.facebook.react.uimanager.PixelUtil; @@ -352,100 +343,6 @@ private void preallocateView( isLayoutable)); } - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem createMountItem( - String componentName, - @Nullable ReadableMap props, - @Nullable Object stateWrapper, - int reactRootTag, - int reactTag, - boolean isLayoutable) { - String component = getFabricComponentName(componentName); - - // This could be null if teardown/navigation away from a surface on the main thread happens - // while a commit is being processed in a different thread. By contract we expect this to be - // possible at teardown, but this race should *never* happen at startup. - @Nullable ThemedReactContext reactContext = mReactContextForRootTag.get(reactRootTag); - - return new CreateMountItem( - reactContext, - reactRootTag, - reactTag, - component, - props, - (StateWrapper) stateWrapper, - isLayoutable); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem insertMountItem(int reactTag, int parentReactTag, int index) { - return new InsertMountItem(reactTag, parentReactTag, index); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem removeDeleteMultiMountItem(int[] metadata) { - return new RemoveDeleteMultiMountItem(metadata); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem updateLayoutMountItem( - int reactTag, int x, int y, int width, int height, int layoutDirection) { - return new UpdateLayoutMountItem(reactTag, x, y, width, height, layoutDirection); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem updatePaddingMountItem(int reactTag, int left, int top, int right, int bottom) { - return new UpdatePaddingMountItem(reactTag, left, top, right, bottom); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem updatePropsMountItem(int reactTag, ReadableMap map) { - return new UpdatePropsMountItem(reactTag, map); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem updateStateMountItem(int reactTag, @Nullable Object stateWrapper) { - return new UpdateStateMountItem(reactTag, (StateWrapper) stateWrapper); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem updateEventEmitterMountItem(int reactTag, Object eventEmitter) { - return new UpdateEventEmitterMountItem(reactTag, (EventEmitterWrapper) eventEmitter); - } - - @DoNotStrip - @SuppressWarnings("unused") - @AnyThread - @ThreadConfined(ANY) - private MountItem createBatchMountItem( - int rootTag, MountItem[] items, int size, int commitNumber) { - return new BatchMountItem(rootTag, items, size, commitNumber); - } - @DoNotStrip @SuppressWarnings("unused") @AnyThread @@ -599,7 +496,7 @@ public void synchronouslyUpdateViewOnUIThread( @Override public void execute(@NonNull MountingManager mountingManager) { try { - updatePropsMountItem(reactTag, props).execute(mountingManager); + mountingManager.updateProps(reactTag, props); } catch (Exception ex) { // TODO T42943890: Fix animations in Fabric and remove this try/catch ReactSoftException.logSoftException( @@ -664,12 +561,9 @@ private void scheduleMountItem( // When Binding.cpp calls scheduleMountItems during a commit phase, it always calls with // a BatchMountItem. No other sites call into this with a BatchMountItem, and Binding.cpp only // calls scheduleMountItems with a BatchMountItem. - boolean isClassicBatchMountItem = mountItem instanceof BatchMountItem; - boolean isIntBufferMountItem = mountItem instanceof IntBufferBatchMountItem; - boolean isBatchMountItem = isClassicBatchMountItem || isIntBufferMountItem; + boolean isBatchMountItem = mountItem instanceof IntBufferBatchMountItem; boolean shouldSchedule = - (isClassicBatchMountItem && ((BatchMountItem) mountItem).shouldSchedule()) - || (isIntBufferMountItem && ((IntBufferBatchMountItem) mountItem).shouldSchedule()) + (isBatchMountItem && ((IntBufferBatchMountItem) mountItem).shouldSchedule()) || (!isBatchMountItem && mountItem != null); // In case of sync rendering, this could be called on the UI thread. Otherwise, @@ -939,16 +833,6 @@ private boolean dispatchMountItems() { } try { - // Make sure surface associated with this MountItem has been started, and not stopped. - // TODO T68118357: clean up this logic and simplify this method overall - if (mountItem instanceof BatchMountItem) { - BatchMountItem batchMountItem = (BatchMountItem) mountItem; - if (!isSurfaceActiveForExecution( - batchMountItem.getRootTag(), "dispatchMountItems BatchMountItem")) { - continue; - } - } - // Make sure surface associated with this MountItem has been started, and not stopped. // TODO T68118357: clean up this logic and simplify this method overall if (mountItem instanceof IntBufferBatchMountItem) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 3800b495bb5de0..41388f46f10461 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -437,9 +437,6 @@ void Binding::installFabricUIManager( // Keep reference to config object and cache some feature flags here reactNativeConfig_ = config; - useIntBufferBatchMountItem_ = reactNativeConfig_->getBool( - "react_fabric:use_int_buffer_batch_mountitem_android"); - disablePreallocateViews_ = reactNativeConfig_->getBool( "react_fabric:disabled_view_preallocation_android"); @@ -506,226 +503,7 @@ local_ref getPlatformComponentName(const ShadowView &shadowView) { return componentName; } -local_ref createUpdateEventEmitterMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - if (!mutation.newChildShadowView.eventEmitter) { - return nullptr; - } - SharedEventEmitter eventEmitter = mutation.newChildShadowView.eventEmitter; - - // Do not hold a reference to javaEventEmitter from the C++ side. - auto javaEventEmitter = EventEmitterWrapper::newObjectJavaArgs(); - EventEmitterWrapper *cEventEmitter = cthis(javaEventEmitter); - cEventEmitter->eventEmitter = eventEmitter; - - static auto updateEventEmitterInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint, jobject)>( - "updateEventEmitterMountItem"); - - return updateEventEmitterInstruction( - javaUIManager, mutation.newChildShadowView.tag, javaEventEmitter.get()); -} - -local_ref createUpdatePropsMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - auto shadowView = mutation.newChildShadowView; - - // TODO: move props from map to a typed object. - auto newProps = shadowView.props->rawProps; - - local_ref readableMap = - castReadableMap(ReadableNativeMap::newObjectCxxArgs(newProps)); - static auto updatePropsInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint, ReadableMap::javaobject)>( - "updatePropsMountItem"); - - return updatePropsInstruction( - javaUIManager, mutation.newChildShadowView.tag, readableMap.get()); -} - -local_ref createUpdateLayoutMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - auto oldChildShadowView = mutation.oldChildShadowView; - auto newChildShadowView = mutation.newChildShadowView; - - if (newChildShadowView.layoutMetrics != EmptyLayoutMetrics && - oldChildShadowView.layoutMetrics != newChildShadowView.layoutMetrics) { - static auto updateLayoutInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod( - jint, jint, jint, jint, jint, jint)>("updateLayoutMountItem"); - auto layoutMetrics = newChildShadowView.layoutMetrics; - auto pointScaleFactor = layoutMetrics.pointScaleFactor; - auto frame = layoutMetrics.frame; - - int x = round(frame.origin.x * pointScaleFactor); - int y = round(frame.origin.y * pointScaleFactor); - int w = round(frame.size.width * pointScaleFactor); - int h = round(frame.size.height * pointScaleFactor); - auto layoutDirection = - toInt(newChildShadowView.layoutMetrics.layoutDirection); - return updateLayoutInstruction( - javaUIManager, newChildShadowView.tag, x, y, w, h, layoutDirection); - } - - return nullptr; -} - -local_ref createUpdatePaddingMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - auto oldChildShadowView = mutation.oldChildShadowView; - auto newChildShadowView = mutation.newChildShadowView; - - if (oldChildShadowView.layoutMetrics.contentInsets == - newChildShadowView.layoutMetrics.contentInsets && - mutation.type != ShadowViewMutation::Type::Insert) { - return nullptr; - } - - static auto updatePaddingInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint, jint, jint, jint, jint)>( - "updatePaddingMountItem"); - - auto layoutMetrics = newChildShadowView.layoutMetrics; - auto pointScaleFactor = layoutMetrics.pointScaleFactor; - auto contentInsets = layoutMetrics.contentInsets; - - int left = floor(contentInsets.left * pointScaleFactor); - int top = floor(contentInsets.top * pointScaleFactor); - int right = floor(contentInsets.right * pointScaleFactor); - int bottom = floor(contentInsets.bottom * pointScaleFactor); - - return updatePaddingInstruction( - javaUIManager, newChildShadowView.tag, left, top, right, bottom); -} - -local_ref createInsertMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - static auto insertInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint, jint, jint)>( - "insertMountItem"); - - return insertInstruction( - javaUIManager, - mutation.newChildShadowView.tag, - mutation.parentShadowView.tag, - mutation.index); -} - -local_ref createUpdateStateMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation) { - static auto updateStateInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jint, jobject)>( - "updateStateMountItem"); - - auto state = mutation.newChildShadowView.state; - - // Do not hold onto Java object from C - // We DO want to hold onto C object from Java, since we don't know the - // lifetime of the Java object - local_ref javaStateWrapper = nullptr; - if (state != nullptr) { - javaStateWrapper = StateWrapperImpl::newObjectJavaArgs(); - StateWrapperImpl *cStateWrapper = cthis(javaStateWrapper); - cStateWrapper->state_ = state; - } - - return updateStateInstruction( - javaUIManager, - mutation.newChildShadowView.tag, - (javaStateWrapper != nullptr ? javaStateWrapper.get() : nullptr)); -} - -local_ref createRemoveAndDeleteMultiMountItem( - const jni::global_ref &javaUIManager, - const std::vector &metadata) { - auto env = Environment::current(); - auto removeAndDeleteArray = env->NewIntArray(metadata.size() * 4); - int position = 0; - jint temp[4]; - for (const auto &x : metadata) { - temp[0] = x.tag; - temp[1] = x.parentTag; - temp[2] = x.index; - temp[3] = (x.shouldRemove ? 1 : 0) | (x.shouldDelete ? 2 : 0); - env->SetIntArrayRegion(removeAndDeleteArray, position, 4, temp); - position += 4; - } - - static auto removeDeleteMultiInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod(jintArray)>( - "removeDeleteMultiMountItem"); - - auto ret = removeDeleteMultiInstruction(javaUIManager, removeAndDeleteArray); - - // It is not strictly necessary to manually delete the ref here, in this - // particular case. If JNI memory is being allocated in a loop, it's easy to - // overload the localref table and crash; this is not possible in this case - // since the JNI would automatically clear this ref when it goes out of scope, - // anyway. However, this is being left here as a reminder of good hygiene and - // to be careful with JNI-allocated memory in general. - env->DeleteLocalRef(removeAndDeleteArray); - - return ret; -} - -// TODO T48019320: because we pass initial props and state to the Create (and -// preallocate) mount instruction, we technically don't need to pass the first -// Update to any components. Dedupe? -local_ref createCreateMountItem( - const jni::global_ref &javaUIManager, - const ShadowViewMutation &mutation, - const Tag surfaceId) { - static auto createJavaInstruction = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod( - jstring, ReadableMap::javaobject, jobject, jint, jint, jboolean)>( - "createMountItem"); - - auto newChildShadowView = mutation.newChildShadowView; - - local_ref componentName = - getPlatformComponentName(newChildShadowView); - - jboolean isLayoutable = - newChildShadowView.layoutMetrics != EmptyLayoutMetrics; - - local_ref props = castReadableMap( - ReadableNativeMap::newObjectCxxArgs(newChildShadowView.props->rawProps)); - - // Do not hold onto Java object from C - // We DO want to hold onto C object from Java, since we don't know the - // lifetime of the Java object - local_ref javaStateWrapper = nullptr; - if (newChildShadowView.state != nullptr) { - javaStateWrapper = StateWrapperImpl::newObjectJavaArgs(); - StateWrapperImpl *cStateWrapper = cthis(javaStateWrapper); - cStateWrapper->state_ = newChildShadowView.state; - } - - return createJavaInstruction( - javaUIManager, - componentName.get(), - props.get(), - (javaStateWrapper != nullptr ? javaStateWrapper.get() : nullptr), - surfaceId, - newChildShadowView.tag, - isLayoutable); -} - -void Binding::schedulerDidFinishTransactionIntBuffer( +void Binding::schedulerDidFinishTransaction( MountingCoordinator::Shared const &mountingCoordinator) { std::lock_guard lock(commitMutex_); @@ -1183,251 +961,6 @@ void Binding::schedulerDidFinishTransactionIntBuffer( env->DeleteLocalRef(intBufferArray); } -void Binding::schedulerDidFinishTransaction( - MountingCoordinator::Shared const &mountingCoordinator) { - std::lock_guard lock(commitMutex_); - - if (useIntBufferBatchMountItem_) { - return schedulerDidFinishTransactionIntBuffer(mountingCoordinator); - } - - SystraceSection s("FabricUIManagerBinding::schedulerDidFinishTransaction"); - auto finishTransactionStartTime = telemetryTimePointNow(); - - jni::global_ref localJavaUIManager = getJavaUIManager(); - if (!localJavaUIManager) { - LOG(ERROR) - << "Binding::schedulerDidFinishTransaction: JavaUIManager disappeared"; - return; - } - - auto mountingTransaction = mountingCoordinator->pullTransaction(); - - if (!mountingTransaction.has_value()) { - return; - } - - auto telemetry = mountingTransaction->getTelemetry(); - auto surfaceId = mountingTransaction->getSurfaceId(); - auto &mutations = mountingTransaction->getMutations(); - - auto revisionNumber = telemetry.getRevisionNumber(); - - std::vector> queue; - // Upper bound estimation of mount items to be delivered to Java side. - int size = mutations.size() * 3 + 42; - - local_ref> mountItemsArray = - JArrayClass::newArray(size); - - auto mountItems = *(mountItemsArray); - std::unordered_set deletedViewTags; - - // Find the set of tags that are removed and deleted in one block - std::vector toRemove; - - int position = 0; - for (const auto &mutation : mutations) { - auto oldChildShadowView = mutation.oldChildShadowView; - auto newChildShadowView = mutation.newChildShadowView; - - bool isVirtual = newChildShadowView.layoutMetrics == EmptyLayoutMetrics && - oldChildShadowView.layoutMetrics == EmptyLayoutMetrics; - - // Handle accumulated removals/deletions - if (mutation.type != ShadowViewMutation::Remove && - mutation.type != ShadowViewMutation::Delete) { - if (toRemove.size() > 0) { - mountItems[position++] = - createRemoveAndDeleteMultiMountItem(localJavaUIManager, toRemove); - toRemove.clear(); - } - } - - switch (mutation.type) { - case ShadowViewMutation::Create: { - if (disablePreallocateViews_ || - mutation.newChildShadowView.props->revision > 1 || - deletedViewTags.find(mutation.newChildShadowView.tag) != - deletedViewTags.end()) { - mountItems[position++] = - createCreateMountItem(localJavaUIManager, mutation, surfaceId); - } - break; - } - case ShadowViewMutation::Remove: { - if (!isVirtual) { - toRemove.push_back( - RemoveDeleteMetadata{mutation.oldChildShadowView.tag, - mutation.parentShadowView.tag, - mutation.index, - true, - false}); - } - break; - } - case ShadowViewMutation::Delete: { - // It is impossible to delete without removing node first - const auto &it = std::find_if( - std::begin(toRemove), - std::end(toRemove), - [&mutation](const auto &x) { - return x.tag == mutation.oldChildShadowView.tag; - }); - - if (it != std::end(toRemove)) { - it->shouldDelete = true; - } else { - toRemove.push_back(RemoveDeleteMetadata{ - mutation.oldChildShadowView.tag, -1, -1, false, true}); - } - - deletedViewTags.insert(mutation.oldChildShadowView.tag); - break; - } - case ShadowViewMutation::Update: { - if (!isVirtual) { - if (mutation.oldChildShadowView.props != - mutation.newChildShadowView.props) { - mountItems[position++] = - createUpdatePropsMountItem(localJavaUIManager, mutation); - } - if (mutation.oldChildShadowView.state != - mutation.newChildShadowView.state) { - mountItems[position++] = - createUpdateStateMountItem(localJavaUIManager, mutation); - } - - // Padding: padding mountItems must be executed before layout props - // are updated in the view. This is necessary to ensure that events - // (resulting from layout changes) are dispatched with the correct - // padding information. - auto updatePaddingMountItem = - createUpdatePaddingMountItem(localJavaUIManager, mutation); - if (updatePaddingMountItem) { - mountItems[position++] = updatePaddingMountItem; - } - - auto updateLayoutMountItem = - createUpdateLayoutMountItem(localJavaUIManager, mutation); - if (updateLayoutMountItem) { - mountItems[position++] = updateLayoutMountItem; - } - } - - if (mutation.oldChildShadowView.eventEmitter != - mutation.newChildShadowView.eventEmitter) { - auto updateEventEmitterMountItem = - createUpdateEventEmitterMountItem(localJavaUIManager, mutation); - if (updateEventEmitterMountItem) { - mountItems[position++] = updateEventEmitterMountItem; - } - } - break; - } - case ShadowViewMutation::Insert: { - if (!isVirtual) { - // Insert item - mountItems[position++] = - createInsertMountItem(localJavaUIManager, mutation); - - if (disablePreallocateViews_ || - mutation.newChildShadowView.props->revision > 1 || - deletedViewTags.find(mutation.newChildShadowView.tag) != - deletedViewTags.end()) { - mountItems[position++] = - createUpdatePropsMountItem(localJavaUIManager, mutation); - } - - // State - if (mutation.newChildShadowView.state) { - mountItems[position++] = - createUpdateStateMountItem(localJavaUIManager, mutation); - } - - // Padding: padding mountItems must be executed before layout props - // are updated in the view. This is necessary to ensure that events - // (resulting from layout changes) are dispatched with the correct - // padding information. - auto updatePaddingMountItem = - createUpdatePaddingMountItem(localJavaUIManager, mutation); - if (updatePaddingMountItem) { - mountItems[position++] = updatePaddingMountItem; - } - - // Layout - auto updateLayoutMountItem = - createUpdateLayoutMountItem(localJavaUIManager, mutation); - if (updateLayoutMountItem) { - mountItems[position++] = updateLayoutMountItem; - } - } - - // EventEmitter - auto updateEventEmitterMountItem = - createUpdateEventEmitterMountItem(localJavaUIManager, mutation); - if (updateEventEmitterMountItem) { - mountItems[position++] = updateEventEmitterMountItem; - } - - break; - } - default: { - break; - } - } - } - - // Handle remaining removals and deletions - if (toRemove.size() > 0) { - mountItems[position++] = - createRemoveAndDeleteMultiMountItem(localJavaUIManager, toRemove); - toRemove.clear(); - } - - static auto createMountItemsBatchContainer = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod( - jint, jtypeArray, jint, jint)>( - "createBatchMountItem"); - - // If there are no items, we pass a nullptr instead of passing the object - // through the JNI - auto batch = createMountItemsBatchContainer( - localJavaUIManager, - surfaceId, - position == 0 ? nullptr : mountItemsArray.get(), - position, - revisionNumber); - - static auto scheduleMountItem = - jni::findClassStatic(Binding::UIManagerJavaDescriptor) - ->getMethod("scheduleMountItem"); - - auto finishTransactionEndTime = telemetryTimePointNow(); - - scheduleMountItem( - localJavaUIManager, - batch.get(), - telemetry.getRevisionNumber(), - telemetryTimePointToMilliseconds(telemetry.getCommitStartTime()), - telemetryTimePointToMilliseconds(telemetry.getDiffStartTime()), - telemetryTimePointToMilliseconds(telemetry.getDiffEndTime()), - telemetryTimePointToMilliseconds(telemetry.getLayoutStartTime()), - telemetryTimePointToMilliseconds(telemetry.getLayoutEndTime()), - telemetryTimePointToMilliseconds(finishTransactionStartTime), - telemetryTimePointToMilliseconds(finishTransactionEndTime)); -} - void Binding::setPixelDensity(float pointScaleFactor) { pointScaleFactor_ = pointScaleFactor; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index 61e2e2b783bd34..377762eb806af5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -169,14 +169,9 @@ class Binding : public jni::HybridClass, float pointScaleFactor_ = 1; std::shared_ptr reactNativeConfig_{nullptr}; - bool useIntBufferBatchMountItem_{false}; bool disablePreallocateViews_{false}; bool disableVirtualNodePreallocation_{false}; bool enableFabricLogs_{false}; - - private: - void schedulerDidFinishTransactionIntBuffer( - MountingCoordinator::Shared const &mountingCoordinator); }; } // namespace react diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java deleted file mode 100644 index 9a7e573edd0581..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.common.logging.FLog; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.bridge.ReactMarker; -import com.facebook.react.bridge.ReactMarkerConstants; -import com.facebook.react.fabric.mounting.MountingManager; -import com.facebook.systrace.Systrace; - -/** - * This class represents a batch of {@link MountItem}s - * - *

A MountItem batch contains an array of {@link MountItem} and a size. The size determines the - * amount of items that needs to be processed in the array. - * - *

The purpose of encapsulating the array of MountItems this way, is to reduce the amount of - * allocations in C++ - */ -@DoNotStrip -public class BatchMountItem implements MountItem { - static final String TAG = "FabricBatchMountItem"; - - private final int mRootTag; - @NonNull private final MountItem[] mMountItems; - - private final int mSize; - - private final int mCommitNumber; - - public BatchMountItem(int rootTag, MountItem[] items, int size, int commitNumber) { - int itemsLength = (items == null ? 0 : items.length); - if (size < 0 || size > itemsLength) { - throw new IllegalArgumentException( - "Invalid size received by parameter size: " + size + " items.size = " + itemsLength); - } - mRootTag = rootTag; - mMountItems = items; - mSize = size; - mCommitNumber = commitNumber; - } - - private void beginMarkers(String reason) { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "FabricUIManager::" + reason + " - " + mSize + " items"); - - if (mCommitNumber > 0) { - ReactMarker.logFabricMarker( - ReactMarkerConstants.FABRIC_BATCH_EXECUTION_START, null, mCommitNumber); - } - } - - private void endMarkers() { - if (mCommitNumber > 0) { - ReactMarker.logFabricMarker( - ReactMarkerConstants.FABRIC_BATCH_EXECUTION_END, null, mCommitNumber); - } - - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - beginMarkers("mountViews"); - - int mountItemIndex = 0; - try { - for (; mountItemIndex < mSize; mountItemIndex++) { - mMountItems[mountItemIndex].execute(mountingManager); - } - } catch (RuntimeException e) { - FLog.e( - TAG, - "Caught exception executing mountItem @" - + mountItemIndex - + ": " - + mMountItems[mountItemIndex].toString(), - e); - throw e; - } - - endMarkers(); - } - - public int getRootTag() { - return mRootTag; - } - - public boolean shouldSchedule() { - return mSize != 0; - } - - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - for (int i = 0; i < mSize; i++) { - if (s.length() > 0) { - s.append("\n"); - } - s.append("BatchMountItem [S:" + mRootTag + "] (") - .append(i + 1) - .append("/") - .append(mSize) - .append("): ") - .append(mMountItems[i]); - } - return s.toString(); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/CreateMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/CreateMountItem.java deleted file mode 100644 index d96bab3326e086..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/CreateMountItem.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.fabric.mounting.MountingManager; -import com.facebook.react.uimanager.StateWrapper; -import com.facebook.react.uimanager.ThemedReactContext; - -public class CreateMountItem implements MountItem { - - @NonNull private final String mComponent; - private final int mRootTag; - private final int mReactTag; - @NonNull private final ThemedReactContext mContext; - private final @Nullable ReadableMap mProps; - private final @Nullable StateWrapper mStateWrapper; - private final boolean mIsLayoutable; - - public CreateMountItem( - @Nullable ThemedReactContext context, - int rootTag, - int reactTag, - @NonNull String component, - @Nullable ReadableMap props, - @NonNull StateWrapper stateWrapper, - boolean isLayoutable) { - mContext = context; - mComponent = component; - mRootTag = rootTag; - mReactTag = reactTag; - mProps = props; - mStateWrapper = stateWrapper; - mIsLayoutable = isLayoutable; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - if (mContext == null) { - throw new IllegalStateException( - "Cannot execute PreAllocateViewMountItem without Context for ReactTag: " - + mReactTag - + " and rootTag: " - + mRootTag); - } - mountingManager.createView( - mContext, mComponent, mReactTag, mProps, mStateWrapper, mIsLayoutable); - } - - @Override - public String toString() { - return "CreateMountItem [" - + mReactTag - + "] - component: " - + mComponent - + " - rootTag: " - + mRootTag - + " - isLayoutable: " - + mIsLayoutable; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/InsertMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/InsertMountItem.java deleted file mode 100644 index edfc46ac7109cf..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/InsertMountItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.react.fabric.mounting.MountingManager; - -public class InsertMountItem implements MountItem { - - private int mReactTag; - private int mParentReactTag; - private int mIndex; - - public InsertMountItem(int reactTag, int parentReactTag, int index) { - mReactTag = reactTag; - mParentReactTag = parentReactTag; - mIndex = index; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.addViewAt(mParentReactTag, mReactTag, mIndex); - } - - public int getParentReactTag() { - return mParentReactTag; - } - - public int getIndex() { - return mIndex; - } - - @Override - public String toString() { - return "InsertMountItem [" - + mReactTag - + "] - parentTag: [" - + mParentReactTag - + "] - index: " - + mIndex; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveDeleteMultiMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveDeleteMultiMountItem.java deleted file mode 100644 index daf3ed5ca75d5e..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/RemoveDeleteMultiMountItem.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.react.fabric.mounting.MountingManager; - -public class RemoveDeleteMultiMountItem implements MountItem { - - // Metadata is an array of ints, grouped into 4 ints per instruction (so the length of metadata - // is always divisible by 4): - // - // `instruction*4 + 0`: react tag of view instruction - // `instruction*4 + 1`: react tag of view's parent - // `instruction*4 + 2`: index of view in parents' children instruction - // `instruction*4 + 3`: flags indicating if the view should be removed, and/or deleted - @NonNull private int[] mMetadata; - - // Bitfields of "flag", indicating if a view should be removed and/or deleted - private static final int REMOVE_FLAG = 1; - private static final int DELETE_FLAG = 2; - - // Indices for each parameter within an "instruction" - private static final int INSTRUCTION_FIELDS_LEN = 4; - private static final int TAG_INDEX = 0; - private static final int PARENT_TAG_INDEX = 1; - private static final int VIEW_INDEX_INDEX = 2; - private static final int FLAGS_INDEX = 3; - - public RemoveDeleteMultiMountItem(@NonNull int[] metadata) { - mMetadata = metadata; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - // First, go through instructions and remove all views that are marked - // for removal. - // Not all views that are removed are deleted, and not all deleted views - // are removed first. - // *All* views must be removed here before we can delete any views. - // Removal of a view from a parent is based on indices within the parents' children, - // and deletion causes reordering; so we must perform all removals first. - for (int i = 0; i < mMetadata.length; i += INSTRUCTION_FIELDS_LEN) { - int flags = mMetadata[i + FLAGS_INDEX]; - if ((flags & REMOVE_FLAG) != 0) { - int parentTag = mMetadata[i + PARENT_TAG_INDEX]; - int tag = mMetadata[i + TAG_INDEX]; - int index = mMetadata[i + VIEW_INDEX_INDEX]; - mountingManager.removeViewAt(tag, parentTag, index); - } - } - - // After removing all views, delete all views marked for deletion. - for (int i = 0; i < mMetadata.length; i += 4) { - int flags = mMetadata[i + FLAGS_INDEX]; - if ((flags & DELETE_FLAG) != 0) { - int tag = mMetadata[i + TAG_INDEX]; - mountingManager.deleteView(tag); - } - } - } - - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - for (int i = 0; i < mMetadata.length; i += 4) { - if (s.length() > 0) { - s.append("\n"); - } - s.append("RemoveDeleteMultiMountItem (") - .append(i / INSTRUCTION_FIELDS_LEN + 1) - .append("/") - .append(mMetadata.length / INSTRUCTION_FIELDS_LEN) - .append("): [") - .append(mMetadata[i + TAG_INDEX]) - .append("] parent [") - .append(mMetadata[i + PARENT_TAG_INDEX]) - .append("] idx ") - .append(mMetadata[i + VIEW_INDEX_INDEX]) - .append(" ") - .append(mMetadata[i + FLAGS_INDEX]); - } - return s.toString(); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateEventEmitterMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateEventEmitterMountItem.java deleted file mode 100644 index 72331c6b963484..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateEventEmitterMountItem.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.react.fabric.events.EventEmitterWrapper; -import com.facebook.react.fabric.mounting.MountingManager; - -public class UpdateEventEmitterMountItem implements MountItem { - - @NonNull private final EventEmitterWrapper mEventHandler; - private final int mReactTag; - - public UpdateEventEmitterMountItem(int reactTag, @NonNull EventEmitterWrapper EventHandler) { - mReactTag = reactTag; - mEventHandler = EventHandler; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.updateEventEmitter(mReactTag, mEventHandler); - } - - @Override - public String toString() { - return "UpdateEventEmitterMountItem [" + mReactTag + "]"; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateLayoutMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateLayoutMountItem.java deleted file mode 100644 index cd8edd887e205b..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateLayoutMountItem.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import android.annotation.TargetApi; -import android.os.Build; -import android.util.LayoutDirection; -import androidx.annotation.NonNull; -import com.facebook.react.fabric.mounting.MountingManager; - -public class UpdateLayoutMountItem implements MountItem { - - private final int mReactTag; - private final int mX; - private final int mY; - private final int mWidth; - private final int mHeight; - private final int mLayoutDirection; - - public UpdateLayoutMountItem( - int reactTag, int x, int y, int width, int height, int layoutDirection) { - mReactTag = reactTag; - mX = x; - mY = y; - mWidth = width; - mHeight = height; - mLayoutDirection = convertLayoutDirection(layoutDirection); - } - - // TODO move this from here - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static int convertLayoutDirection(int layoutDirection) { - switch (layoutDirection) { - case 0: - return LayoutDirection.INHERIT; - case 1: - return LayoutDirection.LTR; - case 2: - return LayoutDirection.RTL; - default: - throw new IllegalArgumentException("Unsupported layout direction: " + layoutDirection); - } - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.updateLayout(mReactTag, mX, mY, mWidth, mHeight); - } - - public int getX() { - return mX; - } - - public int getY() { - return mY; - } - - public int getHeight() { - return mHeight; - } - - public int getWidth() { - return mWidth; - } - - public int getLayoutDirection() { - return mLayoutDirection; - } - - @Override - public String toString() { - return "UpdateLayoutMountItem [" - + mReactTag - + "] - x: " - + mX - + " - y: " - + mY - + " - height: " - + mHeight - + " - width: " - + mWidth - + " - layoutDirection: " - + +mLayoutDirection; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePaddingMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePaddingMountItem.java deleted file mode 100644 index e0403627bbd99d..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePaddingMountItem.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import com.facebook.react.fabric.mounting.MountingManager; - -/** - * A MountItem that represents setting the padding properties of a view (left, top, right, bottom). - * This is distinct from layout because it happens far less frequently from layout; so it is a perf - * optimization to transfer this data and execute the methods strictly less than the layout-related - * properties. - */ -public class UpdatePaddingMountItem implements MountItem { - - private final int mReactTag; - private final int mLeft; - private final int mTop; - private final int mRight; - private final int mBottom; - - public UpdatePaddingMountItem(int reactTag, int left, int top, int right, int bottom) { - mReactTag = reactTag; - mLeft = left; - mTop = top; - mRight = right; - mBottom = bottom; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.updatePadding(mReactTag, mLeft, mTop, mRight, mBottom); - } - - @Override - public String toString() { - return "UpdatePaddingMountItem [" - + mReactTag - + "] - left: " - + mLeft - + " - top: " - + mTop - + " - right: " - + mRight - + " - bottom: " - + mBottom; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePropsMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePropsMountItem.java deleted file mode 100644 index 8b980705e9dc84..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdatePropsMountItem.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT; - -import androidx.annotation.NonNull; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.fabric.mounting.MountingManager; - -public class UpdatePropsMountItem implements MountItem { - - private final int mReactTag; - @NonNull private final ReadableMap mUpdatedProps; - - public UpdatePropsMountItem(int reactTag, @NonNull ReadableMap updatedProps) { - mReactTag = reactTag; - mUpdatedProps = updatedProps; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.updateProps(mReactTag, mUpdatedProps); - } - - @Override - public String toString() { - StringBuilder result = - new StringBuilder("UpdatePropsMountItem [").append(mReactTag).append("]"); - - if (IS_DEVELOPMENT_ENVIRONMENT) { - result.append(" props: ").append(mUpdatedProps); - } - - return result.toString(); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateStateMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateStateMountItem.java deleted file mode 100644 index 4544e8f935e23e..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/UpdateStateMountItem.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.fabric.mounting.mountitems; - -import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.facebook.react.fabric.mounting.MountingManager; -import com.facebook.react.uimanager.StateWrapper; - -public class UpdateStateMountItem implements MountItem { - - private final int mReactTag; - @Nullable private final StateWrapper mStateWrapper; - - public UpdateStateMountItem(int reactTag, @Nullable StateWrapper stateWrapper) { - mReactTag = reactTag; - mStateWrapper = stateWrapper; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.updateState(mReactTag, mStateWrapper); - } - - @Override - public String toString() { - StringBuilder result = - new StringBuilder("UpdateStateMountItem [").append(mReactTag).append("]"); - - if (IS_DEVELOPMENT_ENVIRONMENT) { - result.append(" state: ").append(mStateWrapper != null ? mStateWrapper.getState() : ""); - } - - return result.toString(); - } -} From a4526bcc3f89f5b9d3f86c814ade8f55c86e819e Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 5 Jan 2021 11:04:17 -0800 Subject: [PATCH 0322/1810] fix: incorrect ScrollView offset on update (#30647) Summary: This pull request is to fix https://github.com/facebook/react-native/issues/30258. After an investigation, I found out the scroll offset of the list seems to be calculated incorrectly due to a workaround in the source code. Instead of fixing the `calculateOffsetForContentSize`, I chose to remove it, the reason why I do so is because this workaround is for fixing the offset when `contentSize` is set manually, but according to the source code, there is no interface for a react-native user to set the `contentSize` of ScrollView, it is just set to `GCSizeZero` and will never be changed ([ref](https://github.com/facebook/react-native/pull/30647/files#diff-cf6f991f585ebf4cfdd555fe474e1f9ce40c2e4f823fc3f42b549414639c8c30L304)). Also I changed the function name from `updateContentOffsetIfNeeded` to `updateContentSizeIfNeeded` according what the function is actually doing. ## Changelog [iOS] [Fixed] - Incorrect ScrollView offset on update Pull Request resolved: https://github.com/facebook/react-native/pull/30647 Test Plan: 1. Create a fresh new project named `testapp` using npx create-react-native-app 2. Apply example code to `testapp` from https://snack.expo.io/lokomass/flatlist 3. Run `testapp` on iOS emulator and reproduce the bug 4. Make changes to files in `testapp/node_modules/react-native/` 5. Rebuild `testapp` and run on iOS emulator again, the bug is no more exist 6. Apply changes from step 4 to react-native, make a pull request. #### Screenshots Before: The scroll offset is incorrect after children of FlatList has changed https://user-images.githubusercontent.com/48589760/103155130-b54a0580-47d7-11eb-97af-bdfd3e728714.mov After: No more incorrect scroll offset if children of FlatList has changed https://user-images.githubusercontent.com/48589760/103155091-6ef4a680-47d7-11eb-89fa-6f708bfef1c9.mov Reviewed By: sammy-SC Differential Revision: D25732958 Pulled By: shergin fbshipit-source-id: dac6eff15ac3bbfec502452ac14b3d49fee76c29 --- React/Views/ScrollView/RCTScrollContentView.m | 2 +- React/Views/ScrollView/RCTScrollView.h | 8 +-- React/Views/ScrollView/RCTScrollView.m | 62 +------------------ 3 files changed, 4 insertions(+), 68 deletions(-) diff --git a/React/Views/ScrollView/RCTScrollContentView.m b/React/Views/ScrollView/RCTScrollContentView.m index cf6a0b1f17953d..8006540a70f136 100644 --- a/React/Views/ScrollView/RCTScrollContentView.m +++ b/React/Views/ScrollView/RCTScrollContentView.m @@ -26,7 +26,7 @@ - (void)reactSetFrame:(CGRect)frame RCTAssert([scrollView isKindOfClass:[RCTScrollView class]], @"Unexpected view hierarchy of RCTScrollView component."); - [scrollView updateContentOffsetIfNeeded]; + [scrollView updateContentSizeIfNeeded]; } @end diff --git a/React/Views/ScrollView/RCTScrollView.h b/React/Views/ScrollView/RCTScrollView.h index 4a508ee1e9d8a2..765d3b3378a5a6 100644 --- a/React/Views/ScrollView/RCTScrollView.h +++ b/React/Views/ScrollView/RCTScrollView.h @@ -28,12 +28,6 @@ */ @property (nonatomic, readonly) UIView *contentView; -/** - * If the `contentSize` is not specified (or is specified as {0, 0}, then the - * `contentSize` will automatically be determined by the size of the subview. - */ -@property (nonatomic, assign) CGSize contentSize; - /** * The underlying scrollView (TODO: can we remove this?) */ @@ -68,7 +62,7 @@ @interface RCTScrollView (Internal) -- (void)updateContentOffsetIfNeeded; +- (void)updateContentSizeIfNeeded; @end diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index c52f449c730015..c9fe67bb9edbbe 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -301,7 +301,6 @@ - (instancetype)initWithEventDispatcher:(id)eventDis _automaticallyAdjustContentInsets = YES; _contentInset = UIEdgeInsetsZero; - _contentSize = CGSizeZero; _lastClippedToRect = CGRectNull; _scrollEventThrottle = 0.0; @@ -381,7 +380,7 @@ - (void)didUpdateReactSubviews - (void)didSetProps:(NSArray *)changedProps { if ([changedProps containsObject:@"contentSize"]) { - [self updateContentOffsetIfNeeded]; + [self updateContentSizeIfNeeded]; } } @@ -799,8 +798,6 @@ - (UIView *)viewForZoomingInScrollView:(__unused UIScrollView *)scrollView return _contentView; } -#pragma mark - Setters - - (CGSize)_calculateViewportSize { CGSize viewportSize = self.bounds.size; @@ -813,71 +810,16 @@ - (CGSize)_calculateViewportSize return viewportSize; } -- (CGPoint)calculateOffsetForContentSize:(CGSize)newContentSize -{ - CGPoint oldOffset = _scrollView.contentOffset; - CGPoint newOffset = oldOffset; - - CGSize oldContentSize = _scrollView.contentSize; - CGSize viewportSize = [self _calculateViewportSize]; - - BOOL fitsinViewportY = oldContentSize.height <= viewportSize.height && newContentSize.height <= viewportSize.height; - if (newContentSize.height < oldContentSize.height && !fitsinViewportY) { - CGFloat offsetHeight = oldOffset.y + viewportSize.height; - if (oldOffset.y < 0) { - // overscrolled on top, leave offset alone - } else if (offsetHeight > oldContentSize.height) { - // overscrolled on the bottom, preserve overscroll amount - newOffset.y = MAX(0, oldOffset.y - (oldContentSize.height - newContentSize.height)); - } else if (offsetHeight > newContentSize.height) { - // offset falls outside of bounds, scroll back to end of list - newOffset.y = MAX(0, newContentSize.height - viewportSize.height); - } - } - - BOOL fitsinViewportX = oldContentSize.width <= viewportSize.width && newContentSize.width <= viewportSize.width; - if (newContentSize.width < oldContentSize.width && !fitsinViewportX) { - CGFloat offsetHeight = oldOffset.x + viewportSize.width; - if (oldOffset.x < 0) { - // overscrolled at the beginning, leave offset alone - } else if (offsetHeight > oldContentSize.width && newContentSize.width > viewportSize.width) { - // overscrolled at the end, preserve overscroll amount as much as possible - newOffset.x = MAX(0, oldOffset.x - (oldContentSize.width - newContentSize.width)); - } else if (offsetHeight > newContentSize.width) { - // offset falls outside of bounds, scroll back to end - newOffset.x = MAX(0, newContentSize.width - viewportSize.width); - } - } - - // all other cases, offset doesn't change - return newOffset; -} - -/** - * Once you set the `contentSize`, to a nonzero value, it is assumed to be - * managed by you, and we'll never automatically compute the size for you, - * unless you manually reset it back to {0, 0} - */ - (CGSize)contentSize { - if (!CGSizeEqualToSize(_contentSize, CGSizeZero)) { - return _contentSize; - } - return _contentView.frame.size; } -- (void)updateContentOffsetIfNeeded +- (void)updateContentSizeIfNeeded { CGSize contentSize = self.contentSize; if (!CGSizeEqualToSize(_scrollView.contentSize, contentSize)) { - // When contentSize is set manually, ScrollView internals will reset - // contentOffset to {0, 0}. Since we potentially set contentSize whenever - // anything in the ScrollView updates, we workaround this issue by manually - // adjusting contentOffset whenever this happens - CGPoint newOffset = [self calculateOffsetForContentSize:contentSize]; _scrollView.contentSize = contentSize; - _scrollView.contentOffset = newOffset; } } From 08eacf8acdb288562bd1a29981acbaa7ea02203a Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 5 Jan 2021 11:47:07 -0800 Subject: [PATCH 0323/1810] Ship optimization of ReadableNativeMaps Summary: Ship optimization of ReadableNativeMaps - see D25361169 (https://github.com/facebook/react-native/commit/503a6f4463f5d2f7576b33158c18d8d8e99f3291) QE showed neutral metrics changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25776019 fbshipit-source-id: 7fd32087bf2ca81236fe0aebe082be01330de2fa --- .../react/bridge/ReadableNativeMap.java | 117 ++++++++---------- .../react/config/ReactFeatureFlags.java | 3 - 2 files changed, 52 insertions(+), 68 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java index d6693e1d87d9d2..a2e4319224abcc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java @@ -12,7 +12,6 @@ import com.facebook.infer.annotation.Assertions; import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.config.ReactFeatureFlags; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -89,64 +88,6 @@ private HashMap getLocalMap() { return mLocalTypeMap; } - private Iterator> createExperimentalIterator() { - if (mKeys == null) { - mKeys = Assertions.assertNotNull(importKeys()); - } - final String[] iteratorKeys = mKeys; - final Object[] iteratorValues = Assertions.assertNotNull(importValues()); - return new Iterator>() { - int currentIndex = 0; - - @Override - public boolean hasNext() { - return currentIndex < iteratorKeys.length; - } - - @Override - public Map.Entry next() { - final int index = currentIndex++; - return new Map.Entry() { - @Override - public String getKey() { - return iteratorKeys[index]; - } - - @Override - public Object getValue() { - return iteratorValues[index]; - } - - @Override - public Object setValue(Object value) { - throw new UnsupportedOperationException( - "Can't set a value while iterating over a ReadableNativeMap"); - } - }; - } - }; - } - - private ReadableMapKeySetIterator createExperimentalKeySetIterator() { - if (mKeys == null) { - mKeys = Assertions.assertNotNull(importKeys()); - } - final String[] iteratorKeys = mKeys; - return new ReadableMapKeySetIterator() { - int currentIndex = 0; - - @Override - public boolean hasNextKey() { - return currentIndex < iteratorKeys.length; - } - - @Override - public String nextKey() { - return iteratorKeys[currentIndex++]; - } - }; - } - private native Object[] importTypes(); @Override @@ -246,16 +187,62 @@ public int getInt(@NonNull String name) { @Override public @NonNull Iterator> getEntryIterator() { - return ReactFeatureFlags.enableExperimentalReadableNativeMapIterator - ? createExperimentalIterator() - : getLocalMap().entrySet().iterator(); + if (mKeys == null) { + mKeys = Assertions.assertNotNull(importKeys()); + } + final String[] iteratorKeys = mKeys; + final Object[] iteratorValues = Assertions.assertNotNull(importValues()); + return new Iterator>() { + int currentIndex = 0; + + @Override + public boolean hasNext() { + return currentIndex < iteratorKeys.length; + } + + @Override + public Map.Entry next() { + final int index = currentIndex++; + return new Map.Entry() { + @Override + public String getKey() { + return iteratorKeys[index]; + } + + @Override + public Object getValue() { + return iteratorValues[index]; + } + + @Override + public Object setValue(Object value) { + throw new UnsupportedOperationException( + "Can't set a value while iterating over a ReadableNativeMap"); + } + }; + } + }; } @Override public @NonNull ReadableMapKeySetIterator keySetIterator() { - return ReactFeatureFlags.enableExperimentalReadableNativeMapIterator - ? createExperimentalKeySetIterator() - : new ReadableNativeMapKeySetIterator(this); + if (mKeys == null) { + mKeys = Assertions.assertNotNull(importKeys()); + } + final String[] iteratorKeys = mKeys; + return new ReadableMapKeySetIterator() { + int currentIndex = 0; + + @Override + public boolean hasNextKey() { + return currentIndex < iteratorKeys.length; + } + + @Override + public String nextKey() { + return iteratorKeys[currentIndex++]; + } + }; } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index f233da7d48c8e6..2fddf14715c8ea 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -66,9 +66,6 @@ public class ReactFeatureFlags { */ public static boolean enableStartSurfaceRaceConditionFix = false; - /** Enables the usage of an experimental optimized iterator for ReadableNativeMaps. */ - public static boolean enableExperimentalReadableNativeMapIterator = false; - /** Enables Static ViewConfig in RN Android native code. */ public static boolean enableExperimentalStaticViewConfigs = false; } From dc9132e2979c71c50ad71beb3a8071fd7e54b7f8 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Tue, 5 Jan 2021 17:43:00 -0800 Subject: [PATCH 0324/1810] remove -javadoc.jar, -sources.jar from NPM package validation (#30686) Summary: In https://github.com/facebook/react-native/commit/a4d8632890df43c40ee3f892dc2817238de143db, I removed javadoc.jar, and sources.jar generation, but forgot to change artifact validation for NPM publish. This PR removes javadoc.jar and sources.jar from validation. ## Changelog [Internal] [Changed] - remove javadoc.jar, sources.jar from NPM package validation Pull Request resolved: https://github.com/facebook/react-native/pull/30686 Test Plan: publish_npm_package CI job must succeed. Reviewed By: mdvacca Differential Revision: D25775320 Pulled By: fkgozali fbshipit-source-id: b2cff66986818c5216754dcf14d9fcd756d14231 --- scripts/publish-npm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 6107a9efd2a1a6..954eaaf7c77a12 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -137,7 +137,7 @@ exec('git checkout ReactAndroid/gradle.properties'); echo('Generated artifacts for Maven'); -let artifacts = ['-javadoc.jar', '-sources.jar', '.aar', '.pom'].map(suffix => { +let artifacts = ['.aar', '.pom'].map(suffix => { return `react-native-${releaseVersion}${suffix}`; }); From 381fb395ad9d2d48717a5d082aaedbecdd804554 Mon Sep 17 00:00:00 2001 From: Jayme Deffenbaugh Date: Tue, 5 Jan 2021 23:20:56 -0800 Subject: [PATCH 0325/1810] Expose the testID to black-box testing frameworks on Android (#29610) Summary: There has been a long-standing issue where black-box testing frameworks like Appium and Xamarin UITest have not been able to access the `testID` view prop for Android (see https://github.com/facebook/react-native/issues/7135). A natural place for this to be exposed is via a view's `resource-id`. The `resource-id` is what I have used when working on UIAutomator-based tests for native Android apps and is a non-localized, development-only identifier. As mentioned in the linked ticket, you can dynamically set the resource-id using the view's AccessibilityNodeInfo. This change simply checks to see if a testID is provided for a view and then exposes it through the view's accessibility node delegate. ## Changelog [Android] [Fixed] - Fixes https://github.com/facebook/react-native/issues/7135, https://github.com/facebook/react-native/issues/9942, and https://github.com/facebook/react-native/issues/16137. Display the `testID` as the `resource-id` for black-box testing frameworks Pull Request resolved: https://github.com/facebook/react-native/pull/29610 Test Plan: I used the `uiautomatorviewer` tool to verify that the resource-id is populated with the `testID` of a few different views of the RNTester app. Screen Shot 2020-08-10 at 3 38 27 PM Screen Shot 2020-08-10 at 3 40 41 PM Reviewed By: JoshuaGross Differential Revision: D25799550 Pulled By: fkgozali fbshipit-source-id: e64ff1b90fb66b427fce7af533aa94792cfbcad3 --- .../react/uimanager/ReactAccessibilityDelegate.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java index 22b82bed0ca1d5..f371e341f17d8a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java @@ -246,6 +246,15 @@ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCo } } } + + // Expose the testID prop as the resource-id name of the view. Black-box E2E/UI testing + // frameworks, which interact with the UI through the accessibility framework, do not have + // access to view tags. This allows developers/testers to avoid polluting the + // content-description with test identifiers. + final String testId = (String) host.getTag(R.id.react_test_id); + if (testId != null) { + info.setViewIdResourceName(testId); + } } @Override @@ -425,7 +434,8 @@ public static void setDelegate(final View view) { if (!ViewCompat.hasAccessibilityDelegate(view) && (view.getTag(R.id.accessibility_role) != null || view.getTag(R.id.accessibility_state) != null - || view.getTag(R.id.accessibility_actions) != null)) { + || view.getTag(R.id.accessibility_actions) != null + || view.getTag(R.id.react_test_id) != null)) { ViewCompat.setAccessibilityDelegate(view, new ReactAccessibilityDelegate()); } } From 2e631471092090e743245377742166ecae1d7e26 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 5 Jan 2021 23:21:47 -0800 Subject: [PATCH 0326/1810] Refactor creation of views in Fabric Android Summary: This diff refactors the createViewInstance method in order to ensure that viewID is set before props are updated in the view. This is necessary because there are components that deliver events at the same time their props are set. This means that some components might not have their viewId set correctly when events are delivered. Since viewId is used to determine if a view belongs to Fabric or Paper, there are cases when the events are not delivered to the right renderer changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25667987 fbshipit-source-id: 4acfa8f80d66e9e59514354481957d7d3b571248 --- .../react/fabric/mounting/MountingManager.java | 2 +- .../uimanager/NativeViewHierarchyManager.java | 2 +- .../facebook/react/uimanager/ViewManager.java | 16 ++++++++-------- .../react/uimanager/SimpleViewPropertyTest.java | 10 ++++++++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 2ea54f35e42bb3..fe00e5d35b9dfb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -533,7 +533,7 @@ public void createView( // View Managers are responsible for dealing with initial state and props. view = viewManager.createView( - themedReactContext, propsDiffMap, stateWrapper, mJSResponderHandler); + reactTag, themedReactContext, propsDiffMap, stateWrapper, mJSResponderHandler); view.setId(reactTag); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index ff1147ad3fe09b..26dc859215cdb7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -278,7 +278,7 @@ public synchronized void createView( try { ViewManager viewManager = mViewManagers.get(className); - View view = viewManager.createView(themedContext, null, null, mJSResponderHandler); + View view = viewManager.createView(tag, themedContext, null, null, mJSResponderHandler); mTagsToViews.put(tag, view); mTagsToViewManagers.put(tag, viewManager); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index 5401620f715751..cf1be7c7ce0b62 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -67,19 +67,14 @@ protected ViewManagerDelegate getDelegate() { return null; } - /** Creates a view and installs event emitters on it. */ - private final @NonNull T createView( - @NonNull ThemedReactContext reactContext, JSResponderHandler jsResponderHandler) { - return createView(reactContext, null, null, jsResponderHandler); - } - /** Creates a view with knowledge of props and state. */ public @NonNull T createView( + int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap props, @Nullable StateWrapper stateWrapper, JSResponderHandler jsResponderHandler) { - T view = createViewInstance(reactContext, props, stateWrapper); + T view = createViewInstance(reactTag, reactContext, props, stateWrapper); if (view instanceof ReactInterceptingViewGroup) { ((ReactInterceptingViewGroup) view).setOnInterceptTouchEventListener(jsResponderHandler); } @@ -129,13 +124,18 @@ public C createShadowNodeInstance() { * that will call createViewInstance for you. Override it if you need props upon creation of the * view. * - * @param reactContext + * @param reactTag reactTag that should be set as ID of the view instance + * @param reactContext ReactContext used to initialize view instance + * @param initialProps initial props for the view instance + * @param stateWrapper initial state for the view instance */ protected @NonNull T createViewInstance( + int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) { T view = createViewInstance(reactContext); + view.setId(reactTag); addEventEmitters(reactContext, view); if (initialProps != null) { updateProperties(view, initialProps); diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java index ed1d23990e437b..91be74945d9c9b 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java @@ -36,6 +36,8 @@ public class SimpleViewPropertyTest { @Rule public PowerMockRule rule = new PowerMockRule(); + private static int sViewTag = 2; + private static class ConcreteViewManager extends SimpleViewManager { @ReactProp(name = "foo") @@ -75,7 +77,9 @@ public ReactStylesDiffMap buildStyles(Object... keysAndValues) { @Test public void testOpacity() { - View view = mManager.createView(mThemedContext, buildStyles(), null, new JSResponderHandler()); + View view = + mManager.createView( + sViewTag, mThemedContext, buildStyles(), null, new JSResponderHandler()); mManager.updateProperties(view, buildStyles()); assertThat(view.getAlpha()).isEqualTo(1.0f); @@ -89,7 +93,9 @@ public void testOpacity() { @Test public void testBackgroundColor() { - View view = mManager.createView(mThemedContext, buildStyles(), null, new JSResponderHandler()); + View view = + mManager.createView( + sViewTag, mThemedContext, buildStyles(), null, new JSResponderHandler()); mManager.updateProperties(view, buildStyles()); assertThat(view.getBackground()).isEqualTo(null); From d3a3ce857ef5a54e7014e06af194b596ec18a03e Mon Sep 17 00:00:00 2001 From: David Vacca Date: Wed, 6 Jan 2021 00:47:36 -0800 Subject: [PATCH 0327/1810] Refactor initialization of Fabric to avoid loading UIManagerModule Summary: This diff refactors the intialization of Fabric in order to avoid loading UIManagerModule as part of the creation of FabricJSIModuleProvider. One caveat is that now we are not taking into consideration the flag mLazyViewManagersEnabled ``` master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java177 if (mLazyViewManagersEnabled) { ``` As a side effect of this diff view managers will be initialized twice if the user has fabric and paper enabled This diff was originally backed out in D25739854 (https://github.com/facebook/react-native/commit/4984c1e525e310f15c7d89230fdb2fa8fea91f05) because it produced a couple of bugs: - https://fb.workplace.com/groups/rn.support/permalink/4917641074951135/ - https://fb.workplace.com/groups/rn.support/permalink/4918163014898941/ These bugs are fixed by D25667987 (https://github.com/facebook/react-native/commit/2e631471092090e743245377742166ecae1d7e26). changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D25746024 fbshipit-source-id: 3d12d29973a12b1edfea75f4dd954790f835e9bd --- .../react/fabric/FabricJSIModuleProvider.java | 18 ++++++++---------- .../react/uiapp/RNTesterApplication.java | 11 ++++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index 86e5cf383739be..4ffef756aa1410 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -8,7 +8,6 @@ package com.facebook.react.fabric; import androidx.annotation.NonNull; -import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSIModuleProvider; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UIManager; @@ -26,9 +25,10 @@ import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem; import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent; import com.facebook.react.uimanager.StateWrapper; -import com.facebook.react.uimanager.UIManagerModule; +import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.uimanager.events.BatchEventDispatchedListener; import com.facebook.react.uimanager.events.EventDispatcher; +import com.facebook.react.uimanager.events.EventDispatcherImpl; import com.facebook.systrace.Systrace; public class FabricJSIModuleProvider implements JSIModuleProvider { @@ -36,14 +36,17 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { @NonNull private final ReactApplicationContext mReactApplicationContext; @NonNull private final ComponentFactory mComponentFactory; @NonNull private final ReactNativeConfig mConfig; + @NonNull private final ViewManagerRegistry mViewManagerRegistry; public FabricJSIModuleProvider( @NonNull ReactApplicationContext reactApplicationContext, @NonNull ComponentFactory componentFactory, - @NonNull ReactNativeConfig config) { + @NonNull ReactNativeConfig config, + @NonNull ViewManagerRegistry viewManagerRegistry) { mReactApplicationContext = reactApplicationContext; mComponentFactory = componentFactory; mConfig = config; + mViewManagerRegistry = viewManagerRegistry; } @Override @@ -79,15 +82,10 @@ public UIManager get() { private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager"); - UIManagerModule nativeModule = - Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class)); - EventDispatcher eventDispatcher = nativeModule.getEventDispatcher(); + EventDispatcher eventDispatcher = new EventDispatcherImpl(mReactApplicationContext); FabricUIManager fabricUIManager = new FabricUIManager( - mReactApplicationContext, - nativeModule.getViewManagerRegistry_DO_NOT_USE(), - eventDispatcher, - eventBeatManager); + mReactApplicationContext, mViewManagerRegistry, eventDispatcher, eventBeatManager); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); return fabricUIManager; diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index b892f527c0e4a9..e8eec3ae80b7a3 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -34,6 +34,7 @@ import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.shell.MainReactPackage; import com.facebook.react.turbomodule.core.TurboModuleManager; +import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.views.text.ReactFontManager; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; @@ -168,6 +169,13 @@ public JSIModuleType getJSIModuleType() { public JSIModuleProvider getJSIModuleProvider() { final ComponentFactory ComponentFactory = new ComponentFactory(); CoreComponentsRegistry.register(ComponentFactory); + final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); + + ViewManagerRegistry viewManagerRegistry = + new ViewManagerRegistry( + reactInstanceManager.getOrCreateViewManagers( + reactApplicationContext)); + return new FabricJSIModuleProvider( reactApplicationContext, ComponentFactory, @@ -192,7 +200,8 @@ public String getString(final String s) { public double getDouble(final String s) { return 0; } - }); + }, + viewManagerRegistry); } }); } From 6651b7c59b5c9c182198e8d83f86d01556328475 Mon Sep 17 00:00:00 2001 From: Panagiotis Vekris Date: Wed, 6 Jan 2021 17:22:30 -0800 Subject: [PATCH 0328/1810] restore core lib Flow definitions for Request, Response, etc. Summary: The main change of this diff is in file react-native-github/interface.js. This file used to override the definitions for `fetch`, `Headers`, `Request`, `Response`, `requestAnimationFrame` of flow/lib/bom.js and type them as `any` instead. This is inconsistent with the rest of the flow library definitions that expect `Request`, for example, to be adequately typed. Overriding this defnition with `any` raises `[value-as-type]` errors in the library definitions themselves. Due to a Flow bug, these errors were silently suppressed, leading to loss of coverage. I'm trying to clean-up these errors and fix the Flow bug so that library errors are always surfaced. This diff also: * Removes 53 unused suppression comments * Adds 110 new error suppressions Changelog: [Internal] Reviewed By: pieterv Differential Revision: D25806504 fbshipit-source-id: e312bc5d64818b63c3b8b4f86dea51e13aacfac0 --- interface.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/interface.js b/interface.js index a5e7987fe744ee..22337a98731be1 100644 --- a/interface.js +++ b/interface.js @@ -15,11 +15,3 @@ declare var __DEV__: boolean; declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{ inject: ?((stuff: Object) => void) };*/ - -declare var fetch: any; -declare var Headers: any; -declare var Request: any; -declare var Response: any; -declare module requestAnimationFrame { - declare module.exports: (callback: any) => any; -} From 2027d6236a4832c5cc287776ac8e0165fb5f0d8d Mon Sep 17 00:00:00 2001 From: David Vacca Date: Wed, 6 Jan 2021 21:35:17 -0800 Subject: [PATCH 0329/1810] Revert D25746024: Refactor initialization of Fabric to avoid loading UIManagerModule Differential Revision: D25746024 (https://github.com/facebook/react-native/commit/d3a3ce857ef5a54e7014e06af194b596ec18a03e) Original commit changeset: 3d12d29973a1 fbshipit-source-id: 67a7f045e5c6b1bc0201ad58b569fc870c3a89f9 --- .../react/fabric/FabricJSIModuleProvider.java | 18 ++++++++++-------- .../react/uiapp/RNTesterApplication.java | 11 +---------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index 4ffef756aa1410..86e5cf383739be 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -8,6 +8,7 @@ package com.facebook.react.fabric; import androidx.annotation.NonNull; +import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSIModuleProvider; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UIManager; @@ -25,10 +26,9 @@ import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem; import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent; import com.facebook.react.uimanager.StateWrapper; -import com.facebook.react.uimanager.ViewManagerRegistry; +import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.events.BatchEventDispatchedListener; import com.facebook.react.uimanager.events.EventDispatcher; -import com.facebook.react.uimanager.events.EventDispatcherImpl; import com.facebook.systrace.Systrace; public class FabricJSIModuleProvider implements JSIModuleProvider { @@ -36,17 +36,14 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { @NonNull private final ReactApplicationContext mReactApplicationContext; @NonNull private final ComponentFactory mComponentFactory; @NonNull private final ReactNativeConfig mConfig; - @NonNull private final ViewManagerRegistry mViewManagerRegistry; public FabricJSIModuleProvider( @NonNull ReactApplicationContext reactApplicationContext, @NonNull ComponentFactory componentFactory, - @NonNull ReactNativeConfig config, - @NonNull ViewManagerRegistry viewManagerRegistry) { + @NonNull ReactNativeConfig config) { mReactApplicationContext = reactApplicationContext; mComponentFactory = componentFactory; mConfig = config; - mViewManagerRegistry = viewManagerRegistry; } @Override @@ -82,10 +79,15 @@ public UIManager get() { private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager"); - EventDispatcher eventDispatcher = new EventDispatcherImpl(mReactApplicationContext); + UIManagerModule nativeModule = + Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class)); + EventDispatcher eventDispatcher = nativeModule.getEventDispatcher(); FabricUIManager fabricUIManager = new FabricUIManager( - mReactApplicationContext, mViewManagerRegistry, eventDispatcher, eventBeatManager); + mReactApplicationContext, + nativeModule.getViewManagerRegistry_DO_NOT_USE(), + eventDispatcher, + eventBeatManager); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); return fabricUIManager; diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index e8eec3ae80b7a3..b892f527c0e4a9 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -34,7 +34,6 @@ import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.shell.MainReactPackage; import com.facebook.react.turbomodule.core.TurboModuleManager; -import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.views.text.ReactFontManager; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; @@ -169,13 +168,6 @@ public JSIModuleType getJSIModuleType() { public JSIModuleProvider getJSIModuleProvider() { final ComponentFactory ComponentFactory = new ComponentFactory(); CoreComponentsRegistry.register(ComponentFactory); - final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); - - ViewManagerRegistry viewManagerRegistry = - new ViewManagerRegistry( - reactInstanceManager.getOrCreateViewManagers( - reactApplicationContext)); - return new FabricJSIModuleProvider( reactApplicationContext, ComponentFactory, @@ -200,8 +192,7 @@ public String getString(final String s) { public double getDouble(final String s) { return 0; } - }, - viewManagerRegistry); + }); } }); } From fa406ac2aa171c5771b153b773483e0b05410d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 7 Jan 2021 03:16:31 -0800 Subject: [PATCH 0330/1810] Implement typed event emitters Summary: Adds types to Event Emitters and migrates the most relevant modules using them in `react-native`. The most relevant file of this diff is `react-native/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js` with the Flow tests showing and testing the behavior of the new types Changelog: [Internal] Add types for Event Emitters and subclasses Reviewed By: motiz88 Differential Revision: D25587936 fbshipit-source-id: feeb09f9ad15d383cdd82deaaaba0d12b94e868b --- Libraries/AppState/AppState.js | 116 ++++++++++++---- .../AccessibilityInfo.android.js | 31 +++-- .../AccessibilityInfo.ios.js | 61 +++++---- Libraries/Components/Keyboard/Keyboard.js | 98 +++++++------- .../Keyboard/__tests__/Keyboard-test.js | 11 +- .../Components/StatusBar/StatusBarIOS.js | 16 ++- Libraries/EventEmitter/NativeEventEmitter.js | 22 +-- .../EventEmitter/RCTDeviceEventEmitter.js | 29 ++-- .../__mocks__/NativeEventEmitter.js | 4 +- Libraries/Interaction/InteractionManager.js | 5 +- Libraries/Linking/Linking.js | 21 ++- Libraries/Modal/Modal.js | 6 +- Libraries/Network/RCTNetworking.android.js | 1 + Libraries/Network/RCTNetworking.ios.js | 1 + .../PushNotificationIOS.js | 26 +++- Libraries/Utilities/Appearance.js | 10 +- Libraries/Utilities/DevSettings.js | 6 +- Libraries/Utilities/Dimensions.js | 4 +- Libraries/WebSocket/WebSocket.js | 16 ++- Libraries/vendor/emitter/EventEmitter.js | 3 +- .../vendor/emitter/_EmitterSubscription.js | 25 ++-- Libraries/vendor/emitter/_EventEmitter.js | 64 ++++++--- .../vendor/emitter/_EventSubscription.js | 14 +- .../emitter/_EventSubscriptionVendor.js | 33 +++-- .../__flowtests__/EventEmitter-flowtest.js | 127 ++++++++++++++++++ 25 files changed, 537 insertions(+), 213 deletions(-) create mode 100644 Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index 280247634303a5..5e31fe2b954121 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -11,20 +11,48 @@ 'use strict'; import NativeEventEmitter from '../EventEmitter/NativeEventEmitter'; +import type EventSubscription from '../vendor/emitter/_EventSubscription'; +import type EmitterSubscription from '../vendor/emitter/_EmitterSubscription'; import logError from '../Utilities/logError'; import EventEmitter from '../vendor/emitter/EventEmitter'; import NativeAppState from './NativeAppState'; import invariant from 'invariant'; +export type AppStateValues = 'inactive' | 'background' | 'active'; + +type AppStateEventDefinitions = { + change: [AppStateValues], + memoryWarning: [], + blur: [], + focus: [], +}; + +type NativeAppStateEventDefinitions = { + appStateDidChange: [{app_state: AppStateValues}], + appStateFocusChange: [boolean], + memoryWarning: [], +}; + /** * `AppState` can tell you if the app is in the foreground or background, * and notify you when the state changes. * * See https://reactnative.dev/docs/appstate.html */ -class AppState extends NativeEventEmitter<$FlowFixMe> { - _eventHandlers: Object; - _supportedEvents = ['change', 'memoryWarning', 'blur', 'focus']; +class AppState extends NativeEventEmitter { + _eventHandlers: { + [key: $Keys]: Map< + /* Handler */ $FlowFixMe, + EventSubscription, + >, + ..., + }; + _supportedEvents: $ReadOnlyArray<$Keys> = [ + 'change', + 'memoryWarning', + 'blur', + 'focus', + ]; currentState: ?string; isAvailable: boolean; @@ -57,6 +85,7 @@ class AppState extends NativeEventEmitter<$FlowFixMe> { // It's possible that the state will have changed here & listeners need to be notified if (!eventUpdated && this.currentState !== appStateData.app_state) { this.currentState = appStateData.app_state; + // $FlowExpectedError[incompatible-call] this.emit('appStateDidChange', appStateData); } }, logError); @@ -73,7 +102,10 @@ class AppState extends NativeEventEmitter<$FlowFixMe> { * * See https://reactnative.dev/docs/appstate.html#addeventlistener */ - addEventListener(type: string, handler: Function) { + addEventListener>( + type: K, + handler: (...$ElementType) => void, + ): void { invariant( this._supportedEvents.indexOf(type) !== -1, 'Trying to subscribe to unknown event: "%s"', @@ -82,32 +114,38 @@ class AppState extends NativeEventEmitter<$FlowFixMe> { switch (type) { case 'change': { + // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type + const changeHandler: AppStateValues => void = handler; this._eventHandlers[type].set( handler, this.addListener('appStateDidChange', appStateData => { - handler(appStateData.app_state); + changeHandler(appStateData.app_state); }), ); break; } case 'memoryWarning': { + // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type + const memoryWarningHandler: () => void = handler; this._eventHandlers[type].set( handler, - this.addListener('memoryWarning', handler), + this.addListener('memoryWarning', memoryWarningHandler), ); break; } case 'blur': case 'focus': { + // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type + const focusOrBlurHandler: () => void = handler; this._eventHandlers[type].set( handler, this.addListener('appStateFocusChange', hasFocus => { if (type === 'blur' && !hasFocus) { - handler(); + focusOrBlurHandler(); } if (type === 'focus' && hasFocus) { - handler(); + focusOrBlurHandler(); } }), ); @@ -120,52 +158,72 @@ class AppState extends NativeEventEmitter<$FlowFixMe> { * * See https://reactnative.dev/docs/appstate.html#removeeventlistener */ - removeEventListener(type: string, handler: Function) { + removeEventListener>( + type: K, + handler: (...$ElementType) => void, + ) { invariant( this._supportedEvents.indexOf(type) !== -1, 'Trying to remove listener for unknown event: "%s"', type, ); - if (!this._eventHandlers[type].has(handler)) { + const subscription = this._eventHandlers[type].get(handler); + if (!subscription) { return; } - this._eventHandlers[type].get(handler).remove(); + subscription.remove(); this._eventHandlers[type].delete(handler); } } -function throwMissingNativeModule() { - invariant( - false, - 'Cannot use AppState module when native RCTAppState is not included in the build.\n' + - 'Either include it, or check AppState.isAvailable before calling any methods.', - ); +class MissingNativeModuleError extends Error { + constructor() { + super( + 'Cannot use AppState module when native RCTAppState is not included in the build.\n' + + 'Either include it, or check AppState.isAvailable before calling any methods.', + ); + } } -class MissingNativeAppStateShim extends EventEmitter<$FlowFixMe> { +class MissingNativeAppStateShim extends EventEmitter { // AppState isAvailable: boolean = false; currentState: ?string = null; - addEventListener(type: string, handler: Function) { - throwMissingNativeModule(); + addEventListener>( + type: K, + handler: (...$ElementType) => mixed, + ): void { + throw new MissingNativeModuleError(); } - removeEventListener(type: string, handler: Function) { - throwMissingNativeModule(); + removeEventListener>( + type: K, + handler: (...$ElementType) => mixed, + ) { + throw new MissingNativeModuleError(); } - // EventEmitter - addListener(): any { - throwMissingNativeModule(); + // $FlowIssue[invalid-tuple-arity] + addListener>( + eventType: K, + // $FlowIssue[incompatible-extend] + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): EmitterSubscription { + throw new MissingNativeModuleError(); } - removeAllListeners() { - throwMissingNativeModule(); + removeAllListeners>( + eventType: ?K, + ): void { + throw new MissingNativeModuleError(); } - removeSubscription() { - throwMissingNativeModule(); + removeSubscription>( + subscription: EmitterSubscription, + ): void { + throw new MissingNativeModuleError(); } } diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js index e57383d8a8483c..63614d22dccc18 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js @@ -13,16 +13,17 @@ import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter'; import UIManager from '../../ReactNative/UIManager'; import NativeAccessibilityInfo from './NativeAccessibilityInfo'; +import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; const REDUCE_MOTION_EVENT = 'reduceMotionDidChange'; const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange'; -type ChangeEventName = $Keys<{ - change: string, - reduceMotionChanged: string, - screenReaderChanged: string, - ... -}>; +type AccessibilityEventDefinitions = { + reduceMotionChanged: [boolean], + screenReaderChanged: [boolean], + // alias for screenReaderChanged + change: [boolean], +}; const _subscriptions = new Map(); @@ -98,7 +99,10 @@ const AccessibilityInfo = { return this.isScreenReaderEnabled; }, - addEventListener: function(eventName: ChangeEventName, handler: T): void { + addEventListener: function>( + eventName: K, + handler: (...$ElementType) => void, + ): EventSubscription { let listener; if (eventName === 'change' || eventName === 'screenReaderChanged') { @@ -115,11 +119,18 @@ const AccessibilityInfo = { // $FlowFixMe[escaped-generic] _subscriptions.set(handler, listener); + + return { + remove: () => { + // $FlowIssue flow does not recognize handler properly + AccessibilityInfo.removeEventListener(eventName, handler); + }, + }; }, - removeEventListener: function( - eventName: ChangeEventName, - handler: T, + removeEventListener: function>( + eventName: K, + handler: (...$ElementType) => void, ): void { // $FlowFixMe[escaped-generic] const listener = _subscriptions.get(handler); diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js index 8ae146272de650..a0121e5d4f9a6f 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js @@ -12,6 +12,7 @@ import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter'; import NativeAccessibilityManager from './NativeAccessibilityManager'; +import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; const CHANGE_EVENT_NAME = { announcementFinished: 'announcementFinished', @@ -23,17 +24,22 @@ const CHANGE_EVENT_NAME = { screenReaderChanged: 'screenReaderChanged', }; -type ChangeEventName = $Keys<{ - announcementFinished: string, - boldTextChanged: string, - change: string, - grayscaleChanged: string, - invertColorsChanged: string, - reduceMotionChanged: string, - reduceTransparencyChanged: string, - screenReaderChanged: string, - ... -}>; +type AccessibilityEventDefinitions = { + boldTextChanged: [boolean], + grayscaleChanged: [boolean], + invertColorsChanged: [boolean], + reduceMotionChanged: [boolean], + reduceTransparencyChanged: [boolean], + screenReaderChanged: [boolean], + // alias for screenReaderChanged + change: [boolean], + announcementFinished: [ + { + announcement: string, + success: boolean, + }, + ], +}; const _subscriptions = new Map(); @@ -202,31 +208,30 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#addeventlistener */ - addEventListener: function( - eventName: ChangeEventName, - handler: T, - ): {remove: () => void} { - let listener; + addEventListener: function>( + eventName: K, + handler: (...$ElementType) => void, + ): EventSubscription { + let subscription: EventSubscription; if (eventName === 'change') { - listener = RCTDeviceEventEmitter.addListener( + subscription = RCTDeviceEventEmitter.addListener( CHANGE_EVENT_NAME.screenReaderChanged, // $FlowFixMe[incompatible-call] handler, ); } else if (CHANGE_EVENT_NAME[eventName]) { - // $FlowFixMe[incompatible-call] - listener = RCTDeviceEventEmitter.addListener(eventName, handler); + subscription = RCTDeviceEventEmitter.addListener(eventName, handler); } // $FlowFixMe[escaped-generic] - _subscriptions.set(handler, listener); + _subscriptions.set(handler, subscription); + return { - remove: AccessibilityInfo.removeEventListener.bind( - null, - eventName, - handler, - ), + remove: () => { + // $FlowIssue flow does not recognize handler properly + AccessibilityInfo.removeEventListener(eventName, handler); + }, }; }, @@ -257,9 +262,9 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#removeeventlistener */ - removeEventListener: function( - eventName: ChangeEventName, - handler: T, + removeEventListener: function>( + eventName: K, + handler: (...$ElementType) => void, ): void { // $FlowFixMe[escaped-generic] const listener = _subscriptions.get(handler); diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index 3c445e04e887b1..5b56ad03a42271 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -14,18 +14,9 @@ import NativeEventEmitter from '../../EventEmitter/NativeEventEmitter'; import LayoutAnimation from '../../LayoutAnimation/LayoutAnimation'; import dismissKeyboard from '../../Utilities/dismissKeyboard'; import NativeKeyboardObserver from './NativeKeyboardObserver'; -import invariant from 'invariant'; -const KeyboardEventEmitter: NativeEventEmitter<$FlowFixMe> = new NativeEventEmitter( - NativeKeyboardObserver, -); - -export type KeyboardEventName = - | 'keyboardWillShow' - | 'keyboardDidShow' - | 'keyboardWillHide' - | 'keyboardDidHide' - | 'keyboardWillChangeFrame' - | 'keyboardDidChangeFrame'; +import type EmitterSubscription from '../../vendor/emitter/_EmitterSubscription'; + +export type KeyboardEventName = $Keys; export type KeyboardEventEasing = | 'easeIn' @@ -61,11 +52,14 @@ export type IOSKeyboardEvent = $ReadOnly<{| isEventFromThisApp: boolean, |}>; -type KeyboardEventListener = (e: KeyboardEvent) => void; - -// The following object exists for documentation purposes -// Actual work happens in -// https://github.com/facebook/react-native/blob/master/Libraries/EventEmitter/NativeEventEmitter.js +type KeyboardEventDefinitions = { + keyboardWillShow: [KeyboardEvent], + keyboardDidShow: [KeyboardEvent], + keyboardWillHide: [KeyboardEvent], + keyboardDidHide: [KeyboardEvent], + keyboardWillChangeFrame: [KeyboardEvent], + keyboardDidChangeFrame: [KeyboardEvent], +}; /** * `Keyboard` module to control keyboard events. @@ -109,7 +103,11 @@ type KeyboardEventListener = (e: KeyboardEvent) => void; *``` */ -const Keyboard = { +class Keyboard extends NativeEventEmitter { + constructor() { + super(NativeKeyboardObserver); + } + /** * The `addListener` function connects a JavaScript function to an identified native * keyboard notification event. @@ -133,9 +131,13 @@ const Keyboard = { * * @param {function} callback function to be called when the event fires. */ - addListener(eventName: KeyboardEventName, callback: KeyboardEventListener) { - invariant(false, 'Dummy method used for documentation'); - }, + addListener>( + eventType: K, + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): EmitterSubscription { + return super.addListener(eventType, listener); + } /** * Removes a specific listener. @@ -143,51 +145,45 @@ const Keyboard = { * @param {string} eventName The `nativeEvent` is the string that identifies the event you're listening for. * @param {function} callback function to be called when the event fires. */ - removeListener( - eventName: KeyboardEventName, - callback: KeyboardEventListener, - ) { - invariant(false, 'Dummy method used for documentation'); - }, + removeListener>( + eventType: K, + listener: (...$ElementType) => mixed, + ): void { + super.removeListener(eventType, listener); + } /** * Removes all listeners for a specific event type. * * @param {string} eventType The native event string listeners are watching which will be removed. */ - removeAllListeners(eventName: KeyboardEventName) { - invariant(false, 'Dummy method used for documentation'); - }, + removeAllListeners>(eventType: ?K): void { + super.removeAllListeners(eventType); + } /** * Dismisses the active keyboard and removes focus. */ - dismiss() { - invariant(false, 'Dummy method used for documentation'); - }, + dismiss(): void { + dismissKeyboard(); + } /** * Useful for syncing TextInput (or other keyboard accessory view) size of * position changes with keyboard movements. */ - scheduleLayoutAnimation(event: KeyboardEvent) { - invariant(false, 'Dummy method used for documentation'); - }, -}; - -// Throw away the dummy object and reassign it to original module -KeyboardEventEmitter.dismiss = dismissKeyboard; -KeyboardEventEmitter.scheduleLayoutAnimation = function(event: KeyboardEvent) { - const {duration, easing} = event; - if (duration != null && duration !== 0) { - LayoutAnimation.configureNext({ - duration: duration, - update: { + scheduleLayoutAnimation(event: KeyboardEvent): void { + const {duration, easing} = event; + if (duration != null && duration !== 0) { + LayoutAnimation.configureNext({ duration: duration, - type: (easing != null && LayoutAnimation.Types[easing]) || 'keyboard', - }, - }); + update: { + duration: duration, + type: (easing != null && LayoutAnimation.Types[easing]) || 'keyboard', + }, + }); + } } -}; +} -module.exports = KeyboardEventEmitter; +module.exports = (new Keyboard(): Keyboard); diff --git a/Libraries/Components/Keyboard/__tests__/Keyboard-test.js b/Libraries/Components/Keyboard/__tests__/Keyboard-test.js index 639cdd0db5f4f0..ab38d1ccb8b3ab 100644 --- a/Libraries/Components/Keyboard/__tests__/Keyboard-test.js +++ b/Libraries/Components/Keyboard/__tests__/Keyboard-test.js @@ -19,6 +19,7 @@ const Keyboard = require('../Keyboard'); import NativeEventEmitter from '../../../EventEmitter/NativeEventEmitter'; jest.mock('../../../LayoutAnimation/LayoutAnimation'); +jest.mock('../../../Utilities/dismissKeyboard'); describe('Keyboard', () => { beforeEach(() => { @@ -36,14 +37,14 @@ describe('Keyboard', () => { }); it('uses dismissKeyboard utility', () => { - expect(Keyboard.dismiss).toBe(dismissKeyboard); + Keyboard.dismiss(); + expect(dismissKeyboard).toHaveBeenCalled(); }); describe('scheduling layout animation', () => { - const scheduleLayoutAnimation = ( - duration: number | null, - easing: string | null, - ): void => Keyboard.scheduleLayoutAnimation({duration, easing}); + const scheduleLayoutAnimation = (duration, easing): void => + // $FlowFixMe[incompatible-call] + Keyboard.scheduleLayoutAnimation({duration, easing}); it('triggers layout animation', () => { scheduleLayoutAnimation(12, 'spring'); diff --git a/Libraries/Components/StatusBar/StatusBarIOS.js b/Libraries/Components/StatusBar/StatusBarIOS.js index 8a166cd36e63b7..7764ea59be4cf4 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.js @@ -13,9 +13,23 @@ import NativeEventEmitter from '../../EventEmitter/NativeEventEmitter'; import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS'; +type StatusBarFrameChangeEvent = { + frame: { + x: number, + y: number, + width: number, + height: number, + }, +}; + +type StatusBarIOSEventDefinitions = { + statusBarFrameDidChange: [StatusBarFrameChangeEvent], + statusBarFrameWillChange: [StatusBarFrameChangeEvent], +}; + /** * Use `StatusBar` for mutating the status bar. */ -class StatusBarIOS extends NativeEventEmitter<$FlowFixMe> {} +class StatusBarIOS extends NativeEventEmitter {} module.exports = (new StatusBarIOS(NativeStatusBarManagerIOS): StatusBarIOS); diff --git a/Libraries/EventEmitter/NativeEventEmitter.js b/Libraries/EventEmitter/NativeEventEmitter.js index 3dfa20071198b2..328a02300c4d7c 100644 --- a/Libraries/EventEmitter/NativeEventEmitter.js +++ b/Libraries/EventEmitter/NativeEventEmitter.js @@ -12,7 +12,7 @@ import Platform from '../Utilities/Platform'; import EventEmitter from '../vendor/emitter/EventEmitter'; -import {type EventSubscription} from '../vendor/emitter/EventEmitter'; +import type EmitterSubscription from '../vendor/emitter/_EmitterSubscription'; import RCTDeviceEventEmitter from './RCTDeviceEventEmitter'; import invariant from 'invariant'; @@ -35,8 +35,8 @@ const DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS = { * a subset of the standard EventEmitter node module API. */ export default class NativeEventEmitter< - _GenericArgumentPlaceholder, -> extends EventEmitter { + EventDefinitions: {...}, +> extends EventEmitter { _nativeModule: ?NativeModule; _disableCallsIntoModule: boolean; @@ -53,18 +53,18 @@ export default class NativeEventEmitter< } } - addListener( - eventType: string, - listener: Function, - context: ?Object, - ): EventSubscription { + addListener>( + eventType: K, + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): EmitterSubscription { if (this._nativeModule != null && !this._disableCallsIntoModule) { this._nativeModule.addListener(eventType); } return super.addListener(eventType, listener, context); } - removeAllListeners(eventType: string) { + removeAllListeners>(eventType: ?K): void { invariant(eventType, 'eventType argument is required.'); const count = this.listenerCount(eventType); if (this._nativeModule != null && !this._disableCallsIntoModule) { @@ -73,7 +73,9 @@ export default class NativeEventEmitter< super.removeAllListeners(eventType); } - removeSubscription(subscription: EventSubscription) { + removeSubscription>( + subscription: EmitterSubscription, + ): void { if (this._nativeModule != null && !this._disableCallsIntoModule) { this._nativeModule.removeListeners(1); } diff --git a/Libraries/EventEmitter/RCTDeviceEventEmitter.js b/Libraries/EventEmitter/RCTDeviceEventEmitter.js index 39e456b8096b52..5fe2757a610afd 100644 --- a/Libraries/EventEmitter/RCTDeviceEventEmitter.js +++ b/Libraries/EventEmitter/RCTDeviceEventEmitter.js @@ -44,34 +44,38 @@ function checkNativeEventModule(eventType: ?string) { * Deprecated - subclass NativeEventEmitter to create granular event modules instead of * adding all event listeners directly to RCTDeviceEventEmitter. */ -class RCTDeviceEventEmitter extends EventEmitter { - sharedSubscriber: EventSubscriptionVendor; +class RCTDeviceEventEmitter< + EventDefinitions: {...}, +> extends EventEmitter { + sharedSubscriber: EventSubscriptionVendor; constructor() { - const sharedSubscriber = new EventSubscriptionVendor(); + const sharedSubscriber = new EventSubscriptionVendor(); super(sharedSubscriber); this.sharedSubscriber = sharedSubscriber; } - addListener( - eventType: string, - listener: Function, - context: ?Object, - ): EmitterSubscription { + addListener>( + eventType: K, + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): EmitterSubscription { if (__DEV__) { checkNativeEventModule(eventType); } return super.addListener(eventType, listener, context); } - removeAllListeners(eventType: ?string) { + removeAllListeners>(eventType: ?K): void { if (__DEV__) { checkNativeEventModule(eventType); } super.removeAllListeners(eventType); } - removeSubscription(subscription: EmitterSubscription) { + removeSubscription>( + subscription: EmitterSubscription, + ): void { if (subscription.emitter !== this) { subscription.emitter.removeSubscription(subscription); } else { @@ -80,4 +84,7 @@ class RCTDeviceEventEmitter extends EventEmitter { } } -export default (new RCTDeviceEventEmitter(): RCTDeviceEventEmitter); +// FIXME: use typed events +type RCTDeviceEventDefinitions = $FlowFixMe; + +export default (new RCTDeviceEventEmitter(): RCTDeviceEventEmitter); diff --git a/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js b/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js index cf812706d0266f..fc303ff4e1aff2 100644 --- a/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +++ b/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js @@ -16,7 +16,9 @@ import RCTDeviceEventEmitter from '../RCTDeviceEventEmitter'; /** * Mock the NativeEventEmitter as a normal JS EventEmitter. */ -export default class NativeEventEmitter extends EventEmitter { +export default class NativeEventEmitter< + EventDefinitions: {...}, +> extends EventEmitter { constructor() { super(RCTDeviceEventEmitter.sharedSubscriber); } diff --git a/Libraries/Interaction/InteractionManager.js b/Libraries/Interaction/InteractionManager.js index 0ba50eae35e4af..c2bf262a4014a7 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -21,7 +21,10 @@ import EventEmitter from '../vendor/emitter/EventEmitter'; export type Handle = number; import type {Task} from './TaskQueue'; -const _emitter = new EventEmitter<$FlowFixMe>(); +const _emitter = new EventEmitter<{ + interactionComplete: [], + interactionStart: [], +}>(); const DEBUG_DELAY: 0 = 0; const DEBUG: false = false; diff --git a/Libraries/Linking/Linking.js b/Libraries/Linking/Linking.js index de4172d388d1d9..5dd517f4db361a 100644 --- a/Libraries/Linking/Linking.js +++ b/Libraries/Linking/Linking.js @@ -18,13 +18,17 @@ import NativeIntentAndroid from './NativeIntentAndroid'; import invariant from 'invariant'; import nullthrows from 'nullthrows'; +type LinkingEventDefinitions = { + url: [{url: string}], +}; + /** * `Linking` gives you a general interface to interact with both incoming * and outgoing app links. * * See https://reactnative.dev/docs/linking.html */ -class Linking extends NativeEventEmitter<$FlowFixMe> { +class Linking extends NativeEventEmitter { constructor() { super(Platform.OS === 'ios' ? nullthrows(NativeLinkingManager) : undefined); } @@ -35,8 +39,12 @@ class Linking extends NativeEventEmitter<$FlowFixMe> { * * See https://reactnative.dev/docs/linking.html#addeventlistener */ - addEventListener(type: string, handler: T) { - this.addListener(type, handler); + addEventListener>( + eventType: K, + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): void { + this.addListener(eventType, listener); } /** @@ -44,8 +52,11 @@ class Linking extends NativeEventEmitter<$FlowFixMe> { * * See https://reactnative.dev/docs/linking.html#removeeventlistener */ - removeEventListener(type: string, handler: T) { - this.removeListener(type, handler); + removeEventListener>( + eventType: K, + listener: (...$ElementType) => mixed, + ): void { + this.removeListener(eventType, listener); } /** diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index 858886c3816c52..9d1810741c239a 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -29,9 +29,13 @@ import type {DirectEventHandler} from '../Types/CodegenTypes'; import {type EventSubscription} from '../vendor/emitter/EventEmitter'; import RCTModalHostView from './RCTModalHostViewNativeComponent'; +type ModalEventDefinitions = { + modalDismissed: [{modalID: number}], +}; + const ModalEventEmitter = Platform.OS === 'ios' && NativeModalManager != null - ? new NativeEventEmitter<$FlowFixMe>(NativeModalManager) + ? new NativeEventEmitter(NativeModalManager) : null; /** diff --git a/Libraries/Network/RCTNetworking.android.js b/Libraries/Network/RCTNetworking.android.js index 45c7141db4a87c..87334689cae811 100644 --- a/Libraries/Network/RCTNetworking.android.js +++ b/Libraries/Network/RCTNetworking.android.js @@ -38,6 +38,7 @@ function generateRequestId(): number { * This class is a wrapper around the native RCTNetworking module. It adds a necessary unique * requestId to each network request that can be used to abort that request later on. */ +// FIXME: use typed events class RCTNetworking extends NativeEventEmitter<$FlowFixMe> { constructor() { super(NativeNetworkingAndroid); diff --git a/Libraries/Network/RCTNetworking.ios.js b/Libraries/Network/RCTNetworking.ios.js index 5992cf84cf6df9..125f5cf3ecc259 100644 --- a/Libraries/Network/RCTNetworking.ios.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -16,6 +16,7 @@ import type {NativeResponseType} from './XMLHttpRequest'; import convertRequestBody from './convertRequestBody'; import type {RequestBody} from './convertRequestBody'; +// FIXME: use typed events class RCTNetworking extends NativeEventEmitter<$FlowFixMe> { constructor() { const disableCallsIntoModule = diff --git a/Libraries/PushNotificationIOS/PushNotificationIOS.js b/Libraries/PushNotificationIOS/PushNotificationIOS.js index d033f26422b01d..85ebf4b4ffcde4 100644 --- a/Libraries/PushNotificationIOS/PushNotificationIOS.js +++ b/Libraries/PushNotificationIOS/PushNotificationIOS.js @@ -14,7 +14,31 @@ import NativeEventEmitter from '../EventEmitter/NativeEventEmitter'; import NativePushNotificationManagerIOS from './NativePushNotificationManagerIOS'; import invariant from 'invariant'; -const PushNotificationEmitter = new NativeEventEmitter<$FlowFixMe>( +type NativePushNotificationIOSEventDefinitions = { + remoteNotificationReceived: [ + { + notificationId: string, + remote: boolean, + ... + }, + ], + remoteNotificationsRegistered: [ + { + deviceToken?: ?string, + ... + }, + ], + remoteNotificationRegistrationError: [ + { + message: string, + code: number, + details: {...}, + }, + ], + localNotificationReceived: [{...}], +}; + +const PushNotificationEmitter = new NativeEventEmitter( NativePushNotificationManagerIOS, ); diff --git a/Libraries/Utilities/Appearance.js b/Libraries/Utilities/Appearance.js index e898c0b1896ac4..09a385d88e70fc 100644 --- a/Libraries/Utilities/Appearance.js +++ b/Libraries/Utilities/Appearance.js @@ -20,10 +20,16 @@ import invariant from 'invariant'; import {isAsyncDebugging} from './DebugEnvironment'; type AppearanceListener = (preferences: AppearancePreferences) => void; -const eventEmitter = new EventEmitter<$FlowFixMe>(); +const eventEmitter = new EventEmitter<{ + change: [AppearancePreferences], +}>(); + +type NativeAppearanceEventDefinitions = { + appearanceChanged: [AppearancePreferences], +}; if (NativeAppearance) { - const nativeEventEmitter = new NativeEventEmitter<$FlowFixMe>( + const nativeEventEmitter = new NativeEventEmitter( NativeAppearance, ); nativeEventEmitter.addListener( diff --git a/Libraries/Utilities/DevSettings.js b/Libraries/Utilities/DevSettings.js index 58054b3553b850..0a95bed8f70fcb 100644 --- a/Libraries/Utilities/DevSettings.js +++ b/Libraries/Utilities/DevSettings.js @@ -17,7 +17,11 @@ interface IDevSettings { onFastRefresh(): void; } -class DevSettings extends NativeEventEmitter<$FlowFixMe> +type DevSettingsEventDefinitions = { + didPressMenuItem: [{title: string}], +}; + +class DevSettings extends NativeEventEmitter implements IDevSettings { _menuItems: Map mixed>; diff --git a/Libraries/Utilities/Dimensions.js b/Libraries/Utilities/Dimensions.js index 4ac8c17f6c26ca..d07cdddd625b85 100644 --- a/Libraries/Utilities/Dimensions.js +++ b/Libraries/Utilities/Dimensions.js @@ -24,7 +24,9 @@ type DimensionsValue = { ... }; -const eventEmitter = new EventEmitter<$FlowFixMe>(); +const eventEmitter = new EventEmitter<{ + change: [DimensionsValue], +}>(); let dimensionsInitialized = false; let dimensions: DimensionsValue; diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index dc47f9ffc141a7..7975508604c9ab 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -11,10 +11,11 @@ 'use strict'; import Blob from '../Blob/Blob'; +import type {BlobData} from '../Blob/BlobTypes'; import BlobManager from '../Blob/BlobManager'; import NativeEventEmitter from '../EventEmitter/NativeEventEmitter'; import binaryToBase64 from '../Utilities/binaryToBase64'; -import {type EventSubscription} from '../vendor/emitter/EventEmitter'; +import type {EventSubscription} from '../vendor/emitter/EventEmitter'; import NativeWebSocketModule from './NativeWebSocketModule'; import WebSocketEvent from './WebSocketEvent'; import base64 from 'base64-js'; @@ -46,6 +47,17 @@ const WEBSOCKET_EVENTS = ['close', 'error', 'message', 'open']; let nextWebSocketId = 0; +type WebSocketEventDefinitions = { + websocketOpen: [{id: number, protocol: string}], + websocketClosed: [{id: number, code: number, reason: string}], + websocketMessage: [ + | {type: 'binary', id: number, data: string} + | {type: 'text', id: number, data: string} + | {type: 'blob', id: number, data: BlobData}, + ], + websocketFailed: [{id: number, message: string}], +}; + /** * Browser-compatible WebSockets implementation. * @@ -64,7 +76,7 @@ class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS): any) { CLOSED: number = CLOSED; _socketId: number; - _eventEmitter: NativeEventEmitter<$FlowFixMe>; + _eventEmitter: NativeEventEmitter; _subscriptions: Array; _binaryType: ?BinaryType; diff --git a/Libraries/vendor/emitter/EventEmitter.js b/Libraries/vendor/emitter/EventEmitter.js index 3057ea4cb5642e..380aedabb35db1 100644 --- a/Libraries/vendor/emitter/EventEmitter.js +++ b/Libraries/vendor/emitter/EventEmitter.js @@ -4,13 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow strict-local + * @flow strict * @format */ 'use strict'; -// $FlowFixMe - EventEmitter Type Safety const EventEmitter = require('./_EventEmitter'); export default EventEmitter; diff --git a/Libraries/vendor/emitter/_EmitterSubscription.js b/Libraries/vendor/emitter/_EmitterSubscription.js index dc2c72efb85c15..e78af30b2e8cb7 100644 --- a/Libraries/vendor/emitter/_EmitterSubscription.js +++ b/Libraries/vendor/emitter/_EmitterSubscription.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict */ 'use strict'; @@ -17,11 +17,13 @@ import type EventSubscriptionVendor from './_EventSubscriptionVendor'; /** * EmitterSubscription represents a subscription with listener and context data. */ -class EmitterSubscription extends EventSubscription { - // $FlowFixMe[value-as-type] - emitter: EventEmitter; - listener: Function; - context: ?Object; +class EmitterSubscription< + EventDefinitions: {...}, + K: $Keys, +> extends EventSubscription { + emitter: EventEmitter; + listener: ?(...$ElementType) => mixed; + context: ?$FlowFixMe; /** * @param {EventEmitter} emitter - The event emitter that registered this @@ -34,11 +36,10 @@ class EmitterSubscription extends EventSubscription { * listener */ constructor( - // $FlowFixMe[value-as-type] - emitter: EventEmitter, - subscriber: EventSubscriptionVendor, - listener: Function, - context: ?Object, + emitter: EventEmitter, + subscriber: EventSubscriptionVendor, + listener: (...$ElementType) => mixed, + context: ?$FlowFixMe, ) { super(subscriber); this.emitter = emitter; @@ -52,7 +53,7 @@ class EmitterSubscription extends EventSubscription { * but deliberately not calling `super.remove()` as the responsibility * for removing the subscription lies with the EventEmitter. */ - remove() { + remove(): void { this.emitter.removeSubscription(this); } } diff --git a/Libraries/vendor/emitter/_EventEmitter.js b/Libraries/vendor/emitter/_EventEmitter.js index 150c2538916698..4786dacd283812 100644 --- a/Libraries/vendor/emitter/_EventEmitter.js +++ b/Libraries/vendor/emitter/_EventEmitter.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @noflow + * @flow strict * @typecheck */ @@ -18,6 +18,21 @@ import EventSubscriptionVendor from './_EventSubscriptionVendor'; const sparseFilterPredicate = () => true; +export interface IEventEmitter { + addListener>( + eventType: K, + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): EmitterSubscription; + + removeAllListeners>(eventType: ?K): void; + + emit>( + eventType: K, + ...args: $ElementType + ): void; +} + /** * @class EventEmitter * @description @@ -31,8 +46,9 @@ const sparseFilterPredicate = () => true; * mechanism on top of which extra functionality can be composed. For example, a * more advanced emitter may use an EventHolder and EventFactory. */ -class EventEmitter { - _subscriber: EventSubscriptionVendor; +class EventEmitter + implements IEventEmitter { + _subscriber: EventSubscriptionVendor; /** * @constructor @@ -40,8 +56,9 @@ class EventEmitter { * @param {EventSubscriptionVendor} subscriber - Optional subscriber instance * to use. If omitted, a new subscriber will be created for the emitter. */ - constructor(subscriber: ?EventSubscriptionVendor) { - this._subscriber = subscriber || new EventSubscriptionVendor(); + constructor(subscriber: ?EventSubscriptionVendor) { + this._subscriber = + subscriber || new EventSubscriptionVendor(); } /** @@ -58,15 +75,16 @@ class EventEmitter { * @param {*} context - Optional context object to use when invoking the * listener */ - addListener( - eventType: string, - listener: Function, - context: ?Object, - ): EmitterSubscription { + addListener>( + eventType: K, + // FIXME: listeners should return void instead of mixed to prevent issues + listener: (...$ElementType) => mixed, + context: $FlowFixMe, + ): EmitterSubscription { return (this._subscriber.addSubscription( eventType, new EmitterSubscription(this, this._subscriber, listener, context), - ): any); + ): $FlowFixMe); } /** @@ -76,7 +94,7 @@ class EventEmitter { * @param {?string} eventType - Optional name of the event whose registered * listeners to remove */ - removeAllListeners(eventType: ?string) { + removeAllListeners>(eventType: ?K): void { this._subscriber.removeAllSubscriptions(eventType); } @@ -84,7 +102,9 @@ class EventEmitter { * Removes a specific subscription. Called by the `remove()` method of the * subscription itself to ensure any necessary cleanup is performed. */ - removeSubscription(subscription: EmitterSubscription) { + removeSubscription>( + subscription: EmitterSubscription, + ): void { invariant( subscription.emitter === this, 'Subscription does not belong to this emitter.', @@ -99,7 +119,7 @@ class EventEmitter { * @param {string} eventType - Name of the event to query * @returns {number} */ - listenerCount(eventType: string): number { + listenerCount>(eventType: K): number { const subscriptions = this._subscriber.getSubscriptionsForType(eventType); return subscriptions ? // We filter out missing entries because the array is sparse. @@ -124,7 +144,10 @@ class EventEmitter { * * emitter.emit('someEvent', 'abc'); // logs 'abc' */ - emit(eventType: string) { + emit>( + eventType: K, + ...args: $ElementType + ): void { const subscriptions = this._subscriber.getSubscriptionsForType(eventType); if (subscriptions) { for (let i = 0, l = subscriptions.length; i < l; i++) { @@ -132,10 +155,7 @@ class EventEmitter { // The subscription may have been removed during this event loop. if (subscription && subscription.listener) { - subscription.listener.apply( - subscription.context, - Array.prototype.slice.call(arguments, 1), - ); + subscription.listener.apply(subscription.context, args); } } } @@ -154,7 +174,11 @@ class EventEmitter { * }); // removes the listener if already registered * */ - removeListener(eventType: String, listener) { + removeListener>( + eventType: K, + // FIXME: listeners should return void instead of mixed to prevent issues + listener: (...$ElementType) => mixed, + ): void { const subscriptions = this._subscriber.getSubscriptionsForType(eventType); if (subscriptions) { for (let i = 0, l = subscriptions.length; i < l; i++) { diff --git a/Libraries/vendor/emitter/_EventSubscription.js b/Libraries/vendor/emitter/_EventSubscription.js index 54ec8f2f2ddc41..7a4243811e3e9e 100644 --- a/Libraries/vendor/emitter/_EventSubscription.js +++ b/Libraries/vendor/emitter/_EventSubscription.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow strict-local + * @flow strict */ 'use strict'; @@ -16,23 +16,25 @@ import type EventSubscriptionVendor from './_EventSubscriptionVendor'; * EventSubscription represents a subscription to a particular event. It can * remove its own subscription. */ -class EventSubscription { - eventType: string; +class EventSubscription> { + eventType: K; key: number; - subscriber: EventSubscriptionVendor; + subscriber: EventSubscriptionVendor; + listener: ?(...$ElementType) => mixed; + context: ?$FlowFixMe; /** * @param {EventSubscriptionVendor} subscriber the subscriber that controls * this subscription. */ - constructor(subscriber: EventSubscriptionVendor) { + constructor(subscriber: EventSubscriptionVendor) { this.subscriber = subscriber; } /** * Removes this subscription from the subscriber that controls it. */ - remove() { + remove(): void { this.subscriber.removeSubscription(this); } } diff --git a/Libraries/vendor/emitter/_EventSubscriptionVendor.js b/Libraries/vendor/emitter/_EventSubscriptionVendor.js index 5ea0aa821e0360..ace97393e42537 100644 --- a/Libraries/vendor/emitter/_EventSubscriptionVendor.js +++ b/Libraries/vendor/emitter/_EventSubscriptionVendor.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict */ 'use strict'; @@ -18,13 +18,16 @@ import type EventSubscription from './_EventSubscription'; * EventSubscriptionVendor stores a set of EventSubscriptions that are * subscribed to a particular event type. */ -class EventSubscriptionVendor { - _subscriptionsForType: Object; - _currentSubscription: ?EventSubscription; +class EventSubscriptionVendor { + _subscriptionsForType: { + [type: $Keys]: Array< + EventSubscription, + >, + ..., + }; constructor() { this._subscriptionsForType = {}; - this._currentSubscription = null; } /** @@ -33,10 +36,10 @@ class EventSubscriptionVendor { * @param {string} eventType * @param {EventSubscription} subscription */ - addSubscription( - eventType: string, - subscription: EventSubscription, - ): EventSubscription { + addSubscription>( + eventType: K, + subscription: EventSubscription, + ): EventSubscription { invariant( subscription.subscriber === this, 'The subscriber of the subscription is incorrectly set.', @@ -57,8 +60,8 @@ class EventSubscriptionVendor { * @param {?string} eventType - Optional name of the event type whose * registered supscriptions to remove, if null remove all subscriptions. */ - removeAllSubscriptions(eventType: ?string) { - if (eventType === undefined) { + removeAllSubscriptions>(eventType: ?K): void { + if (eventType == null) { this._subscriptionsForType = {}; } else { delete this._subscriptionsForType[eventType]; @@ -71,7 +74,9 @@ class EventSubscriptionVendor { * * @param {object} subscription */ - removeSubscription(subscription: Object) { + removeSubscription>( + subscription: EventSubscription, + ): void { const eventType = subscription.eventType; const key = subscription.key; @@ -93,7 +98,9 @@ class EventSubscriptionVendor { * @param {string} eventType * @returns {?array} */ - getSubscriptionsForType(eventType: string): ?[EventSubscription] { + getSubscriptionsForType>( + eventType: K, + ): ?Array> { return this._subscriptionsForType[eventType]; } } diff --git a/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js b/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js new file mode 100644 index 00000000000000..3047f21ff10ea7 --- /dev/null +++ b/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js @@ -0,0 +1,127 @@ +/** + * (c) Facebook, Inc. and its affiliates. Confidential and proprietary. + * + * @flow strict + * @format + */ + +'use strict'; + +import EventEmitter from '../EventEmitter'; + +type MyEvents = { + noArgsEvent: [], + stringEvent: [string], + numberEvent: [number], + anotherNumberEvent: [number], + objectAndBooleanEvent: [{prop: string}, boolean], +}; + +export function testBaseEventEmitterInstance() { + const emitter = new EventEmitter(); + + emitter.addListener('noArgsEvent', expectedUndefined => { + (expectedUndefined: void); + }); + + emitter.addListener('stringEvent', expectedString => { + (expectedString: string); + }); + + emitter.addListener('numberEvent', expectedNumber => { + (expectedNumber: number); + }); + + emitter.addListener('anotherNumberEvent', expectedNumber => { + (expectedNumber: number); + }); + + emitter.addListener( + 'objectAndBooleanEvent', + (expectedObject, expectedBoolean, unexpectedArg) => { + (expectedObject: {prop: string}); + (expectedBoolean: boolean); + (unexpectedArg: void); + }, + ); + + // $FlowExpectedError[prop-missing] + emitter.addListener('unexpectedEvent', () => {}); + + // $FlowExpectedError[incompatible-call] + emitter.addListener('noArgsEvent', (value: number) => {}); + + // $FlowExpectedError[incompatible-call] + emitter.addListener('numberEvent', (value: string) => {}); + + emitter.emit('noArgsEvent'); + emitter.emit('stringEvent', 'value'); + emitter.emit('numberEvent', 4); + emitter.emit('anotherNumberEvent', 4); + emitter.emit('objectAndBooleanEvent', {prop: 'value'}, true); +} + +export function testSubclass() { + // $FlowExpectedError[incompatible-type-arg] + class EmitterWithUndefinedDefinition extends EventEmitter {} + + // $FlowExpectedError[incompatible-type-arg] + class EmitterWithNumberDefinition extends EventEmitter {} + + class EmitterWithInvalidDefinitions extends EventEmitter<{ + foo: number, + }> {} + + const emitter = new EmitterWithInvalidDefinitions(); + // $FlowExpectedError[not-an-array] + // $FlowExpectedError[incompatible-call] + emitter.emit('foo'); + + class EmitterWithValidDefinitions extends EventEmitter {} +} + +export function testSubclassInstance() { + class MyEmitter extends EventEmitter {} + + const emitter = new MyEmitter(); + + emitter.addListener('noArgsEvent', expectedUndefined => { + (expectedUndefined: void); + }); + + emitter.addListener('stringEvent', expectedString => { + (expectedString: string); + }); + + emitter.addListener('numberEvent', expectedNumber => { + (expectedNumber: number); + }); + + emitter.addListener('anotherNumberEvent', expectedNumber => { + (expectedNumber: number); + }); + + emitter.addListener( + 'objectAndBooleanEvent', + (expectedObject, expectedBoolean, unexpectedArg) => { + (expectedObject: {prop: string}); + (expectedBoolean: boolean); + (unexpectedArg: void); + }, + ); + + // $FlowExpectedError[prop-missing] + emitter.addListener('unexpectedEvent', () => {}); + + // $FlowExpectedError[incompatible-call] + emitter.addListener('noArgsEvent', (value: number) => {}); + + // $FlowExpectedError[incompatible-call] + emitter.addListener('numberEvent', (value: string) => {}); + + emitter.emit('noArgsEvent'); + emitter.emit('stringEvent', 'value'); + emitter.emit('numberEvent', 4); + emitter.emit('anotherNumberEvent', 4); + emitter.emit('objectAndBooleanEvent', {prop: 'value'}, true); +} From f2052fedc2db0bc8a460d0e66a9eb6dad3c2f92f Mon Sep 17 00:00:00 2001 From: Pieter Vanderwerff Date: Thu, 7 Jan 2021 11:31:16 -0800 Subject: [PATCH 0331/1810] Land suppressions for 0.142.0 release to xplat Summary: This change contains the suppressions for the up coming v0.142.0 Flow release. The new suppressions are a result the following changes: * Disallow flowing functions or inexact objects to indexed objects to improve object soundness. This can cause errors if you are passing a function or inexact objects when an indexed object is expected. * Flow now processes imports before checking the body of a file. In some rare cases this can expose previously skipped errors due to the processing order. Reviewed By: mroch Differential Revision: D25820434 fbshipit-source-id: 59cc1d852ffc8cc39f0d5112ce485fb33f05c092 --- Libraries/Animated/AnimatedEvent.js | 1 + Libraries/Pressability/__tests__/Pressability-test.js | 6 ++++++ Libraries/StyleSheet/splitLayoutProps.js | 2 ++ Libraries/Text/TextNativeComponent.js | 2 ++ 4 files changed, 11 insertions(+) diff --git a/Libraries/Animated/AnimatedEvent.js b/Libraries/Animated/AnimatedEvent.js index 98ff42eb197071..87a434752be9e2 100644 --- a/Libraries/Animated/AnimatedEvent.js +++ b/Libraries/Animated/AnimatedEvent.js @@ -74,6 +74,7 @@ function attachNativeEvent( NativeAnimatedHelper.API.removeAnimatedEventFromView( viewTag, eventName, + // $FlowFixMe[incompatible-call] mapping.animatedValueTag, ); }); diff --git a/Libraries/Pressability/__tests__/Pressability-test.js b/Libraries/Pressability/__tests__/Pressability-test.js index d584d215b7cc3e..b0be50280ee149 100644 --- a/Libraries/Pressability/__tests__/Pressability-test.js +++ b/Libraries/Pressability/__tests__/Pressability-test.js @@ -716,7 +716,9 @@ describe('Pressability', () => { handlers.onResponderMove( createMockPressEvent({ registrationName: 'onResponderMove', + // $FlowFixMe[unsafe-addition] pageX: mockRegion.width + mockSlop.right / 2, + // $FlowFixMe[unsafe-addition] pageY: mockRegion.height + mockSlop.bottom / 2, }), ); @@ -750,7 +752,9 @@ describe('Pressability', () => { handlers.onResponderMove( createMockPressEvent({ registrationName: 'onResponderMove', + // $FlowFixMe[unsafe-addition] pageX: mockRegion.width + mockSlop.right / 2, + // $FlowFixMe[unsafe-addition] pageY: mockRegion.height + mockSlop.bottom / 2, }), ); @@ -870,9 +874,11 @@ describe('Pressability', () => { config.onStartShouldSetResponder_DEPRECATED, ); + // $FlowFixMe[prop-missing] onStartShouldSetResponder_DEPRECATED.mockReturnValue(false); expect(handlers.onStartShouldSetResponder()).toBe(false); + // $FlowFixMe[prop-missing] onStartShouldSetResponder_DEPRECATED.mockReturnValue(true); expect(handlers.onStartShouldSetResponder()).toBe(true); }); diff --git a/Libraries/StyleSheet/splitLayoutProps.js b/Libraries/StyleSheet/splitLayoutProps.js index 03bb726001e1ac..491da11c45f255 100644 --- a/Libraries/StyleSheet/splitLayoutProps.js +++ b/Libraries/StyleSheet/splitLayoutProps.js @@ -55,9 +55,11 @@ export default function splitLayoutProps( case 'bottom': case 'top': case 'transform': + // $FlowFixMe[cannot-write] outer[prop] = props[prop]; break; default: + // $FlowFixMe[cannot-write] inner[prop] = props[prop]; break; } diff --git a/Libraries/Text/TextNativeComponent.js b/Libraries/Text/TextNativeComponent.js index b98dca5a5b3541..742c2931cd5bbf 100644 --- a/Libraries/Text/TextNativeComponent.js +++ b/Libraries/Text/TextNativeComponent.js @@ -26,6 +26,7 @@ type NativeTextProps = $ReadOnly<{ export const NativeText: HostComponent = (createReactNativeComponentClass( 'RCTText', () => ({ + // $FlowFixMe[incompatible-call] validAttributes: { ...ReactNativeViewAttributes.UIView, isHighlighted: true, @@ -60,6 +61,7 @@ export const NativeVirtualText: HostComponent = UIManager.getViewManagerConfig('RCTVirtualText') == null ? NativeText : (createReactNativeComponentClass('RCTVirtualText', () => ({ + // $FlowFixMe[incompatible-call] validAttributes: { ...ReactNativeViewAttributes.UIView, isHighlighted: true, From deda35134a24ee8b131b88c36de69de7387ab0fb Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 7 Jan 2021 13:40:12 -0800 Subject: [PATCH 0332/1810] Make EventQueue a virtual class Summary: Changelog: [internal] EventQueue is used as a virtual class, this diff makes it one. Reviewed By: JoshuaGross, shergin Differential Revision: D25826983 fbshipit-source-id: 60e6937514cd3b837b0ca9f61bfaa081823ffc61 --- ReactCommon/react/renderer/core/BatchedEventQueue.cpp | 2 -- ReactCommon/react/renderer/core/EventQueue.cpp | 4 ---- ReactCommon/react/renderer/core/EventQueue.h | 2 +- ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp | 2 -- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp index 55bc9c7b0aabeb..1c363a64c65d58 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp @@ -17,8 +17,6 @@ BatchedEventQueue::BatchedEventQueue( : EventQueue(eventPipe, statePipe, std::move(eventBeat)) {} void BatchedEventQueue::onEnqueue() const { - EventQueue::onEnqueue(); - eventBeat_->request(); } diff --git a/ReactCommon/react/renderer/core/EventQueue.cpp b/ReactCommon/react/renderer/core/EventQueue.cpp index 2db952292ff9ea..639d29a4751729 100644 --- a/ReactCommon/react/renderer/core/EventQueue.cpp +++ b/ReactCommon/react/renderer/core/EventQueue.cpp @@ -48,10 +48,6 @@ void EventQueue::enqueueStateUpdate(const StateUpdate &stateUpdate) const { onEnqueue(); } -void EventQueue::onEnqueue() const { - // Default implementation does nothing. -} - void EventQueue::onBeat(jsi::Runtime &runtime) const { flushEvents(runtime); flushStateUpdates(); diff --git a/ReactCommon/react/renderer/core/EventQueue.h b/ReactCommon/react/renderer/core/EventQueue.h index ab6bac9ac3bbf2..ed77cad3f6157d 100644 --- a/ReactCommon/react/renderer/core/EventQueue.h +++ b/ReactCommon/react/renderer/core/EventQueue.h @@ -51,7 +51,7 @@ class EventQueue { * Override in subclasses to trigger beat `request` and/or beat `induce`. * Default implementation does nothing. */ - virtual void onEnqueue() const; + virtual void onEnqueue() const = 0; void onBeat(jsi::Runtime &runtime) const; void flushEvents(jsi::Runtime &runtime) const; diff --git a/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp b/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp index 4de0e8c747d85a..98210411f7482d 100644 --- a/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp @@ -11,8 +11,6 @@ namespace facebook { namespace react { void UnbatchedEventQueue::onEnqueue() const { - EventQueue::onEnqueue(); - eventBeat_->request(); eventBeat_->induce(); } From a4920ed909973ea4fcafef1cb451c0feebef6d7c Mon Sep 17 00:00:00 2001 From: Pieter Vanderwerff Date: Thu, 7 Jan 2021 17:23:20 -0800 Subject: [PATCH 0333/1810] Deploy 0.142.0 to xplat Reviewed By: Hans-Halverson Differential Revision: D25839306 fbshipit-source-id: 8d59a57647ce33b17f7e006d5ab14916f80ff044 --- .flowconfig | 2 +- .flowconfig.android | 2 +- package.json | 2 +- repo-config/package.json | 2 +- template/_flowconfig | 2 +- yarn.lock | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.flowconfig b/.flowconfig index f79a1216c94575..76b4ab64f6fe72 100644 --- a/.flowconfig +++ b/.flowconfig @@ -71,4 +71,4 @@ untyped-import untyped-type-import [version] -^0.140.0 +^0.142.0 diff --git a/.flowconfig.android b/.flowconfig.android index e05cf8812f5a1f..42d32c3789a7ae 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -71,4 +71,4 @@ untyped-import untyped-type-import [version] -^0.140.0 +^0.142.0 diff --git a/package.json b/package.json index 5bd66383837161..bf5216500fb676 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "ws": "^6.1.4" }, "devDependencies": { - "flow-bin": "^0.140.0", + "flow-bin": "^0.142.0", "react": "17.0.1" }, "detox": { diff --git a/repo-config/package.json b/repo-config/package.json index 8799da761e95c5..22ab5143b99f6e 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -33,7 +33,7 @@ "eslint-plugin-react-hooks": "^4.0.7", "eslint-plugin-react-native": "3.10.0", "eslint-plugin-relay": "1.8.1", - "flow-bin": "^0.140.0", + "flow-bin": "^0.142.0", "jest": "^26.5.2", "jest-junit": "^10.0.0", "jscodeshift": "^0.11.0", diff --git a/template/_flowconfig b/template/_flowconfig index d4f258ae45fa54..a6f99306d378e1 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -64,4 +64,4 @@ untyped-import untyped-type-import [version] -^0.140.0 +^0.142.0 diff --git a/yarn.lock b/yarn.lock index fc2cc068f910df..711464dca3fbf7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3032,10 +3032,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -flow-bin@^0.140.0: - version "0.140.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.140.0.tgz#bf1a2984a0e5604daa0d1e0432138d9897af65bb" - integrity sha512-9P/VciKACXocClhLiDg/p1ntYmgCEEc9QrNOoTqTi2SEdEZDTiAmJLONRJfw4uglPVRZ1p/esWF9KlbZiuxqVw== +flow-bin@^0.142.0: + version "0.142.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.142.0.tgz#b46b69de1123cf7c5a50917402968e07291df054" + integrity sha512-YgiapK/wrJjcgSgOWfoncbZ4vZrZWdHs+p7V9duI9zo4ehW2nM/VRrpSaWoZ+CWu3t+duGyAvupJvC6MM2l07w== flow-parser@0.*, flow-parser@^0.121.0: version "0.121.0" From d5cfad551908097c71b9ef42b00419aa44868f8e Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 7 Jan 2021 19:37:29 -0800 Subject: [PATCH 0334/1810] Make android codegen target generate static library Reviewed By: fkgozali Differential Revision: D25835846 fbshipit-source-id: 214b8059d73c6e675a5006c7ca46db9ebc425e9b --- packages/react-native-codegen/DEFS.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 7cd02e2c0e2e79..b8122b153b9627 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -201,6 +201,7 @@ def rn_codegen_modules( "-std=c++14", "-Wall", ], + force_static = True, preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", "-DWITH_FBSYSTRACE=1", From 92159804719b1bfdef7fe70826863672f1c3ae44 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 7 Jan 2021 19:37:29 -0800 Subject: [PATCH 0335/1810] Remove moduleSpecName Summary: All our codegen JavaScript now simply uses libraryName instead of moduleSpecName. In our buck infra, we assign native_module_spec_name to libraryName. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25842696 fbshipit-source-id: efd3af402585f9ad4ff3b593179147eea91cc331 --- packages/react-native-codegen/DEFS.bzl | 7 +++--- .../modules/GenerateModuleObjCpp-test.js | 4 ++-- .../src/cli/generators/generate-all.js | 7 +++--- .../src/generators/RNCodegen.js | 13 ++-------- .../GenerateComponentDescriptorH.js | 1 - .../components/GenerateComponentHObjCpp.js | 1 - .../components/GenerateEventEmitterCpp.js | 1 - .../components/GenerateEventEmitterH.js | 1 - .../generators/components/GeneratePropsCpp.js | 1 - .../generators/components/GeneratePropsH.js | 1 - .../components/GeneratePropsJavaDelegate.js | 1 - .../components/GeneratePropsJavaInterface.js | 1 - .../components/GenerateShadowNodeCpp.js | 1 - .../components/GenerateShadowNodeH.js | 1 - .../generators/components/GenerateTests.js | 1 - .../GenerateComponentDescriptorH-test.js | 4 +--- .../GenerateComponentHObjCpp-test.js | 4 +--- .../__tests__/GenerateEventEmitterCpp-test.js | 4 +--- .../__tests__/GenerateEventEmitterH-test.js | 4 +--- .../__tests__/GeneratePropsCpp-test.js | 4 +--- .../__tests__/GeneratePropsH-test.js | 4 +--- .../GeneratePropsJavaDelegate-test.js | 4 +--- .../GeneratePropsJavaInterface-test.js | 4 +--- .../__tests__/GenerateShadowNodeH-test.js | 4 +--- .../__tests__/GenerateTests-test.js | 4 +--- .../generators/modules/GenerateModuleCpp.js | 1 - .../src/generators/modules/GenerateModuleH.js | 1 - .../modules/GenerateModuleJavaSpec.js | 1 - .../modules/GenerateModuleJniCpp.js | 5 ++-- .../generators/modules/GenerateModuleJniH.js | 3 +-- .../modules/GenerateModuleObjCpp/index.js | 5 ++-- .../__tests__/GenerateModuleCpp-test.js | 1 - .../modules/__tests__/GenerateModuleH-test.js | 1 - .../__tests__/GenerateModuleHObjCpp-test.js | 3 +-- .../__tests__/GenerateModuleJavaSpec-test.js | 1 - .../__tests__/GenerateModuleJniCpp-test.js | 1 - .../__tests__/GenerateModuleJniH-test.js | 1 - .../__tests__/GenerateModuleMm-test.js | 6 +++-- .../GenerateModuleHObjCpp-test.js.snap | 12 +++++----- .../GenerateModuleJniCpp-test.js.snap | 24 +++++++++---------- .../GenerateModuleJniH-test.js.snap | 12 +++++----- .../GenerateModuleMm-test.js.snap | 24 +++++++++---------- scripts/generate-specs-cli.js | 10 +------- 43 files changed, 67 insertions(+), 127 deletions(-) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index b8122b153b9627..4b1ff7acc7bd60 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -119,11 +119,10 @@ def rn_codegen_modules( fb_native.genrule( name = generate_fixtures_rule_name, srcs = native.glob(["src/generators/**/*.js"]), - cmd = "$(exe {generator_script}) $(location {schema_target}) {library_name} $OUT {native_module_spec_name} {android_package_name}".format( + cmd = "$(exe {generator_script}) $(location {schema_target}) {library_name} $OUT {android_package_name}".format( generator_script = react_native_root_target("packages/react-native-codegen:generate_all_from_schema"), schema_target = schema_target, - library_name = name, - native_module_spec_name = native_module_spec_name, + library_name = native_module_spec_name, android_package_name = android_package_name, ), out = "codegenfiles-{}".format(name), @@ -285,7 +284,7 @@ def rn_codegen_components( fb_native.genrule( name = generate_fixtures_rule_name, srcs = native.glob(["src/generators/**/*.js"]), - cmd = "$(exe {}) $(location {}) {} $OUT {}".format(react_native_root_target("packages/react-native-codegen:generate_all_from_schema"), schema_target, name, name), + cmd = "$(exe {}) $(location {}) {} $OUT".format(react_native_root_target("packages/react-native-codegen:generate_all_from_schema"), schema_target, name), out = "codegenfiles-{}".format(name), labels = ["codegen_rule"], ) diff --git a/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js b/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js index 2b2deec0b0fe33..039c05323bdd08 100644 --- a/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js +++ b/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js @@ -38,13 +38,13 @@ function getModules(): SchemaType { describe('GenerateModuleObjCpp', () => { it('can generate a header file NativeModule specs', () => { const libName = 'RNCodegenModuleFixtures'; - const output = generator.generate(libName, getModules(), libName); + const output = generator.generate(libName, getModules()); expect(output.get(libName + '.h')).toMatchSnapshot(); }); it('can generate an implementation file NativeModule specs', () => { const libName = 'RNCodegenModuleFixtures'; - const output = generator.generate(libName, getModules(), libName); + const output = generator.generate(libName, getModules()); expect(output.get(libName + '-generated.mm')).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/cli/generators/generate-all.js b/packages/react-native-codegen/src/cli/generators/generate-all.js index 6b7e8509e9589c..3aaca12c7a28ad 100644 --- a/packages/react-native-codegen/src/cli/generators/generate-all.js +++ b/packages/react-native-codegen/src/cli/generators/generate-all.js @@ -19,7 +19,7 @@ const fs = require('fs'); const mkdirp = require('mkdirp'); const args = process.argv.slice(2); -if (args.length < 4) { +if (args.length < 3) { throw new Error( `Expected to receive path to schema, library name, output directory and module spec name. Received ${args.join( ', ', @@ -30,8 +30,7 @@ if (args.length < 4) { const schemaPath = args[0]; const libraryName = args[1]; const outputDirectory = args[2]; -const moduleSpecName = args[3]; -const packageName = args[4]; +const packageName = args[3]; const schemaText = fs.readFileSync(schemaPath, 'utf-8'); @@ -49,7 +48,7 @@ try { } RNCodegen.generate( - {libraryName, schema, outputDirectory, moduleSpecName, packageName}, + {libraryName, schema, outputDirectory, packageName}, { generators: [ 'descriptors', diff --git a/packages/react-native-codegen/src/generators/RNCodegen.js b/packages/react-native-codegen/src/generators/RNCodegen.js index 06cf6f07845623..34b2a390300bc5 100644 --- a/packages/react-native-codegen/src/generators/RNCodegen.js +++ b/packages/react-native-codegen/src/generators/RNCodegen.js @@ -44,7 +44,6 @@ type Options = $ReadOnly<{ libraryName: string, schema: SchemaType, outputDirectory: string, - moduleSpecName: string, packageName?: string, // Some platforms have a notion of package, which should be configurable. }>; @@ -153,13 +152,7 @@ function checkFilesForChanges( module.exports = { generate( - { - libraryName, - schema, - outputDirectory, - moduleSpecName, - packageName, - }: Options, + {libraryName, schema, outputDirectory, packageName}: Options, {generators, test}: Config, ): boolean { schemaValidator.validate(schema); @@ -167,9 +160,7 @@ module.exports = { const generatedFiles = []; for (const name of generators) { for (const generator of GENERATORS[name]) { - generatedFiles.push( - ...generator(libraryName, schema, moduleSpecName, packageName), - ); + generatedFiles.push(...generator(libraryName, schema, packageName)); } } diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js index cf3d0e03fbb0da..2adf7ad393631d 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js @@ -47,7 +47,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'ComponentDescriptors.h'; diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index b8950352b58c33..a2f42c8b3476f0 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -323,7 +323,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'RCTComponentViewHelpers.h'; diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 62201df8f368c3..b4f32f428079c7 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -189,7 +189,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const moduleComponents: ComponentCollection = Object.keys(schema.modules) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js index 6a6607ac8bb8be..812783b947d3b3 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js @@ -238,7 +238,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const moduleComponents: ComponentCollection = Object.keys(schema.modules) diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js index 1380c768102c1c..39fc1ffc60fbb7 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js @@ -85,7 +85,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'Props.cpp'; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index d9dd5152248474..d218d809bc5bac 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -751,7 +751,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'Props.h'; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index e931e1fe125631..0e71cdbaa8673b 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -264,7 +264,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { // TODO: This doesn't support custom package name yet. diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index daa2afe92c3d64..77781ec192b22a 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -212,7 +212,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { // TODO: This doesn't support custom package name yet. diff --git a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js index 2644808cac19d8..f52444da89d64e 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js @@ -44,7 +44,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'ShadowNodes.cpp'; diff --git a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js index 1855b379d447f8..b42da9bd557615 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js @@ -54,7 +54,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'ShadowNodes.h'; diff --git a/packages/react-native-codegen/src/generators/components/GenerateTests.js b/packages/react-native-codegen/src/generators/components/GenerateTests.js index b8fde56ab584b1..ef5c3a47dfc2af 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateTests.js +++ b/packages/react-native-codegen/src/generators/components/GenerateTests.js @@ -139,7 +139,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const fileName = 'Tests.cpp'; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js index c73dd315c8bf95..02133c76f90539 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js @@ -21,9 +21,7 @@ describe('GenerateComponentDescriptorH', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js index 44528dbbb02a37..52b638973aae82 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js @@ -21,9 +21,7 @@ describe('GenerateComponentHObjCpp', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js index 5a17690e597b8f..14ac106e959b4d 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js @@ -21,9 +21,7 @@ describe('GenerateEventEmitterCpp', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js index 3b1974f66539f1..2b6a26422aa306 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js @@ -21,9 +21,7 @@ describe('GenerateEventEmitterH', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js index 284c5457acadcb..f9b9332a1259ca 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js @@ -21,9 +21,7 @@ describe('GeneratePropsCpp', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js index 23f8769ebeb814..77305fc2c4a077 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js @@ -21,9 +21,7 @@ describe('GeneratePropsH', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js index b9c5724c914e6a..36f1f9e8a5ca1a 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js @@ -21,9 +21,7 @@ describe('GeneratePropsJavaDelegate', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js index a14ac875cc7b9a..cc1eadab41ab78 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js @@ -21,9 +21,7 @@ describe('GeneratePropsJavaInterface', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js index 3edd5e3695fdab..ea704d4773d614 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js @@ -21,9 +21,7 @@ describe('GenerateShadowNodeH', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js index 8b9f066b0c18b4..6961d0b1754ee1 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js @@ -21,9 +21,7 @@ describe('GenerateTests', () => { const fixture = fixtures[fixtureName]; it(`can generate fixture ${fixtureName}`, () => { - expect( - generator.generate(fixtureName, fixture, 'SampleSpec'), - ).toMatchSnapshot(); + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); }); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index bd94bb33cfb7a4..215b57846dc8a8 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -184,7 +184,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const nativeModules = getModules(schema); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index e1925f02eed790..2b50bd76b827c6 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -123,7 +123,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const nativeModules = getModules(schema); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index 8739e09bafad58..3f7f81897497e3 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -367,7 +367,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const files = new Map(); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index b75aea926b731d..9bebea4886f8e0 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -357,7 +357,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const nativeModules = getModules(schema); @@ -451,12 +450,12 @@ module.exports = { }, ); - const fileName = `${moduleSpecName}-generated.cpp`; + const fileName = `${libraryName}-generated.cpp`; const replacedTemplate = FileTemplate({ modules: modules, libraryName: libraryName.replace(/-/g, '_'), moduleLookups, - include: `"${moduleSpecName}.h"`, + include: `"${libraryName}.h"`, }); return new Map([[`jni/${fileName}`, replacedTemplate]]); }, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js index a83207961bf120..43aee3cb585b63 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js @@ -97,7 +97,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const nativeModules = getModules(schema); @@ -113,7 +112,7 @@ module.exports = { .map(hasteModuleName => ModuleClassDeclarationTemplate({hasteModuleName})) .join('\n'); - const fileName = `${moduleSpecName}.h`; + const fileName = `${libraryName}.h`; const replacedTemplate = HeaderFileTemplate({ modules: modules, libraryName: libraryName.replace(/-/g, '_'), diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js index 69fecf7e0e336c..eae698f52ace35 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js @@ -113,7 +113,6 @@ module.exports = { generate( libraryName: string, schema: SchemaType, - moduleSpecName: string, packageName?: string, ): FilesOutput { const nativeModules = getModules(schema); @@ -191,13 +190,13 @@ module.exports = { ); } - const headerFileName = `${moduleSpecName}.h`; + const headerFileName = `${libraryName}.h`; const headerFile = HeaderFileTemplate({ moduleDeclarations: moduleDeclarations.join('\n'), structInlineMethods: structInlineMethods.join('\n'), }); - const sourceFileName = `${moduleSpecName}-generated.mm`; + const sourceFileName = `${libraryName}-generated.mm`; const sourceFile = SourceFileTemplate({ headerFileName, moduleImplementations: moduleImplementations.join('\n'), diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js index 6904c804baf900..a03ef0508b7851 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js @@ -25,7 +25,6 @@ describe('GenerateModuleCpp', () => { generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ), ).toMatchSnapshot(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js index ffe05d6880de5a..3acbc7f638f94c 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js @@ -25,7 +25,6 @@ describe('GenerateModuleH', () => { generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ), ).toMatchSnapshot(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js index fc148e2efc47ff..4544348ccff62c 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js @@ -24,11 +24,10 @@ describe('GenerateModuleHObjCpp', () => { const output = generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ); expect( - new Map([['SampleSpec.h', output.get('SampleSpec.h')]]), + new Map([[`${fixtureName}.h`, output.get(`${fixtureName}.h`)]]), ).toMatchSnapshot(); }); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js index e7c77457dd7eba..854d21388c18a8 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js @@ -25,7 +25,6 @@ describe('GenerateModuleJavaSpec', () => { generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ), ).toMatchSnapshot(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js index d3dae278440717..0dfc249f71458f 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js @@ -25,7 +25,6 @@ describe('GenerateModuleJniCpp', () => { generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ), ).toMatchSnapshot(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js index d5ac7ecfb32858..4e9e116b9619cb 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js @@ -25,7 +25,6 @@ describe('GenerateModuleJniH', () => { generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ), ).toMatchSnapshot(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js index 3c0e5686585416..0d3fd81dd20694 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js @@ -24,12 +24,14 @@ describe('GenerateModuleMm', () => { const output = generator.generate( fixtureName, fixture, - 'SampleSpec', 'com.facebook.fbreact.specs', ); expect( new Map([ - ['SampleSpec-generated.mm', output.get('SampleSpec-generated.mm')], + [ + `${fixtureName}-generated.mm`, + output.get(`${fixtureName}-generated.mm`), + ], ]), ).toMatchSnapshot(); }); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap index bc98ff9c128927..713889b0cf196e 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap @@ -2,7 +2,7 @@ exports[`GenerateModuleHObjCpp can generate fixture COMPLEX_OBJECTS 1`] = ` Map { - "SampleSpec.h" => "/** + "COMPLEX_OBJECTS.h" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -260,7 +260,7 @@ inline facebook::react::LazyVector "/** + "EMPTY_NATIVE_MODULES.h" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -311,7 +311,7 @@ namespace facebook { exports[`GenerateModuleHObjCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` Map { - "SampleSpec.h" => "/** + "NATIVE_MODULES_WITH_TYPE_ALIASES.h" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -482,7 +482,7 @@ inline folly::Optional JS::AliasTurboModule::Options::allowExternalStorage exports[`GenerateModuleHObjCpp can generate fixture REAL_MODULE_EXAMPLE 1`] = ` Map { - "SampleSpec.h" => "/** + "REAL_MODULE_EXAMPLE.h" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -772,7 +772,7 @@ inline bool JS::NativeImagePickerIOS::SpecOpenCameraDialogConfig::videoMode() co exports[`GenerateModuleHObjCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` Map { - "SampleSpec.h" => "/** + "SIMPLE_NATIVE_MODULES.h" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -878,7 +878,7 @@ inline JS::NativeSampleTurboModule::Constants::Builder::Builder(Constants i) : _ exports[`GenerateModuleHObjCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` Map { - "SampleSpec.h" => "/** + "TWO_MODULES_DIFFERENT_FILES.h" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap index 932a69b65e466b..328f1a34779a55 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap @@ -2,7 +2,7 @@ exports[`GenerateModuleJniCpp can generate fixture COMPLEX_OBJECTS 1`] = ` Map { - "jni/SampleSpec-generated.cpp" => " + "jni/COMPLEX_OBJECTS-generated.cpp" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -12,7 +12,7 @@ Map { * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SampleSpec.h\\" +#include \\"COMPLEX_OBJECTS.h\\" namespace facebook { namespace react { @@ -56,7 +56,7 @@ std::shared_ptr COMPLEX_OBJECTS_ModuleProvider(const std::string mo exports[`GenerateModuleJniCpp can generate fixture EMPTY_NATIVE_MODULES 1`] = ` Map { - "jni/SampleSpec-generated.cpp" => " + "jni/EMPTY_NATIVE_MODULES-generated.cpp" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -66,7 +66,7 @@ Map { * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SampleSpec.h\\" +#include \\"EMPTY_NATIVE_MODULES.h\\" namespace facebook { namespace react { @@ -93,7 +93,7 @@ std::shared_ptr EMPTY_NATIVE_MODULES_ModuleProvider(const std::stri exports[`GenerateModuleJniCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` Map { - "jni/SampleSpec-generated.cpp" => " + "jni/NATIVE_MODULES_WITH_TYPE_ALIASES-generated.cpp" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -103,7 +103,7 @@ Map { * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SampleSpec.h\\" +#include \\"NATIVE_MODULES_WITH_TYPE_ALIASES.h\\" namespace facebook { namespace react { @@ -134,7 +134,7 @@ std::shared_ptr NATIVE_MODULES_WITH_TYPE_ALIASES_ModuleProvider(con exports[`GenerateModuleJniCpp can generate fixture REAL_MODULE_EXAMPLE 1`] = ` Map { - "jni/SampleSpec-generated.cpp" => " + "jni/REAL_MODULE_EXAMPLE-generated.cpp" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -144,7 +144,7 @@ Map { * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SampleSpec.h\\" +#include \\"REAL_MODULE_EXAMPLE.h\\" namespace facebook { namespace react { @@ -216,7 +216,7 @@ std::shared_ptr REAL_MODULE_EXAMPLE_ModuleProvider(const std::strin exports[`GenerateModuleJniCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` Map { - "jni/SampleSpec-generated.cpp" => " + "jni/SIMPLE_NATIVE_MODULES-generated.cpp" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -226,7 +226,7 @@ Map { * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SampleSpec.h\\" +#include \\"SIMPLE_NATIVE_MODULES.h\\" namespace facebook { namespace react { @@ -305,7 +305,7 @@ std::shared_ptr SIMPLE_NATIVE_MODULES_ModuleProvider(const std::str exports[`GenerateModuleJniCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` Map { - "jni/SampleSpec-generated.cpp" => " + "jni/TWO_MODULES_DIFFERENT_FILES-generated.cpp" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -315,7 +315,7 @@ Map { * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SampleSpec.h\\" +#include \\"TWO_MODULES_DIFFERENT_FILES.h\\" namespace facebook { namespace react { diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap index 412b15cb456707..821ffc8303e736 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap @@ -2,7 +2,7 @@ exports[`GenerateModuleJniH can generate fixture COMPLEX_OBJECTS 1`] = ` Map { - "jni/SampleSpec.h" => " + "jni/COMPLEX_OBJECTS.h" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -68,7 +68,7 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture EMPTY_NATIVE_MODULES 1`] = ` Map { - "jni/SampleSpec.h" => " + "jni/EMPTY_NATIVE_MODULES.h" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -134,7 +134,7 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` Map { - "jni/SampleSpec.h" => " + "jni/NATIVE_MODULES_WITH_TYPE_ALIASES.h" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -200,7 +200,7 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture REAL_MODULE_EXAMPLE 1`] = ` Map { - "jni/SampleSpec.h" => " + "jni/REAL_MODULE_EXAMPLE.h" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -274,7 +274,7 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` Map { - "jni/SampleSpec.h" => " + "jni/SIMPLE_NATIVE_MODULES.h" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -340,7 +340,7 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` Map { - "jni/SampleSpec.h" => " + "jni/TWO_MODULES_DIFFERENT_FILES.h" => " /** * Copyright (c) Facebook, Inc. and its affiliates. * diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap index b72fed68efcdec..f59a5b2b6f47ab 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap @@ -2,7 +2,7 @@ exports[`GenerateModuleMm can generate fixture COMPLEX_OBJECTS 1`] = ` Map { - "SampleSpec-generated.mm" => "/** + "COMPLEX_OBJECTS-generated.mm" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -15,7 +15,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SampleSpec.h\\" +#import \\"COMPLEX_OBJECTS.h\\" @implementation RCTCxxConvert (NativeSampleTurboModule_SpecDifficultAE) + (RCTManagedPointer *)JS_NativeSampleTurboModule_SpecDifficultAE:(id)json @@ -95,7 +95,7 @@ namespace facebook { exports[`GenerateModuleMm can generate fixture EMPTY_NATIVE_MODULES 1`] = ` Map { - "SampleSpec-generated.mm" => "/** + "EMPTY_NATIVE_MODULES-generated.mm" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -108,7 +108,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SampleSpec.h\\" +#import \\"EMPTY_NATIVE_MODULES.h\\" namespace facebook { @@ -127,7 +127,7 @@ namespace facebook { exports[`GenerateModuleMm can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` Map { - "SampleSpec-generated.mm" => "/** + "NATIVE_MODULES_WITH_TYPE_ALIASES-generated.mm" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -140,7 +140,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SampleSpec.h\\" +#import \\"NATIVE_MODULES_WITH_TYPE_ALIASES.h\\" @implementation RCTCxxConvert (AliasTurboModule_OptionsOffset) + (RCTManagedPointer *)JS_AliasTurboModule_OptionsOffset:(id)json @@ -187,7 +187,7 @@ namespace facebook { exports[`GenerateModuleMm can generate fixture REAL_MODULE_EXAMPLE 1`] = ` Map { - "SampleSpec-generated.mm" => "/** + "REAL_MODULE_EXAMPLE-generated.mm" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -200,7 +200,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SampleSpec.h\\" +#import \\"REAL_MODULE_EXAMPLE.h\\" @implementation RCTCxxConvert (NativeCameraRollManager_GetPhotosParams) + (RCTManagedPointer *)JS_NativeCameraRollManager_GetPhotosParams:(id)json @@ -319,7 +319,7 @@ namespace facebook { exports[`GenerateModuleMm can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` Map { - "SampleSpec-generated.mm" => "/** + "SIMPLE_NATIVE_MODULES-generated.mm" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -332,7 +332,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SampleSpec.h\\" +#import \\"SIMPLE_NATIVE_MODULES.h\\" namespace facebook { @@ -426,7 +426,7 @@ namespace facebook { exports[`GenerateModuleMm can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` Map { - "SampleSpec-generated.mm" => "/** + "TWO_MODULES_DIFFERENT_FILES-generated.mm" => "/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -439,7 +439,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SampleSpec.h\\" +#import \\"TWO_MODULES_DIFFERENT_FILES.h\\" namespace facebook { diff --git a/scripts/generate-specs-cli.js b/scripts/generate-specs-cli.js index 72310cb54b7414..53b263faccdf95 100644 --- a/scripts/generate-specs-cli.js +++ b/scripts/generate-specs-cli.js @@ -35,7 +35,6 @@ function generateSpec( libraryName, packageName, ) { - const moduleSpecName = libraryName; const schemaText = fs.readFileSync(schemaPath, 'utf-8'); if (schemaText == null) { @@ -43,13 +42,7 @@ function generateSpec( } if (!outputDirectory) { - outputDirectory = path.resolve( - __dirname, - '..', - 'Libraries', - libraryName, - moduleSpecName, - ); + outputDirectory = path.resolve(__dirname, '..', 'Libraries', libraryName); } mkdirp.sync(outputDirectory); @@ -65,7 +58,6 @@ function generateSpec( libraryName, schema, outputDirectory, - moduleSpecName, packageName, }, { From 6bfd89d27724f2aac602fa2acbf4753950f4152e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mu=CC=88ller?= Date: Thu, 7 Jan 2021 20:28:00 -0800 Subject: [PATCH 0336/1810] Update OkHttp to 3.14.9 to improve security (#30609) Summary: Okhttp 3.12.X allows Connections using TLS 1.0 and TLS1.1. TLS 1.0 and TLS 1.1 are no longer secure. Google, Mozilla, Microsoft, and Apple announced that their browsers will require TLSv1.2 or better starting in early 2020. https://square.github.io/okhttp/changelog_3x/#version-310 https://github.com/facebook/react-native/wiki/Changelog Starting from 3.13.0 TLSv1 and TLSv1.1 are no longer enabled by default. 3.13.0 requires JAVA 8 and Android SDK 21 (which was blocking the Upgrade in the Past). ## Changelog [Android] [Changed] - Update Okhttp to version 3.14.19 Pull Request resolved: https://github.com/facebook/react-native/pull/30609 Test Plan: Current tests should pass. Connections using TLS 1.0 and TLS 1.1 should not be possible. Reviewed By: mdvacca Differential Revision: D25843511 Pulled By: fkgozali fbshipit-source-id: f0b648c8037f945130c6f9983404ee7f75b178cb --- ReactAndroid/gradle.properties | 2 +- ReactAndroid/src/main/third-party/java/okhttp/BUCK | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/gradle.properties b/ReactAndroid/gradle.properties index 2287cd057099fc..6e87e5187d3d33 100644 --- a/ReactAndroid/gradle.properties +++ b/ReactAndroid/gradle.properties @@ -12,7 +12,7 @@ JUNIT_VERSION=4.12 ANDROIDX_TEST_VERSION=1.1.0 FRESCO_VERSION=2.0.0 -OKHTTP_VERSION=3.12.12 +OKHTTP_VERSION=3.14.9 SO_LOADER_VERSION=0.9.0 BOOST_VERSION=1_63_0 diff --git a/ReactAndroid/src/main/third-party/java/okhttp/BUCK b/ReactAndroid/src/main/third-party/java/okhttp/BUCK index a19336522a9b90..90b3f3f9f84c07 100644 --- a/ReactAndroid/src/main/third-party/java/okhttp/BUCK +++ b/ReactAndroid/src/main/third-party/java/okhttp/BUCK @@ -9,8 +9,8 @@ rn_prebuilt_jar( fb_native.remote_file( name = "okhttp3-binary.jar", - sha1 = "d3e1ce1d2b3119adf270b2d00d947beb03fe3321", - url = "mvn:com.squareup.okhttp3:okhttp:jar:3.12.12", + sha1 = "3e6d101343c7ea687cd593e4990f73b25c878383", + url = "mvn:com.squareup.okhttp3:okhttp:jar:3.14.9", ) rn_prebuilt_jar( @@ -21,6 +21,6 @@ rn_prebuilt_jar( fb_native.remote_file( name = "okhttp3-urlconnection-binary.jar", - sha1 = "3cfbe11fb8c48d30600a70f90b3283fc858aea72", - url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.12.12", + sha1 = "c9a3b45b815cf2982415ec8145339f5af58989c3", + url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.14.9", ) From 2aeb6545bcbe359865fc32e2edb92461de10b0eb Mon Sep 17 00:00:00 2001 From: Joseph Semrai Date: Fri, 8 Jan 2021 12:05:09 -0800 Subject: [PATCH 0337/1810] Add remaining prop examples for the Image component (#30554) Summary: Adds missing prop examples for the Image component in rn-tester. ## Changelog [Internal] [Added] New examples for LoadingIndicatorSource, Accessibility, AccessibilityLabel, fadeDuration, onLayout, onPartialLoad, accessibilityLabel, etc. Pull Request resolved: https://github.com/facebook/react-native/pull/30554 Test Plan: - [x] Build rn-tester and verify that it runs - [x] Interact with each component - [x] Verify that the examples function as intended Reviewed By: shergin Differential Revision: D25680504 Pulled By: rickhanlonii fbshipit-source-id: bf797c92f8d0b4e66cdede2e32445ea4941b19fe --- .../js/examples/Image/ImageExample.js | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) diff --git a/packages/rn-tester/js/examples/Image/ImageExample.js b/packages/rn-tester/js/examples/Image/ImageExample.js index b0d665ed31c305..4374fcb8cb59f3 100644 --- a/packages/rn-tester/js/examples/Image/ImageExample.js +++ b/packages/rn-tester/js/examples/Image/ImageExample.js @@ -36,6 +36,7 @@ type NetworkImageCallbackExampleState = {| events: Array, startLoadPrefetched: boolean, mountTime: number, + imageHash: number, |}; type NetworkImageCallbackExampleProps = $ReadOnly<{| @@ -51,6 +52,7 @@ class NetworkImageCallbackExample extends React.Component< events: [], startLoadPrefetched: false, mountTime: Date.now(), + imageHash: Date.now(), }; UNSAFE_componentWillMount() { @@ -63,6 +65,10 @@ class NetworkImageCallbackExample extends React.Component< })); }; + updateLoadingImageHash = () => { + this.setState({imageHash: Date.now()}); + }; + render() { const {mountTime} = this.state; return ( @@ -340,6 +346,193 @@ class MultipleSourcesExample extends React.Component< } } +type LoadingIndicatorSourceExampleState = {| + imageHash: number, +|}; + +type LoadingIndicatorSourceExampleProps = $ReadOnly<{||}>; + +class LoadingIndicatorSourceExample extends React.Component< + LoadingIndicatorSourceExampleProps, + LoadingIndicatorSourceExampleState, +> { + state = { + imageHash: Date.now(), + }; + + reloadImage = () => { + this.setState({ + imageHash: Date.now(), + }); + }; + + loaderGif = { + uri: 'https://media1.giphy.com/media/3oEjI6SIIHBdRxXI40/200.gif', + }; + + render() { + const loadingImage = { + uri: `https://www.facebook.com/ads/pics/successstories.png?hash=${this.state.imageHash}`, + }; + + return ( + + + + Refresh Image + + + + Image Hash: {this.state.imageHash} + Image URI: {loadingImage.uri} + + ); + } +} + +type OnLayoutExampleState = {| + width: number, + height: number, + layoutHandlerMessage: string, +|}; + +type OnLayoutExampleProps = $ReadOnly<{||}>; + +class OnLayoutExample extends React.Component< + OnLayoutExampleProps, + OnLayoutExampleState, +> { + state = { + width: 30, + height: 30, + layoutHandlerMessage: 'No Message', + }; + + onLayoutHandler = event => { + this.setState({ + width: this.state.width, + height: this.state.height, + layoutHandlerMessage: JSON.stringify(event.nativeEvent), + }); + console.log(event.nativeEvent); + }; + + increaseImageSize = () => { + if (this.state.width >= 100) { + return; + } + this.setState({ + width: this.state.width + 10, + height: this.state.height + 10, + }); + }; + + increaseImageSize = () => { + if (this.state.width >= 100) { + return; + } + this.setState({ + width: this.state.width + 10, + height: this.state.height + 10, + }); + }; + + decreaseImageSize = () => { + if (this.state.width <= 10) { + return; + } + this.setState({ + width: this.state.width - 10, + height: this.state.height - 10, + }); + }; + + render() { + return ( + + Adjust the image size to trigger the OnLayout handler. + + + Decrease image size + + + Increase image size + + + + Container image size: {this.state.width}x{this.state.height}{' '} + + + + + Layout Handler Message: {this.state.layoutHandlerMessage} + + ); + } +} + +type OnPartialLoadExampleState = {| + hasLoaded: boolean, +|}; + +type OnPartialLoadExampleProps = $ReadOnly<{||}>; + +class OnPartialLoadExample extends React.Component< + OnPartialLoadExampleProps, + OnPartialLoadExampleState, +> { + state = { + hasLoaded: false, + }; + + partialLoadHandler = () => { + this.setState({ + hasLoaded: true, + }); + }; + + render() { + return ( + + + Partial Load Function Executed: {JSON.stringify(this.state.hasLoaded)} + + + + ); + } +} + const fullImage = { uri: 'https://www.facebook.com/ads/pics/successstories.png', }; @@ -951,4 +1144,60 @@ exports.examples = [ ); }, }, + { + title: 'Accessibility', + description: ('If the `accessible` (boolean) prop is set to True, the image will be indicated as an accessbility element.': string), + render: function(): React.Node { + return ; + }, + }, + { + title: 'Accessibility Label', + description: ('When an element is marked as accessibile (using the accessibility prop), it is good practice to set an accessibilityLabel on the image to provide a description of the element to people who use VoiceOver. VoiceOver will read this string when people select this element.': string), + render: function(): React.Node { + return ( + + ); + }, + }, + { + title: 'Fade Duration', + description: ('The time (in miliseconds) that an image will fade in for when it appears (default = 300).': string), + render: function(): React.Node { + return ( + <> + + This image will fade in over the time of 1.5s. + + ); + }, + platform: 'android', + }, + { + title: 'Loading Indicator Source', + description: ('This prop is used to set the resource that will be used as the loading indicator for the image (displayed until the image is ready to be displayed).': string), + render: function(): React.Node { + return ; + }, + }, + { + title: 'On Layout', + description: ('This prop is used to set the handler function to be called when the image is mounted or its layout changes. The function receives an event with `{nativeEvent: {layout: {x, y, width, height}}}`': string), + render: function(): React.Node { + return ; + }, + }, + { + title: 'On Partial Load', + description: ('This prop is used to set the handler function to be called when the partial load of the image is complete. This is meant for progressive JPEG loads.': string), + render: function(): React.Node { + return ; + }, + platform: 'ios', + }, ]; From b64ffd70cd1022d10c30d2df9e6cfdff72f79798 Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Fri, 8 Jan 2021 12:07:21 -0800 Subject: [PATCH 0338/1810] Added missing examples for TouchableHighlight and TouchableWithoutFeedback (#30364) Summary: Added example for the following missing props in TouchableHighlight * onHideUnderlay * onShowUnderlay **Motivation** - Missing examples for these props in the RNTester app ## Changelog [General] [Added] - Added example to ToucableHighlight Pull Request resolved: https://github.com/facebook/react-native/pull/30364 Test Plan: * Tested on an Android device ![under_2](https://user-images.githubusercontent.com/26821140/98783116-0a47dd00-241f-11eb-95a1-feffb5c8a00b.png) ![under_1](https://user-images.githubusercontent.com/26821140/98783118-0c11a080-241f-11eb-907a-498cdfceee13.png) ![Screenshot_1605441612](https://user-images.githubusercontent.com/26821140/99184542-946aab00-2769-11eb-847c-e5f71ff5093a.png) Reviewed By: TheSavior Differential Revision: D25563070 Pulled By: rickhanlonii fbshipit-source-id: c8a10601cda28f4884e1444039a208d0b70cbdf1 --- .../js/examples/Touchable/TouchableExample.js | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/packages/rn-tester/js/examples/Touchable/TouchableExample.js b/packages/rn-tester/js/examples/Touchable/TouchableExample.js index 7c313cbf185604..7c06a2b830bd58 100644 --- a/packages/rn-tester/js/examples/Touchable/TouchableExample.js +++ b/packages/rn-tester/js/examples/Touchable/TouchableExample.js @@ -479,6 +479,105 @@ const remoteImage = { uri: 'https://www.facebook.com/favicon.ico', }; +const TouchableHighlightUnderlayMethods = () => { + const [underlayVisible, setUnderlayVisible] = useState( + 'Underlay not visible', + ); + + const hiddenUnderlay = () => { + setUnderlayVisible('Press to make underlay visible'); + }; + + const shownUnderlay = () => { + setUnderlayVisible('Underlay visible'); + }; + return ( + { + console.log('TouchableHighlight underlay shown!'); + }}> + {underlayVisible} + + ); +}; + +const TouchableTouchSoundDisabled = () => { + const [soundEnabled, setSoundEnabled] = useState(false); + const toggleTouchableSound = () => { + soundEnabled ? setSoundEnabled(false) : setSoundEnabled(true); + }; + return ( + <> + {Platform.OS === 'android' ? ( + <> + console.log('touchSoundDisabled pressed!')}> + + Touchables make a sound on Android, which can be turned off. + + + + + {soundEnabled + ? 'Disable Touchable Sound' + : 'Enable Touchable Sound'} + + + + ) : null} + + ); +}; + +function TouchableOnFocus>() { + const ref = useRef | {focus: Function}>(null); + const [isFocused, setIsFocused] = useState(false); + const [focusStatus, setFocusStatus] = useState( + 'This touchable is not focused.', + ); + const [isBlurred, setIsBlurred] = useState( + 'This item still has focus, onBlur is not called', + ); + + const toggleFocus = () => { + isFocused + ? setFocusStatus('This touchable is focused') + : setIsFocused('This touchable is not focused') && + setIsBlurred('This item has lost focus, onBlur called'); + }; + const focusTouchable = () => { + if (ref.current) { + ref.current.focus(); + } + }; + + return ( + + + {focusStatus} + {'\n'} + {isBlurred} + + + ); +} + const styles = StyleSheet.create({ row: { justifyContent: 'center', @@ -603,6 +702,24 @@ exports.examples = [ ); }, }, + { + title: 'TouchableHighlight Underlay Visibility', + render: function(): React.Node { + return ; + }, + }, + { + title: 'Touchable Touch Sound', + render: function(): React.Node { + return ; + }, + }, + { + title: 'Touchable onFocus', + render: function(): React.Node { + return ; + }, + }, { title: ' with highlight', render: function(): React.Element { From a724c8d95ede7f0bdf5b91901beed701f0fc9c9f Mon Sep 17 00:00:00 2001 From: Su Min Kim Date: Fri, 8 Jan 2021 12:10:14 -0800 Subject: [PATCH 0339/1810] Add keyboard avoiding view examples (#30380) Summary: Added examples to keyboard avoiding view in RNTester for: 1. contentContainerStyle 2. enabled ## Changelog [General] [Added] - Add keyboard avoiding view examples Pull Request resolved: https://github.com/facebook/react-native/pull/30380 Test Plan: ![Example](http://g.recordit.co/At5k7cF4kA.gif) Reviewed By: PeteTheHeat Differential Revision: D25399114 Pulled By: rickhanlonii fbshipit-source-id: 4b893b5be02770eb582807add5f8d7dbb7941549 --- .../KeyboardAvoidingViewExample.js | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/packages/rn-tester/js/examples/KeyboardAvoidingView/KeyboardAvoidingViewExample.js b/packages/rn-tester/js/examples/KeyboardAvoidingView/KeyboardAvoidingViewExample.js index 4ca55175b14dda..c494fffc9b3c9a 100644 --- a/packages/rn-tester/js/examples/KeyboardAvoidingView/KeyboardAvoidingViewExample.js +++ b/packages/rn-tester/js/examples/KeyboardAvoidingView/KeyboardAvoidingViewExample.js @@ -50,7 +50,7 @@ const CloseButton = props => { {marginHorizontal: props.behavior === 'position' ? 0 : 25}, ]}> props.setModdalOpen(false)} + onPress={() => props.setModalOpen(false)} style={styles.closeButton}> Close @@ -59,7 +59,7 @@ const CloseButton = props => { }; const KeyboardAvoidingViewBehaviour = () => { - const [modalOpen, setModdalOpen] = useState(false); + const [modalOpen, setModalOpen] = useState(false); const [behavior, setBehavior] = useState('padding'); return ( @@ -87,7 +87,7 @@ const KeyboardAvoidingViewBehaviour = () => { {backgroundColor: behavior === 'position' ? 'blue' : 'white'}, ]}> - Padding + Position { - + - setModdalOpen(true)}> + setModalOpen(true)}> Open Example @@ -118,7 +118,7 @@ const KeyboardAvoidingViewBehaviour = () => { }; const KeyboardAvoidingDisabled = () => { - const [modalOpen, setModdalOpen] = useState(false); + const [modalOpen, setModalOpen] = useState(false); return ( @@ -126,12 +126,12 @@ const KeyboardAvoidingDisabled = () => { enabled={false} behavior={'height'} style={styles.container}> - + - setModdalOpen(true)}> + setModalOpen(true)}> Open Example @@ -140,7 +140,7 @@ const KeyboardAvoidingDisabled = () => { }; const KeyboardAvoidingVerticalOffset = () => { - const [modalOpen, setModdalOpen] = useState(false); + const [modalOpen, setModalOpen] = useState(false); return ( @@ -148,12 +148,35 @@ const KeyboardAvoidingVerticalOffset = () => { keyboardVerticalOffset={20} behavior={'padding'} style={styles.container}> - + - setModdalOpen(true)}> + setModalOpen(true)}> + Open Example + + + + ); +}; + +const KeyboardAvoidingContentContainerStyle = () => { + const [modalOpen, setModalOpen] = useState(false); + return ( + + + + + + + + + setModalOpen(true)}> Open Example @@ -172,6 +195,10 @@ const styles = StyleSheet.create({ paddingHorizontal: 20, paddingTop: 20, }, + contentContainer: { + paddingTop: 20, + backgroundColor: '#abdebf', + }, textInput: { borderRadius: 5, borderWidth: 1, @@ -225,4 +252,10 @@ exports.examples = [ return ; }, }, + { + title: 'Keyboard Avoiding View with contentContainerStyle', + render(): React.Node { + return ; + }, + }, ]; From 835117aba39019ba8fff1dc87fa43d890b6bb17f Mon Sep 17 00:00:00 2001 From: Kshitij Kotasthane Date: Fri, 8 Jan 2021 12:39:23 -0800 Subject: [PATCH 0340/1810] Added sharedAction example to Share API (#30333) Summary: * Added an example for `sharedAction` and `dismissedAction` in Share API examples **Motivation** - Missing example for `sharedAction` in examples ## Changelog [General] [Added] - Added an example in ShareExample.js Pull Request resolved: https://github.com/facebook/react-native/pull/30333 Test Plan: * Tested on Android ![sharedAction](https://user-images.githubusercontent.com/26821140/98447958-ed758600-214e-11eb-8a50-67ad5dcebea5.png) Reviewed By: cpojer Differential Revision: D25246375 Pulled By: rickhanlonii fbshipit-source-id: f0d25a04c77ba02c9bea07aceccbfb65b2aa67e9 --- .../ScrollView/ScrollViewStickyHeader.js | 2 +- .../js/examples/Share/ShareExample.js | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 05e1af3ad03faf..20d5d344f892f1 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -177,7 +177,7 @@ class ScrollViewStickyHeader extends React.Component { // Fabric Detection // eslint-disable-next-line dot-notation const isFabric = !!( - this._ref && this._ref['_internalInstanceHandle']?.stateNode?.canonical + this._ref && this._ref._internalInstanceHandle?.stateNode?.canonical ); // Initially and in the case of updated props or layout, we diff --git a/packages/rn-tester/js/examples/Share/ShareExample.js b/packages/rn-tester/js/examples/Share/ShareExample.js index 3ec9a7d6f5c89f..1bcd7cfd174da7 100644 --- a/packages/rn-tester/js/examples/Share/ShareExample.js +++ b/packages/rn-tester/js/examples/Share/ShareExample.js @@ -76,6 +76,46 @@ const ShareMessageWithTitle = () => { ); }; +const SharedAction = () => { + const [shared, setShared] = React.useState(); + + const sharedAction = async () => { + try { + const result = await Share.share( + { + title: 'Create native apps', + message: ('React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces.': string), + url: 'https://reactnative.dev/', + }, + { + subject: 'MUST READ: Create native apps with React Native', + dialogTitle: 'Share React Native Home Page', + tintColor: 'blue', + }, + ); + if (result.action === Share.sharedAction) { + setShared(result.action); + } else if (result.action === Share.dismissedAction) { + //iOS only, if dialog was dismissed + setShared(null); + } + } catch (e) { + console.error(e); + } + }; + return ( + + action: {shared ? shared : 'null'} + Create native apps + + React Native combines the best parts of native development with React, a + best-in-class JavaScript library for building user interfaces. + +