@exodus/react-native-webview 11.26.1-exodus.9 → 13.16.0-exodus.1

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.
Files changed (94) hide show
  1. package/README.md +36 -63
  2. package/android/build.gradle +83 -110
  3. package/android/gradle.properties +3 -4
  4. package/android/src/main/AndroidManifest.xml +12 -0
  5. package/android/src/main/AndroidManifestNew.xml +26 -0
  6. package/android/src/main/java/com/reactnativecommunity/webview/RNCBasicAuthCredential.java +11 -0
  7. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +407 -0
  8. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java +468 -0
  9. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java +330 -0
  10. package/android/src/main/java/com/reactnativecommunity/webview/{WebViewConfig.java → RNCWebViewConfig.java} +3 -4
  11. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java +1 -1
  12. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +746 -0
  13. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewMessagingModule.kt +9 -0
  14. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java +554 -0
  15. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java +57 -12
  16. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewWrapper.kt +39 -0
  17. package/android/src/main/java/com/reactnativecommunity/webview/events/SubResourceErrorEvent.kt +25 -0
  18. package/android/src/main/java/com/reactnativecommunity/webview/events/TopCustomMenuSelectionEvent.kt +24 -0
  19. package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +25 -0
  20. package/android/src/main/java/com/reactnativecommunity/webview/events/TopNewWindowEvent.kt +25 -0
  21. package/android/src/main/java/com/reactnativecommunity/webview/events/TopRenderProcessGoneEvent.kt +25 -0
  22. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java +570 -0
  23. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java +57 -0
  24. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java +341 -0
  25. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java +59 -0
  26. package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
  27. package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
  28. package/apple/RNCWebView.h +26 -100
  29. package/apple/RNCWebView.mm +555 -0
  30. package/apple/RNCWebViewDecisionManager.h +20 -0
  31. package/apple/RNCWebViewDecisionManager.m +47 -0
  32. package/apple/RNCWebViewImpl.h +164 -0
  33. package/apple/{RNCWebView.m → RNCWebViewImpl.m} +802 -225
  34. package/apple/RNCWebViewManager.h +4 -8
  35. package/apple/RNCWebViewManager.mm +221 -0
  36. package/apple/RNCWebViewModule.h +23 -0
  37. package/apple/RNCWebViewModule.mm +34 -0
  38. package/index.d.ts +2 -3
  39. package/lib/NativeRNCWebViewModule.d.ts +8 -0
  40. package/lib/NativeRNCWebViewModule.js +1 -0
  41. package/lib/RNCWebViewNativeComponent.d.ts +245 -0
  42. package/lib/RNCWebViewNativeComponent.js +1 -0
  43. package/lib/WebView.android.d.ts +0 -1
  44. package/lib/WebView.android.js +1 -135
  45. package/lib/WebView.d.ts +2 -3
  46. package/lib/WebView.ios.d.ts +0 -1
  47. package/lib/WebView.ios.js +1 -114
  48. package/lib/WebView.js +1 -11
  49. package/lib/WebView.macos.d.ts +6 -0
  50. package/lib/WebView.macos.js +1 -0
  51. package/lib/WebView.styles.d.ts +37 -11
  52. package/lib/WebView.styles.js +1 -33
  53. package/lib/WebView.windows.d.ts +17 -0
  54. package/lib/WebView.windows.js +1 -0
  55. package/lib/WebViewNativeComponent.macos.d.ts +3 -0
  56. package/lib/WebViewNativeComponent.macos.js +1 -0
  57. package/lib/WebViewNativeComponent.windows.d.ts +3 -0
  58. package/lib/WebViewNativeComponent.windows.js +1 -0
  59. package/lib/WebViewShared.d.ts +30 -9
  60. package/lib/WebViewShared.js +1 -174
  61. package/lib/WebViewTypes.d.ts +514 -98
  62. package/lib/WebViewTypes.js +1 -6
  63. package/lib/index.d.ts +0 -1
  64. package/lib/index.js +1 -3
  65. package/lib/validation.d.ts +3 -0
  66. package/lib/validation.js +1 -0
  67. package/package.json +57 -33
  68. package/react-native-webview.podspec +32 -5
  69. package/react-native.config.js +22 -18
  70. package/src/NativeRNCWebViewModule.ts +13 -0
  71. package/src/RNCWebViewNativeComponent.ts +348 -0
  72. package/src/WebView.android.tsx +345 -0
  73. package/src/WebView.ios.tsx +341 -0
  74. package/src/WebView.macos.tsx +252 -0
  75. package/src/WebView.styles.ts +41 -0
  76. package/src/WebView.tsx +25 -0
  77. package/src/WebView.windows.tsx +217 -0
  78. package/src/WebViewNativeComponent.macos.ts +7 -0
  79. package/src/WebViewNativeComponent.windows.ts +8 -0
  80. package/src/WebViewShared.tsx +476 -0
  81. package/src/WebViewTypes.ts +1402 -0
  82. package/src/__tests__/WebViewShared-test.js +323 -0
  83. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
  84. package/src/__tests__/validation-test.js +38 -0
  85. package/src/index.ts +4 -0
  86. package/src/validation.ts +20 -0
  87. package/android/.editorconfig +0 -6
  88. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +0 -1408
  89. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java +0 -506
  90. package/apple/RNCWebViewManager.m +0 -278
  91. package/lib/WebViewNativeComponent.android.d.ts +0 -4
  92. package/lib/WebViewNativeComponent.android.js +0 -3
  93. package/lib/WebViewNativeComponent.ios.d.ts +0 -4
  94. package/lib/WebViewNativeComponent.ios.js +0 -3
