Browse Source

Rename back to RCT

Jamon Holmgren 6 years ago
parent
commit
e9a6c6134f

ios/IRWebView.h → ios/RCTWebView.h View File

7
 
7
 
8
 #import <React/RCTView.h>
8
 #import <React/RCTView.h>
9
 
9
 
10
-@class IRWebView;
10
+@class RCTWebView;
11
 
11
 
12
 /**
12
 /**
13
  * Special scheme used to pass messages to the injectedJavaScript
13
  * Special scheme used to pass messages to the injectedJavaScript
17
  */
17
  */
18
 extern NSString *const RCTJSNavigationScheme;
18
 extern NSString *const RCTJSNavigationScheme;
19
 
19
 
20
-@protocol IRWebViewDelegate <NSObject>
20
+@protocol RCTWebViewDelegate <NSObject>
21
 
21
 
22
-- (BOOL)webView:(IRWebView *)webView
22
+- (BOOL)webView:(RCTWebView *)webView
23
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
23
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
24
    withCallback:(RCTDirectEventBlock)callback;
24
    withCallback:(RCTDirectEventBlock)callback;
25
 
25
 
26
 @end
26
 @end
27
 
27
 
28
-@interface IRWebView : RCTView
28
+@interface RCTWebView : RCTView
29
 
29
 
30
-@property (nonatomic, weak) id<IRWebViewDelegate> delegate;
30
+@property (nonatomic, weak) id<RCTWebViewDelegate> delegate;
31
 
31
 
32
 @property (nonatomic, copy) NSDictionary *source;
32
 @property (nonatomic, copy) NSDictionary *source;
33
 @property (nonatomic, assign) UIEdgeInsets contentInset;
33
 @property (nonatomic, assign) UIEdgeInsets contentInset;

ios/IRWebView.m → ios/RCTWebView.m View File

5
  * LICENSE file in the root directory of this source tree.
5
  * LICENSE file in the root directory of this source tree.
6
  */
6
  */
7
 
7
 
8
-#import "IRWebView.h"
8
+#import "RCTWebView.h"
9
 
9
 
10
 #import <UIKit/UIKit.h>
10
 #import <UIKit/UIKit.h>
11
 
11
 
21
 
21
 
22
 static NSString *const kPostMessageHost = @"postMessage";
22
 static NSString *const kPostMessageHost = @"postMessage";
23
 
23
 
24
-@interface IRWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
24
+@interface RCTWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
25
 
25
 
26
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
26
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
27
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
27
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
31
 
31
 
32
 @end
32
 @end
33
 
33
 
