@exodus/react-native-webview 13.16.0-exodus.3 → 13.16.0-exodus.5

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 (43) hide show
  1. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +15 -18
  2. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java +0 -7
  3. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java +0 -21
  4. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +5 -50
  5. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java +0 -58
  6. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java +0 -40
  7. package/apple/RNCWebView.mm +0 -39
  8. package/apple/RNCWebViewDecisionManager.m +17 -0
  9. package/apple/RNCWebViewImpl.h +0 -10
  10. package/apple/RNCWebViewImpl.m +24 -72
  11. package/apple/RNCWebViewManager.mm +0 -11
  12. package/lib/RNCWebViewNativeComponent.d.ts +0 -26
  13. package/lib/RNCWebViewNativeComponent.js +1 -1
  14. package/lib/WebView.android.js +1 -1
  15. package/lib/WebView.d.ts +2 -2
  16. package/lib/WebView.ios.js +1 -1
  17. package/lib/WebView.js +1 -1
  18. package/lib/WebViewShared.d.ts +5 -5
  19. package/lib/WebViewShared.js +1 -1
  20. package/lib/WebViewTypes.d.ts +5 -358
  21. package/lib/WebViewTypes.js +1 -1
  22. package/package.json +6 -12
  23. package/react-native-webview.podspec +1 -1
  24. package/src/RNCWebViewNativeComponent.ts +0 -37
  25. package/src/WebView.android.tsx +293 -284
  26. package/src/WebView.ios.tsx +223 -256
  27. package/src/WebView.tsx +2 -8
  28. package/src/WebViewShared.tsx +2 -11
  29. package/src/WebViewTypes.ts +2 -396
  30. package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +0 -25
  31. package/lib/WebView.macos.d.ts +0 -6
  32. package/lib/WebView.macos.js +0 -1
  33. package/lib/WebView.windows.d.ts +0 -17
  34. package/lib/WebView.windows.js +0 -1
  35. package/lib/WebViewNativeComponent.windows.d.ts +0 -3
  36. package/lib/WebViewNativeComponent.windows.js +0 -1
  37. package/src/WebView.macos.tsx +0 -252
  38. package/src/WebView.windows.tsx +0 -217
  39. package/src/WebViewNativeComponent.macos.ts +0 -7
  40. package/src/WebViewNativeComponent.windows.ts +0 -8
  41. package/src/__tests__/WebViewShared-test.js +0 -323
  42. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +0 -8
  43. package/src/__tests__/validation-test.js +0 -38
@@ -185,9 +185,7 @@ RCTAutoInsetsProtocol>
185
185
  _contentInset = UIEdgeInsetsZero;
186
186
  _savedKeyboardDisplayRequiresUserAction = YES;
187
187
  _injectedJavaScript = nil;
188
- _injectedJavaScriptForMainFrameOnly = YES;
189
188
  _injectedJavaScriptBeforeContentLoaded = nil;
190
- _injectedJavaScriptBeforeContentLoadedForMainFrameOnly = YES;
191
189
  _enableApplePay = NO;
192
190
  #if TARGET_OS_IOS
193
191
  _savedStatusBarStyle = RCTSharedApplication().statusBarStyle;
@@ -443,23 +441,13 @@ RCTAutoInsetsProtocol>
443
441
  }
444
442
  #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
445
443
  if (@available(iOS 13.0, *)) {
446
- if (!_fraudulentWebsiteWarningEnabled) {
447
- prefs.fraudulentWebsiteWarningEnabled = NO;
448
- _prefsUsed = YES;
449
- }
450
- }
451
- #endif
452
- if (_allowUniversalAccessFromFileURLs) {
453
- [wkWebViewConfig setValue:@TRUE forKey:@"allowUniversalAccessFromFileURLs"];
454
- }
455
- if (_allowFileAccessFromFileURLs) {
456
- [prefs setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
457
- _prefsUsed = YES;
458
- }
459
- if (_javaScriptCanOpenWindowsAutomatically) {
460
- [prefs setValue:@TRUE forKey:@"javaScriptCanOpenWindowsAutomatically"];
444
+ // Exodus: Always force fraudulent website warning enabled for security
445
+ prefs.fraudulentWebsiteWarningEnabled = YES;
461
446
  _prefsUsed = YES;
462
447
  }
448
+ #endif
449
+ // Exodus: Force javaScriptCanOpenWindowsAutomatically = NO for security
450
+ // WKPreferences default is NO, so we don't need to set anything
463
451
  #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140500 /* iOS 14.5 */
464
452
  if (@available(iOS 14.5, *)) {
465
453
  if (!_textInteractionEnabled) {
@@ -505,7 +493,8 @@ RCTAutoInsetsProtocol>
505
493
  [self resetupScripts:wkWebViewConfig];
506
494
 
507
495
  if(@available(macos 10.11, ios 9.0, *)) {
508
- wkWebViewConfig.allowsAirPlayForMediaPlayback = _allowsAirPlayForMediaPlayback;
496
+ // Exodus: Force AirPlay disabled for security
497
+ wkWebViewConfig.allowsAirPlayForMediaPlayback = NO;
509
498
  }
510
499
 
511
500
  #if !TARGET_OS_OSX
@@ -517,10 +506,6 @@ RCTAutoInsetsProtocol>
517
506
  wkWebViewConfig.dataDetectorTypes = _dataDetectorTypes;
518
507
  #endif // !TARGET_OS_OSX
519
508
 
520
- if (_applicationNameForUserAgent) {
521
- wkWebViewConfig.applicationNameForUserAgent = [NSString stringWithFormat:@"%@ %@", wkWebViewConfig.applicationNameForUserAgent, _applicationNameForUserAgent];
522
- }
523
-
524
509
  return wkWebViewConfig;
525
510
  }
526
511
 
@@ -815,17 +800,6 @@ RCTAutoInsetsProtocol>
815
800
  }
816
801
  }
817
802
 
818
- - (void)setAllowingReadAccessToURL:(NSString *)allowingReadAccessToURL
819
- {
820
- if (![_allowingReadAccessToURL isEqualToString:allowingReadAccessToURL]) {
821
- _allowingReadAccessToURL = [allowingReadAccessToURL copy];
822
-
823
- if (_webView != nil) {
824
- [self visitSource];
825
- }
826
- }
827
- }
828
-
829
803
  - (void)setContentInset:(UIEdgeInsets)contentInset
830
804
  {
831
805
  #if !TARGET_OS_OSX
@@ -869,7 +843,6 @@ RCTAutoInsetsProtocol>
869
843
 
870
844
  NSURLRequest *request = [self requestForSource:_source];
871
845
  __weak WKWebView *webView = _webView;
872
- NSString *allowingReadAccessToURL = _allowingReadAccessToURL;
873
846
 
874
847
  [self syncCookiesToWebView:^{
875
848
  // Add observer to sync cookies from webview to sharedHTTPCookieStorage
@@ -887,13 +860,12 @@ RCTAutoInsetsProtocol>
887
860
  [webView loadHTMLString:@"" baseURL:nil];
888
861
  return;
889
862
  }
890
- if (request.URL.host) {
891
- [webView loadRequest:request];
892
- }
893
- else {
894
- NSURL* readAccessUrl = allowingReadAccessToURL ? [RCTConvert NSURL:allowingReadAccessToURL] : request.URL;
895
- [webView loadFileURL:request.URL allowingReadAccessToURL:readAccessUrl];
863
+ // Exodus: Block file:// URL loads for security
864
+ if ([request.URL.scheme isEqualToString:@"file"]) {
865
+ NSLog(@"RNCWebView: file:// URL loads are blocked for security");
866
+ return;
896
867
  }
868
+ [webView loadRequest:request];
897
869
  }];
898
870
  }
899
871
 
@@ -1325,6 +1297,15 @@ RCTAutoInsetsProtocol>
1325
1297
  initiatedByFrame:(WKFrameInfo *)frame
1326
1298
  type:(WKMediaCaptureType)type
1327
1299
  decisionHandler:(void (^)(WKPermissionDecision decision))decisionHandler {
1300
+ // Exodus: Check origin against camera permission whitelist
1301
+ if (cameraPermissionOriginWhitelist != nil && cameraPermissionOriginWhitelist.count > 0) {
1302
+ NSString *originHost = origin.host;
1303
+ if (originHost == nil || ![cameraPermissionOriginWhitelist containsObject:originHost]) {
1304
+ decisionHandler(WKPermissionDecisionDeny);
1305
+ return;
1306
+ }
1307
+ }
1308
+
1328
1309
  if (_mediaCapturePermissionGrantType == RNCWebViewPermissionGrantType_GrantIfSameHost_ElsePrompt || _mediaCapturePermissionGrantType == RNCWebViewPermissionGrantType_GrantIfSameHost_ElseDeny) {
1329
1310
  if ([origin.host isEqualToString:webView.URL.host]) {
1330
1311
  decisionHandler(WKPermissionDecisionGrant);
@@ -1481,32 +1462,13 @@ RCTAutoInsetsProtocol>
1481
1462
  if ([navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]) {
1482
1463
  NSHTTPURLResponse *response = (NSHTTPURLResponse *)navigationResponse.response;
1483
1464
  NSInteger statusCode = response.statusCode;
1484
- if (_onHttpError && navigationResponse.forMainFrame) {
1485
- if (statusCode >= 400) {
1486
- NSMutableDictionary<NSString *, id> *httpErrorEvent = [self baseEvent];
1487
- [httpErrorEvent addEntriesFromDictionary: @{
1488
- @"url": response.URL.absoluteString,
1489
- @"statusCode": @(statusCode)
1490
- }];
1491
-
1492
- _onHttpError(httpErrorEvent);
1493
- }
1494
- }
1495
1465
  NSString *disposition = nil;
1496
1466
  if (@available(iOS 13, macOS 10.15, *)) {
1497
1467
  disposition = [response valueForHTTPHeaderField:@"Content-Disposition"];
1498
1468
  }
1499
1469
  BOOL isAttachment = disposition != nil && [disposition hasPrefix:@"attachment"];
1500
1470
  if (isAttachment || !navigationResponse.canShowMIMEType) {
1501
- if (_onFileDownload) {
1502
- policy = WKNavigationResponsePolicyCancel;
1503
-
1504
- NSMutableDictionary<NSString *, id> *downloadEvent = [self baseEvent];
1505
- [downloadEvent addEntriesFromDictionary: @{
1506
- @"downloadUrl": (response.URL).absoluteString,
1507
- }];
1508
- _onFileDownload(downloadEvent);
1509
- }
1471
+ policy = WKNavigationResponsePolicyCancel;
1510
1472
  }
1511
1473
  }
1512
1474
 
@@ -1747,7 +1709,7 @@ didFinishNavigation:(WKNavigation *)navigation
1747
1709
 
1748
1710
  self.atEndScript = source == nil ? nil : [[WKUserScript alloc] initWithSource:source
1749
1711
  injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
1750
- forMainFrameOnly:_injectedJavaScriptForMainFrameOnly];
1712
+ forMainFrameOnly:YES];
1751
1713
 
1752
1714
  if(_webView != nil){
1753
1715
  [self resetupScripts:_webView.configuration];
@@ -1787,23 +1749,13 @@ didFinishNavigation:(WKNavigation *)navigation
1787
1749
 
1788
1750
  self.atStartScript = source == nil ? nil : [[WKUserScript alloc] initWithSource:source
1789
1751
  injectionTime:WKUserScriptInjectionTimeAtDocumentStart
1790
- forMainFrameOnly:_injectedJavaScriptBeforeContentLoadedForMainFrameOnly];
1752
+ forMainFrameOnly:YES];
1791
1753
 
1792
1754
  if(_webView != nil){
1793
1755
  [self resetupScripts:_webView.configuration];
1794
1756
  }
1795
1757
  }
1796
1758
 
1797
- - (void)setInjectedJavaScriptForMainFrameOnly:(BOOL)mainFrameOnly {
1798
- _injectedJavaScriptForMainFrameOnly = mainFrameOnly;
1799
- [self setInjectedJavaScript:_injectedJavaScript];
1800
- }
1801
-
1802
- - (void)setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly:(BOOL)mainFrameOnly {
1803
- _injectedJavaScriptBeforeContentLoadedForMainFrameOnly = mainFrameOnly;
1804
- [self setInjectedJavaScriptBeforeContentLoaded:_injectedJavaScriptBeforeContentLoaded];
1805
- }
1806
-
1807
1759
  - (void)setMessagingEnabled:(BOOL)messagingEnabled {
1808
1760
  _messagingEnabled = messagingEnabled;
1809
1761
 
@@ -43,28 +43,20 @@ RCT_EXPORT_MODULE(RNCWebView)
43
43
  RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
44
44
  // New arch only
45
45
  RCT_CUSTOM_VIEW_PROPERTY(newSource, NSDictionary, RNCWebViewImpl) {}
46
- RCT_EXPORT_VIEW_PROPERTY(onFileDownload, RCTDirectEventBlock)
47
46
  RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
48
47
  RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
49
48
  RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
50
49
  RCT_EXPORT_VIEW_PROPERTY(onLoadingProgress, RCTDirectEventBlock)
51
- RCT_EXPORT_VIEW_PROPERTY(onHttpError, RCTDirectEventBlock)
52
50
  RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
53
51
  RCT_EXPORT_VIEW_PROPERTY(onContentProcessDidTerminate, RCTDirectEventBlock)
54
52
  RCT_EXPORT_VIEW_PROPERTY(onOpenWindow, RCTDirectEventBlock)
55
53
  RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
56
54
  RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoaded, NSString)
57
- RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptForMainFrameOnly, BOOL)
58
- RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoadedForMainFrameOnly, BOOL)
59
55
  RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptObject, NSString)