@@ -1,13 +1,9 @@
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
- */
1
+ #ifndef RNCWebViewManager_h
2
+ #define RNCWebViewManager_h
7
3
 
8
4
  #import <React/RCTViewManager.h>
9
5
 
10
6
  @interface RNCWebViewManager : RCTViewManager
11
- @property (nonatomic, copy) NSArray<NSDictionary *> * _Nullable menuItems;
12
- @property (nonatomic, copy) RCTDirectEventBlock onCustomMenuSelection;
13
7
  @end
8
+
9
+ #endif /* RNCWebViewManager_h */
@@ -0,0 +1,221 @@
1
+ #import <React/RCTUIManager.h>
2
+
3
+ #import "RNCWebViewManager.h"
4
+ #import "RNCWebViewImpl.h"
5
+
6
+ #if TARGET_OS_OSX
7
+ #define RNCView NSView
8
+ @class NSView;
9
+ #else
10
+ #define RNCView UIView
11
+ @class UIView;
12
+ #endif // TARGET_OS_OSX
13
+
14
+ @implementation RCTConvert (WKWebView)
15
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
16
+ RCT_ENUM_CONVERTER(WKContentMode, (@{
17
+ @"recommended": @(WKContentModeRecommended),
18
+ @"mobile": @(WKContentModeMobile),
19
+ @"desktop": @(WKContentModeDesktop),
20
+ }), WKContentModeRecommended, integerValue)
21
+ #endif
22
+
23
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 /* iOS 15 */
24
+ RCT_ENUM_CONVERTER(RNCWebViewPermissionGrantType, (@{
25
+ @"grantIfSameHostElsePrompt": @(RNCWebViewPermissionGrantType_GrantIfSameHost_ElsePrompt),
26
+ @"grantIfSameHostElseDeny": @(RNCWebViewPermissionGrantType_GrantIfSameHost_ElseDeny),
27
+ @"deny": @(RNCWebViewPermissionGrantType_Deny),
28
+ @"grant": @(RNCWebViewPermissionGrantType_Grant),
29
+ @"prompt": @(RNCWebViewPermissionGrantType_Prompt),
30
+ }), RNCWebViewPermissionGrantType_Prompt, integerValue)
31
+ #endif
32
+ @end
33
+
34
+ @implementation RNCWebViewManager
35
+
36
+ RCT_EXPORT_MODULE(RNCWebView)
37
+
38
+ - (RNCView *)view
39
+ {
40
+ return [[RNCWebViewImpl alloc] init];
41
+ }
42
+
43
+ RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
44
+ // New arch only
45
+ RCT_CUSTOM_VIEW_PROPERTY(newSource, NSDictionary, RNCWebViewImpl) {}
46
+ RCT_EXPORT_VIEW_PROPERTY(onFileDownload, RCTDirectEventBlock)
47
+ RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
48
+ RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
49
+ RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
50
+ RCT_EXPORT_VIEW_PROPERTY(onLoadingProgress, RCTDirectEventBlock)
51
+ RCT_EXPORT_VIEW_PROPERTY(onHttpError, RCTDirectEventBlock)
52
+ RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
53
+ RCT_EXPORT_VIEW_PROPERTY(onContentProcessDidTerminate, RCTDirectEventBlock)
54
+ RCT_EXPORT_VIEW_PROPERTY(onOpenWindow, RCTDirectEventBlock)
55
+ RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
56
+ RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoaded, NSString)
57
+ RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptForMainFrameOnly, BOOL)
58
+ RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoadedForMainFrameOnly, BOOL)
59
+ RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptObject, NSString)
60
+ RCT_EXPORT_VIEW_PROPERTY(javaScriptEnabled, BOOL)
61
+ RCT_EXPORT_VIEW_PROPERTY(javaScriptCanOpenWindowsAutomatically, BOOL)
62
+ RCT_EXPORT_VIEW_PROPERTY(allowFileAccessFromFileURLs, BOOL)
63
+ RCT_EXPORT_VIEW_PROPERTY(allowUniversalAccessFromFileURLs, BOOL)
64
+ RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL)
65
+ RCT_EXPORT_VIEW_PROPERTY(allowsPictureInPictureMediaPlayback, BOOL)
66
+ RCT_EXPORT_VIEW_PROPERTY(webviewDebuggingEnabled, BOOL)
67
+ RCT_EXPORT_VIEW_PROPERTY(allowsAirPlayForMediaPlayback, BOOL)
68
+ RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL)
69
+ RCT_EXPORT_VIEW_PROPERTY(dataDetectorTypes, WKDataDetectorTypes)
70
+ RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
71
+ RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
72
+ RCT_EXPORT_VIEW_PROPERTY(autoManageStatusBarEnabled, BOOL)
73
+ RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
74
+ RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
75
+ RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
76
+ RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
77
+ RCT_EXPORT_VIEW_PROPERTY(applicationNameForUserAgent, NSString)
78
+ RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
79
+ RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
80
+ RCT_EXPORT_VIEW_PROPERTY(allowingReadAccessToURL, NSString)
81
+ RCT_EXPORT_VIEW_PROPERTY(basicAuthCredential, NSDictionary)
82
+ // Exodus: Camera permission whitelist for security
83
+ RCT_EXPORT_VIEW_PROPERTY(cameraPermissionOriginWhitelist, NSArray)
84
+
85
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
86
+ RCT_EXPORT_VIEW_PROPERTY(contentInsetAdjustmentBehavior, UIScrollViewContentInsetAdjustmentBehavior)
87
+ #endif
88
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */
89
+ RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustsScrollIndicatorInsets, BOOL)
90
+ #endif
91
+
92
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
93
+ RCT_EXPORT_VIEW_PROPERTY(contentMode, WKContentMode)
94
+ #endif
95
+
96
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 /* iOS 14 */
97
+ RCT_EXPORT_VIEW_PROPERTY(limitsNavigationsToAppBoundDomains, BOOL)
98
+ #endif
99
+
100
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140500 /* iOS 14.5 */
101
+ RCT_EXPORT_VIEW_PROPERTY(textInteractionEnabled, BOOL)
102
+ #endif
103
+
104
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 /* iOS 15 */
105
+ RCT_EXPORT_VIEW_PROPERTY(mediaCapturePermissionGrantType, RNCWebViewPermissionGrantType)
106
+ #endif
107
+
108
+ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
109
+ RCT_EXPORT_VIEW_PROPERTY(fraudulentWebsiteWarningEnabled, BOOL)
110
+ #endif
111
+
112
+ /**
113
+ * Expose methods to enable messaging the webview.
114
+ */
115
+ RCT_EXPORT_VIEW_PROPERTY(messagingEnabled, BOOL)
116
+ RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
117
+ RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
118
+ RCT_EXPORT_VIEW_PROPERTY(enableApplePay, BOOL)
119
+ RCT_EXPORT_VIEW_PROPERTY(menuItems, NSArray);
120
+ RCT_EXPORT_VIEW_PROPERTY(suppressMenuItems, NSArray);
121
+
122
+ // New arch only
123
+ RCT_CUSTOM_VIEW_PROPERTY(hasOnFileDownload, BOOL, RNCWebViewImpl) {}
124
+ RCT_CUSTOM_VIEW_PROPERTY(hasOnOpenWindowEvent, BOOL, RNCWebViewImpl) {}
125
+
126
+ RCT_EXPORT_VIEW_PROPERTY(onCustomMenuSelection, RCTDirectEventBlock)
127
+ RCT_CUSTOM_VIEW_PROPERTY(pullToRefreshEnabled, BOOL, RNCWebViewImpl) {
128
+ view.pullToRefreshEnabled = json == nil ? false : [RCTConvert BOOL: json];
129
+ }
130
+ RCT_CUSTOM_VIEW_PROPERTY(refreshControlLightMode, BOOL, RNCWebViewImpl) {
131
+ view.refreshControlLightMode = json == nil ? false : [RCTConvert BOOL: json];
132
+ }
133
+
134
+ RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RNCWebViewImpl) {
135
+ view.bounces = json == nil ? true : [RCTConvert BOOL: json];
136
+ }
137
+
138
+ RCT_CUSTOM_VIEW_PROPERTY(useSharedProcessPool, BOOL, RNCWebViewImpl) {
139
+ view.useSharedProcessPool = json == nil ? true : [RCTConvert BOOL: json];
140
+ }
141
+
142
+ RCT_CUSTOM_VIEW_PROPERTY(userAgent, NSString, RNCWebViewImpl) {
143
+ view.userAgent = [RCTConvert NSString: json];
144
+ }
145
+
146
+ RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RNCWebViewImpl) {
147
+ view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
148
+ }
149
+
150
+ RCT_CUSTOM_VIEW_PROPERTY(sharedCookiesEnabled, BOOL, RNCWebViewImpl) {
151
+ view.sharedCookiesEnabled = json == nil ? false : [RCTConvert BOOL: json];
152
+ }
153
+
154
+ #if !TARGET_OS_OSX
155
+ RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RNCWebViewImpl) {
156
+ view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
157
+ }
158
+ #endif // !TARGET_OS_OSX
159
+
160
+ RCT_CUSTOM_VIEW_PROPERTY(directionalLockEnabled, BOOL, RNCWebViewImpl) {
161
+ view.directionalLockEnabled = json == nil ? true : [RCTConvert BOOL: json];
162
+ }
163
+
164
+ RCT_CUSTOM_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL, RNCWebViewImpl) {
165
+ view.showsHorizontalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
166
+ }
167
+
168
+ RCT_CUSTOM_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL, RNCWebViewImpl) {
169
+ view.showsVerticalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
170
+ }
171
+
172
+ RCT_CUSTOM_VIEW_PROPERTY(indicatorStyle, NSString, RNCWebViewImpl) {
173
+ view.indicatorStyle = [RCTConvert NSString: json];
174
+ }
175
+
176
+ RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWebViewImpl) {
177
+ view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json];
178
+ }
179
+
180
+ #if !TARGET_OS_OSX
181
+ #define BASE_VIEW_PER_OS() UIView
182
+ #else
183
+ #define BASE_VIEW_PER_OS() NSView
184
+ #endif
185
+
186
+ #define QUICK_RCT_EXPORT_COMMAND_METHOD(name) \
187
+ RCT_EXPORT_METHOD(name:(nonnull NSNumber *)reactTag) \
188
+ { \
189
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, BASE_VIEW_PER_OS() *> *viewRegistry) { \
190
+ RNCWebViewImpl *view = (RNCWebViewImpl *)viewRegistry[reactTag]; \
191
+ if (![view isKindOfClass:[RNCWebViewImpl class]]) { \
192
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view); \
193
+ } else { \
194
+ [view name]; \
195
+ } \
196
+ }]; \
197
+ }
198
+ #define QUICK_RCT_EXPORT_COMMAND_METHOD_PARAMS(name, in_param, out_param) \
199
+ RCT_EXPORT_METHOD(name:(nonnull NSNumber *)reactTag in_param) \
200
+ { \
201
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, BASE_VIEW_PER_OS() *> *viewRegistry) { \
202
+ RNCWebViewImpl *view = (RNCWebViewImpl *)viewRegistry[reactTag]; \
203
+ if (![view isKindOfClass:[RNCWebViewImpl class]]) { \
204
+ RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view); \
205
+ } else { \
206
+ [view name:out_param]; \
207
+ } \
208
+ }]; \
209
+ }
210
+
211
+ QUICK_RCT_EXPORT_COMMAND_METHOD(reload)
212
+ QUICK_RCT_EXPORT_COMMAND_METHOD(goBack)
213
+ QUICK_RCT_EXPORT_COMMAND_METHOD(goForward)
214
+ QUICK_RCT_EXPORT_COMMAND_METHOD(stopLoading)
215
+ QUICK_RCT_EXPORT_COMMAND_METHOD(requestFocus)
216
+
217
+ QUICK_RCT_EXPORT_COMMAND_METHOD_PARAMS(postMessage, message:(NSString *)message, message)
218
+ QUICK_RCT_EXPORT_COMMAND_METHOD_PARAMS(injectJavaScript, script:(NSString *)script, script)
219
+ QUICK_RCT_EXPORT_COMMAND_METHOD_PARAMS(clearCache, includeDiskFiles:(BOOL)includeDiskFiles, includeDiskFiles)
220
+
221
+ @end
@@ -0,0 +1,23 @@
1
+ #ifndef RNCWebViewModule_h
2
+ #define RNCWebViewModule_h
3
+
4
+ #ifdef RCT_NEW_ARCH_ENABLED
5
+ #import "RNCWebViewSpec/RNCWebViewSpec.h"
6
+ #endif /* RCT_NEW_ARCH_ENABLED */
7
+
8
+ #import <React/RCTBridgeModule.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface RNCWebViewModule : NSObject <
13
+ #ifdef RCT_NEW_ARCH_ENABLED
14
+ NativeRNCWebViewModuleSpec
15
+ #else
16
+ RCTBridgeModule
17
+ #endif /* RCT_NEW_ARCH_ENABLED */
18
+ >
19
+ @end
20
+
21
+ NS_ASSUME_NONNULL_END
22
+
23
+ #endif /* RNCWebViewModule_h */
@@ -0,0 +1,34 @@
1
+ #import "RNCWebViewModule.h"
2
+
3
+ #import "RNCWebViewDecisionManager.h"
4
+
5
+ #ifdef RCT_NEW_ARCH_ENABLED
6
+ #import <React/RCTFabricComponentsPlugins.h>
7
+ #endif /* RCT_NEW_ARCH_ENABLED */
8
+
9
+ @implementation RNCWebViewModule
10
+
11
+ RCT_EXPORT_MODULE(RNCWebViewModule)
12
+
13
+ RCT_EXPORT_METHOD(isFileUploadSupported:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
14
+ if (resolve) {
15
+ resolve(@(YES));
16
+ }
17
+ }
18
+
19
+ RCT_EXPORT_METHOD(shouldStartLoadWithLockIdentifier:(BOOL)shouldStart lockIdentifier:(double)lockIdentifier)
20
+ {
21
+ [[RNCWebViewDecisionManager getInstance] setResult:shouldStart forLockIdentifier:(int)lockIdentifier];
22
+ }
23
+
24
+ #ifdef RCT_NEW_ARCH_ENABLED
25
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
26
+ return std::make_shared<facebook::react::NativeRNCWebViewModuleSpecJSI>(params);
27
+ }
28
+ #endif /* RCT_NEW_ARCH_ENABLED */
29
+
30
+ Class RNCWebViewModuleCls(void) {
31
+ return RNCWebViewModule.class;
32
+ }
33
+
34
+ @end
package/index.d.ts CHANGED
@@ -33,7 +33,7 @@ declare class WebView<P = {}> extends Component<WebViewProps & P> {
33
33
  injectJavaScript: (script: string) => void;
34
34
 
35
35
  /**
36
- * Focuses on WebView redered page.
36
+ * Focuses on WebView rendered page.
37
37
  */
38
38
  requestFocus: () => void;
39
39
 
@@ -49,10 +49,9 @@ declare class WebView<P = {}> extends Component<WebViewProps & P> {
49
49
  clearFormData?: () => void;
50
50
 
51
51
  /**
52
- * (Android only)
53
52
  * Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used.
54
53
  */
55
- clearCache?: (clear: boolean) => void;
54
+ clearCache: (includeDiskFiles: boolean) => void;
56
55
 
57
56
  /**
58
57
  * (Android only)
@@ -0,0 +1,8 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { Double } from 'react-native/Libraries/Types/CodegenTypes';
3
+ export interface Spec extends TurboModule {
4
+ isFileUploadSupported(): Promise<boolean>;
5
+ shouldStartLoadWithLockIdentifier(shouldStart: boolean, lockIdentifier: Double): void;
6
+ }
7
+ declare const _default: Spec;
8
+ export default _default;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var _default=exports.default=_reactNative.TurboModuleRegistry.getEnforcing('RNCWebViewModule');
@@ -0,0 +1,245 @@
1
+ import type { HostComponent, ViewProps } from 'react-native';
2
+ import { DirectEventHandler, Double, Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
3
+ export type WebViewNativeEvent = Readonly<{
4
+ url: string;
5
+ loading: boolean;
6
+ title: string;
7
+ canGoBack: boolean;
8
+ canGoForward: boolean;
9
+ lockIdentifier: Double;
10
+ }>;
11
+ export type WebViewCustomMenuSelectionEvent = Readonly<{
12
+ label: string;
13
+ key: string;
14
+ selectedText: string;
15
+ }>;
16
+ export type WebViewMessageEvent = Readonly<{
17
+ url: string;
18
+ loading: boolean;
19
+ title: string;
20
+ canGoBack: boolean;
21
+ canGoForward: boolean;
22
+ lockIdentifier: Double;
23
+ data: string;
24
+ }>;
25
+ export type WebViewOpenWindowEvent = Readonly<{
26
+ targetUrl: string;
27
+ }>;
28
+ export type WebViewHttpErrorEvent = Readonly<{
29
+ url: string;
30
+ loading: boolean;
31
+ title: string;
32
+ canGoBack: boolean;
33
+ canGoForward: boolean;
34
+ lockIdentifier: Double;
35
+ description: string;
36
+ statusCode: Int32;
37
+ }>;
38
+ export type WebViewErrorEvent = Readonly<{
39
+ url: string;
40
+ loading: boolean;
41
+ title: string;
42
+ canGoBack: boolean;
43
+ canGoForward: boolean;
44
+ lockIdentifier: Double;
45
+ domain?: string;
46
+ code: Int32;
47
+ description: string;
48
+ }>;
49
+ export type WebViewNativeProgressEvent = Readonly<{
50
+ url: string;
51
+ loading: boolean;
52
+ title: string;
53
+ canGoBack: boolean;
54
+ canGoForward: boolean;
55
+ lockIdentifier: Double;
56
+ progress: Double;
57
+ }>;
58
+ export type WebViewNavigationEvent = Readonly<{
59
+ url: string;
60
+ loading: boolean;
61
+ title: string;
62
+ canGoBack: boolean;
63
+ canGoForward: boolean;
64
+ lockIdentifier: Double;
65
+ navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
66
+ mainDocumentURL?: string;
67
+ }>;
68
+ export type ShouldStartLoadRequestEvent = Readonly<{
69
+ url: string;
70
+ loading: boolean;
71
+ title: string;
72
+ canGoBack: boolean;
73
+ canGoForward: boolean;
74
+ lockIdentifier: Double;
75
+ navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
76
+ mainDocumentURL?: string;
77
+ isTopFrame: boolean;
78
+ }>;
79
+ type ScrollEvent = Readonly<{
80
+ contentInset: {
81
+ bottom: Double;
82
+ left: Double;
83
+ right: Double;
84
+ top: Double;
85
+ };
86
+ contentOffset: {
87
+ y: Double;
88
+ x: Double;
89
+ };
90
+ contentSize: {
91
+ height: Double;
92
+ width: Double;
93
+ };
94
+ layoutMeasurement: {
95
+ height: Double;
96
+ width: Double;
97
+ };
98
+ targetContentOffset?: {
99
+ y: Double;
100
+ x: Double;
101
+ };
102
+ velocity?: {
103
+ y: Double;
104
+ x: Double;
105
+ };
106
+ zoomScale?: Double;
107
+ responderIgnoreScroll?: boolean;
108
+ }>;
109
+ type WebViewRenderProcessGoneEvent = Readonly<{
110
+ didCrash: boolean;
111
+ }>;
112
+ type WebViewDownloadEvent = Readonly<{
113
+ downloadUrl: string;
114
+ }>;
115
+ export interface NativeProps extends ViewProps {
116
+ allowFileAccess?: boolean;
117
+ allowsProtectedMedia?: boolean;
118
+ allowsFullscreenVideo?: boolean;
119
+ androidLayerType?: WithDefault<'none' | 'software' | 'hardware', 'none'>;
120
+ cacheMode?: WithDefault<'LOAD_DEFAULT' | 'LOAD_CACHE_ELSE_NETWORK' | 'LOAD_NO_CACHE' | 'LOAD_CACHE_ONLY', 'LOAD_DEFAULT'>;
121
+ domStorageEnabled?: boolean;
122
+ downloadingMessage?: string;
123
+ forceDarkOn?: boolean;
124
+ geolocationEnabled?: boolean;
125
+ lackPermissionToDownloadMessage?: string;
126
+ messagingModuleName: string;
127
+ minimumFontSize?: Int32;
128
+ mixedContentMode?: WithDefault<'never' | 'always' | 'compatibility', 'never'>;
129
+ nestedScrollEnabled?: boolean;
130
+ onContentSizeChange?: DirectEventHandler<WebViewNativeEvent>;
131
+ onRenderProcessGone?: DirectEventHandler<WebViewRenderProcessGoneEvent>;
132
+ overScrollMode?: string;
133
+ saveFormDataDisabled?: boolean;
134
+ scalesPageToFit?: WithDefault<boolean, true>;
135
+ setBuiltInZoomControls?: WithDefault<boolean, true>;
136
+ setDisplayZoomControls?: boolean;
137
+ setSupportMultipleWindows?: WithDefault<boolean, true>;
138
+ textZoom?: Int32;
139
+ thirdPartyCookiesEnabled?: WithDefault<boolean, true>;
140
+ hasOnScroll?: boolean;
141
+ allowingReadAccessToURL?: string;
142
+ allowsBackForwardNavigationGestures?: boolean;
143
+ allowsInlineMediaPlayback?: boolean;
144
+ allowsPictureInPictureMediaPlayback?: boolean;
145
+ allowsAirPlayForMediaPlayback?: boolean;
146
+ allowsLinkPreview?: WithDefault<boolean, true>;
147
+ automaticallyAdjustContentInsets?: WithDefault<boolean, true>;
148
+ autoManageStatusBarEnabled?: WithDefault<boolean, true>;
149
+ bounces?: WithDefault<boolean, true>;
150
+ contentInset?: Readonly<{
151
+ top?: Double;
152
+ left?: Double;
153
+ bottom?: Double;
154
+ right?: Double;
155
+ }>;
156
+ contentInsetAdjustmentBehavior?: WithDefault<'never' | 'automatic' | 'scrollableAxes' | 'always', 'never'>;
157
+ contentMode?: WithDefault<'recommended' | 'mobile' | 'desktop', 'recommended'>;
158
+ dataDetectorTypes?: WithDefault<ReadonlyArray<'address' | 'link' | 'calendarEvent' | 'trackingNumber' | 'flightNumber' | 'lookupSuggestion' | 'phoneNumber' | 'all' | 'none'>, 'phoneNumber'>;
159
+ decelerationRate?: Double;
160
+ directionalLockEnabled?: WithDefault<boolean, true>;
161
+ enableApplePay?: boolean;
162
+ hideKeyboardAccessoryView?: boolean;
163
+ keyboardDisplayRequiresUserAction?: WithDefault<boolean, true>;
164
+ limitsNavigationsToAppBoundDomains?: boolean;
165
+ mediaCapturePermissionGrantType?: WithDefault<'prompt' | 'grant' | 'deny' | 'grantIfSameHostElsePrompt' | 'grantIfSameHostElseDeny', 'prompt'>;
166
+ pagingEnabled?: boolean;
167
+ pullToRefreshEnabled?: boolean;
168
+ refreshControlLightMode?: boolean;
169
+ scrollEnabled?: WithDefault<boolean, true>;
170
+ sharedCookiesEnabled?: boolean;
171
+ textInteractionEnabled?: WithDefault<boolean, true>;
172
+ useSharedProcessPool?: WithDefault<boolean, true>;
173
+ onContentProcessDidTerminate?: DirectEventHandler<WebViewNativeEvent>;
174
+ onCustomMenuSelection?: DirectEventHandler<WebViewCustomMenuSelectionEvent>;
175
+ onFileDownload?: DirectEventHandler<WebViewDownloadEvent>;
176
+ menuItems?: ReadonlyArray<Readonly<{
177
+ label: string;
178
+ key: string;
179
+ }>>;
180
+ suppressMenuItems?: Readonly<string>[];
181
+ hasOnFileDownload?: boolean;
182
+ fraudulentWebsiteWarningEnabled?: WithDefault<boolean, true>;
183
+ allowFileAccessFromFileURLs?: boolean;
184
+ allowUniversalAccessFromFileURLs?: boolean;
185
+ applicationNameForUserAgent?: string;
186
+ basicAuthCredential?: Readonly<{
187
+ username: string;
188
+ password: string;
189
+ }>;
190
+ cacheEnabled?: WithDefault<boolean, true>;
191
+ incognito?: boolean;
192
+ injectedJavaScript?: string;
193
+ injectedJavaScriptBeforeContentLoaded?: string;
194
+ injectedJavaScriptForMainFrameOnly?: WithDefault<boolean, true>;
195
+ injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: WithDefault<boolean, true>;
196
+ javaScriptCanOpenWindowsAutomatically?: boolean;
197
+ javaScriptEnabled?: WithDefault<boolean, true>;
198
+ webviewDebuggingEnabled?: boolean;
199
+ mediaPlaybackRequiresUserAction?: WithDefault<boolean, true>;
200
+ messagingEnabled: boolean;
201
+ onLoadingError: DirectEventHandler<WebViewErrorEvent>;
202
+ onLoadingSubResourceError: DirectEventHandler<WebViewErrorEvent>;
203
+ onLoadingFinish: DirectEventHandler<WebViewNavigationEvent>;
204
+ onLoadingProgress: DirectEventHandler<WebViewNativeProgressEvent>;
205
+ onLoadingStart: DirectEventHandler<WebViewNavigationEvent>;
206
+ onHttpError: DirectEventHandler<WebViewHttpErrorEvent>;
207
+ onMessage: DirectEventHandler<WebViewMessageEvent>;
208
+ onOpenWindow?: DirectEventHandler<WebViewOpenWindowEvent>;
209
+ hasOnOpenWindowEvent?: boolean;
210
+ onScroll?: DirectEventHandler<ScrollEvent>;
211
+ onShouldStartLoadWithRequest: DirectEventHandler<ShouldStartLoadRequestEvent>;
212
+ showsHorizontalScrollIndicator?: WithDefault<boolean, true>;
213
+ showsVerticalScrollIndicator?: WithDefault<boolean, true>;
214
+ indicatorStyle?: WithDefault<'default' | 'black' | 'white', 'default'>;
215
+ newSource: Readonly<{
216
+ uri?: string;
217
+ method?: string;
218
+ body?: string;
219
+ headers?: ReadonlyArray<Readonly<{
220
+ name: string;
221
+ value: string;
222
+ }>>;
223
+ html?: string;
224
+ baseUrl?: string;
225
+ }>;
226
+ userAgent?: string;
227
+ injectedJavaScriptObject?: string;
228
+ paymentRequestEnabled?: boolean;
229
+ }
230
+ export interface NativeCommands {
231
+ goBack: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
232
+ goForward: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
233
+ reload: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
234
+ stopLoading: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
235
+ injectJavaScript: (viewRef: React.ElementRef<HostComponent<NativeProps>>, javascript: string) => void;
236
+ requestFocus: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
237
+ postMessage: (viewRef: React.ElementRef<HostComponent<NativeProps>>, data: string) => void;
238
+ loadUrl: (viewRef: React.ElementRef<HostComponent<NativeProps>>, url: string) => void;
239
+ clearFormData: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
240
+ clearCache: (viewRef: React.ElementRef<HostComponent<NativeProps>>, includeDiskFiles: boolean) => void;
241
+ clearHistory: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
242
+ }
243
+ export declare const Commands: NativeCommands;
244
+ declare const _default: HostComponent<NativeProps>;
245
+ export default _default;
@@ -0,0 +1 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.__INTERNAL_VIEW_CONFIG=exports.Commands=void 0;var _codegenNativeComponent=_interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));var _codegenNativeCommands=_interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeCommands"));var NativeComponentRegistry=require('react-native/Libraries/NativeComponent/NativeComponentRegistry');var _require=require('react-native/Libraries/NativeComponent/ViewConfigIgnore'),ConditionallyIgnoredEventHandlers=_require.ConditionallyIgnoredEventHandlers;var _require2=require("react-native/Libraries/ReactNative/RendererProxy"),dispatchCommand=_require2.dispatchCommand;var nativeComponentName='RNCWebView';var __INTERNAL_VIEW_CONFIG=exports.__INTERNAL_VIEW_CONFIG={uiViewClassName:'RNCWebView',directEventTypes:{topContentSizeChange:{registrationName:'onContentSizeChange'},topRenderProcessGone:{registrationName:'onRenderProcessGone'},topContentProcessDidTerminate:{registrationName:'onContentProcessDidTerminate'},topCustomMenuSelection:{registrationName:'onCustomMenuSelection'},topFileDownload:{registrationName:'onFileDownload'},topLoadingError:{registrationName:'onLoadingError'},topLoadingSubResourceError:{registrationName:'onLoadingSubResourceError'},topLoadingFinish:{registrationName:'onLoadingFinish'},topLoadingProgress:{registrationName:'onLoadingProgress'},topLoadingStart:{registrationName:'onLoadingStart'},topHttpError:{registrationName:'onHttpError'},topMessage:{registrationName:'onMessage'},topOpenWindow:{registrationName:'onOpenWindow'},topScroll:{registrationName:'onScroll'},topShouldStartLoadWithRequest:{registrationName:'onShouldStartLoadWithRequest'}},validAttributes:Object.assign({allowFileAccess:true,allowsProtectedMedia:true,allowsFullscreenVideo:true,androidLayerType:true,cacheMode:true,domStorageEnabled:true,downloadingMessage:true,forceDarkOn:true,geolocationEnabled:true,lackPermissionToDownloadMessage:true,messagingModuleName:true,minimumFontSize:true,mixedContentMode:true,nestedScrollEnabled:true,overScrollMode:true,saveFormDataDisabled:true,scalesPageToFit:true,setBuiltInZoomControls:true,setDisplayZoomControls:true,setSupportMultipleWindows:true,textZoom:true,thirdPartyCookiesEnabled:true,hasOnScroll:true,allowingReadAccessToURL:true,allowsBackForwardNavigationGestures:true,allowsInlineMediaPlayback:true,allowsPictureInPictureMediaPlayback:true,allowsAirPlayForMediaPlayback:true,allowsLinkPreview:true,automaticallyAdjustContentInsets:true,autoManageStatusBarEnabled:true,bounces:true,contentInset:true,contentInsetAdjustmentBehavior:true,contentMode:true,dataDetectorTypes:true,decelerationRate:true,directionalLockEnabled:true,enableApplePay:true,hideKeyboardAccessoryView:true,keyboardDisplayRequiresUserAction:true,limitsNavigationsToAppBoundDomains:true,mediaCapturePermissionGrantType:true,pagingEnabled:true,pullToRefreshEnabled:true,refreshControlLightMode:true,scrollEnabled:true,sharedCookiesEnabled:true,textInteractionEnabled:true,useSharedProcessPool:true,menuItems:true,suppressMenuItems:true,hasOnFileDownload:true,fraudulentWebsiteWarningEnabled:true,allowFileAccessFromFileURLs:true,allowUniversalAccessFromFileURLs:true,applicationNameForUserAgent:true,basicAuthCredential:true,cacheEnabled:true,incognito:true,injectedJavaScript:true,injectedJavaScriptBeforeContentLoaded:true,injectedJavaScriptForMainFrameOnly:true,injectedJavaScriptBeforeContentLoadedForMainFrameOnly:true,javaScriptCanOpenWindowsAutomatically:true,javaScriptEnabled:true,webviewDebuggingEnabled:true,mediaPlaybackRequiresUserAction:true,messagingEnabled:true,hasOnOpenWindowEvent:true,showsHorizontalScrollIndicator:true,showsVerticalScrollIndicator:true,indicatorStyle:true,newSource:true,userAgent:true,injectedJavaScriptObject:true,paymentRequestEnabled:true},ConditionallyIgnoredEventHandlers({onContentSizeChange:true,onRenderProcessGone:true,onContentProcessDidTerminate:true,onCustomMenuSelection:true,onFileDownload:true,onLoadingError:true,onLoadingSubResourceError:true,onLoadingFinish:true,onLoadingProgress:true,onLoadingStart:true,onHttpError:true,onMessage:true,onOpenWindow:true,onScroll:true,onShouldStartLoadWithRequest:true}))};var _default=exports.default=NativeComponentRegistry.get(nativeComponentName,function(){return __INTERNAL_VIEW_CONFIG;});var Commands=exports.Commands={goBack:function goBack(ref){dispatchCommand(ref,"goBack",[]);},goForward:function goForward(ref){dispatchCommand(ref,"goForward",[]);},reload:function reload(ref){dispatchCommand(ref,"reload",[]);},stopLoading:function stopLoading(ref){dispatchCommand(ref,"stopLoading",[]);},injectJavaScript:function injectJavaScript(ref,javascript){dispatchCommand(ref,"injectJavaScript",[javascript]);},requestFocus:function requestFocus(ref){dispatchCommand(ref,"requestFocus",[]);},postMessage:function postMessage(ref,data){dispatchCommand(ref,"postMessage",[data]);},loadUrl:function loadUrl(ref,url){dispatchCommand(ref,"loadUrl",[url]);},clearFormData:function clearFormData(ref){dispatchCommand(ref,"clearFormData",[]);},clearCache:function clearCache(ref,includeDiskFiles){dispatchCommand(ref,"clearCache",[includeDiskFiles]);},clearHistory:function clearHistory(ref){dispatchCommand(ref,"clearHistory",[]);}};
@@ -4,4 +4,3 @@ declare const WebView: React.ForwardRefExoticComponent<AndroidWebViewProps & Rea
4
4
  isFileUploadSupported: () => Promise<boolean>;
5
5
  };
6
6
  export default WebView;
7
- //# sourceMappingURL=WebView.android.d.ts.map