34
-@implementation IRWebView
34
+@implementation RCTWebView
35
 {
35
 {
36
   UIWebView *_webView;
36
   UIWebView *_webView;
37
   NSString *_injectedJavaScript;
37
   NSString *_injectedJavaScript;

ios/IRWebView.podspec → ios/RCTWebView.podspec View File

1
 
1
 
2
 Pod::Spec.new do |s|
2
 Pod::Spec.new do |s|
3
-  s.name         = "IRWebView"
3
+  s.name         = "RCTWebView"
4
   s.version      = "1.0.0"
4
   s.version      = "1.0.0"
5
-  s.summary      = "IRWebView"
5
+  s.summary      = "RCTWebView"
6
   s.description  = <<-DESC
6
   s.description  = <<-DESC
7
-                  IRWebView
7
+                  RCTWebView
8
                    DESC
8
                    DESC
9
   s.homepage     = ""
9
   s.homepage     = ""
10
   s.license      = "MIT"
10
   s.license      = "MIT"
11
   # s.license      = { :type => "MIT", :file => "FILE_LICENSE" }
11
   # s.license      = { :type => "MIT", :file => "FILE_LICENSE" }
12
   s.author             = { "author" => "author@domain.cn" }
12
   s.author             = { "author" => "author@domain.cn" }
13
   s.platform     = :ios, "7.0"
13
   s.platform     = :ios, "7.0"
14
-  s.source       = { :git => "https://github.com/author/IRWebView.git", :tag => "master" }
15
-  s.source_files  = "IRWebView/**/*.{h,m}"
14
+  s.source       = { :git => "https://github.com/author/RCTWebView.git", :tag => "master" }
15
+  s.source_files  = "RCTWebView/**/*.{h,m}"
16
   s.requires_arc = true
16
   s.requires_arc = true
17
 
17
 
18
 
18
 

ios/IRWebView.xcodeproj/project.pbxproj → ios/RCTWebView.xcodeproj/project.pbxproj View File

7
 	objects = {
7
 	objects = {
8
 
8
 
9
 /* Begin PBXBuildFile section */
9
 /* Begin PBXBuildFile section */
10
-		B3E7B58A1CC2AC0600A0062D /* IRWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* IRWebView.m */; };
10
+		B3E7B58A1CC2AC0600A0062D /* RCTWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RCTWebView.m */; };
11
 /* End PBXBuildFile section */
11
 /* End PBXBuildFile section */
12
 
12
 
13
 /* Begin PBXCopyFilesBuildPhase section */
13
 /* Begin PBXCopyFilesBuildPhase section */
23
 /* End PBXCopyFilesBuildPhase section */
23
 /* End PBXCopyFilesBuildPhase section */
24
 
24
 
25
 /* Begin PBXFileReference section */
25
 /* Begin PBXFileReference section */
26
-		134814201AA4EA6300B7C361 /* libIRWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIRWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
-		B3E7B5881CC2AC0600A0062D /* IRWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRWebView.h; sourceTree = "<group>"; };
28
-		B3E7B5891CC2AC0600A0062D /* IRWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IRWebView.m; sourceTree = "<group>"; };
26
+		134814201AA4EA6300B7C361 /* libRCTWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
+		B3E7B5881CC2AC0600A0062D /* RCTWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebView.h; sourceTree = "<group>"; };
28
+		B3E7B5891CC2AC0600A0062D /* RCTWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWebView.m; sourceTree = "<group>"; };
29
 /* End PBXFileReference section */
29
 /* End PBXFileReference section */
30
 
30
 
31
 /* Begin PBXFrameworksBuildPhase section */
31
 /* Begin PBXFrameworksBuildPhase section */
42
 		134814211AA4EA7D00B7C361 /* Products */ = {
42
 		134814211AA4EA7D00B7C361 /* Products */ = {
43
 			isa = PBXGroup;
43
 			isa = PBXGroup;
44
 			children = (
44
 			children = (
45
-				134814201AA4EA6300B7C361 /* libIRWebView.a */,
45
+				134814201AA4EA6300B7C361 /* libRCTWebView.a */,
46
 			);
46
 			);
47
 			name = Products;
47
 			name = Products;
48
 			sourceTree = "<group>";
48
 			sourceTree = "<group>";
50
 		58B511D21A9E6C8500147676 = {
50
 		58B511D21A9E6C8500147676 = {
51
 			isa = PBXGroup;
51
 			isa = PBXGroup;
52
 			children = (
52
 			children = (
53
-				B3E7B5881CC2AC0600A0062D /* IRWebView.h */,
54
-				B3E7B5891CC2AC0600A0062D /* IRWebView.m */,
53
+				B3E7B5881CC2AC0600A0062D /* RCTWebView.h */,
54
+				B3E7B5891CC2AC0600A0062D /* RCTWebView.m */,
55
 				134814211AA4EA7D00B7C361 /* Products */,
55
 				134814211AA4EA7D00B7C361 /* Products */,
56
 			);
56
 			);
57
 			sourceTree = "<group>";
57
 			sourceTree = "<group>";
59
 /* End PBXGroup section */
59
 /* End PBXGroup section */
60
 
60
 
61
 /* Begin PBXNativeTarget section */
61
 /* Begin PBXNativeTarget section */
62
-		58B511DA1A9E6C8500147676 /* IRWebView */ = {
62
+		58B511DA1A9E6C8500147676 /* RCTWebView */ = {
63
 			isa = PBXNativeTarget;
63
 			isa = PBXNativeTarget;
64
-			buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "IRWebView" */;
64
+			buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTWebView" */;
65
 			buildPhases = (
65
 			buildPhases = (
66
 				58B511D71A9E6C8500147676 /* Sources */,
66
 				58B511D71A9E6C8500147676 /* Sources */,
67
 				58B511D81A9E6C8500147676 /* Frameworks */,
67
 				58B511D81A9E6C8500147676 /* Frameworks */,
71
 			);
71
 			);
72
 			dependencies = (
72
 			dependencies = (
73
 			);
73
 			);
74
-			name = IRWebView;
74
+			name = RCTWebView;
75
 			productName = RCTDataManager;
75
 			productName = RCTDataManager;
76
-			productReference = 134814201AA4EA6300B7C361 /* libIRWebView.a */;
76
+			productReference = 134814201AA4EA6300B7C361 /* libRCTWebView.a */;
77
 			productType = "com.apple.product-type.library.static";
77
 			productType = "com.apple.product-type.library.static";
78
 		};
78
 		};
79
 /* End PBXNativeTarget section */
79
 /* End PBXNativeTarget section */
90
 					};
90
 					};
91
 				};
91
 				};
92
 			};
92
 			};