60
56
  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
57
  RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL)
65
58
  RCT_EXPORT_VIEW_PROPERTY(allowsPictureInPictureMediaPlayback, BOOL)
66
59
  RCT_EXPORT_VIEW_PROPERTY(webviewDebuggingEnabled, BOOL)
67
- RCT_EXPORT_VIEW_PROPERTY(allowsAirPlayForMediaPlayback, BOOL)
68
60
  RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL)
69
61
  RCT_EXPORT_VIEW_PROPERTY(dataDetectorTypes, WKDataDetectorTypes)
70
62
  RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
@@ -74,10 +66,8 @@ RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
74
66
  RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
75
67
  RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
76
68
  RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
77
- RCT_EXPORT_VIEW_PROPERTY(applicationNameForUserAgent, NSString)
78
69
  RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
79
70
  RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
80
- RCT_EXPORT_VIEW_PROPERTY(allowingReadAccessToURL, NSString)
81
71
  RCT_EXPORT_VIEW_PROPERTY(basicAuthCredential, NSDictionary)
82
72
  // Exodus: Camera permission whitelist for security
83
73
  RCT_EXPORT_VIEW_PROPERTY(cameraPermissionOriginWhitelist, NSArray)
@@ -120,7 +110,6 @@ RCT_EXPORT_VIEW_PROPERTY(menuItems, NSArray);
120
110
  RCT_EXPORT_VIEW_PROPERTY(suppressMenuItems, NSArray);
121
111
 
122
112
  // New arch only
123
- RCT_CUSTOM_VIEW_PROPERTY(hasOnFileDownload, BOOL, RNCWebViewImpl) {}
124
113
  RCT_CUSTOM_VIEW_PROPERTY(hasOnOpenWindowEvent, BOOL, RNCWebViewImpl) {}
125
114
 
126
115
  RCT_EXPORT_VIEW_PROPERTY(onCustomMenuSelection, RCTDirectEventBlock)
