Skip to content

Commit

Permalink
Remove <Webkit/Webkit.h> import in RCTConvert.h (#39794)
Browse files Browse the repository at this point in the history
Summary:
This PR is in response to #39758 (comment) .

`RCTConvert.h` currently takes an import of `<Webkit/Webkit.h>` for... one enum: `WKDataDetectorTypes`. This has a few problems:

1) RCTConvert is JS engine agnostic, it shouldn't be depending on Webkit
2) As far as I can tell, this code is dead, we also define (and use) the UIKit equivalent `UIDataDetectorTypes`.

Let's just combine the two, update some JS typing, and get rid of the Webkit header import.

## Changelog:

[IOS] [CHANGED] - Remove `<Webkit/Webkit.h>` import in `RCTConvert.h`

Pull Request resolved: #39794

Test Plan: CI should pass

Reviewed By: rshest

Differential Revision: D49898701

Pulled By: NickGerleman

fbshipit-source-id: 5420cb62317e1186426aae019bcc43d27c49ea26
  • Loading branch information
Saadnajmi authored and facebook-github-bot committed Oct 4, 2023
1 parent acb88d4 commit 452bf0f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ type DataDetectorTypes =
| 'link'
| 'address'
| 'calendarEvent'
| 'trackingNumber'
| 'flightNumber'
| 'lookupSuggestion'
| 'none'
| 'all';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type DataDetectorTypesType =
| 'link'
| 'address'
| 'calendarEvent'
| 'trackingNumber'
| 'flightNumber'
| 'lookupSuggestion'
| 'none'
| 'all';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ type DataDetectorTypesType =
| 'link'
| 'address'
| 'calendarEvent'
| 'trackingNumber'
| 'flightNumber'
| 'lookupSuggestion'
| 'none'
| 'all';

Expand Down
7 changes: 0 additions & 7 deletions packages/react-native/React/Base/RCTConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#import <React/RCTPointerEvents.h>
#import <React/RCTTextDecorationLineType.h>
#import <yoga/Yoga.h>
#if TARGET_OS_IPHONE
#import <WebKit/WebKit.h>
#endif

/**
* This class provides a collection of conversion functions for mapping
Expand Down Expand Up @@ -78,10 +75,6 @@ typedef NSURL RCTFileURL;
+ (UIDataDetectorTypes)UIDataDetectorTypes:(id)json;
#endif

#if TARGET_OS_IPHONE
+ (WKDataDetectorTypes)WKDataDetectorTypes:(id)json;
#endif

+ (UIViewContentMode)UIViewContentMode:(id)json;
#if !TARGET_OS_TV
+ (UIBarStyle)UIBarStyle:(id)json;
Expand Down
19 changes: 3 additions & 16 deletions packages/react-native/React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,28 +450,15 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
@"link" : @(UIDataDetectorTypeLink),
@"address" : @(UIDataDetectorTypeAddress),
@"calendarEvent" : @(UIDataDetectorTypeCalendarEvent),
@"trackingNumber" : @(UIDataDetectorTypeShipmentTrackingNumber),
@"flightNumber" : @(UIDataDetectorTypeFlightNumber),
@"lookupSuggestion" : @(UIDataDetectorTypeLookupSuggestion),
@"none" : @(UIDataDetectorTypeNone),
@"all" : @(UIDataDetectorTypeAll),
}),
UIDataDetectorTypePhoneNumber,
unsignedLongLongValue)

RCT_MULTI_ENUM_CONVERTER(
WKDataDetectorTypes,
(@{
@"phoneNumber" : @(WKDataDetectorTypePhoneNumber),
@"link" : @(WKDataDetectorTypeLink),
@"address" : @(WKDataDetectorTypeAddress),
@"calendarEvent" : @(WKDataDetectorTypeCalendarEvent),
@"trackingNumber" : @(WKDataDetectorTypeTrackingNumber),
@"flightNumber" : @(WKDataDetectorTypeFlightNumber),
@"lookupSuggestion" : @(WKDataDetectorTypeLookupSuggestion),
@"none" : @(WKDataDetectorTypeNone),
@"all" : @(WKDataDetectorTypeAll),
}),
WKDataDetectorTypePhoneNumber,
unsignedLongLongValue)

RCT_ENUM_CONVERTER(
UIKeyboardAppearance,
(@{
Expand Down

0 comments on commit 452bf0f

Please sign in to comment.