@wanderlogapp/react-native 0.86.3-wanderlog.2 → 0.86.3-wanderlog.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,6 @@ import type {RootTag} from '../Types/RootTagTypes';
14
14
  import type {UIManagerJSInterface} from '../Types/UIManagerJSInterface';
15
15
 
16
16
  import {unstable_hasComponent} from '../NativeComponent/NativeComponentRegistryUnstable';
17
- import defineLazyObjectProperty from '../Utilities/defineLazyObjectProperty';
18
17
  import Platform from '../Utilities/Platform';
19
18
  import {getFabricUIManager} from './FabricUIManager';
20
19
  import nullthrows from 'nullthrows';
@@ -44,6 +43,20 @@ const getUIManagerConstantsCached = (function () {
44
43
  const getConstantsForViewManager: ?(viewManagerName: string) => ?Object =
45
44
  global.RN$LegacyInterop_UIManager_getConstantsForViewManager;
46
45
 
46
+ // Unknown names are cached as null too, because a miss is slow on Android:
47
+ // every on-demand package tries to create the view manager.
48
+ const viewManagerConfigCache: Map<string, ?Object> = new Map();
49
+
50
+ function getConstantsForViewManagerCached(viewManagerName: string): ?Object {
51
+ if (!viewManagerConfigCache.has(viewManagerName)) {
52
+ viewManagerConfigCache.set(
53
+ viewManagerName,
54
+ nullthrows(getConstantsForViewManager)(viewManagerName),
55
+ );
56
+ }
57
+ return viewManagerConfigCache.get(viewManagerName);
58
+ }
59
+
47
60
  const getDefaultEventTypes: ?() => Object =
48
61
  global.RN$LegacyInterop_UIManager_getDefaultEventTypes;
49
62
 
@@ -167,20 +180,12 @@ const UIManagerJSPlatformAPIs = Platform.select({
167
180
  android: {
168
181
  getConstantsForViewManager: (viewManagerName: string): ?Object => {
169
182
  if (getConstantsForViewManager) {
170
- return getConstantsForViewManager(viewManagerName);
183
+ return getConstantsForViewManagerCached(viewManagerName);
171
184
  }
172
185
 
173
186
  raiseSoftError('getConstantsForViewManager');
174
187
  return {};
175
188
  },
176
- getDefaultEventTypes: (): Array<string> => {
177
- if (getDefaultEventTypes) {
178
- return getDefaultEventTypesCached();
179
- }
180
-
181
- raiseSoftError('getDefaultEventTypes');
182
- return [];
183
- },
184
189
  setLayoutAnimationEnabledExperimental: (enabled: boolean): void => {
185
190
  if (__DEV__) {
186
191
  console.warn(
@@ -266,16 +271,8 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
266
271
  ...UIManagerJSPlatformAPIs,
267
272
  ...UIManagerJSUnusedInNewArchAPIs,
268
273
  getViewManagerConfig: (viewManagerName: string): unknown => {
269
- if (getUIManagerConstants) {
270
- const constants = getUIManagerConstantsCached();
271
- if (
272
- !constants[viewManagerName] &&
273
- UIManagerJS.getConstantsForViewManager
274
- ) {
275
- constants[viewManagerName] =
276
- UIManagerJS.getConstantsForViewManager(viewManagerName);
277
- }
278
- return constants[viewManagerName];
274
+ if (getConstantsForViewManager) {
275
+ return getConstantsForViewManagerCached(viewManagerName);
279
276
  } else {
280
277
  raiseSoftError(
281
278
  `getViewManagerConfig('${viewManagerName}')`,
@@ -295,6 +292,14 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
295
292
  return null;
296
293
  }
297
294
  },
295
+ getDefaultEventTypes: (): Object => {
296
+ if (getDefaultEventTypes) {
297
+ return getDefaultEventTypesCached();
298
+ }
299
+
300
+ raiseSoftError('getDefaultEventTypes');
301
+ return {};
302
+ },
298
303
  findSubviewIn: (
299
304
  reactTag: number,
300
305
  point: Array<number>,
@@ -396,19 +401,4 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
396
401
  },
397
402
  };
398
403
 
399
- if (getUIManagerConstants) {
400
- Object.keys(getUIManagerConstantsCached()).forEach(viewConfigName => {
401
- UIManagerJS[viewConfigName] = getUIManagerConstantsCached()[viewConfigName];
402
- });
403
-
404
- if (UIManagerJS.getConstants().ViewManagerNames) {
405
- UIManagerJS.getConstants().ViewManagerNames.forEach(viewManagerName => {
406
- defineLazyObjectProperty(UIManagerJS, viewManagerName, {
407
- get: () =>
408
- nullthrows(UIManagerJS.getConstantsForViewManager)(viewManagerName),
409
- });
410
- });
411
- }
412
- }
413
-
414
404
  export default UIManagerJS;
@@ -23,9 +23,7 @@ const UIManagerImpl: UIManagerJSInterface =
23
23
  ? require('./BridgelessUIManager').default
24
24
  : require('./PaperUIManager').default;
25
25
 
26
- // $FlowFixMe[cannot-spread-interface]
27
- const UIManager: UIManagerJSInterface = {
28
- ...UIManagerImpl,
26
+ const UIManagerOverrides = {
29
27
  measure(
30
28
  reactTag: number,
31
29
  callback: (
@@ -190,4 +188,19 @@ const UIManager: UIManagerJSInterface = {
190
188
  },
191
189
  };
192
190
 
191
+ // Copy property descriptors instead of spreading UIManagerImpl. In Bridgeless
192
+ // mode, UIManagerImpl may define enumerable lazy ViewManager getters. Spreading
193
+ // the object would invoke every getter during module initialization.
194
+ // $FlowFixMe[incompatible-type] Flow cannot infer properties from descriptors.
195
+ const UIManager: UIManagerJSInterface = Object.create(
196
+ Object.getPrototypeOf(UIManagerImpl),
197
+ {
198
+ ...Object.getOwnPropertyDescriptors(
199
+ // $FlowFixMe[class-object-subtyping] UIManagerImpl is a runtime object.
200
+ UIManagerImpl,
201
+ ),
202
+ ...Object.getOwnPropertyDescriptors(UIManagerOverrides),
203
+ },
204
+ );
205
+
193
206
  export default UIManager;
@@ -110,6 +110,12 @@ function getNativeComponentAttributes(uiViewClassName: string): any {
110
110
  }
111
111
 
112
112
  function attachDefaultEventTypes(viewConfig: any) {
113
+ // Prefer getDefaultEventTypes, because getConstants() builds every view
114
+ // manager's config. Only bridge mode gets past this.
115
+ if (global.RN$LegacyInterop_UIManager_getDefaultEventTypes != null) {
116
+ merge(viewConfig, nullthrows(UIManager.getDefaultEventTypes)());
117
+ return;
118
+ }
113
119
  // This is supported on UIManager platforms (ex: Android),
114
120
  // as lazy view managers are not implemented for all platforms.
115
121
  // See [UIManager] for details on constants and implementations.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Wanderlog-specific header
2
2
 
3
- This is Wanderlog's fork of React Native. See [**Patching React Native**](https://app.notion.com/p/wanderlog/Patching-React-Native-17b4797ed24d481eb2155c9daec1ba98) in Notion for how to patch, backport, publish and upgrade it.
3
+ This is Wanderlog's fork of React Native, published to npm as [`@wanderlogapp/react-native`](https://www.npmjs.com/package/@wanderlogapp/react-native). See [**Patching React Native**](https://app.notion.com/p/wanderlog/Patching-React-Native-17b4797ed24d481eb2155c9daec1ba98) in Notion for how to patch, backport, release and upgrade it.
4
4
 
5
5
  --------
6
6
 
@@ -21,12 +21,36 @@ using namespace facebook::react;
21
21
  static NSString *const kRCTLegacyInteropChildComponentKey = @"childComponentView";
22
22
  static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
23
23
 
24
+ /**
25
+ * How native-driver Animated frames reach a legacy (Paper) view
26
+ *
27
+ * Every legacy view manager (e.g. react-native-maps' AIRGoogleMapPolyline) renders through this one view class, but
28
+ * each manager registers its own component descriptor under its own handle. Animated frames used to look up the
29
+ * descriptor by this class's shared handle, find nothing, and get dropped without a warning.
30
+ *
31
+ * Now, for each frame:
32
+ *
33
+ * 1. Animated works out the frame's props, like a polyline's new stroke color, and hands them to RCTSurfacePresenter.
34
+ * 2. RCTSurfacePresenter finds this manager's descriptor using the handle the view registry created this view for.
35
+ * 3. RCTMountingManager merges the frame's props into this view's props. It calls updateProps:oldProps: with
36
+ * Animated's keys cleared, so we don't skip any of them.
37
+ * 4. In finalizeUpdates:, the adapter sends the paper view only the props that changed, and the paper view's setter
38
+ * runs (e.g. -[AIRGoogleMapPolyline setStrokeColor:]).
39
+ *
40
+ * When JS re-renders the view later, Animated's keys are still set during updateProps:oldProps:. So we skip them,
41
+ * and the paper view keeps its animated value instead of the stale JS one.
42
+ */
24
43
  @implementation RCTLegacyViewManagerInteropComponentView {
25
44
  NSMutableArray<NSDictionary *> *_viewsToBeMounted;
26
45
  NSMutableArray<UIView *> *_viewsToBeUnmounted;
27
46
  RCTLegacyViewManagerInteropCoordinatorAdapter *_adapter;
28
47
  LegacyViewManagerInteropShadowNode::ConcreteState::Shared _state;
29
48
  BOOL _hasInvokedForwardingWarning;
49
+ /**
50
+ * Keys that native-driver Animated owns, for the props update in progress. We skip them on a JS commit so the paper
51
+ * view keeps its animated value instead of the stale JS one.
52
+ */
53
+ NSSet<NSString *> *_Nullable _propKeysToSkip;
30
54
  }
31
55
 
32
56
  - (instancetype)initWithFrame:(CGRect)frame
@@ -165,6 +189,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
165
189
  _state.reset();
166
190
  self.contentView = nil;
167
191
  _hasInvokedForwardingWarning = NO;
192
+ _propKeysToSkip = nil;
168
193
  [super prepareForRecycle];
169
194
  }
170
195
 
@@ -204,6 +229,15 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
204
229
  return concreteComponentDescriptorProvider<LegacyViewManagerInteropComponentDescriptor>();
205
230
  }
206
231
 
232
+ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
233
+ {
234
+ // This is named "broken" because once Animated touches a key, JS can't set that key again until the view is
235
+ // recycled. That's what we want here: Animated owns those keys, like opacity and transform in RCTViewComponentView.
236
+ // It's nil only while RCTMountingManager applies an Animated frame, so it tells a frame apart from a JS commit.
237
+ _propKeysToSkip = self.propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN;
238
+ [super updateProps:props oldProps:oldProps];
239
+ }
240
+
207
241
  - (void)updateState:(const State::Shared &)state oldState:(const State::Shared &)oldState
208
242
  {
209
243
  _state = std::static_pointer_cast<const LegacyViewManagerInteropShadowNode::ConcreteState>(state);
@@ -271,7 +305,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
271
305
  {
272
306
  if (updateMask & RNComponentViewUpdateMaskProps) {
273
307
  const auto &newProps = static_cast<const LegacyViewManagerInteropViewProps &>(*_props);
274
- [_adapter setProps:newProps.otherProps];
308
+ [_adapter setProps:newProps.otherProps propKeysToSkip:_propKeysToSkip];
275
309
  }
276
310
  }
277
311
 
@@ -18,10 +18,23 @@ NS_ASSUME_NONNULL_BEGIN
18
18
 
19
19
  @property (nonatomic, copy, nullable) void (^eventInterceptor)(std::string eventName, folly::dynamic &&event);
20
20
 
21
- - (void)setProps:(const folly::dynamic &)props;
21
+ /**
22
+ * Sends the paper view only the props that changed since the last call, leaving out `propKeysToSkip`, which
23
+ * native-driver Animated owns.
24
+ */
25
+ - (void)setProps:(const folly::dynamic &)props propKeysToSkip:(nullable NSSet<NSString *> *)propKeysToSkip;
22
26
 
23
27
  - (void)handleCommand:(NSString *)commandName args:(NSArray *)args;
24
28
 
25
29
  @end
26
30
 
31
+ /**
32
+ * Returns the props that differ from `sentProps`, and records them in `sentProps`. Leaves out `propKeysToSkip`, which
33
+ * native-driver Animated owns.
34
+ */
35
+ folly::dynamic RCTLegacyViewManagerInteropDiffProps(
36
+ const folly::dynamic &props,
37
+ folly::dynamic &sentProps,
38
+ NSSet<NSString *> *_Nullable propKeysToSkip);
39
+
27
40
  NS_ASSUME_NONNULL_END
@@ -6,13 +6,18 @@
6
6
  */
7
7
 
8
8
  #import "RCTLegacyViewManagerInteropCoordinatorAdapter.h"
9
+ #import <React/RCTConversions.h>
9
10
  #import <React/UIView+React.h>
10
11
  #import <react/utils/FollyConvert.h>
11
12
 
12
13
  @implementation RCTLegacyViewManagerInteropCoordinatorAdapter {
13
14
  RCTLegacyViewManagerInteropCoordinator *_coordinator;
14
15
  NSInteger _tag;
15
- NSDictionary<NSString *, id> *_oldProps;
16
+ /**
17
+ * The props we last sent to the paper view. We diff against these so a frame of a native-driver animation only
18
+ * converts and sends the keys it changed, not every prop (e.g. a polyline's whole coordinates array).
19
+ */
20
+ folly::dynamic _sentProps;
16
21
  }
17
22
 
18
23
  - (instancetype)initWithCoordinator:(RCTLegacyViewManagerInteropCoordinator *)coordinator reactTag:(NSInteger)tag
@@ -20,6 +25,7 @@
20
25
  if (self = [super init]) {
21
26
  _coordinator = coordinator;
22
27
  _tag = tag;
28
+ _sentProps = folly::dynamic::object();
23
29
  }
24
30
  return self;
25
31
  }
@@ -45,16 +51,16 @@
45
51
  return _paperView;
46
52
  }
47
53
 
48
- - (void)setProps:(const folly::dynamic &)props
54
+ - (void)setProps:(const folly::dynamic &)props propKeysToSkip:(nullable NSSet<NSString *> *)propKeysToSkip
49
55
  {
50
- if (props.isObject()) {
51
- NSDictionary<NSString *, id> *convertedProps = facebook::react::convertFollyDynamicToId(props);
52
- NSDictionary<NSString *, id> *diffedProps = [self _diffProps:convertedProps];
53
-
54
- [_coordinator setProps:diffedProps forView:self.paperView];
55
-
56
- _oldProps = convertedProps;
56
+ if (!props.isObject()) {
57
+ return;
58
+ }
59
+ folly::dynamic changedProps = RCTLegacyViewManagerInteropDiffProps(props, _sentProps, propKeysToSkip);
60
+ if (changedProps.empty()) {
61
+ return;
57
62
  }
63
+ [_coordinator setProps:facebook::react::convertFollyDynamicToId(changedProps) forView:self.paperView];
58
64
  }
59
65
 
60
66
  - (void)handleCommand:(NSString *)commandName args:(NSArray *)args
@@ -62,87 +68,24 @@
62
68
  [_coordinator handleCommand:commandName args:args reactTag:_tag paperView:self.paperView];
63
69
  }
64
70
 
65
- - (NSDictionary<NSString *, id> *)_diffProps:(NSDictionary<NSString *, id> *)newProps
66
- {
67
- NSMutableDictionary<NSString *, id> *diffedProps = [NSMutableDictionary new];
68
-
69
- [newProps enumerateKeysAndObjectsUsingBlock:^(NSString *key, id newProp, __unused BOOL *stop) {
70
- id oldProp = _oldProps[key];
71
- if ([self _prop:newProp isDifferentFrom:oldProp]) {
72
- diffedProps[key] = newProp;
73
- }
74
- }];
75
-
76
- return diffedProps;
77
- }
78
-
79
- #pragma mark - Private
71
+ @end
80
72
 
81
- - (BOOL)_prop:(id)oldProp isDifferentFrom:(id)newProp
73
+ folly::dynamic RCTLegacyViewManagerInteropDiffProps(
74
+ const folly::dynamic &props,
75
+ folly::dynamic &sentProps,
76
+ NSSet<NSString *> *_Nullable propKeysToSkip)
82
77
  {
83
- // Check for JSON types.
84
- // JSON types can be of:
85
- // * number
86
- // * bool
87
- // * String
88
- // * Array
89
- // * Objects => Dictionaries in ObjectiveC
90
- // * Null
91
-
92
- // Check for NULL
93
- BOOL bothNil = !oldProp && !newProp;
94
- if (bothNil) {
95
- return NO;
96
- }
97
-
98
- BOOL onlyOneNil = (oldProp && !newProp) || (!oldProp && newProp);
99
- if (onlyOneNil) {
100
- return YES;
101
- }
102
-
103
- if ([self _propIsSameNumber:oldProp second:newProp]) {
104
- // Boolean should be captured by NSNumber
105
- return NO;
106
- }
107
-
108
- if ([self _propIsSameString:oldProp second:newProp]) {
109
- return NO;
110
- }
111
-
112
- if ([self _propIsSameArray:oldProp second:newProp]) {
113
- return NO;
114
- }
115
-
116
- if ([self _propIsSameObject:oldProp second:newProp]) {
117
- return NO;
78
+ folly::dynamic changedProps = folly::dynamic::object();
79
+ for (const auto &[key, value] : props.items()) {
80
+ if (propKeysToSkip != nil && [propKeysToSkip containsObject:RCTNSStringFromString(key.asString())]) {
81
+ continue;
82
+ }
83
+ auto sentProp = sentProps.find(key);
84
+ if (sentProp != sentProps.items().end() && sentProp->second == value) {
85
+ continue;
86
+ }
87
+ changedProps[key] = value;
88
+ sentProps[key] = value;
118
89
  }
119
-
120
- // Previous behavior, fallback to YES
121
- return YES;
90
+ return changedProps;
122
91
  }
123
-
124
- - (BOOL)_propIsSameNumber:(id)first second:(id)second
125
- {
126
- return [first isKindOfClass:[NSNumber class]] && [second isKindOfClass:[NSNumber class]] &&
127
- [(NSNumber *)first isEqualToNumber:(NSNumber *)second];
128
- }
129
-
130
- - (BOOL)_propIsSameString:(id)first second:(id)second
131
- {
132
- return [first isKindOfClass:[NSString class]] && [second isKindOfClass:[NSString class]] &&
133
- [(NSString *)first isEqualToString:(NSString *)second];
134
- }
135
-
136
- - (BOOL)_propIsSameArray:(id)first second:(id)second
137
- {
138
- return [first isKindOfClass:[NSArray class]] && [second isKindOfClass:[NSArray class]] &&
139
- [(NSArray *)first isEqualToArray:(NSArray *)second];
140
- }
141
-
142
- - (BOOL)_propIsSameObject:(id)first second:(id)second
143
- {
144
- return [first isKindOfClass:[NSDictionary class]] && [second isKindOfClass:[NSDictionary class]] &&
145
- [(NSDictionary *)first isEqualToDictionary:(NSDictionary *)second];
146
- }
147
-
148
- @end
@@ -8,6 +8,7 @@
8
8
  #import <UIKit/UIKit.h>
9
9
 
10
10
  #import <React/RCTComponentViewProtocol.h>
11
+ #import <react/renderer/core/ReactPrimitives.h>
11
12
 
12
13
  NS_ASSUME_NONNULL_BEGIN
13
14
 
@@ -23,6 +24,13 @@ class RCTComponentViewDescriptor final {
23
24
  */
24
25
  __strong UIView<RCTComponentViewProtocol> *const view = nil;
25
26
 
27
+ /*
28
+ * The handle of the component descriptor this view was created for. Use this instead of the view class's
29
+ * `componentDescriptorProvider` handle: one class can serve several handles. For example, every legacy (Paper) view
30
+ * manager renders through RCTLegacyViewManagerInteropComponentView, but each one has its own handle.
31
+ */
32
+ const facebook::react::ComponentHandle componentHandle{};
33
+
26
34
  /*
27
35
  * Indicates a requirement to call on the view methods from
28
36
  * `RCTMountingTransactionObserving` protocol.
@@ -214,6 +214,7 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
214
214
 
215
215
  return RCTComponentViewDescriptor{
216
216
  .view = [viewClass new],
217
+ .componentHandle = componentHandle,
217
218
  .observesMountingTransactionWillMount = componentViewClassDescriptor.observesMountingTransactionWillMount,
218
219
  .observesMountingTransactionDidMount = componentViewClassDescriptor.observesMountingTransactionDidMount,
219
220
  .shouldBeRecycled = componentViewClassDescriptor.shouldBeRecycled,
@@ -7,6 +7,8 @@
7
7
 
8
8
  #import <UIKit/UIKit.h>
9
9
 
10
+ #import <optional>
11
+
10
12
  #import <React/RCTComponentViewDescriptor.h>
11
13
  #import <React/RCTComponentViewFactory.h>
12
14
  #import <React/RCTComponentViewProtocol.h>
@@ -50,6 +52,12 @@ NS_ASSUME_NONNULL_BEGIN
50
52
  */
51
53
  - (nullable UIView<RCTComponentViewProtocol> *)findComponentViewWithTag:(facebook::react::Tag)tag;
52
54
 
55
+ /**
56
+ * Finds the handle of the component descriptor that the view with given `tag` was created for.
57
+ * Returns `std::nullopt` if there is no registered component with the `tag`.
58
+ */
59
+ - (std::optional<facebook::react::ComponentHandle>)findComponentHandleWithTag:(facebook::react::Tag)tag;
60
+
53
61
  @end
54
62
 
55
63
  NS_ASSUME_NONNULL_END
@@ -87,6 +87,16 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
87
87
  return iterator->second.view;
88
88
  }
89
89
 
90
+ - (std::optional<ComponentHandle>)findComponentHandleWithTag:(Tag)tag
91
+ {
92
+ RCTAssertMainQueue();
93
+ auto iterator = _registry.find(tag);
94
+ if (iterator == _registry.end()) {
95
+ return std::nullopt;
96
+ }
97
+ return iterator->second.componentHandle;
98
+ }
99
+
90
100
  - (RCTComponentViewDescriptor)_dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
91
101
  {
92
102
  RCTAssertMainQueue();
@@ -161,13 +161,14 @@ using namespace facebook::react;
161
161
  return;
162
162
  }
163
163
 
164
- UIView<RCTComponentViewProtocol> *componentView =
165
- [_mountingManager.componentViewRegistry findComponentViewWithTag:tag];
166
- if (componentView == nil) {
164
+ std::optional<ComponentHandle> handle = [_mountingManager.componentViewRegistry findComponentHandleWithTag:tag];
165
+ if (!handle) {
167
166
  return; // This view probably isn't managed by Fabric
168
167
  }
169
- ComponentHandle handle = [[componentView class] componentDescriptorProvider].handle;
170
- auto *componentDescriptor = [scheduler findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN:handle];
168
+ // Use the handle the view was created for, not its class's handle. They differ for legacy interop views, like
169
+ // react-native-maps' iOS Google polylines: they share one class, but each legacy view manager has its own handle.
170
+ // The class's handle would find no descriptor, and we'd drop their native-driver Animated updates.
171
+ auto *componentDescriptor = [scheduler findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN:*handle];
171
172
 
172
173
  if (!componentDescriptor) {
173
174
  return;
@@ -58,6 +58,20 @@ using namespace facebook::react;
58
58
  XCTAssertEqual(newViewDescriptor.view, [_componentViewRegistry findComponentViewWithTag:existingTag]);
59
59
  }
60
60
 
61
+ - (void)testFindComponentHandleWithTag
62
+ {
63
+ Tag nonExistingTag = 12;
64
+ XCTAssertFalse([_componentViewRegistry findComponentHandleWithTag:nonExistingTag].has_value());
65
+
66
+ Tag existingTag = 2;
67
+ auto handle = [RCTViewComponentView componentDescriptorProvider].handle;
68
+ [_componentViewRegistry dequeueComponentViewWithComponentHandle:handle tag:existingTag];
69
+
70
+ auto foundHandle = [_componentViewRegistry findComponentHandleWithTag:existingTag];
71
+ XCTAssertTrue(foundHandle.has_value());
72
+ XCTAssertEqual(foundHandle.value_or(0), handle);
73
+ }
74
+
61
75
  - (void)testDequeueAndEnqueue
62
76
  {
63
77
  Tag existingTag = 2;
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.86.3-wanderlog.2
1
+ VERSION_NAME=0.86.3
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
  react.internal.hermesPublishingGroup=com.facebook.hermes
4
4
 
@@ -13,7 +13,9 @@ namespace facebook::react {
13
13
  /*
14
14
  * Installs UIManger constants provider into JavaScript runtime. This is needed
15
15
  * to implement UIManager.getConstants in bridgeless mode. The constants object
16
- * contains view configs for every legacy native component.
16
+ * contains view configs for every legacy native component. Also installs
17
+ * getConstantsForViewManager, which builds one view config, and
18
+ * getDefaultEventTypes.
17
19
  */
18
20
  void installLegacyUIManagerConstantsProviderBinding(jsi::Runtime &runtime);
19
21
  } // namespace facebook::react
@@ -17,27 +17,69 @@
17
17
  namespace facebook::react {
18
18
  namespace {
19
19
 
20
+ // Cached, since modules register in +load, before JS runs
21
+ NSDictionary<NSString *, Class> *getViewManagerClassesByName()
22
+ {
23
+ static NSDictionary<NSString *, Class> *viewManagerClassesByName;
24
+ static dispatch_once_t onceToken;
25
+ dispatch_once(&onceToken, ^{
26
+ NSMutableDictionary<NSString *, Class> *classesByName = [NSMutableDictionary new];
27
+ for (Class moduleClass in RCTGetModuleClasses()) {
28
+ if ([moduleClass isSubclassOfClass:RCTViewManager.class]) {
29
+ classesByName[RCTViewManagerModuleNameForClass(moduleClass)] = moduleClass;
30
+ }
31
+ }
32
+ viewManagerClassesByName = classesByName;
33
+ });
34
+ return viewManagerClassesByName;
35
+ }
36
+
37
+ NSMutableDictionary<NSString *, id> *viewConfigForViewManagerClass(
38
+ Class moduleClass,
39
+ NSString *name,
40
+ NSMutableDictionary<NSString *, NSDictionary *> *directEvents,
41
+ NSMutableDictionary<NSString *, NSDictionary *> *bubblingEvents)
42
+ {
43
+ auto viewConfig = [RCTComponentData viewConfigForViewMangerClass:moduleClass];
44
+ return RCTModuleConstantsForDestructuredComponent(directEvents, bubblingEvents, moduleClass, name, viewConfig);
45
+ }
46
+
20
47
  jsi::Value getConstants(facebook::jsi::Runtime &runtime)
21
48
  {
22
49
  NSMutableDictionary<NSString *, NSObject *> *result = [NSMutableDictionary new];
23
50
  auto directEvents = [NSMutableDictionary new];
24
51
  auto bubblingEvents = [NSMutableDictionary new];
25
- for (Class moduleClass in RCTGetModuleClasses()) {
26
- if ([moduleClass isSubclassOfClass:RCTViewManager.class]) {
27
- auto name = RCTViewManagerModuleNameForClass(moduleClass);
28
- auto viewConfig = [RCTComponentData viewConfigForViewMangerClass:moduleClass];
29
- auto moduleConstants =
30
- RCTModuleConstantsForDestructuredComponent(directEvents, bubblingEvents, moduleClass, name, viewConfig);
31
- result[name] = moduleConstants;
32
- }
33
- }
52
+ [getViewManagerClassesByName()
53
+ enumerateKeysAndObjectsUsingBlock:^(NSString *name, Class moduleClass, __unused BOOL *stop) {
54
+ result[name] = viewConfigForViewManagerClass(moduleClass, name, directEvents, bubblingEvents);
55
+ }];
34
56
  return TurboModuleConvertUtils::convertObjCObjectToJSIValue(runtime, result);
35
57
  };
36
58
 
59
+ jsi::Value getConstantsForViewManager(facebook::jsi::Runtime &runtime, const std::string &viewManagerName)
60
+ {
61
+ NSString *name = [NSString stringWithUTF8String:viewManagerName.c_str()];
62
+ Class moduleClass = getViewManagerClassesByName()[name];
63
+ if (moduleClass == nil) {
64
+ return jsi::Value::null();
65
+ }
66
+ return TurboModuleConvertUtils::convertObjCObjectToJSIValue(
67
+ runtime, viewConfigForViewManagerClass(moduleClass, name, [NSMutableDictionary new], [NSMutableDictionary new]));
68
+ }
69
+
70
+ // Empty, since iOS has no generic event types, unlike Android. Events every
71
+ // view supports, like touches, are in BaseViewConfig.ios.js.
72
+ jsi::Value getDefaultEventTypes(facebook::jsi::Runtime &runtime)
73
+ {
74
+ return jsi::Object(runtime);
75
+ }
76
+
37
77
  } // namespace
38
78
 
39
79
  void installLegacyUIManagerConstantsProviderBinding(jsi::Runtime &runtime)
40
80
  {
41
81
  LegacyUIManagerConstantsProviderBinding::install(runtime, "getConstants", getConstants);
82
+ LegacyUIManagerConstantsProviderBinding::install(runtime, "getConstantsForViewManager", getConstantsForViewManager);
83
+ LegacyUIManagerConstantsProviderBinding::install(runtime, "getDefaultEventTypes", getDefaultEventTypes);
42
84
  }
43
85
  } // namespace facebook::react
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wanderlogapp/react-native",
3
- "version": "0.86.3-wanderlog.2",
3
+ "version": "0.86.3-wanderlog.4",
4
4
  "description": "A framework for building native apps using React",
5
5
  "license": "MIT",
6
6
  "repository": {