@@ -25,16 +25,6 @@ export type WebViewMessageEvent = Readonly<{
25
25
  export type WebViewOpenWindowEvent = Readonly<{
26
26
  targetUrl: string;
27
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
28
  export type WebViewErrorEvent = Readonly<{
39
29
  url: string;
40
30
  loading: boolean;
@@ -109,11 +99,7 @@ type ScrollEvent = Readonly<{
109
99
  type WebViewRenderProcessGoneEvent = Readonly<{
110
100
  didCrash: boolean;
111
101
  }>;
112
- type WebViewDownloadEvent = Readonly<{
113
- downloadUrl: string;
114
- }>;
115
102
  export interface NativeProps extends ViewProps {
116
- allowFileAccess?: boolean;
117
103
  allowsProtectedMedia?: boolean;
118
104
  allowsFullscreenVideo?: boolean;
119
105
  androidLayerType?: WithDefault<'none' | 'software' | 'hardware', 'none'>;
@@ -138,11 +124,9 @@ export interface NativeProps extends ViewProps {
138
124
  textZoom?: Int32;
139
125
  thirdPartyCookiesEnabled?: WithDefault<boolean, true>;
140
126
  hasOnScroll?: boolean;
141
- allowingReadAccessToURL?: string;
142
127
  allowsBackForwardNavigationGestures?: boolean;
143
128
  allowsInlineMediaPlayback?: boolean;
144
129
  allowsPictureInPictureMediaPlayback?: boolean;
145
- allowsAirPlayForMediaPlayback?: boolean;
146
130
  allowsLinkPreview?: WithDefault<boolean, true>;
147
131
  automaticallyAdjustContentInsets?: WithDefault<boolean, true>;
148
132
  autoManageStatusBarEnabled?: WithDefault<boolean, true>;
@@ -172,17 +156,12 @@ export interface NativeProps extends ViewProps {
172
156
  useSharedProcessPool?: WithDefault<boolean, true>;
173
157
  onContentProcessDidTerminate?: DirectEventHandler<WebViewNativeEvent>;
174
158
  onCustomMenuSelection?: DirectEventHandler<WebViewCustomMenuSelectionEvent>;
175
- onFileDownload?: DirectEventHandler<WebViewDownloadEvent>;
176
159
  menuItems?: ReadonlyArray<Readonly<{
177
160
  label: string;
178
161
  key: string;
179
162
  }>>;
180
163
  suppressMenuItems?: Readonly<string>[];
181
- hasOnFileDownload?: boolean;
182
164
  fraudulentWebsiteWarningEnabled?: WithDefault<boolean, true>;
183
- allowFileAccessFromFileURLs?: boolean;
184
- allowUniversalAccessFromFileURLs?: boolean;
185
- applicationNameForUserAgent?: string;
186
165
  basicAuthCredential?: Readonly<{
187
166
  username: string;
188
167
  password: string;
@@ -191,9 +170,6 @@ export interface NativeProps extends ViewProps {
191
170
  incognito?: boolean;
192
171
  injectedJavaScript?: string;
193
172
  injectedJavaScriptBeforeContentLoaded?: string;
194
- injectedJavaScriptForMainFrameOnly?: WithDefault<boolean, true>;
195
- injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: WithDefault<boolean, true>;
196
- javaScriptCanOpenWindowsAutomatically?: boolean;
197
173
  javaScriptEnabled?: WithDefault<boolean, true>;
198
174
  webviewDebuggingEnabled?: boolean;
199
175
  mediaPlaybackRequiresUserAction?: WithDefault<boolean, true>;
@@ -203,7 +179,6 @@ export interface NativeProps extends ViewProps {
203
179
  onLoadingFinish: DirectEventHandler<WebViewNavigationEvent>;
204
180
  onLoadingProgress: DirectEventHandler<WebViewNativeProgressEvent>;
205
181
  onLoadingStart: DirectEventHandler<WebViewNavigationEvent>;
206
- onHttpError: DirectEventHandler<WebViewHttpErrorEvent>;
207
182
  onMessage: DirectEventHandler<WebViewMessageEvent>;
208
183
  onOpenWindow?: DirectEventHandler<WebViewOpenWindowEvent>;
209
184
  hasOnOpenWindowEvent?: boolean;
@@ -232,7 +207,6 @@ export interface NativeCommands {
232
207
  goForward: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
233
208
  reload: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
234
209
  stopLoading: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
235
- injectJavaScript: (viewRef: React.ElementRef<HostComponent<NativeProps>>, javascript: string) => void;
236
210
  requestFocus: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
237
211
  postMessage: (viewRef: React.ElementRef<HostComponent<NativeProps>>, data: string) => void;
238
212
  loadUrl: (viewRef: React.ElementRef<HostComponent<NativeProps>>, url: string) => void;
@@ -1 +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",[]);}};
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'},topLoadingError:{registrationName:'onLoadingError'},topLoadingSubResourceError:{registrationName:'onLoadingSubResourceError'},topLoadingFinish:{registrationName:'onLoadingFinish'},topLoadingProgress:{registrationName:'onLoadingProgress'},topLoadingStart:{registrationName:'onLoadingStart'},topMessage:{registrationName:'onMessage'},topOpenWindow:{registrationName:'onOpenWindow'},topScroll:{registrationName:'onScroll'},topShouldStartLoadWithRequest:{registrationName:'onShouldStartLoadWithRequest'}},validAttributes:Object.assign({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,allowsBackForwardNavigationGestures:true,allowsInlineMediaPlayback:true,allowsPictureInPictureMediaPlayback: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,fraudulentWebsiteWarningEnabled:true,basicAuthCredential:true,cacheEnabled:true,incognito:true,injectedJavaScript:true,injectedJavaScriptBeforeContentLoaded: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,onLoadingError:true,onLoadingSubResourceError:true,onLoadingFinish:true,onLoadingProgress:true,onLoadingStart: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",[]);},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",[]);}};
@@ -1 +1 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _BatchedBridge=_interopRequireDefault(require("react-native/Libraries/BatchedBridge/BatchedBridge"));var _EventEmitter=_interopRequireDefault(require("react-native/Libraries/vendor/emitter/EventEmitter"));var _invariant=_interopRequireDefault(require("invariant"));var _RNCWebViewNativeComponent=_interopRequireWildcard(require("./RNCWebViewNativeComponent"));var _NativeRNCWebViewModule=_interopRequireDefault(require("./NativeRNCWebViewModule"));var _WebViewShared=require("./WebViewShared");var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["overScrollMode","javaScriptEnabled","thirdPartyCookiesEnabled","scalesPageToFit","allowsFullscreenVideo","allowFileAccess","saveFormDataDisabled","cacheEnabled","androidLayerType","originWhitelist","deeplinkWhitelist","setBuiltInZoomControls","setDisplayZoomControls","nestedScrollEnabled","startInLoadingState","onNavigationStateChange","onLoadStart","onError","onLoad","onLoadEnd","onLoadSubResourceError","onLoadProgress","onHttpError","onRenderProcessGone","onMessage","onOpenWindow","renderLoading","renderError","style","containerStyle","source","nativeConfig","onShouldStartLoadWithRequest","injectedJavaScriptObject","validateMeta","validateData","minimumChromeVersion","unsupportedVersionComponent"],_excluded2=["messagingModuleName"],_excluded3=["messagingModuleName"];var _require$registerCall,_this=this,_jsxFileName="/Users/raulgomezacuna/Development/react-native-webview/src/WebView.android.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var resolveAssetSource=_reactNative.Image.resolveAssetSource;var directEventEmitter=new _EventEmitter.default();var registerCallableModule=(_require$registerCall=require('react-native').registerCallableModule)!=null?_require$registerCall:_BatchedBridge.default.registerCallableModule.bind(_BatchedBridge.default);registerCallableModule('RNCWebViewMessagingModule',{onShouldStartLoadWithRequest:function onShouldStartLoadWithRequest(event){directEventEmitter.emit('onShouldStartLoadWithRequest',event);},onMessage:function onMessage(event){directEventEmitter.emit('onMessage',event);}});var _ref=_reactNative.NativeModules.RNCWebViewUtils||{},getWebViewDefaultUserAgent=_ref.getWebViewDefaultUserAgent;var userAgentPromise;function getUserAgent(){return _getUserAgent.apply(this,arguments);}function _getUserAgent(){_getUserAgent=(0,_asyncToGenerator2.default)(function*(){if(!getWebViewDefaultUserAgent)return'unknown';if(!userAgentPromise)userAgentPromise=getWebViewDefaultUserAgent();var userAgent=yield userAgentPromise;return userAgent||'unknown';});return _getUserAgent.apply(this,arguments);}var hardMinimumChromeVersion='100.0';var mediaPlaybackRequiresUserAction=true;var securitySupportMultipleWindows=true;var securityMixedContentMode='never';var uniqueRef=0;var WebViewComponent=(0,_react.forwardRef)(function(_ref2,ref){var _userAgent$match;var _ref2$overScrollMode=_ref2.overScrollMode,overScrollMode=_ref2$overScrollMode===void 0?'always':_ref2$overScrollMode,_ref2$javaScriptEnabl=_ref2.javaScriptEnabled,javaScriptEnabled=_ref2$javaScriptEnabl===void 0?true:_ref2$javaScriptEnabl,_ref2$thirdPartyCooki=_ref2.thirdPartyCookiesEnabled,thirdPartyCookiesEnabled=_ref2$thirdPartyCooki===void 0?true:_ref2$thirdPartyCooki,_ref2$scalesPageToFit=_ref2.scalesPageToFit,scalesPageToFit=_ref2$scalesPageToFit===void 0?true:_ref2$scalesPageToFit,_ref2$allowsFullscree=_ref2.allowsFullscreenVideo,allowsFullscreenVideo=_ref2$allowsFullscree===void 0?false:_ref2$allowsFullscree,_ref2$allowFileAccess=_ref2.allowFileAccess,allowFileAccess=_ref2$allowFileAccess===void 0?false:_ref2$allowFileAccess,_ref2$saveFormDataDis=_ref2.saveFormDataDisabled,saveFormDataDisabled=_ref2$saveFormDataDis===void 0?false:_ref2$saveFormDataDis,_ref2$cacheEnabled=_ref2.cacheEnabled,cacheEnabled=_ref2$cacheEnabled===void 0?true:_ref2$cacheEnabled,_ref2$androidLayerTyp=_ref2.androidLayerType,androidLayerType=_ref2$androidLayerTyp===void 0?'none':_ref2$androidLayerTyp,_ref2$originWhitelist=_ref2.originWhitelist,originWhitelist=_ref2$originWhitelist===void 0?_WebViewShared.defaultOriginWhitelist:_ref2$originWhitelist,_ref2$deeplinkWhiteli=_ref2.deeplinkWhitelist,deeplinkWhitelist=_ref2$deeplinkWhiteli===void 0?_WebViewShared.defaultDeeplinkWhitelist:_ref2$deeplinkWhiteli,_ref2$setBuiltInZoomC=_ref2.setBuiltInZoomControls,setBuiltInZoomControls=_ref2$setBuiltInZoomC===void 0?true:_ref2$setBuiltInZoomC,_ref2$setDisplayZoomC=_ref2.setDisplayZoomControls,setDisplayZoomControls=_ref2$setDisplayZoomC===void 0?false:_ref2$setDisplayZoomC,_ref2$nestedScrollEna=_ref2.nestedScrollEnabled,nestedScrollEnabled=_ref2$nestedScrollEna===void 0?false:_ref2$nestedScrollEna,startInLoadingState=_ref2.startInLoadingState,onNavigationStateChange=_ref2.onNavigationStateChange,onLoadStart=_ref2.onLoadStart,onError=_ref2.onError,onLoad=_ref2.onLoad,onLoadEnd=_ref2.onLoadEnd,onLoadSubResourceError=_ref2.onLoadSubResourceError,onLoadProgress=_ref2.onLoadProgress,onHttpErrorProp=_ref2.onHttpError,onRenderProcessGoneProp=_ref2.onRenderProcessGone,onMessageProp=_ref2.onMessage,onOpenWindowProp=_ref2.onOpenWindow,renderLoading=_ref2.renderLoading,renderError=_ref2.renderError,style=_ref2.style,containerStyle=_ref2.containerStyle,source=_ref2.source,nativeConfig=_ref2.nativeConfig,onShouldStartLoadWithRequestProp=_ref2.onShouldStartLoadWithRequest,injectedJavaScriptObject=_ref2.injectedJavaScriptObject,validateMeta=_ref2.validateMeta,validateData=_ref2.validateData,minimumChromeVersion=_ref2.minimumChromeVersion,UnsupportedVersionComponent=_ref2.unsupportedVersionComponent,otherProps=(0,_objectWithoutProperties2.default)(_ref2,_excluded);var messagingModuleName=(0,_react.useRef)(`WebViewMessageHandler${uniqueRef+=1}`).current;var webViewRef=(0,_react.useRef)(null);var _useState=(0,_react.useState)(),_useState2=(0,_slicedToArray2.default)(_useState,2),userAgent=_useState2[0],setUserAgent=_useState2[1];(0,_react.useEffect)(function(){getUserAgent().then(setUserAgent);},[]);var onShouldStartLoadWithRequestCallback=(0,_react.useCallback)(function(shouldStart,url,lockIdentifier){if(lockIdentifier){_NativeRNCWebViewModule.default.shouldStartLoadWithLockIdentifier(shouldStart,lockIdentifier);}else if(shouldStart&&webViewRef.current){_RNCWebViewNativeComponent.Commands.loadUrl(webViewRef.current,url);}},[]);var _useWebViewLogic=(0,_WebViewShared.useWebViewLogic)({onNavigationStateChange:onNavigationStateChange,onLoad:onLoad,onError:onError,onHttpErrorProp:onHttpErrorProp,onLoadSubResourceError:onLoadSubResourceError,onLoadEnd:onLoadEnd,onLoadProgress:onLoadProgress,onLoadStart:onLoadStart,onRenderProcessGoneProp:onRenderProcessGoneProp,onMessageProp:onMessageProp,onOpenWindowProp:onOpenWindowProp,startInLoadingState:startInLoadingState,originWhitelist:originWhitelist,deeplinkWhitelist:deeplinkWhitelist,onShouldStartLoadWithRequestProp:onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback:onShouldStartLoadWithRequestCallback,validateMeta:validateMeta,validateData:validateData}),onLoadingStart=_useWebViewLogic.onLoadingStart,onShouldStartLoadWithRequest=_useWebViewLogic.onShouldStartLoadWithRequest,onMessage=_useWebViewLogic.onMessage,viewState=_useWebViewLogic.viewState,setViewState=_useWebViewLogic.setViewState,lastErrorEvent=_useWebViewLogic.lastErrorEvent,onHttpError=_useWebViewLogic.onHttpError,onLoadingError=_useWebViewLogic.onLoadingError,onLoadingSubResourceError=_useWebViewLogic.onLoadingSubResourceError,onLoadingFinish=_useWebViewLogic.onLoadingFinish,onLoadingProgress=_useWebViewLogic.onLoadingProgress,onOpenWindow=_useWebViewLogic.onOpenWindow,onRenderProcessGone=_useWebViewLogic.onRenderProcessGone;(0,_react.useImperativeHandle)(ref,function(){return{goForward:function goForward(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goForward(webViewRef.current);},goBack:function goBack(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goBack(webViewRef.current);},reload:function reload(){setViewState('LOADING');if(webViewRef.current){_RNCWebViewNativeComponent.Commands.reload(webViewRef.current);}},stopLoading:function stopLoading(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.stopLoading(webViewRef.current);},postMessage:function postMessage(data){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.postMessage(webViewRef.current,data);},injectJavaScript:function injectJavaScript(data){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.injectJavaScript(webViewRef.current,data);},requestFocus:function requestFocus(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.requestFocus(webViewRef.current);},clearFormData:function clearFormData(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearFormData(webViewRef.current);},clearCache:function clearCache(includeDiskFiles){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearCache(webViewRef.current,includeDiskFiles);},clearHistory:function clearHistory(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearHistory(webViewRef.current);}};},[setViewState,webViewRef]);(0,_react.useEffect)(function(){var onShouldStartLoadWithRequestSubscription=directEventEmitter.addListener('onShouldStartLoadWithRequest',function(event){if(event.messagingModuleName===messagingModuleName){var _=event.messagingModuleName,rest=(0,_objectWithoutProperties2.default)(event,_excluded2);onShouldStartLoadWithRequest(rest);}});var onMessageSubscription=directEventEmitter.addListener('onMessage',function(event){if(event.messagingModuleName===messagingModuleName){var _=event.messagingModuleName,rest=(0,_objectWithoutProperties2.default)(event,_excluded3);onMessage(rest);}});return function(){onShouldStartLoadWithRequestSubscription.remove();onMessageSubscription.remove();};},[messagingModuleName,onMessage,onShouldStartLoadWithRequest]);if(!userAgent)return null;var chromeVersion=(_userAgent$match=userAgent.match(/chrome\/((?:[0-9]+\.)+[0-9]+)/i))==null?void 0:_userAgent$match[1];if(!((0,_WebViewShared.versionPasses)(chromeVersion,minimumChromeVersion)&&(0,_WebViewShared.versionPasses)(chromeVersion,hardMinimumChromeVersion))){if(UnsupportedVersionComponent){return(0,_jsxRuntime.jsx)(UnsupportedVersionComponent,{});}return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{alignSelf:'flex-start'},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:'red'},children:"Chrome version is outdated and insecure. Update it to continue."})});}var otherView;if(viewState==='LOADING'){otherView=(renderLoading||_WebViewShared.defaultRenderLoading)();}else if(viewState==='ERROR'){(0,_invariant.default)(lastErrorEvent!=null,'lastErrorEvent expected to be non-null');if(lastErrorEvent){otherView=(renderError||_WebViewShared.defaultRenderError)(lastErrorEvent.domain,lastErrorEvent.code,lastErrorEvent.description);}}else if(viewState!=='IDLE'){console.error(`RNCWebView invalid state encountered: ${viewState}`);}var webViewStyles=[_WebView.default.container,_WebView.default.webView,style];var webViewContainerStyle=[_WebView.default.container,containerStyle];if(typeof source!=='number'&&source&&'method'in source){if(source.method==='POST'&&source.headers){console.warn('WebView: `source.headers` is not supported when using POST.');}else if(source.method==='GET'&&source.body){console.warn('WebView: `source.body` is not supported when using GET.');}}var NativeWebView=(nativeConfig==null?void 0:nativeConfig.component)||_RNCWebViewNativeComponent.default;var sourceResolved=resolveAssetSource(source);var newSource=typeof sourceResolved==='object'?Object.entries(sourceResolved).reduce(function(prev,_ref3){var _ref4=(0,_slicedToArray2.default)(_ref3,2),currKey=_ref4[0],currValue=_ref4[1];return Object.assign({},prev,(0,_defineProperty2.default)({},currKey,currKey==='headers'&&currValue&&typeof currValue==='object'?Object.entries(currValue).map(function(_ref5){var _ref6=(0,_slicedToArray2.default)(_ref5,2),key=_ref6[0],value=_ref6[1];return{name:key,value:value};}):currValue));},{}):sourceResolved;var webView=(0,_jsxRuntime.jsx)(NativeWebView,Object.assign({},otherProps,{messagingEnabled:typeof onMessageProp==='function',messagingModuleName:messagingModuleName,hasOnScroll:!!otherProps.onScroll,onLoadingError:onLoadingError,onLoadingSubResourceError:onLoadingSubResourceError,onLoadingFinish:onLoadingFinish,onLoadingProgress:onLoadingProgress,onLoadingStart:onLoadingStart,onHttpError:onHttpError,onRenderProcessGone:onRenderProcessGone,onMessage:onMessage,onOpenWindow:onOpenWindow,hasOnOpenWindowEvent:onOpenWindowProp!==undefined,onShouldStartLoadWithRequest:onShouldStartLoadWithRequest,ref:webViewRef,source:sourceResolved,newSource:newSource,style:webViewStyles,overScrollMode:overScrollMode,javaScriptEnabled:javaScriptEnabled,thirdPartyCookiesEnabled:thirdPartyCookiesEnabled,scalesPageToFit:scalesPageToFit,allowsFullscreenVideo:allowsFullscreenVideo,allowFileAccess:allowFileAccess,saveFormDataDisabled:saveFormDataDisabled,cacheEnabled:cacheEnabled,androidLayerType:androidLayerType,setSupportMultipleWindows:securitySupportMultipleWindows,setBuiltInZoomControls:setBuiltInZoomControls,setDisplayZoomControls:setDisplayZoomControls,nestedScrollEnabled:nestedScrollEnabled,mixedContentMode:securityMixedContentMode,mediaPlaybackRequiresUserAction:mediaPlaybackRequiresUserAction,injectedJavaScriptObject:JSON.stringify(injectedJavaScriptObject)},nativeConfig==null?void 0:nativeConfig.props),"webViewKey");return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:webViewContainerStyle,children:[webView,otherView]});});var isFileUploadSupported=_NativeRNCWebViewModule.default.isFileUploadSupported;var WebView=Object.assign(WebViewComponent,{isFileUploadSupported:isFileUploadSupported});var _default=exports.default=WebView;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _BatchedBridge=_interopRequireDefault(require("react-native/Libraries/BatchedBridge/BatchedBridge"));var _EventEmitter=_interopRequireDefault(require("react-native/Libraries/vendor/emitter/EventEmitter"));var _invariant=_interopRequireDefault(require("invariant"));var _RNCWebViewNativeComponent=_interopRequireWildcard(require("./RNCWebViewNativeComponent"));var _NativeRNCWebViewModule=_interopRequireDefault(require("./NativeRNCWebViewModule"));var _WebViewShared=require("./WebViewShared");var _validation=_interopRequireDefault(require("./validation"));var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["overScrollMode","javaScriptEnabled","thirdPartyCookiesEnabled","scalesPageToFit","allowsFullscreenVideo","saveFormDataDisabled","cacheEnabled","androidLayerType","originWhitelist","deeplinkWhitelist","setBuiltInZoomControls","setDisplayZoomControls","nestedScrollEnabled","startInLoadingState","onNavigationStateChange","onLoadStart","onError","onLoad","onLoadEnd","onLoadSubResourceError","onLoadProgress","onRenderProcessGone","onMessage","onOpenWindow","renderLoading","renderError","style","containerStyle","source","onShouldStartLoadWithRequest","injectedJavaScriptObject","validateMeta","validateData","minimumChromeVersion","unsupportedVersionComponent"],_excluded2=["messagingModuleName"],_excluded3=["messagingModuleName"];var _require$registerCall;function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var resolveAssetSource=_reactNative.Image.resolveAssetSource;var directEventEmitter=new _EventEmitter.default();var registerCallableModule=(_require$registerCall=require('react-native').registerCallableModule)!=null?_require$registerCall:_BatchedBridge.default.registerCallableModule.bind(_BatchedBridge.default);registerCallableModule('RNCWebViewMessagingModule',{onShouldStartLoadWithRequest:function onShouldStartLoadWithRequest(event){directEventEmitter.emit('onShouldStartLoadWithRequest',event);},onMessage:function onMessage(event){directEventEmitter.emit('onMessage',event);}});var _ref=_reactNative.NativeModules.RNCWebViewUtils||{},getWebViewDefaultUserAgent=_ref.getWebViewDefaultUserAgent;var userAgentPromise;function getUserAgent(){return _getUserAgent.apply(this,arguments);}function _getUserAgent(){_getUserAgent=(0,_asyncToGenerator2.default)(function*(){if(!getWebViewDefaultUserAgent)return'unknown';if(!userAgentPromise)userAgentPromise=getWebViewDefaultUserAgent();var userAgent=yield userAgentPromise;return userAgent||'unknown';});return _getUserAgent.apply(this,arguments);}var hardMinimumChromeVersion='100.0';var mediaPlaybackRequiresUserAction=true;var securitySupportMultipleWindows=true;var securityMixedContentMode='never';var uniqueRef=0;var WebViewComponent=(0,_react.forwardRef)(function(props,ref){var _userAgent$match;(0,_validation.default)(props);var _props$overScrollMode=props.overScrollMode,overScrollMode=_props$overScrollMode===void 0?'always':_props$overScrollMode,_props$javaScriptEnab=props.javaScriptEnabled,javaScriptEnabled=_props$javaScriptEnab===void 0?true:_props$javaScriptEnab,_props$thirdPartyCook=props.thirdPartyCookiesEnabled,thirdPartyCookiesEnabled=_props$thirdPartyCook===void 0?true:_props$thirdPartyCook,_props$scalesPageToFi=props.scalesPageToFit,scalesPageToFit=_props$scalesPageToFi===void 0?true:_props$scalesPageToFi,_props$allowsFullscre=props.allowsFullscreenVideo,allowsFullscreenVideo=_props$allowsFullscre===void 0?false:_props$allowsFullscre,_props$saveFormDataDi=props.saveFormDataDisabled,saveFormDataDisabled=_props$saveFormDataDi===void 0?false:_props$saveFormDataDi,_props$cacheEnabled=props.cacheEnabled,cacheEnabled=_props$cacheEnabled===void 0?true:_props$cacheEnabled,_props$androidLayerTy=props.androidLayerType,androidLayerType=_props$androidLayerTy===void 0?'none':_props$androidLayerTy,_props$originWhitelis=props.originWhitelist,originWhitelist=_props$originWhitelis===void 0?_WebViewShared.defaultOriginWhitelist:_props$originWhitelis,_props$deeplinkWhitel=props.deeplinkWhitelist,deeplinkWhitelist=_props$deeplinkWhitel===void 0?_WebViewShared.defaultDeeplinkWhitelist:_props$deeplinkWhitel,_props$setBuiltInZoom=props.setBuiltInZoomControls,setBuiltInZoomControls=_props$setBuiltInZoom===void 0?true:_props$setBuiltInZoom,_props$setDisplayZoom=props.setDisplayZoomControls,setDisplayZoomControls=_props$setDisplayZoom===void 0?false:_props$setDisplayZoom,_props$nestedScrollEn=props.nestedScrollEnabled,nestedScrollEnabled=_props$nestedScrollEn===void 0?false:_props$nestedScrollEn,startInLoadingState=props.startInLoadingState,onNavigationStateChange=props.onNavigationStateChange,onLoadStart=props.onLoadStart,onError=props.onError,onLoad=props.onLoad,onLoadEnd=props.onLoadEnd,onLoadSubResourceError=props.onLoadSubResourceError,onLoadProgress=props.onLoadProgress,onRenderProcessGoneProp=props.onRenderProcessGone,onMessageProp=props.onMessage,onOpenWindowProp=props.onOpenWindow,renderLoading=props.renderLoading,renderError=props.renderError,style=props.style,containerStyle=props.containerStyle,source=props.source,onShouldStartLoadWithRequestProp=props.onShouldStartLoadWithRequest,injectedJavaScriptObject=props.injectedJavaScriptObject,validateMeta=props.validateMeta,validateData=props.validateData,minimumChromeVersion=props.minimumChromeVersion,UnsupportedVersionComponent=props.unsupportedVersionComponent,otherProps=(0,_objectWithoutProperties2.default)(props,_excluded);var messagingModuleName=(0,_react.useRef)(`WebViewMessageHandler${uniqueRef+=1}`).current;var webViewRef=(0,_react.useRef)(null);var _useState=(0,_react.useState)(),_useState2=(0,_slicedToArray2.default)(_useState,2),userAgent=_useState2[0],setUserAgent=_useState2[1];(0,_react.useEffect)(function(){getUserAgent().then(setUserAgent);},[]);var onShouldStartLoadWithRequestCallback=(0,_react.useCallback)(function(shouldStart,url,lockIdentifier){if(lockIdentifier){_NativeRNCWebViewModule.default.shouldStartLoadWithLockIdentifier(shouldStart,lockIdentifier);}else if(shouldStart&&webViewRef.current){_RNCWebViewNativeComponent.Commands.loadUrl(webViewRef.current,url);}},[]);var _useWebViewLogic=(0,_WebViewShared.useWebViewLogic)({onNavigationStateChange:onNavigationStateChange,onLoad:onLoad,onError:onError,onLoadSubResourceError:onLoadSubResourceError,onLoadEnd:onLoadEnd,onLoadProgress:onLoadProgress,onLoadStart:onLoadStart,onRenderProcessGoneProp:onRenderProcessGoneProp,onMessageProp:onMessageProp,onOpenWindowProp:onOpenWindowProp,startInLoadingState:startInLoadingState,originWhitelist:originWhitelist,deeplinkWhitelist:deeplinkWhitelist,onShouldStartLoadWithRequestProp:onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback:onShouldStartLoadWithRequestCallback,validateMeta:validateMeta,validateData:validateData}),onLoadingStart=_useWebViewLogic.onLoadingStart,onShouldStartLoadWithRequest=_useWebViewLogic.onShouldStartLoadWithRequest,onMessage=_useWebViewLogic.onMessage,viewState=_useWebViewLogic.viewState,setViewState=_useWebViewLogic.setViewState,lastErrorEvent=_useWebViewLogic.lastErrorEvent,onLoadingError=_useWebViewLogic.onLoadingError,onLoadingSubResourceError=_useWebViewLogic.onLoadingSubResourceError,onLoadingFinish=_useWebViewLogic.onLoadingFinish,onLoadingProgress=_useWebViewLogic.onLoadingProgress,onOpenWindow=_useWebViewLogic.onOpenWindow,onRenderProcessGone=_useWebViewLogic.onRenderProcessGone;(0,_react.useImperativeHandle)(ref,function(){return{goForward:function goForward(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goForward(webViewRef.current);},goBack:function goBack(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goBack(webViewRef.current);},reload:function reload(){setViewState('LOADING');if(webViewRef.current){_RNCWebViewNativeComponent.Commands.reload(webViewRef.current);}},stopLoading:function stopLoading(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.stopLoading(webViewRef.current);},postMessage:function postMessage(data){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.postMessage(webViewRef.current,data);},requestFocus:function requestFocus(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.requestFocus(webViewRef.current);},clearFormData:function clearFormData(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearFormData(webViewRef.current);},clearCache:function clearCache(includeDiskFiles){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearCache(webViewRef.current,includeDiskFiles);},clearHistory:function clearHistory(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearHistory(webViewRef.current);}};},[setViewState,webViewRef]);(0,_react.useEffect)(function(){var onShouldStartLoadWithRequestSubscription=directEventEmitter.addListener('onShouldStartLoadWithRequest',function(event){if(event.messagingModuleName===messagingModuleName){var _=event.messagingModuleName,rest=(0,_objectWithoutProperties2.default)(event,_excluded2);onShouldStartLoadWithRequest(rest);}});var onMessageSubscription=directEventEmitter.addListener('onMessage',function(event){if(event.messagingModuleName===messagingModuleName){var _=event.messagingModuleName,rest=(0,_objectWithoutProperties2.default)(event,_excluded3);onMessage(rest);}});return function(){onShouldStartLoadWithRequestSubscription.remove();onMessageSubscription.remove();};},[messagingModuleName,onMessage,onShouldStartLoadWithRequest]);var compiledWhitelist=(0,_react.useMemo)(function(){return(0,_WebViewShared.compileWhitelist)(originWhitelist);},[originWhitelist]);var safeSource=(0,_react.useMemo)(function(){if(source&&typeof source==='object'&&'uri'in source&&typeof source.uri==='string'){if(!(0,_WebViewShared.passesWhitelist)(compiledWhitelist,source.uri)){console.warn(`WebView: source.uri "${source.uri}" does not pass the origin whitelist. Loading about:blank instead.`);return{uri:'about:blank'};}}return source;},[source,compiledWhitelist]);if(!userAgent)return null;var chromeVersion=(_userAgent$match=userAgent.match(/chrome\/((?:[0-9]+\.)+[0-9]+)/i))==null?void 0:_userAgent$match[1];if(!((0,_WebViewShared.versionPasses)(chromeVersion,minimumChromeVersion)&&(0,_WebViewShared.versionPasses)(chromeVersion,hardMinimumChromeVersion))){if(UnsupportedVersionComponent){return(0,_jsxRuntime.jsx)(UnsupportedVersionComponent,{});}return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{alignSelf:'flex-start'},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:'red'},children:"Chrome version is outdated and insecure. Update it to continue."})});}var otherView;if(viewState==='LOADING'){otherView=(renderLoading||_WebViewShared.defaultRenderLoading)();}else if(viewState==='ERROR'){(0,_invariant.default)(lastErrorEvent!=null,'lastErrorEvent expected to be non-null');if(lastErrorEvent){otherView=(renderError||_WebViewShared.defaultRenderError)(lastErrorEvent.domain,lastErrorEvent.code,lastErrorEvent.description);}}else if(viewState!=='IDLE'){console.error(`RNCWebView invalid state encountered: ${viewState}`);}var webViewStyles=[_WebView.default.container,_WebView.default.webView,style];var webViewContainerStyle=[_WebView.default.container,containerStyle];if(typeof safeSource!=='number'&&safeSource&&'method'in safeSource){if(safeSource.method==='POST'&&safeSource.headers){console.warn('WebView: `source.headers` is not supported when using POST.');}else if(safeSource.method==='GET'&&safeSource.body){console.warn('WebView: `source.body` is not supported when using GET.');}}var sourceResolved=resolveAssetSource(safeSource);var newSource=typeof sourceResolved==='object'?Object.entries(sourceResolved).reduce(function(prev,_ref2){var _ref3=(0,_slicedToArray2.default)(_ref2,2),currKey=_ref3[0],currValue=_ref3[1];return Object.assign({},prev,(0,_defineProperty2.default)({},currKey,currKey==='headers'&&currValue&&typeof currValue==='object'?Object.entries(currValue).map(function(_ref4){var _ref5=(0,_slicedToArray2.default)(_ref4,2),key=_ref5[0],value=_ref5[1];return{name:key,value:value};}):currValue));},{}):sourceResolved;var webView=(0,_jsxRuntime.jsx)(_RNCWebViewNativeComponent.default,Object.assign({},otherProps,{messagingEnabled:typeof onMessageProp==='function',messagingModuleName:messagingModuleName,hasOnScroll:!!otherProps.onScroll,onLoadingError:onLoadingError,onLoadingSubResourceError:onLoadingSubResourceError,onLoadingFinish:onLoadingFinish,onLoadingProgress:onLoadingProgress,onLoadingStart:onLoadingStart,onRenderProcessGone:onRenderProcessGone,onMessage:onMessage,onOpenWindow:onOpenWindow,hasOnOpenWindowEvent:onOpenWindowProp!==undefined,onShouldStartLoadWithRequest:onShouldStartLoadWithRequest,ref:webViewRef,source:sourceResolved,newSource:newSource,style:webViewStyles,overScrollMode:overScrollMode,javaScriptEnabled:javaScriptEnabled,thirdPartyCookiesEnabled:thirdPartyCookiesEnabled,scalesPageToFit:scalesPageToFit,allowsFullscreenVideo:allowsFullscreenVideo,saveFormDataDisabled:saveFormDataDisabled,cacheEnabled:cacheEnabled,androidLayerType:androidLayerType,setSupportMultipleWindows:securitySupportMultipleWindows,setBuiltInZoomControls:setBuiltInZoomControls,setDisplayZoomControls:setDisplayZoomControls,nestedScrollEnabled:nestedScrollEnabled,mixedContentMode:securityMixedContentMode,mediaPlaybackRequiresUserAction:mediaPlaybackRequiresUserAction,injectedJavaScriptObject:JSON.stringify(injectedJavaScriptObject)}),"webViewKey");return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:webViewContainerStyle,children:[webView,otherView]});});var isFileUploadSupported=_NativeRNCWebViewModule.default.isFileUploadSupported;var WebView=Object.assign(WebViewComponent,{isFileUploadSupported:isFileUploadSupported});var _default=exports.default=WebView;
package/lib/WebView.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { IOSWebViewProps, AndroidWebViewProps, WindowsWebViewProps } from './WebViewTypes';
3
- export type WebViewProps = IOSWebViewProps & AndroidWebViewProps & WindowsWebViewProps;
2
+ import { IOSWebViewProps, AndroidWebViewProps } from './WebViewTypes';
3
+ export type WebViewProps = IOSWebViewProps & AndroidWebViewProps;
4
4
  declare const WebView: React.FunctionComponent<WebViewProps>;
5
5
  export { WebView };
6
6
  export default WebView;
@@ -1 +1 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _invariant=_interopRequireDefault(require("invariant"));var _RNCWebViewNativeComponent=_interopRequireWildcard(require("./RNCWebViewNativeComponent"));var _NativeRNCWebViewModule=_interopRequireDefault(require("./NativeRNCWebViewModule"));var _WebViewShared=require("./WebViewShared");var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["fraudulentWebsiteWarningEnabled","javaScriptEnabled","cacheEnabled","originWhitelist","deeplinkWhitelist","textInteractionEnabled","injectedJavaScript","injectedJavaScriptBeforeContentLoaded","injectedJavaScriptForMainFrameOnly","injectedJavaScriptBeforeContentLoadedForMainFrameOnly","injectedJavaScriptObject","startInLoadingState","onNavigationStateChange","onLoadStart","onError","onLoad","onLoadEnd","onLoadProgress","onContentProcessDidTerminate","onFileDownload","onHttpError","onMessage","onOpenWindow","renderLoading","renderError","style","containerStyle","source","nativeConfig","allowsPictureInPictureMediaPlayback","allowsAirPlayForMediaPlayback","incognito","decelerationRate","onShouldStartLoadWithRequest","validateMeta","validateData","minimumIOSVersion","unsupportedVersionComponent"];var _this=this,_jsxFileName="/Users/raulgomezacuna/Development/react-native-webview/src/WebView.ios.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var resolveAssetSource=_reactNative.Image.resolveAssetSource;var processDecelerationRate=function processDecelerationRate(decelerationRate){var newDecelerationRate=decelerationRate;if(newDecelerationRate==='normal'){newDecelerationRate=0.998;}else if(newDecelerationRate==='fast'){newDecelerationRate=0.99;}return newDecelerationRate;};var hardMinimumIOSVersion='12.5.6 <13, 13.6.1 <14, 14.8.1 <15, 15.7.1';var securityMediaPlaybackRequiresUserAction=true;var securityAllowsInlineMediaPlayback=true;var securityUseSharedProcessPool=false;var securitySharedCookiesEnabled=false;var securityEnableApplePay=false;var securityDataDetectorTypes=['none'];var useWarnIfChanges=function useWarnIfChanges(value,name){var ref=(0,_react.useRef)(value);if(ref.current!==value){console.warn(`Changes to property ${name} do nothing after the initial render.`);ref.current=value;}};var WebViewComponent=(0,_react.forwardRef)(function(_ref,ref){var _ref$fraudulentWebsit=_ref.fraudulentWebsiteWarningEnabled,fraudulentWebsiteWarningEnabled=_ref$fraudulentWebsit===void 0?true:_ref$fraudulentWebsit,_ref$javaScriptEnable=_ref.javaScriptEnabled,javaScriptEnabled=_ref$javaScriptEnable===void 0?true:_ref$javaScriptEnable,_ref$cacheEnabled=_ref.cacheEnabled,cacheEnabled=_ref$cacheEnabled===void 0?true:_ref$cacheEnabled,_ref$originWhitelist=_ref.originWhitelist,originWhitelist=_ref$originWhitelist===void 0?_WebViewShared.defaultOriginWhitelist:_ref$originWhitelist,_ref$deeplinkWhitelis=_ref.deeplinkWhitelist,deeplinkWhitelist=_ref$deeplinkWhitelis===void 0?_WebViewShared.defaultDeeplinkWhitelist:_ref$deeplinkWhitelis,_ref$textInteractionE=_ref.textInteractionEnabled,textInteractionEnabled=_ref$textInteractionE===void 0?true:_ref$textInteractionE,injectedJavaScript=_ref.injectedJavaScript,injectedJavaScriptBeforeContentLoaded=_ref.injectedJavaScriptBeforeContentLoaded,_ref$injectedJavaScri=_ref.injectedJavaScriptForMainFrameOnly,injectedJavaScriptForMainFrameOnly=_ref$injectedJavaScri===void 0?true:_ref$injectedJavaScri,_ref$injectedJavaScri2=_ref.injectedJavaScriptBeforeContentLoadedForMainFrameOnly,injectedJavaScriptBeforeContentLoadedForMainFrameOnly=_ref$injectedJavaScri2===void 0?true:_ref$injectedJavaScri2,injectedJavaScriptObject=_ref.injectedJavaScriptObject,startInLoadingState=_ref.startInLoadingState,onNavigationStateChange=_ref.onNavigationStateChange,onLoadStart=_ref.onLoadStart,onError=_ref.onError,onLoad=_ref.onLoad,onLoadEnd=_ref.onLoadEnd,onLoadProgress=_ref.onLoadProgress,onContentProcessDidTerminateProp=_ref.onContentProcessDidTerminate,onFileDownload=_ref.onFileDownload,onHttpErrorProp=_ref.onHttpError,onMessageProp=_ref.onMessage,onOpenWindowProp=_ref.onOpenWindow,renderLoading=_ref.renderLoading,renderError=_ref.renderError,style=_ref.style,containerStyle=_ref.containerStyle,source=_ref.source,nativeConfig=_ref.nativeConfig,_ref$allowsPictureInP=_ref.allowsPictureInPictureMediaPlayback,allowsPictureInPictureMediaPlayback=_ref$allowsPictureInP===void 0?true:_ref$allowsPictureInP,allowsAirPlayForMediaPlayback=_ref.allowsAirPlayForMediaPlayback,incognito=_ref.incognito,decelerationRateProp=_ref.decelerationRate,onShouldStartLoadWithRequestProp=_ref.onShouldStartLoadWithRequest,validateMeta=_ref.validateMeta,validateData=_ref.validateData,minimumIOSVersion=_ref.minimumIOSVersion,UnsupportedVersionComponent=_ref.unsupportedVersionComponent,otherProps=(0,_objectWithoutProperties2.default)(_ref,_excluded);var webViewRef=(0,_react.useRef)(null);var onShouldStartLoadWithRequestCallback=(0,_react.useCallback)(function(shouldStart,_url){var lockIdentifier=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;_NativeRNCWebViewModule.default.shouldStartLoadWithLockIdentifier(shouldStart,lockIdentifier);},[]);var _useWebViewLogic=(0,_WebViewShared.useWebViewLogic)({onNavigationStateChange:onNavigationStateChange,onLoad:onLoad,onError:onError,onHttpErrorProp:onHttpErrorProp,onLoadEnd:onLoadEnd,onLoadProgress:onLoadProgress,onLoadStart:onLoadStart,onMessageProp:onMessageProp,onOpenWindowProp:onOpenWindowProp,startInLoadingState:startInLoadingState,originWhitelist:originWhitelist,deeplinkWhitelist:deeplinkWhitelist,onShouldStartLoadWithRequestProp:onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback:onShouldStartLoadWithRequestCallback,onContentProcessDidTerminateProp:onContentProcessDidTerminateProp,validateMeta:validateMeta,validateData:validateData}),onLoadingStart=_useWebViewLogic.onLoadingStart,onShouldStartLoadWithRequest=_useWebViewLogic.onShouldStartLoadWithRequest,onMessage=_useWebViewLogic.onMessage,viewState=_useWebViewLogic.viewState,setViewState=_useWebViewLogic.setViewState,lastErrorEvent=_useWebViewLogic.lastErrorEvent,onHttpError=_useWebViewLogic.onHttpError,onLoadingError=_useWebViewLogic.onLoadingError,onLoadingFinish=_useWebViewLogic.onLoadingFinish,onLoadingProgress=_useWebViewLogic.onLoadingProgress,onOpenWindow=_useWebViewLogic.onOpenWindow,onContentProcessDidTerminate=_useWebViewLogic.onContentProcessDidTerminate;(0,_react.useImperativeHandle)(ref,function(){return{goForward:function goForward(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goForward(webViewRef.current);},goBack:function goBack(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goBack(webViewRef.current);},reload:function reload(){setViewState('LOADING');if(webViewRef.current){_RNCWebViewNativeComponent.Commands.reload(webViewRef.current);}},stopLoading:function stopLoading(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.stopLoading(webViewRef.current);},postMessage:function postMessage(data){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.postMessage(webViewRef.current,data);},injectJavaScript:function injectJavaScript(data){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.injectJavaScript(webViewRef.current,data);},requestFocus:function requestFocus(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.requestFocus(webViewRef.current);},clearCache:function clearCache(includeDiskFiles){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearCache(webViewRef.current,includeDiskFiles);}};},[setViewState,webViewRef]);useWarnIfChanges(securityAllowsInlineMediaPlayback,'allowsInlineMediaPlayback');useWarnIfChanges(allowsPictureInPictureMediaPlayback,'allowsPictureInPictureMediaPlayback');useWarnIfChanges(allowsAirPlayForMediaPlayback,'allowsAirPlayForMediaPlayback');useWarnIfChanges(incognito,'incognito');useWarnIfChanges(securityMediaPlaybackRequiresUserAction,'mediaPlaybackRequiresUserAction');useWarnIfChanges(securityDataDetectorTypes,'dataDetectorTypes');var iosVersion=String(_reactNative.Platform.Version);var passesMinimum=minimumIOSVersion?(0,_WebViewShared.versionPasses)(iosVersion,minimumIOSVersion):true;var passesHardMinimum=(0,_WebViewShared.versionPasses)(iosVersion,hardMinimumIOSVersion);if(!passesMinimum||!passesHardMinimum){if(UnsupportedVersionComponent){return(0,_jsxRuntime.jsx)(UnsupportedVersionComponent,{});}return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{alignSelf:'flex-start'},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:'red'},children:"iOS version is outdated and insecure. Update it to continue."})});}var otherView=null;if(viewState==='LOADING'){otherView=(renderLoading||_WebViewShared.defaultRenderLoading)();}else if(viewState==='ERROR'){var _lastErrorEvent$code,_lastErrorEvent$descr;(0,_invariant.default)(lastErrorEvent!=null,'lastErrorEvent expected to be non-null');otherView=(renderError||_WebViewShared.defaultRenderError)(lastErrorEvent==null?void 0:lastErrorEvent.domain,(_lastErrorEvent$code=lastErrorEvent==null?void 0:lastErrorEvent.code)!=null?_lastErrorEvent$code:0,(_lastErrorEvent$descr=lastErrorEvent==null?void 0:lastErrorEvent.description)!=null?_lastErrorEvent$descr:'');}else if(viewState!=='IDLE'){console.error(`RNCWebView invalid state encountered: ${viewState}`);}var webViewStyles=[_WebView.default.container,_WebView.default.webView,style];var webViewContainerStyle=[_WebView.default.container,containerStyle];var decelerationRate=processDecelerationRate(decelerationRateProp);var NativeWebView=(nativeConfig==null?void 0:nativeConfig.component)||_RNCWebViewNativeComponent.default;var sourceResolved=resolveAssetSource(source);var newSource=typeof sourceResolved==='object'?Object.entries(sourceResolved).reduce(function(prev,_ref2){var _ref3=(0,_slicedToArray2.default)(_ref2,2),currKey=_ref3[0],currValue=_ref3[1];return Object.assign({},prev,(0,_defineProperty2.default)({},currKey,currKey==='headers'&&currValue&&typeof currValue==='object'?Object.entries(currValue).map(function(_ref4){var _ref5=(0,_slicedToArray2.default)(_ref4,2),key=_ref5[0],value=_ref5[1];return{name:key,value:value};}):currValue));},{}):sourceResolved;var webView=(0,_jsxRuntime.jsx)(NativeWebView,Object.assign({},otherProps,{fraudulentWebsiteWarningEnabled:fraudulentWebsiteWarningEnabled,javaScriptEnabled:javaScriptEnabled,cacheEnabled:cacheEnabled,useSharedProcessPool:securityUseSharedProcessPool,sharedCookiesEnabled:securitySharedCookiesEnabled,enableApplePay:securityEnableApplePay,textInteractionEnabled:textInteractionEnabled,decelerationRate:decelerationRate,messagingEnabled:typeof onMessageProp==='function',messagingModuleName:"",onLoadingError:onLoadingError,onLoadingFinish:onLoadingFinish,onLoadingProgress:onLoadingProgress,onFileDownload:onFileDownload,onLoadingStart:onLoadingStart,onHttpError:onHttpError,onMessage:onMessage,onOpenWindow:onOpenWindowProp&&onOpenWindow,hasOnOpenWindowEvent:onOpenWindowProp!==undefined,onShouldStartLoadWithRequest:onShouldStartLoadWithRequest,onContentProcessDidTerminate:onContentProcessDidTerminate,injectedJavaScript:injectedJavaScript,injectedJavaScriptBeforeContentLoaded:injectedJavaScriptBeforeContentLoaded,injectedJavaScriptForMainFrameOnly:injectedJavaScriptForMainFrameOnly,injectedJavaScriptBeforeContentLoadedForMainFrameOnly:injectedJavaScriptBeforeContentLoadedForMainFrameOnly,injectedJavaScriptObject:JSON.stringify(injectedJavaScriptObject),dataDetectorTypes:securityDataDetectorTypes,allowsAirPlayForMediaPlayback:allowsAirPlayForMediaPlayback,allowsInlineMediaPlayback:securityAllowsInlineMediaPlayback,allowsPictureInPictureMediaPlayback:allowsPictureInPictureMediaPlayback,incognito:incognito,mediaPlaybackRequiresUserAction:securityMediaPlaybackRequiresUserAction,newSource:newSource,style:webViewStyles,hasOnFileDownload:!!onFileDownload,ref:webViewRef,source:sourceResolved},nativeConfig==null?void 0:nativeConfig.props),"webViewKey");return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:webViewContainerStyle,children:[webView,otherView]});});var isFileUploadSupported=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(){return true;});return function isFileUploadSupported(){return _ref6.apply(this,arguments);};}();var WebView=Object.assign(WebViewComponent,{isFileUploadSupported:isFileUploadSupported});var _default=exports.default=WebView;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _invariant=_interopRequireDefault(require("invariant"));var _RNCWebViewNativeComponent=_interopRequireWildcard(require("./RNCWebViewNativeComponent"));var _NativeRNCWebViewModule=_interopRequireDefault(require("./NativeRNCWebViewModule"));var _WebViewShared=require("./WebViewShared");var _validation=_interopRequireDefault(require("./validation"));var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["fraudulentWebsiteWarningEnabled","javaScriptEnabled","cacheEnabled","originWhitelist","deeplinkWhitelist","textInteractionEnabled","injectedJavaScript","injectedJavaScriptBeforeContentLoaded","injectedJavaScriptObject","startInLoadingState","onNavigationStateChange","onLoadStart","onError","onLoad","onLoadEnd","onLoadProgress","onContentProcessDidTerminate","onMessage","onOpenWindow","renderLoading","renderError","style","containerStyle","source","allowsPictureInPictureMediaPlayback","incognito","decelerationRate","onShouldStartLoadWithRequest","validateMeta","validateData","minimumIOSVersion","unsupportedVersionComponent"];function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var resolveAssetSource=_reactNative.Image.resolveAssetSource;var processDecelerationRate=function processDecelerationRate(decelerationRate){var newDecelerationRate=decelerationRate;if(newDecelerationRate==='normal'){newDecelerationRate=0.998;}else if(newDecelerationRate==='fast'){newDecelerationRate=0.99;}return newDecelerationRate;};var hardMinimumIOSVersion='12.5.6 <13, 13.6.1 <14, 14.8.1 <15, 15.7.1';var securityMediaPlaybackRequiresUserAction=true;var securityAllowsInlineMediaPlayback=true;var securityUseSharedProcessPool=false;var securitySharedCookiesEnabled=false;var securityEnableApplePay=false;var securityDataDetectorTypes=['none'];var useWarnIfChanges=function useWarnIfChanges(value,name){var ref=(0,_react.useRef)(value);if(ref.current!==value){console.warn(`Changes to property ${name} do nothing after the initial render.`);ref.current=value;}};var WebViewComponent=(0,_react.forwardRef)(function(props,ref){(0,_validation.default)(props);var _props$fraudulentWebs=props.fraudulentWebsiteWarningEnabled,fraudulentWebsiteWarningEnabled=_props$fraudulentWebs===void 0?true:_props$fraudulentWebs,_props$javaScriptEnab=props.javaScriptEnabled,javaScriptEnabled=_props$javaScriptEnab===void 0?true:_props$javaScriptEnab,_props$cacheEnabled=props.cacheEnabled,cacheEnabled=_props$cacheEnabled===void 0?true:_props$cacheEnabled,_props$originWhitelis=props.originWhitelist,originWhitelist=_props$originWhitelis===void 0?_WebViewShared.defaultOriginWhitelist:_props$originWhitelis,_props$deeplinkWhitel=props.deeplinkWhitelist,deeplinkWhitelist=_props$deeplinkWhitel===void 0?_WebViewShared.defaultDeeplinkWhitelist:_props$deeplinkWhitel,_props$textInteractio=props.textInteractionEnabled,textInteractionEnabled=_props$textInteractio===void 0?true:_props$textInteractio,injectedJavaScript=props.injectedJavaScript,injectedJavaScriptBeforeContentLoaded=props.injectedJavaScriptBeforeContentLoaded,injectedJavaScriptObject=props.injectedJavaScriptObject,startInLoadingState=props.startInLoadingState,onNavigationStateChange=props.onNavigationStateChange,onLoadStart=props.onLoadStart,onError=props.onError,onLoad=props.onLoad,onLoadEnd=props.onLoadEnd,onLoadProgress=props.onLoadProgress,onContentProcessDidTerminateProp=props.onContentProcessDidTerminate,onMessageProp=props.onMessage,onOpenWindowProp=props.onOpenWindow,renderLoading=props.renderLoading,renderError=props.renderError,style=props.style,containerStyle=props.containerStyle,source=props.source,_props$allowsPictureI=props.allowsPictureInPictureMediaPlayback,allowsPictureInPictureMediaPlayback=_props$allowsPictureI===void 0?true:_props$allowsPictureI,incognito=props.incognito,decelerationRateProp=props.decelerationRate,onShouldStartLoadWithRequestProp=props.onShouldStartLoadWithRequest,validateMeta=props.validateMeta,validateData=props.validateData,minimumIOSVersion=props.minimumIOSVersion,UnsupportedVersionComponent=props.unsupportedVersionComponent,otherProps=(0,_objectWithoutProperties2.default)(props,_excluded);var webViewRef=(0,_react.useRef)(null);var onShouldStartLoadWithRequestCallback=(0,_react.useCallback)(function(shouldStart,_url){var lockIdentifier=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;_NativeRNCWebViewModule.default.shouldStartLoadWithLockIdentifier(shouldStart,lockIdentifier);},[]);var _useWebViewLogic=(0,_WebViewShared.useWebViewLogic)({onNavigationStateChange:onNavigationStateChange,onLoad:onLoad,onError:onError,onLoadEnd:onLoadEnd,onLoadProgress:onLoadProgress,onLoadStart:onLoadStart,onMessageProp:onMessageProp,onOpenWindowProp:onOpenWindowProp,startInLoadingState:startInLoadingState,originWhitelist:originWhitelist,deeplinkWhitelist:deeplinkWhitelist,onShouldStartLoadWithRequestProp:onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback:onShouldStartLoadWithRequestCallback,onContentProcessDidTerminateProp:onContentProcessDidTerminateProp,validateMeta:validateMeta,validateData:validateData}),onLoadingStart=_useWebViewLogic.onLoadingStart,onShouldStartLoadWithRequest=_useWebViewLogic.onShouldStartLoadWithRequest,onMessage=_useWebViewLogic.onMessage,viewState=_useWebViewLogic.viewState,setViewState=_useWebViewLogic.setViewState,lastErrorEvent=_useWebViewLogic.lastErrorEvent,onLoadingError=_useWebViewLogic.onLoadingError,onLoadingFinish=_useWebViewLogic.onLoadingFinish,onLoadingProgress=_useWebViewLogic.onLoadingProgress,onOpenWindow=_useWebViewLogic.onOpenWindow,onContentProcessDidTerminate=_useWebViewLogic.onContentProcessDidTerminate;(0,_react.useImperativeHandle)(ref,function(){return{goForward:function goForward(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goForward(webViewRef.current);},goBack:function goBack(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.goBack(webViewRef.current);},reload:function reload(){setViewState('LOADING');if(webViewRef.current){_RNCWebViewNativeComponent.Commands.reload(webViewRef.current);}},stopLoading:function stopLoading(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.stopLoading(webViewRef.current);},postMessage:function postMessage(data){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.postMessage(webViewRef.current,data);},requestFocus:function requestFocus(){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.requestFocus(webViewRef.current);},clearCache:function clearCache(includeDiskFiles){return webViewRef.current&&_RNCWebViewNativeComponent.Commands.clearCache(webViewRef.current,includeDiskFiles);}};},[setViewState,webViewRef]);useWarnIfChanges(securityAllowsInlineMediaPlayback,'allowsInlineMediaPlayback');useWarnIfChanges(allowsPictureInPictureMediaPlayback,'allowsPictureInPictureMediaPlayback');useWarnIfChanges(incognito,'incognito');useWarnIfChanges(securityMediaPlaybackRequiresUserAction,'mediaPlaybackRequiresUserAction');useWarnIfChanges(securityDataDetectorTypes,'dataDetectorTypes');var iosVersion=String(_reactNative.Platform.Version);var passesMinimum=minimumIOSVersion?(0,_WebViewShared.versionPasses)(iosVersion,minimumIOSVersion):true;var passesHardMinimum=(0,_WebViewShared.versionPasses)(iosVersion,hardMinimumIOSVersion);if(!passesMinimum||!passesHardMinimum){if(UnsupportedVersionComponent){return(0,_jsxRuntime.jsx)(UnsupportedVersionComponent,{});}return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{alignSelf:'flex-start'},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:'red'},children:"iOS version is outdated and insecure. Update it to continue."})});}var otherView=null;if(viewState==='LOADING'){otherView=(renderLoading||_WebViewShared.defaultRenderLoading)();}else if(viewState==='ERROR'){var _lastErrorEvent$code,_lastErrorEvent$descr;(0,_invariant.default)(lastErrorEvent!=null,'lastErrorEvent expected to be non-null');otherView=(renderError||_WebViewShared.defaultRenderError)(lastErrorEvent==null?void 0:lastErrorEvent.domain,(_lastErrorEvent$code=lastErrorEvent==null?void 0:lastErrorEvent.code)!=null?_lastErrorEvent$code:0,(_lastErrorEvent$descr=lastErrorEvent==null?void 0:lastErrorEvent.description)!=null?_lastErrorEvent$descr:'');}else if(viewState!=='IDLE'){console.error(`RNCWebView invalid state encountered: ${viewState}`);}var webViewStyles=[_WebView.default.container,_WebView.default.webView,style];var webViewContainerStyle=[_WebView.default.container,containerStyle];var decelerationRate=processDecelerationRate(decelerationRateProp);var sourceResolved=resolveAssetSource(source);var newSource=typeof sourceResolved==='object'?Object.entries(sourceResolved).reduce(function(prev,_ref){var _ref2=(0,_slicedToArray2.default)(_ref,2),currKey=_ref2[0],currValue=_ref2[1];return Object.assign({},prev,(0,_defineProperty2.default)({},currKey,currKey==='headers'&&currValue&&typeof currValue==='object'?Object.entries(currValue).map(function(_ref3){var _ref4=(0,_slicedToArray2.default)(_ref3,2),key=_ref4[0],value=_ref4[1];return{name:key,value:value};}):currValue));},{}):sourceResolved;var webView=(0,_jsxRuntime.jsx)(_RNCWebViewNativeComponent.default,Object.assign({},otherProps,{fraudulentWebsiteWarningEnabled:fraudulentWebsiteWarningEnabled,javaScriptEnabled:javaScriptEnabled,cacheEnabled:cacheEnabled,useSharedProcessPool:securityUseSharedProcessPool,sharedCookiesEnabled:securitySharedCookiesEnabled,enableApplePay:securityEnableApplePay,textInteractionEnabled:textInteractionEnabled,decelerationRate:decelerationRate,messagingEnabled:typeof onMessageProp==='function',messagingModuleName:"",onLoadingError:onLoadingError,onLoadingFinish:onLoadingFinish,onLoadingProgress:onLoadingProgress,onLoadingStart:onLoadingStart,onMessage:onMessage,onOpenWindow:onOpenWindowProp&&onOpenWindow,hasOnOpenWindowEvent:onOpenWindowProp!==undefined,onShouldStartLoadWithRequest:onShouldStartLoadWithRequest,onContentProcessDidTerminate:onContentProcessDidTerminate,injectedJavaScript:injectedJavaScript,injectedJavaScriptBeforeContentLoaded:injectedJavaScriptBeforeContentLoaded,injectedJavaScriptObject:JSON.stringify(injectedJavaScriptObject),dataDetectorTypes:securityDataDetectorTypes,allowsInlineMediaPlayback:securityAllowsInlineMediaPlayback,allowsPictureInPictureMediaPlayback:allowsPictureInPictureMediaPlayback,incognito:incognito,mediaPlaybackRequiresUserAction:securityMediaPlaybackRequiresUserAction,newSource:newSource,style:webViewStyles,ref:webViewRef,source:sourceResolved}),"webViewKey");return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:webViewContainerStyle,children:[webView,otherView]});});var isFileUploadSupported=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(){return true;});return function isFileUploadSupported(){return _ref5.apply(this,arguments);};}();var WebView=Object.assign(WebViewComponent,{isFileUploadSupported:isFileUploadSupported});var _default=exports.default=WebView;
package/lib/WebView.js CHANGED
@@ -1 +1 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.WebView=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/raulgomezacuna/Development/react-native-webview/src/WebView.tsx";var WebView=exports.WebView=function WebView(){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:_WebView.default.flexStart,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.colorRed,children:"React Native WebView does not support this platform."})});};var _default=exports.default=WebView;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.WebView=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var WebView=exports.WebView=function WebView(){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:_WebView.default.flexStart,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.colorRed,children:"React Native WebView does not support this platform."})});};var _default=exports.default=WebView;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
- import { OnShouldStartLoadWithRequest, ShouldStartLoadRequestEvent, WebViewError, WebViewErrorEvent, WebViewHttpErrorEvent, WebViewMessage, WebViewMessageEvent, WebViewNavigation, WebViewNativeEvent, WebViewNavigationEvent, WebViewOpenWindowEvent, WebViewProgressEvent, WebViewRenderProcessGoneEvent, WebViewTerminatedEvent } from './WebViewTypes';
2
+ import { OnShouldStartLoadWithRequest, ShouldStartLoadRequestEvent, WebViewError, WebViewErrorEvent, WebViewMessage, WebViewMessageEvent, WebViewNavigation, WebViewNativeEvent, WebViewNavigationEvent, WebViewOpenWindowEvent, WebViewProgressEvent, WebViewRenderProcessGoneEvent, WebViewTerminatedEvent } from './WebViewTypes';
3
3
  declare const defaultOriginWhitelist: readonly ["https://*"];
4
4
  declare const defaultDeeplinkWhitelist: readonly ["https:"];
5
+ declare const compileWhitelist: (originWhitelist: readonly string[]) => readonly RegExp[];
6
+ declare const passesWhitelist: (compiledWhitelist: readonly RegExp[], url: string) => boolean;
5
7
  declare const createOnShouldStartLoadWithRequest: (loadRequest: (shouldStart: boolean, url: string, lockIdentifier: number) => void, originWhitelist: readonly string[], deeplinkWhitelist: readonly string[], onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest) => ({ nativeEvent }: ShouldStartLoadRequestEvent) => void;
6
8
  declare const defaultRenderLoading: () => React.JSX.Element;
7
9
  declare const defaultRenderError: (errorDomain: string | undefined, errorCode: number, errorDesc: string) => React.JSX.Element;
8
- export { defaultOriginWhitelist, defaultDeeplinkWhitelist, createOnShouldStartLoadWithRequest, defaultRenderLoading, defaultRenderError, };
9
- export declare const useWebViewLogic: ({ startInLoadingState, onNavigationStateChange, onLoadStart, onLoad, onLoadProgress, onLoadEnd, onError, onLoadSubResourceError, onHttpErrorProp, onMessageProp, onOpenWindowProp, onRenderProcessGoneProp, onContentProcessDidTerminateProp, originWhitelist, deeplinkWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback, validateMeta, validateData, }: {
10
+ export { defaultOriginWhitelist, defaultDeeplinkWhitelist, createOnShouldStartLoadWithRequest, defaultRenderLoading, defaultRenderError, passesWhitelist, compileWhitelist, };
11
+ export declare const useWebViewLogic: ({ startInLoadingState, onNavigationStateChange, onLoadStart, onLoad, onLoadProgress, onLoadEnd, onError, onLoadSubResourceError, onMessageProp, onOpenWindowProp, onRenderProcessGoneProp, onContentProcessDidTerminateProp, originWhitelist, deeplinkWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback, validateMeta, validateData, }: {
10
12
  startInLoadingState?: boolean | undefined;
11
13
  onNavigationStateChange?: ((event: WebViewNavigation) => void) | undefined;
12
14
  onLoadStart?: ((event: WebViewNavigationEvent) => void) | undefined;
@@ -15,7 +17,6 @@ export declare const useWebViewLogic: ({ startInLoadingState, onNavigationStateC
15
17
  onLoadEnd?: ((event: WebViewNavigationEvent | WebViewErrorEvent) => void) | undefined;
16
18
  onError?: ((event: WebViewErrorEvent) => void) | undefined;
17
19
  onLoadSubResourceError?: ((event: WebViewErrorEvent) => void) | undefined;
18
- onHttpErrorProp?: ((event: WebViewHttpErrorEvent) => void) | undefined;
19
20
  onMessageProp?: ((event: WebViewMessage) => void) | undefined;
20
21
  onOpenWindowProp?: ((event: WebViewOpenWindowEvent) => void) | undefined;
21
22
  onRenderProcessGoneProp?: ((event: WebViewRenderProcessGoneEvent) => void) | undefined;
@@ -33,7 +34,6 @@ export declare const useWebViewLogic: ({ startInLoadingState, onNavigationStateC
33
34
  onLoadingError: (event: WebViewErrorEvent) => void;
34
35
  onLoadingSubResourceError: (event: WebViewErrorEvent) => void;
35
36
  onLoadingFinish: (event: WebViewNavigationEvent) => void;
36
- onHttpError: (event: WebViewHttpErrorEvent) => void;
37
37
  onRenderProcessGone: (event: WebViewRenderProcessGoneEvent) => void;
38
38
  onContentProcessDidTerminate: (event: WebViewTerminatedEvent) => void;
39
39
  onMessage: (event: WebViewMessageEvent) => void;
@@ -1 +1 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.versionPasses=exports.useWebViewLogic=exports.defaultRenderLoading=exports.defaultRenderError=exports.defaultOriginWhitelist=exports.defaultDeeplinkWhitelist=exports.createOnShouldStartLoadWithRequest=void 0;var _toArray2=_interopRequireDefault(require("@babel/runtime/helpers/toArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _escapeStringRegexp=_interopRequireDefault(require("escape-string-regexp"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/raulgomezacuna/Development/react-native-webview/src/WebViewShared.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var defaultOriginWhitelist=exports.defaultOriginWhitelist=['https://*'];var defaultDeeplinkWhitelist=exports.defaultDeeplinkWhitelist=['https:'];var defaultDeeplinkBlocklist=['http:','file:','javascript:'];var urlToProtocolScheme=function urlToProtocolScheme(url){try{return new URL(url).protocol;}catch(_unused){return null;}};var matchWithStringList=function matchWithStringList(prefixes,value){if(typeof value!=='string'){throw new Error('value was not a string');}return Array.prototype.includes.call(prefixes,value);};var stringWhitelistToRegex=function stringWhitelistToRegex(originWhitelist){return new RegExp(`^${(0,_escapeStringRegexp.default)(originWhitelist).replace(/\\\*/g,'.*')}$`);};var matchWithRegexList=function matchWithRegexList(compiledRegexList,value){return compiledRegexList.some(function(x){return x.test(value);});};var compileWhitelist=function compileWhitelist(originWhitelist){return['about:blank'].concat((0,_toConsumableArray2.default)(originWhitelist||[])).map(stringWhitelistToRegex);};var passesWhitelist=function passesWhitelist(compiledWhitelist,url){try{var _URL=new URL(url),href=_URL.href,origin=_URL.origin;if(origin&&origin!=='null'){return matchWithRegexList(compiledWhitelist,origin);}return matchWithRegexList(compiledWhitelist,href);}catch(_unused2){return false;}};var createOnShouldStartLoadWithRequest=exports.createOnShouldStartLoadWithRequest=function createOnShouldStartLoadWithRequest(loadRequest,originWhitelist,deeplinkWhitelist,onShouldStartLoadWithRequest){var compiledWhitelist=compileWhitelist(originWhitelist);return function(_ref){var nativeEvent=_ref.nativeEvent;var shouldStart=true;var url=nativeEvent.url,lockIdentifier=nativeEvent.lockIdentifier,isTopFrame=nativeEvent.isTopFrame;if(!passesWhitelist(compiledWhitelist,url)){var protocol=urlToProtocolScheme(url);if(protocol!==null){var foundMatchInBlocklist=matchWithStringList(defaultDeeplinkBlocklist,protocol);if(!foundMatchInBlocklist){var foundMatchInAllowlist=matchWithStringList(deeplinkWhitelist,protocol);if(foundMatchInAllowlist){_reactNative.Linking.canOpenURL(url).then(function(supported){if(supported&&isTopFrame||protocol.startsWith('mailto:')){return _reactNative.Linking.openURL(url);}console.warn(`Can't open url: ${url}`);return undefined;}).catch(function(e){console.warn('Error opening URL: ',e);});}else{console.warn(`Failed to pass whitelist for deep link url: ${url}`);}}else{console.warn(`Failed to pass default block list for deep link url: ${url}`);}}shouldStart=false;}else if(onShouldStartLoadWithRequest){shouldStart=onShouldStartLoadWithRequest(nativeEvent);}loadRequest(shouldStart,url,lockIdentifier);};};var defaultRenderLoading=exports.defaultRenderLoading=function defaultRenderLoading(){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:_WebView.default.loadingOrErrorView,children:(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{})});};var defaultRenderError=exports.defaultRenderError=function defaultRenderError(errorDomain,errorCode,errorDesc){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_WebView.default.loadingOrErrorView,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorTextTitle,children:"Error loading page"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorText,children:`Domain: ${errorDomain}`}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorText,children:`Error Code: ${errorCode}`}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorText,children:`Description: ${errorDesc}`})]});};var useWebViewLogic=exports.useWebViewLogic=function useWebViewLogic(_ref2){var startInLoadingState=_ref2.startInLoadingState,onNavigationStateChange=_ref2.onNavigationStateChange,onLoadStart=_ref2.onLoadStart,onLoad=_ref2.onLoad,onLoadProgress=_ref2.onLoadProgress,onLoadEnd=_ref2.onLoadEnd,onError=_ref2.onError,onLoadSubResourceError=_ref2.onLoadSubResourceError,onHttpErrorProp=_ref2.onHttpErrorProp,onMessageProp=_ref2.onMessageProp,onOpenWindowProp=_ref2.onOpenWindowProp,onRenderProcessGoneProp=_ref2.onRenderProcessGoneProp,onContentProcessDidTerminateProp=_ref2.onContentProcessDidTerminateProp,originWhitelist=_ref2.originWhitelist,deeplinkWhitelist=_ref2.deeplinkWhitelist,onShouldStartLoadWithRequestProp=_ref2.onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback=_ref2.onShouldStartLoadWithRequestCallback,validateMeta=_ref2.validateMeta,validateData=_ref2.validateData;var _useState=(0,_react.useState)(startInLoadingState?'LOADING':'IDLE'),_useState2=(0,_slicedToArray2.default)(_useState,2),viewState=_useState2[0],setViewState=_useState2[1];var _useState3=(0,_react.useState)(null),_useState4=(0,_slicedToArray2.default)(_useState3,2),lastErrorEvent=_useState4[0],setLastErrorEvent=_useState4[1];var startUrl=(0,_react.useRef)(null);var passesWhitelistCallback=(0,_react.useCallback)(function(url){if(!url||typeof url!=='string')return false;return passesWhitelist(compileWhitelist(originWhitelist),url);},[originWhitelist]);var extractMeta=function extractMeta(nativeEvent){return{url:String(nativeEvent.url),loading:Boolean(nativeEvent.loading),title:String(nativeEvent.title).slice(0,512),canGoBack:Boolean(nativeEvent.canGoBack),canGoForward:Boolean(nativeEvent.canGoForward),lockIdentifier:Number(nativeEvent.lockIdentifier)};};var updateNavigationState=(0,_react.useCallback)(function(event){onNavigationStateChange==null?void 0:onNavigationStateChange(event.nativeEvent);},[onNavigationStateChange]);var onLoadingStart=(0,_react.useCallback)(function(event){startUrl.current=event.nativeEvent.url;onLoadStart==null?void 0:onLoadStart(event);updateNavigationState(event);},[onLoadStart,updateNavigationState]);var onLoadingError=(0,_react.useCallback)(function(event){event.persist();if(onError){onError(event);}else{console.warn('Encountered an error loading page',event.nativeEvent);}onLoadEnd==null?void 0:onLoadEnd(event);if(event.isDefaultPrevented()){return;}setViewState('ERROR');setLastErrorEvent(event.nativeEvent);},[onError,onLoadEnd]);var onLoadingSubResourceError=(0,_react.useCallback)(function(event){onLoadSubResourceError==null?void 0:onLoadSubResourceError(event);},[onLoadSubResourceError]);var onHttpError=(0,_react.useCallback)(function(event){onHttpErrorProp==null?void 0:onHttpErrorProp(event);},[onHttpErrorProp]);var onRenderProcessGone=(0,_react.useCallback)(function(event){onRenderProcessGoneProp==null?void 0:onRenderProcessGoneProp(event);},[onRenderProcessGoneProp]);var onContentProcessDidTerminate=(0,_react.useCallback)(function(event){onContentProcessDidTerminateProp==null?void 0:onContentProcessDidTerminateProp(event);},[onContentProcessDidTerminateProp]);var onLoadingFinish=(0,_react.useCallback)(function(event){onLoad==null?void 0:onLoad(event);onLoadEnd==null?void 0:onLoadEnd(event);var url=event.nativeEvent.url;if(_reactNative.Platform.OS!=='android'||url===startUrl.current){setViewState('IDLE');}updateNavigationState(event);},[onLoad,onLoadEnd,updateNavigationState]);var onMessage=(0,_react.useCallback)(function(event){var nativeEvent=event.nativeEvent;if(!passesWhitelistCallback(nativeEvent.url))return;try{var parsedData=JSON.parse(nativeEvent.data);var _data=JSON.stringify(validateData(parsedData));var meta=validateMeta(extractMeta(nativeEvent));onMessageProp==null?void 0:onMessageProp(Object.assign({},meta,{data:_data}));}catch(err){console.error('Error parsing WebView message',err);}},[onMessageProp,passesWhitelistCallback,validateData,validateMeta]);var onLoadingProgress=(0,_react.useCallback)(function(event){var progress=event.nativeEvent.progress;if(_reactNative.Platform.OS==='android'&&progress===1){setViewState(function(prevViewState){return prevViewState==='LOADING'?'IDLE':prevViewState;});}onLoadProgress==null?void 0:onLoadProgress(event);},[onLoadProgress]);var onShouldStartLoadWithRequest=(0,_react.useMemo)(function(){return createOnShouldStartLoadWithRequest(onShouldStartLoadWithRequestCallback,originWhitelist,deeplinkWhitelist,onShouldStartLoadWithRequestProp);},[originWhitelist,deeplinkWhitelist,onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback]);var onOpenWindow=(0,_react.useCallback)(function(event){onOpenWindowProp==null?void 0:onOpenWindowProp(event);},[onOpenWindowProp]);return{onShouldStartLoadWithRequest:onShouldStartLoadWithRequest,onLoadingStart:onLoadingStart,onLoadingProgress:onLoadingProgress,onLoadingError:onLoadingError,onLoadingSubResourceError:onLoadingSubResourceError,onLoadingFinish:onLoadingFinish,onHttpError:onHttpError,onRenderProcessGone:onRenderProcessGone,onContentProcessDidTerminate:onContentProcessDidTerminate,onMessage:onMessage,onOpenWindow:onOpenWindow,viewState:viewState,setViewState:setViewState,lastErrorEvent:lastErrorEvent};};var versionPasses=exports.versionPasses=function versionPasses(version,minimum){if(!version||!minimum)return false;if(typeof version!=='string'||typeof minimum!=='string')return false;if(minimum.includes(', ')){var variants=minimum.split(', ');if(!variants.slice(0,-1).every(function(x){return x.includes(' <');}))return false;return variants.some(function(x){return versionPasses(version,x);});}if(minimum.includes(' <')){var _minimum$split=minimum.split(' <'),_minimum$split2=(0,_toArray2.default)(_minimum$split),min=_minimum$split2[0],max=_minimum$split2[1],rest=_minimum$split2.slice(2);if(rest.length>0)return false;return versionPasses(version,min)&&!versionPasses(version,max)&&versionPasses(max,version);}var versionRegex=/^[0-9]+(\.[0-9]+)*$/;if(!versionRegex.test(version)||!versionRegex.test(minimum))return false;var versionParts=version.split('.').map(Number);var minimumParts=minimum.split('.').map(Number);var len=Math.max(versionParts.length,minimumParts.length);for(var i=0;i<len;i+=1){var ver=versionParts[i]||0;var _min=minimumParts[i]||0;if(ver>_min)return true;if(ver<_min)return false;}return true;};
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.versionPasses=exports.useWebViewLogic=exports.passesWhitelist=exports.defaultRenderLoading=exports.defaultRenderError=exports.defaultOriginWhitelist=exports.defaultDeeplinkWhitelist=exports.createOnShouldStartLoadWithRequest=exports.compileWhitelist=void 0;var _toArray2=_interopRequireDefault(require("@babel/runtime/helpers/toArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _escapeStringRegexp=_interopRequireDefault(require("escape-string-regexp"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _WebView=_interopRequireDefault(require("./WebView.styles"));var _jsxRuntime=require("react/jsx-runtime");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var defaultOriginWhitelist=exports.defaultOriginWhitelist=['https://*'];var defaultDeeplinkWhitelist=exports.defaultDeeplinkWhitelist=['https:'];var defaultDeeplinkBlocklist=['http:','file:','javascript:'];var urlToProtocolScheme=function urlToProtocolScheme(url){try{return new URL(url).protocol;}catch(_unused){return null;}};var matchWithStringList=function matchWithStringList(prefixes,value){if(typeof value!=='string'){throw new Error('value was not a string');}return Array.prototype.includes.call(prefixes,value);};var stringWhitelistToRegex=function stringWhitelistToRegex(originWhitelist){return new RegExp(`^${(0,_escapeStringRegexp.default)(originWhitelist).replace(/\\\*/g,'.*')}$`);};var matchWithRegexList=function matchWithRegexList(compiledRegexList,value){return compiledRegexList.some(function(x){return x.test(value);});};var compileWhitelist=exports.compileWhitelist=function compileWhitelist(originWhitelist){return['about:blank'].concat((0,_toConsumableArray2.default)(originWhitelist||[])).map(stringWhitelistToRegex);};var passesWhitelist=exports.passesWhitelist=function passesWhitelist(compiledWhitelist,url){try{var _URL=new URL(url),href=_URL.href,origin=_URL.origin;if(origin&&origin!=='null'){return matchWithRegexList(compiledWhitelist,origin);}return matchWithRegexList(compiledWhitelist,href);}catch(_unused2){return false;}};var createOnShouldStartLoadWithRequest=exports.createOnShouldStartLoadWithRequest=function createOnShouldStartLoadWithRequest(loadRequest,originWhitelist,deeplinkWhitelist,onShouldStartLoadWithRequest){var compiledWhitelist=compileWhitelist(originWhitelist);return function(_ref){var nativeEvent=_ref.nativeEvent;var shouldStart=true;var url=nativeEvent.url,lockIdentifier=nativeEvent.lockIdentifier,isTopFrame=nativeEvent.isTopFrame;if(!passesWhitelist(compiledWhitelist,url)){var protocol=urlToProtocolScheme(url);if(protocol!==null){var foundMatchInBlocklist=matchWithStringList(defaultDeeplinkBlocklist,protocol);if(!foundMatchInBlocklist){var foundMatchInAllowlist=matchWithStringList(deeplinkWhitelist,protocol);if(foundMatchInAllowlist){_reactNative.Linking.canOpenURL(url).then(function(supported){if(supported&&isTopFrame||protocol.startsWith('mailto:')){return _reactNative.Linking.openURL(url);}console.warn(`Can't open url: ${url}`);return undefined;}).catch(function(e){console.warn('Error opening URL: ',e);});}else{console.warn(`Failed to pass whitelist for deep link url: ${url}`);}}else{console.warn(`Failed to pass default block list for deep link url: ${url}`);}}shouldStart=false;}else if(onShouldStartLoadWithRequest){shouldStart=onShouldStartLoadWithRequest(nativeEvent);}loadRequest(shouldStart,url,lockIdentifier);};};var defaultRenderLoading=exports.defaultRenderLoading=function defaultRenderLoading(){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:_WebView.default.loadingOrErrorView,children:(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{})});};var defaultRenderError=exports.defaultRenderError=function defaultRenderError(errorDomain,errorCode,errorDesc){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_WebView.default.loadingOrErrorView,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorTextTitle,children:"Error loading page"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorText,children:`Domain: ${errorDomain}`}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorText,children:`Error Code: ${errorCode}`}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_WebView.default.errorText,children:`Description: ${errorDesc}`})]});};var useWebViewLogic=exports.useWebViewLogic=function useWebViewLogic(_ref2){var startInLoadingState=_ref2.startInLoadingState,onNavigationStateChange=_ref2.onNavigationStateChange,onLoadStart=_ref2.onLoadStart,onLoad=_ref2.onLoad,onLoadProgress=_ref2.onLoadProgress,onLoadEnd=_ref2.onLoadEnd,onError=_ref2.onError,onLoadSubResourceError=_ref2.onLoadSubResourceError,onMessageProp=_ref2.onMessageProp,onOpenWindowProp=_ref2.onOpenWindowProp,onRenderProcessGoneProp=_ref2.onRenderProcessGoneProp,onContentProcessDidTerminateProp=_ref2.onContentProcessDidTerminateProp,originWhitelist=_ref2.originWhitelist,deeplinkWhitelist=_ref2.deeplinkWhitelist,onShouldStartLoadWithRequestProp=_ref2.onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback=_ref2.onShouldStartLoadWithRequestCallback,validateMeta=_ref2.validateMeta,validateData=_ref2.validateData;var _useState=(0,_react.useState)(startInLoadingState?'LOADING':'IDLE'),_useState2=(0,_slicedToArray2.default)(_useState,2),viewState=_useState2[0],setViewState=_useState2[1];var _useState3=(0,_react.useState)(null),_useState4=(0,_slicedToArray2.default)(_useState3,2),lastErrorEvent=_useState4[0],setLastErrorEvent=_useState4[1];var startUrl=(0,_react.useRef)(null);var passesWhitelistCallback=(0,_react.useCallback)(function(url){if(!url||typeof url!=='string')return false;return passesWhitelist(compileWhitelist(originWhitelist),url);},[originWhitelist]);var extractMeta=function extractMeta(nativeEvent){return{url:String(nativeEvent.url),loading:Boolean(nativeEvent.loading),title:String(nativeEvent.title).slice(0,512),canGoBack:Boolean(nativeEvent.canGoBack),canGoForward:Boolean(nativeEvent.canGoForward),lockIdentifier:Number(nativeEvent.lockIdentifier)};};var updateNavigationState=(0,_react.useCallback)(function(event){onNavigationStateChange==null?void 0:onNavigationStateChange(event.nativeEvent);},[onNavigationStateChange]);var onLoadingStart=(0,_react.useCallback)(function(event){startUrl.current=event.nativeEvent.url;onLoadStart==null?void 0:onLoadStart(event);updateNavigationState(event);},[onLoadStart,updateNavigationState]);var onLoadingError=(0,_react.useCallback)(function(event){event.persist();if(onError){onError(event);}else{console.warn('Encountered an error loading page',event.nativeEvent);}onLoadEnd==null?void 0:onLoadEnd(event);if(event.isDefaultPrevented()){return;}setViewState('ERROR');setLastErrorEvent(event.nativeEvent);},[onError,onLoadEnd]);var onLoadingSubResourceError=(0,_react.useCallback)(function(event){onLoadSubResourceError==null?void 0:onLoadSubResourceError(event);},[onLoadSubResourceError]);var onRenderProcessGone=(0,_react.useCallback)(function(event){onRenderProcessGoneProp==null?void 0:onRenderProcessGoneProp(event);},[onRenderProcessGoneProp]);var onContentProcessDidTerminate=(0,_react.useCallback)(function(event){onContentProcessDidTerminateProp==null?void 0:onContentProcessDidTerminateProp(event);},[onContentProcessDidTerminateProp]);var onLoadingFinish=(0,_react.useCallback)(function(event){onLoad==null?void 0:onLoad(event);onLoadEnd==null?void 0:onLoadEnd(event);var url=event.nativeEvent.url;if(_reactNative.Platform.OS!=='android'||url===startUrl.current){setViewState('IDLE');}updateNavigationState(event);},[onLoad,onLoadEnd,updateNavigationState]);var onMessage=(0,_react.useCallback)(function(event){var nativeEvent=event.nativeEvent;if(!passesWhitelistCallback(nativeEvent.url))return;try{var parsedData=JSON.parse(nativeEvent.data);var _data=JSON.stringify(validateData(parsedData));var meta=validateMeta(extractMeta(nativeEvent));onMessageProp==null?void 0:onMessageProp(Object.assign({},meta,{data:_data}));}catch(err){console.error('Error parsing WebView message',err);}},[onMessageProp,passesWhitelistCallback,validateData,validateMeta]);var onLoadingProgress=(0,_react.useCallback)(function(event){var progress=event.nativeEvent.progress;if(_reactNative.Platform.OS==='android'&&progress===1){setViewState(function(prevViewState){return prevViewState==='LOADING'?'IDLE':prevViewState;});}onLoadProgress==null?void 0:onLoadProgress(event);},[onLoadProgress]);var onShouldStartLoadWithRequest=(0,_react.useMemo)(function(){return createOnShouldStartLoadWithRequest(onShouldStartLoadWithRequestCallback,originWhitelist,deeplinkWhitelist,onShouldStartLoadWithRequestProp);},[originWhitelist,deeplinkWhitelist,onShouldStartLoadWithRequestProp,onShouldStartLoadWithRequestCallback]);var onOpenWindow=(0,_react.useCallback)(function(event){onOpenWindowProp==null?void 0:onOpenWindowProp(event);},[onOpenWindowProp]);return{onShouldStartLoadWithRequest:onShouldStartLoadWithRequest,onLoadingStart:onLoadingStart,onLoadingProgress:onLoadingProgress,onLoadingError:onLoadingError,onLoadingSubResourceError:onLoadingSubResourceError,onLoadingFinish:onLoadingFinish,onRenderProcessGone:onRenderProcessGone,onContentProcessDidTerminate:onContentProcessDidTerminate,onMessage:onMessage,onOpenWindow:onOpenWindow,viewState:viewState,setViewState:setViewState,lastErrorEvent:lastErrorEvent};};var versionPasses=exports.versionPasses=function versionPasses(version,minimum){if(!version||!minimum)return false;if(typeof version!=='string'||typeof minimum!=='string')return false;if(minimum.includes(', ')){var variants=minimum.split(', ');if(!variants.slice(0,-1).every(function(x){return x.includes(' <');}))return false;return variants.some(function(x){return versionPasses(version,x);});}if(minimum.includes(' <')){var _minimum$split=minimum.split(' <'),_minimum$split2=(0,_toArray2.default)(_minimum$split),min=_minimum$split2[0],max=_minimum$split2[1],rest=_minimum$split2.slice(2);if(rest.length>0)return false;return versionPasses(version,min)&&!versionPasses(version,max)&&versionPasses(max,version);}var versionRegex=/^[0-9]+(\.[0-9]+)*$/;if(!versionRegex.test(version)||!versionRegex.test(minimum))return false;var versionParts=version.split('.').map(Number);var minimumParts=minimum.split('.').map(Number);var len=Math.max(versionParts.length,minimumParts.length);for(var i=0;i<len;i+=1){var ver=versionParts[i]||0;var _min=minimumParts[i]||0;if(ver>_min)return true;if(ver<_min)return false;}return true;};