93
-			buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "IRWebView" */;
93
+			buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTWebView" */;
94
 			compatibilityVersion = "Xcode 3.2";
94
 			compatibilityVersion = "Xcode 3.2";
95
 			developmentRegion = English;
95
 			developmentRegion = English;
96
 			hasScannedForEncodings = 0;
96
 			hasScannedForEncodings = 0;
102
 			projectDirPath = "";
102
 			projectDirPath = "";
103
 			projectRoot = "";
103
 			projectRoot = "";
104
 			targets = (
104
 			targets = (
105
-				58B511DA1A9E6C8500147676 /* IRWebView */,
105
+				58B511DA1A9E6C8500147676 /* RCTWebView */,
106
 			);
106
 			);
107
 		};
107
 		};
108
 /* End PBXProject section */
108
 /* End PBXProject section */
112
 			isa = PBXSourcesBuildPhase;
112
 			isa = PBXSourcesBuildPhase;
113
 			buildActionMask = 2147483647;
113
 			buildActionMask = 2147483647;
114
 			files = (
114
 			files = (
115
-				B3E7B58A1CC2AC0600A0062D /* IRWebView.m in Sources */,
115
+				B3E7B58A1CC2AC0600A0062D /* RCTWebView.m in Sources */,
116
 			);
116
 			);
117
 			runOnlyForDeploymentPostprocessing = 0;
117
 			runOnlyForDeploymentPostprocessing = 0;
118
 		};
118
 		};
211
 				);
211
 				);
212
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
212
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
213
 				OTHER_LDFLAGS = "-ObjC";
213
 				OTHER_LDFLAGS = "-ObjC";
214
-				PRODUCT_NAME = IRWebView;
214
+				PRODUCT_NAME = RCTWebView;
215
 				SKIP_INSTALL = YES;
215
 				SKIP_INSTALL = YES;
216
 			};
216
 			};
217
 			name = Debug;
217
 			name = Debug;
227
 				);
227
 				);
228
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
228
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
229
 				OTHER_LDFLAGS = "-ObjC";
229
 				OTHER_LDFLAGS = "-ObjC";
230
-				PRODUCT_NAME = IRWebView;
230
+				PRODUCT_NAME = RCTWebView;
231
 				SKIP_INSTALL = YES;
231
 				SKIP_INSTALL = YES;
232
 			};
232
 			};
233
 			name = Release;
233
 			name = Release;
235
 /* End XCBuildConfiguration section */
235
 /* End XCBuildConfiguration section */
236
 
236
 
237
 /* Begin XCConfigurationList section */
237
 /* Begin XCConfigurationList section */
