Skip to content

Commit

Permalink
rename RCTWKWebView to CRAWKWebView to avoid symbol clash with RN 0.57
Browse files Browse the repository at this point in the history
  • Loading branch information
headlessme committed Sep 17, 2018
1 parent cdf33ef commit c3064f3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
18 changes: 9 additions & 9 deletions WKWebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'
import deprecatedPropType from 'react-native/Libraries/Utilities/deprecatedPropType';
import invariant from 'fbjs/lib/invariant';
import keyMirror from 'fbjs/lib/keyMirror';
const WKWebViewManager = NativeModules.WKWebViewManager;
const WKWebViewManager = NativeModules.CRAWKWebViewManager;

var BGWASH = 'rgba(255,255,255,0.8)';

Expand Down Expand Up @@ -295,7 +295,7 @@ class WKWebView extends React.Component {
);
} else if (this.state.viewState !== WebViewState.IDLE) {
console.error(
'RCTWKWebView invalid state encountered: ' + this.state.loading
'CRAWKWebView invalid state encountered: ' + this.state.loading
);
}

Expand Down Expand Up @@ -329,7 +329,7 @@ class WKWebView extends React.Component {
const messagingEnabled = typeof this.props.onMessage === 'function';

const webView =
<RCTWKWebView
<CRAWKWebView
ref={ref => { this.webview = ref; }}
key="webViewKey"
style={webViewStyles}
Expand Down Expand Up @@ -375,7 +375,7 @@ class WKWebView extends React.Component {
goForward = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWKWebView.Commands.goForward,
UIManager.CRAWKWebView.Commands.goForward,
null
);
};
Expand All @@ -386,7 +386,7 @@ class WKWebView extends React.Component {
goBack = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWKWebView.Commands.goBack,
UIManager.CRAWKWebView.Commands.goBack,
null
);
};
Expand All @@ -412,7 +412,7 @@ class WKWebView extends React.Component {
this.setState({ viewState: WebViewState.LOADING });
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWKWebView.Commands.reload,
UIManager.CRAWKWebView.Commands.reload,
null
);
};
Expand All @@ -423,7 +423,7 @@ class WKWebView extends React.Component {
stopLoading = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWKWebView.Commands.stopLoading,
UIManager.CRAWKWebView.Commands.stopLoading,
null
)
};
Expand All @@ -441,7 +441,7 @@ class WKWebView extends React.Component {
postMessage = (data) => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWKWebView.Commands.postMessage,
UIManager.CRAWKWebView.Commands.postMessage,
[String(data)]
);
};
Expand Down Expand Up @@ -517,7 +517,7 @@ class WKWebView extends React.Component {
}
}