238
-		58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "IRWebView" */ = {
238
+		58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTWebView" */ = {
239
 			isa = XCConfigurationList;
239
 			isa = XCConfigurationList;
240
 			buildConfigurations = (
240
 			buildConfigurations = (
241
 				58B511ED1A9E6C8500147676 /* Debug */,
241
 				58B511ED1A9E6C8500147676 /* Debug */,
244
 			defaultConfigurationIsVisible = 0;
244
 			defaultConfigurationIsVisible = 0;
245
 			defaultConfigurationName = Release;
245
 			defaultConfigurationName = Release;
246
 		};
246
 		};
247
-		58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "IRWebView" */ = {
247
+		58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTWebView" */ = {
248
 			isa = XCConfigurationList;
248
 			isa = XCConfigurationList;
249
 			buildConfigurations = (
249
 			buildConfigurations = (
250
 				58B511F01A9E6C8500147676 /* Debug */,
250
 				58B511F01A9E6C8500147676 /* Debug */,

ios/IRWebView.xcworkspace/contents.xcworkspacedata → ios/RCTWebView.xcworkspace/contents.xcworkspacedata View File

3
 <Workspace
3
 <Workspace
4
    version = "1.0">
4
    version = "1.0">
5
    <FileRef
5
    <FileRef
6
-      location = "group:IRWebView.xcodeproj">
6
+      location = "group:RCTWebView.xcodeproj">
7
    </FileRef>
7
    </FileRef>
8
 </Workspace>
8
 </Workspace>
9
   
9
   

ios/IRWebViewManager.h → ios/RCTWebViewManager.h View File

5
  * LICENSE file in the root directory of this source tree.
5
  * LICENSE file in the root directory of this source tree.
6
  */
6
  */
7
 
7
 
8
-#import <React/IRViewManager.h>
8
+#import <React/RCTViewManager.h>
9
 
9
 
10
-@interface IRWebViewManager : IRViewManager
10
+@interface RCTWebViewManager : RCTViewManager
11
 
11
 
12
 @end
12
 @end

ios/IRWebViewManager.m → ios/RCTWebViewManager.m View File

5
  * LICENSE file in the root directory of this source tree.
5
  * LICENSE file in the root directory of this source tree.
6
  */
6
  */
7
 
7
 
8
-#import "IRWebViewManager.h"
8
+#import "RCTWebViewManager.h"
9
 
9
 
10
 #import "RCTBridge.h"
10
 #import "RCTBridge.h"
11
 #import "RCTUIManager.h"
11
 #import "RCTUIManager.h"
12
-#import "IRWebView.h"
12
+#import "RCTWebView.h"
13
 #import "UIView+React.h"
13
 #import "UIView+React.h"
14
 
14
 
15
-@interface IRWebViewManager () <IRWebViewDelegate>
15
+@interface RCTWebViewManager () <RCTWebViewDelegate>
16
 
16
 
17
 @end
17
 @end
18
 
18
 
19
-@implementation IRWebViewManager
19
+@implementation RCTWebViewManager
20
 {
20
 {
21
   NSConditionLock *_shouldStartLoadLock;
21
   NSConditionLock *_shouldStartLoadLock;
22
   BOOL _shouldStartLoad;
22
   BOOL _shouldStartLoad;
26
 
26
 
27
 - (UIView *)view
27
 - (UIView *)view
28
 {
28
 {
29
-  IRWebView *webView = [IRWebView new];
29
+  RCTWebView *webView = [RCTWebView new];
30
   webView.delegate = self;
30
   webView.delegate = self;
31
   return webView;
31
   return webView;
32
 }
32
 }
51
 
51
 
52
 RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
52
 RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
53
 {
53
 {
54
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
55
-    IRWebView *view = viewRegistry[reactTag];
56
-    if (![view isKindOfClass:[IRWebView class]]) {
57
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
54
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
55
+    RCTWebView *view = viewRegistry[reactTag];
56
+    if (![view isKindOfClass:[RCTWebView class]]) {
57
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
58
     } else {
58
     } else {
59
       [view goBack];
59
       [view goBack];
60
     }
60
     }
65
 {
65
 {
66
   [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
66
   [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
67
     id view = viewRegistry[reactTag];
67
     id view = viewRegistry[reactTag];
68
-    if (![view isKindOfClass:[IRWebView class]]) {
69
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
68
+    if (![view isKindOfClass:[RCTWebView class]]) {
69
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
70
     } else {
70
     } else {
71
       [view goForward];
71
       [view goForward];
72
     }
72
     }
75
 
75
 
76
 RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
76
 RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
77
 {
77
 {
78
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
79
-    IRWebView *view = viewRegistry[reactTag];
80
-    if (![view isKindOfClass:[IRWebView class]]) {
81
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
78
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
79
+    RCTWebView *view = viewRegistry[reactTag];
80
+    if (![view isKindOfClass:[RCTWebView class]]) {
81
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
82
     } else {
82
     } else {
83
       [view reload];
83
       [view reload];
84
     }
84
     }
87
 
87
 
88
 RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
88
 RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
89
 {
89
 {
90
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
91
-    IRWebView *view = viewRegistry[reactTag];
92
-    if (![view isKindOfClass:[IRWebView class]]) {
93
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
90
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
91
+    RCTWebView *view = viewRegistry[reactTag];
92
+    if (![view isKindOfClass:[RCTWebView class]]) {
93
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
94
     } else {
94
     } else {
95
       [view stopLoading];
95
       [view stopLoading];
96
     }
96
     }
99
 
99
 
100
 RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
100
 RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
101
 {
101
 {
102
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
103
-    IRWebView *view = viewRegistry[reactTag];
104
-    if (![view isKindOfClass:[IRWebView class]]) {
105
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
102
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
103
+    RCTWebView *view = viewRegistry[reactTag];
104
+    if (![view isKindOfClass:[RCTWebView class]]) {
105
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
106
     } else {
106
     } else {
107
       [view postMessage:message];
107
       [view postMessage:message];
108
     }
108
     }
111
 
111
 
112
 RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
112
 RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
113
 {
113
 {
114
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, IRWebView *> *viewRegistry) {
115
-    IRWebView *view = viewRegistry[reactTag];
116
-    if (![view isKindOfClass:[IRWebView class]]) {
117
-      RCTLogError(@"Invalid view returned from registry, expecting IRWebView, got: %@", view);
114
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
115
+    RCTWebView *view = viewRegistry[reactTag];
116
+    if (![view isKindOfClass:[RCTWebView class]]) {
117
+      RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
118
     } else {
118
     } else {
119
       [view injectJavaScript:script];
119
       [view injectJavaScript:script];
120
     }
120
     }
123
 
123
 
124
 #pragma mark - Exported synchronous methods
124
 #pragma mark - Exported synchronous methods
125
 
125
 
126
-- (BOOL)webView:(__unused IRWebView *)webView
126
+- (BOOL)webView:(__unused RCTWebView *)webView
127
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
127
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
128
    withCallback:(RCTDirectEventBlock)callback
128
    withCallback:(RCTDirectEventBlock)callback
129
 {
129
 {

+ 0
- 46
ios/fb/RCTWebView.h View File

1
-// /**
2
-//  * Copyright (c) 2015-present, Facebook, Inc.
3
-//  *
4
-//  * This source code is licensed under the MIT license found in the
5
-//  * LICENSE file in the root directory of this source tree.
6
-//  */
7
-
8
-// #import <React/RCTView.h>
9
-
10
-// @class IRWebView;
11
-
12
-// /**
13
-//  * Special scheme used to pass messages to the injectedJavaScript
14
-//  * code without triggering a page load. Usage:
15
-//  *
16
-//  *   window.location.href = RCTJSNavigationScheme + '://hello'
17
-//  */
18
-// extern NSString *const RCTJSNavigationScheme;
19
-
20
-// @protocol IRWebViewDelegate <NSObject>
21
-
22
-// - (BOOL)webView:(IRWebView *)webView
23
-// shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
24
-//    withCallback:(RCTDirectEventBlock)callback;
25
-
26
-// @end
27
-
28
-// @interface IRWebView : RCTView
29
-
30
-// @property (nonatomic, weak) id<IRWebViewDelegate> delegate;
31
-
32
-// @property (nonatomic, copy) NSDictionary *source;
33
-// @property (nonatomic, assign) UIEdgeInsets contentInset;
34
-// @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
35
-// @property (nonatomic, assign) BOOL messagingEnabled;
36
-// @property (nonatomic, copy) NSString *injectedJavaScript;
37
-// @property (nonatomic, assign) BOOL scalesPageToFit;
38
-
39
-// - (void)goForward;
40
-// - (void)goBack;
41
-// - (void)reload;
42
-// - (void)stopLoading;
43
-// - (void)postMessage:(NSString *)message;
44
-// - (void)injectJavaScript:(NSString *)script;
45
-
46
-// @end

+ 0
- 351
ios/fb/RCTWebView.m View File

1
-// /**
2
-//  * Copyright (c) 2015-present, Facebook, Inc.
3
-//  *
4
-//  * This source code is licensed under the MIT license found in the
5
-//  * LICENSE file in the root directory of this source tree.
6
-//  */
7
-
8
-// #import "IRWebView.h"
9
-
10
-// #import <UIKit/UIKit.h>
11
-
12
-// #import "RCTAutoInsetsProtocol.h"
13
-// #import "RCTConvert.h"
14
-// #import "RCTEventDispatcher.h"
15
-// #import "RCTLog.h"
16
-// #import "RCTUtils.h"
17
-// #import "RCTView.h"
18
-// #import "UIView+React.h"
19
-
20
-// NSString *const RCTJSNavigationScheme = @"react-js-navigation";
21
-
22
-// static NSString *const kPostMessageHost = @"postMessage";
23
-
24
-// @interface IRWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
25
-
26
-// @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
27
-// @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
28
-// @property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
29
-// @property (nonatomic, copy) RCTDirectEventBlock onShouldStartLoadWithRequest;
30
-// @property (nonatomic, copy) RCTDirectEventBlock onMessage;
31
-
32
-// @end
33
-
34
-// @implementation IRWebView
35
-// {
36
-//   UIWebView *_webView;
37
-//   NSString *_injectedJavaScript;
38
-// }
39
-
40
-// - (void)dealloc
41
-// {
42
-//   _webView.delegate = nil;
43
-// }
44
-
45
-// - (instancetype)initWithFrame:(CGRect)frame
46
-// {
47
-//   if ((self = [super initWithFrame:frame])) {
48
-//     super.backgroundColor = [UIColor clearColor];
49
-//     _automaticallyAdjustContentInsets = YES;
50
-//     _contentInset = UIEdgeInsetsZero;
51
-//     _webView = [[UIWebView alloc] initWithFrame:self.bounds];
52
-//     _webView.delegate = self;
53
-// #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
54
-//     if ([_webView.scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
55
-//       _webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
56
-//     }
57
-// #endif
58
-//     [self addSubview:_webView];
59
-//   }
60
-//   return self;
61
-// }
62
-
63
-// RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
64
-
65
-// - (void)goForward
66
-// {
67
-//   [_webView goForward];
68
-// }
69
-
70
-// - (void)goBack
71
-// {
72
-//   [_webView goBack];
73
-// }
74
-
75
-// - (void)reload
76
-// {
77
-//   NSURLRequest *request = [RCTConvert NSURLRequest:self.source];
78
-//   if (request.URL && !_webView.request.URL.absoluteString.length) {
79
-//     [_webView loadRequest:request];
80
-//   }
81
-//   else {
82
-//     [_webView reload];
83
-//   }
84
-// }
85
-
86
-// - (void)stopLoading
87
-// {
88
-//   [_webView stopLoading];
89
-// }
90
-
91
-// - (void)postMessage:(NSString *)message
92
-// {
93
-//   NSDictionary *eventInitDict = @{
94
-//     @"data": message,
95
-//   };
96
-//   NSString *source = [NSString
97
-//     stringWithFormat:@"document.dispatchEvent(new MessageEvent('message', %@));",
98
-//     RCTJSONStringify(eventInitDict, NULL)
99
-//   ];
100
-//   [_webView stringByEvaluatingJavaScriptFromString:source];
101
-// }
102
-
103
-// - (void)injectJavaScript:(NSString *)script
104
-// {
105
-//   [_webView stringByEvaluatingJavaScriptFromString:script];
106
-// }
107
-
108
-// - (void)setSource:(NSDictionary *)source
109
-// {
110
-//   if (![_source isEqualToDictionary:source]) {
111
-//     _source = [source copy];
112
-
113
-//     // Check for a static html source first
114
-//     NSString *html = [RCTConvert NSString:source[@"html"]];
115
-//     if (html) {
116
-//       NSURL *baseURL = [RCTConvert NSURL:source[@"baseUrl"]];
117
-//       if (!baseURL) {
118
-//         baseURL = [NSURL URLWithString:@"about:blank"];
119
-//       }
120
-//       [_webView loadHTMLString:html baseURL:baseURL];
121
-//       return;
122
-//     }
123
-
124
-//     NSURLRequest *request = [RCTConvert NSURLRequest:source];
125
-//     // Because of the way React works, as pages redirect, we actually end up
126
-//     // passing the redirect urls back here, so we ignore them if trying to load
127
-//     // the same url. We'll expose a call to 'reload' to allow a user to load
128
-//     // the existing page.
129
-//     if ([request.URL isEqual:_webView.request.URL]) {
130
-//       return;
131
-//     }
132
-//     if (!request.URL) {
133
-//       // Clear the webview
134
-//       [_webView loadHTMLString:@"" baseURL:nil];
135
-//       return;
136
-//     }
137
-//     [_webView loadRequest:request];
138
-//   }
139
-// }
140
-
141
-// - (void)layoutSubviews
142
-// {
143
-//   [super layoutSubviews];
144
-//   _webView.frame = self.bounds;
145
-// }
146
-
147
-// - (void)setContentInset:(UIEdgeInsets)contentInset
148
-// {
149
-//   _contentInset = contentInset;
150
-//   [RCTView autoAdjustInsetsForView:self
151
-//                     withScrollView:_webView.scrollView
152
-//                       updateOffset:NO];
153
-// }
154
-
155
-// - (void)setScalesPageToFit:(BOOL)scalesPageToFit
156
-// {
157
-//   if (_webView.scalesPageToFit != scalesPageToFit) {
158
-//     _webView.scalesPageToFit = scalesPageToFit;
159
-//     [_webView reload];
160
-//   }
161
-// }
162
-
163
-// - (BOOL)scalesPageToFit
164
-// {
165
-//   return _webView.scalesPageToFit;
166
-// }
167
-
168
-// - (void)setBackgroundColor:(UIColor *)backgroundColor
169
-// {
170
-//   CGFloat alpha = CGColorGetAlpha(backgroundColor.CGColor);
171
-//   self.opaque = _webView.opaque = (alpha == 1.0);
172
-//   _webView.backgroundColor = backgroundColor;
173
-// }
174
-
175
-// - (UIColor *)backgroundColor
176
-// {
177
-//   return _webView.backgroundColor;
178
-// }
179
-
180
-// - (NSMutableDictionary<NSString *, id> *)baseEvent
181
-// {
182
-//   NSMutableDictionary<NSString *, id> *event = [[NSMutableDictionary alloc] initWithDictionary:@{
183
-//     @"url": _webView.request.URL.absoluteString ?: @"",
184
-//     @"loading" : @(_webView.loading),
185
-//     @"title": [_webView stringByEvaluatingJavaScriptFromString:@"document.title"],
186
-//     @"canGoBack": @(_webView.canGoBack),
187
-//     @"canGoForward" : @(_webView.canGoForward),
188
-//   }];
189
-
190
-//   return event;
191
-// }
192
-
193
-// - (void)refreshContentInset
194
-// {
195
-//   [RCTView autoAdjustInsetsForView:self
196
-//                     withScrollView:_webView.scrollView
197
-//                       updateOffset:YES];
198
-// }
199
-
200
-// #pragma mark - UIWebViewDelegate methods
201
-
202
-// - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
203
-//  navigationType:(UIWebViewNavigationType)navigationType
204
-// {
205
-//   BOOL isJSNavigation = [request.URL.scheme isEqualToString:RCTJSNavigationScheme];
206
-
207
-//   static NSDictionary<NSNumber *, NSString *> *navigationTypes;
208
-//   static dispatch_once_t onceToken;
209
-//   dispatch_once(&onceToken, ^{
210
-//     navigationTypes = @{
211
-//       @(UIWebViewNavigationTypeLinkClicked): @"click",
212
-//       @(UIWebViewNavigationTypeFormSubmitted): @"formsubmit",
213
-//       @(UIWebViewNavigationTypeBackForward): @"backforward",
214
-//       @(UIWebViewNavigationTypeReload): @"reload",
215
-//       @(UIWebViewNavigationTypeFormResubmitted): @"formresubmit",
216
-//       @(UIWebViewNavigationTypeOther): @"other",
217
-//     };
218
-//   });
219
-
220
-//   // skip this for the JS Navigation handler
221
-//   if (!isJSNavigation && _onShouldStartLoadWithRequest) {
222
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
223
-//     [event addEntriesFromDictionary: @{
224
-//       @"url": (request.URL).absoluteString,
225
-//       @"navigationType": navigationTypes[@(navigationType)]
226
-//     }];
227
-//     if (![self.delegate webView:self
228
-//       shouldStartLoadForRequest:event
229
-//                    withCallback:_onShouldStartLoadWithRequest]) {
230
-//       return NO;
231
-//     }
232
-//   }
233
-
234
-//   if (_onLoadingStart) {
235
-//     // We have this check to filter out iframe requests and whatnot
236
-//     BOOL isTopFrame = [request.URL isEqual:request.mainDocumentURL];
237
-//     if (isTopFrame) {
238
-//       NSMutableDictionary<NSString *, id> *event = [self baseEvent];
239
-//       [event addEntriesFromDictionary: @{
240
-//         @"url": (request.URL).absoluteString,
241
-//         @"navigationType": navigationTypes[@(navigationType)]
242
-//       }];
243
-//       _onLoadingStart(event);
244
-//     }
245
-//   }
246
-
247
-//   if (isJSNavigation && [request.URL.host isEqualToString:kPostMessageHost]) {
248
-//     NSString *data = request.URL.query;
249
-//     data = [data stringByReplacingOccurrencesOfString:@"+" withString:@" "];
250
-//     data = [data stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
251
-
252
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
253
-//     [event addEntriesFromDictionary: @{
254
-//       @"data": data,
255
-//     }];
256
-
257
-//     NSString *source = @"document.dispatchEvent(new MessageEvent('message:received'));";
258
-
259
-//     [_webView stringByEvaluatingJavaScriptFromString:source];
260
-
261
-//     _onMessage(event);
262
-//   }
263
-
264
-//   // JS Navigation handler
265
-//   return !isJSNavigation;
266
-// }
267
-
268
-// - (void)webView:(__unused UIWebView *)webView didFailLoadWithError:(NSError *)error
269
-// {
270
-//   if (_onLoadingError) {
271
-//     if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled) {
272
-//       // NSURLErrorCancelled is reported when a page has a redirect OR if you load
273
-//       // a new URL in the WebView before the previous one came back. We can just
274
-//       // ignore these since they aren't real errors.
275
-//       // http://stackoverflow.com/questions/1024748/how-do-i-fix-nsurlerrordomain-error-999-in-iphone-3-0-os
276
-//       return;
277
-//     }
278
-
279
-//     if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) {
280
-//       // Error code 102 "Frame load interrupted" is raised by the UIWebView if
281
-//       // its delegate returns FALSE from webView:shouldStartLoadWithRequest:navigationType
282
-//       // when the URL is from an http redirect. This is a common pattern when
283
-//       // implementing OAuth with a WebView.
284
-//       return;
285
-//     }
286
-
287
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
288
-//     [event addEntriesFromDictionary:@{
289
-//       @"domain": error.domain,
290
-//       @"code": @(error.code),
291
-//       @"description": error.localizedDescription,
292
-//     }];
293
-//     _onLoadingError(event);
294
-//   }
295
-// }
296
-
297
-// - (void)webViewDidFinishLoad:(UIWebView *)webView
298
-// {
299
-//   if (_messagingEnabled) {
300
-//     #if RCT_DEV
301
-//     // See isNative in lodash
302
-//     NSString *testPostMessageNative = @"String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
303
-//     BOOL postMessageIsNative = [
304
-//       [webView stringByEvaluatingJavaScriptFromString:testPostMessageNative]
305
-//       isEqualToString:@"true"
306
-//     ];
307
-//     if (!postMessageIsNative) {
308
-//       RCTLogError(@"Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
309
-//     }
310
-//     #endif
311
-//     NSString *source = [NSString stringWithFormat:
312
-//       @"(function() {"
313
-//         "window.originalPostMessage = window.postMessage;"
314
-
315
-//         "var messageQueue = [];"
316
-//         "var messagePending = false;"
317
-
318
-//         "function processQueue() {"
319
-//           "if (!messageQueue.length || messagePending) return;"
320
-//           "messagePending = true;"
321
-//           "window.location = '%@://%@?' + encodeURIComponent(messageQueue.shift());"
322
-//         "}"
323
-
324
-//         "window.postMessage = function(data) {"
325
-//           "messageQueue.push(String(data));"
326
-//           "processQueue();"
327
-//         "};"
328
-
329
-//         "document.addEventListener('message:received', function(e) {"
330
-//           "messagePending = false;"
331
-//           "processQueue();"
332
-//         "});"
333
-//       "})();", RCTJSNavigationScheme, kPostMessageHost
334
-//     ];
335
-//     [webView stringByEvaluatingJavaScriptFromString:source];
336
-//   }
337
-//   if (_injectedJavaScript != nil) {
338
-//     NSString *jsEvaluationValue = [webView stringByEvaluatingJavaScriptFromString:_injectedJavaScript];
339
-
340
-//     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
341
-//     event[@"jsEvaluationValue"] = jsEvaluationValue;
342
-
343
-//     _onLoadingFinish(event);
344
-//   }
345
-//   // we only need the final 'finishLoad' call so only fire the event when we're actually done loading.
346
-//   else if (_onLoadingFinish && !webView.loading && ![webView.request.URL.absoluteString isEqualToString:@"about:blank"]) {
347
-//     _onLoadingFinish([self baseEvent]);
348
-//   }
349
-// }
350
-
351
-// @end