const RCTWKWebView = requireNativeComponent('RCTWKWebView', WKWebView, {
const CRAWKWebView = requireNativeComponent('CRAWKWebView', WKWebView, {
nativeOnly: {
onLoadingStart: true,
onLoadingError: true,
Expand Down
10 changes: 5 additions & 5 deletions ios/RCTWKWebView/RCTWKWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#import <React/RCTView.h>

@class RCTWKWebView;
@class CRAWKWebView;

/**
* Special scheme used to pass messages to the injectedJavaScript
Expand All @@ -12,19 +12,19 @@
*/
extern NSString *const RCTJSNavigationScheme;

@protocol RCTWKWebViewDelegate <NSObject>
@protocol CRAWKWebViewDelegate <NSObject>

- (BOOL)webView:(RCTWKWebView *)webView
- (BOOL)webView:(CRAWKWebView *)webView
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
withCallback:(RCTDirectEventBlock)callback;

@end

@interface RCTWKWebView : RCTView
@interface CRAWKWebView : RCTView

- (instancetype)initWithProcessPool:(WKProcessPool *)processPool;

@property (nonatomic, weak) id<RCTWKWebViewDelegate> delegate;
@property (nonatomic, weak) id<CRAWKWebViewDelegate> delegate;

@property (nonatomic, copy) NSDictionary *source;
@property (nonatomic, assign) UIEdgeInsets contentInset;
Expand Down
4 changes: 2 additions & 2 deletions ios/RCTWKWebView/RCTWKWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ -(id)inputAccessoryView
}
@end

@interface RCTWKWebView () <WKNavigationDelegate, RCTAutoInsetsProtocol, WKScriptMessageHandler, WKUIDelegate, UIScrollViewDelegate>
@interface CRAWKWebView () <WKNavigationDelegate, RCTAutoInsetsProtocol, WKScriptMessageHandler, WKUIDelegate, UIScrollViewDelegate>

@property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
@property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
Expand All @@ -40,7 +40,7 @@ @interface RCTWKWebView () <WKNavigationDelegate, RCTAutoInsetsProtocol, WKScrip

@end

@implementation RCTWKWebView
@implementation CRAWKWebView
{
WKWebView *_webView;
BOOL _injectJavaScriptForMainFrameOnly;
Expand Down
2 changes: 1 addition & 1 deletion ios/RCTWKWebView/RCTWKWebViewManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

@end

@interface RCTWKWebViewManager : RCTViewManager
@interface CRAWKWebViewManager : RCTViewManager

@end
64 changes: 32 additions & 32 deletions ios/RCTWKWebView/RCTWKWebViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ @implementation RCTConvert (UIScrollView)

@end

@interface RCTWKWebViewManager () <RCTWKWebViewDelegate>
@interface CRAWKWebViewManager () <CRAWKWebViewDelegate>

@end

@implementation RCTWKWebViewManager
@implementation CRAWKWebViewManager
{
NSConditionLock *_shouldStartLoadLock;
BOOL _shouldStartLoad;
Expand All @@ -37,7 +37,7 @@ @implementation RCTWKWebViewManager

- (UIView *)view
{
RCTWKWebView *webView = [[RCTWKWebView alloc] initWithProcessPool:[WKProcessPool sharedProcessPool]];
CRAWKWebView *webView = [[CRAWKWebView alloc] initWithProcessPool:[WKProcessPool sharedProcessPool]];
webView.delegate = self;
return webView;
}
Expand Down Expand Up @@ -73,10 +73,10 @@ - (UIView *)view

RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWKWebView, got: %@", view);
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[CRAWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting CRAWKWebView, got: %@", view);
} else {
[view goBack];
}
Expand All @@ -85,10 +85,10 @@ - (UIView *)view

RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWKWebView, got: %@", view);
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[CRAWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting CRAWKWebView, got: %@", view);
} else {
[view goForward];
}
Expand All @@ -99,8 +99,8 @@ - (UIView *)view
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];

resolve([NSNumber numberWithBool:[view canGoBack]]);
}];
Expand All @@ -110,19 +110,19 @@ - (UIView *)view
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];

resolve([NSNumber numberWithBool:[view canGoForward]]);
}];
}

RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWKWebView, got: %@", view);
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[CRAWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting CRAWKWebView, got: %@", view);
} else {
[view reload];
}
Expand All @@ -131,10 +131,10 @@ - (UIView *)view

RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWKWebView, got: %@", view);
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[CRAWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting CRAWKWebView, got: %@", view);
} else {
[view stopLoading];
}
Expand All @@ -143,10 +143,10 @@ - (UIView *)view

RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[CRAWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting CRAWKWebView, got: %@", view);
} else {
[view postMessage:message];
}
Expand All @@ -158,10 +158,10 @@ - (UIView *)view
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
RCTWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[RCTWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting RCTWKWebView, got: %@", view);
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, CRAWKWebView *> *viewRegistry) {
CRAWKWebView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[CRAWKWebView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting CRAWKWebView, got: %@", view);
} else {
[view evaluateJavaScript:js completionHandler:^(id result, NSError *error) {
if (error) {
Expand All @@ -176,7 +176,7 @@ - (UIView *)view

#pragma mark - Exported synchronous methods

- (BOOL)webView:(__unused RCTWKWebView *)webView
- (BOOL)webView:(__unused CRAWKWebView *)webView
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
withCallback:(RCTDirectEventBlock)callback
{
Expand Down

0 comments on commit c3064f3

Please sign in to comment.