@exodus/react-native-webview 11.26.1-exodus.2 → 11.26.1-exodus.4

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.
@@ -699,17 +699,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
699
699
  RNCWebView reactWebView = (RNCWebView) root;
700
700
  JSONObject eventInitDict = new JSONObject();
701
701
  eventInitDict.put("data", args.getString(0));
702
- reactWebView.evaluateJavascriptWithFallback("(function () {" +
703
- "var event;" +
704
- "var data = " + eventInitDict.toString() + ";" +
705
- "try {" +
706
- "event = new MessageEvent('message', data);" +
707
- "} catch (e) {" +
708
- "event = document.createEvent('MessageEvent');" +
709
- "event.initMessageEvent('message', true, true, data.data, data.origin, data.lastEventId, data.source);" +
710
- "}" +
711
- "document.dispatchEvent(event);" +
712
- "})();");
702
+ reactWebView.evaluateJavascriptWithFallback("document.dispatchEvent(new MessageEvent('message', " + eventInitDict.toString() + "));");
713
703
  } catch (JSONException e) {
714
704
  throw new RuntimeException(e);
715
705
  }
@@ -1249,7 +1239,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
1249
1239
  public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
1250
1240
 
1251
1241
  // Always deny
1252
- callback.invoke(origin, true, false);
1242
+ callback.invoke(origin, false, false);
1253
1243
 
1254
1244
  }
1255
1245
 
@@ -95,28 +95,6 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule implements Acti
95
95
  }
96
96
  }
97
97
 
98
- private PermissionListener getWebviewFileDownloaderPermissionListener(String downloadingMessage, String lackPermissionToDownloadMessage) {
99
- return new PermissionListener() {
100
- @Override
101
- public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
102
- switch (requestCode) {
103
- case FILE_DOWNLOAD_PERMISSION_REQUEST: {
104
- // If request is cancelled, the result arrays are empty.
105
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
106
- if (downloadRequest != null) {
107
- downloadFile(downloadingMessage);
108
- }
109
- } else {
110
- Toast.makeText(getCurrentActivity().getApplicationContext(), lackPermissionToDownloadMessage, Toast.LENGTH_LONG).show();
111
- }
112
- return true;
113
- }
114
- }
115
- return false;
116
- }
117
- };
118
- }
119
-
120
98
  public RNCWebViewModule(ReactApplicationContext reactContext) {
121
99
  super(reactContext);
122
100
  reactContext.addActivityEventListener(this);
@@ -321,21 +299,6 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule implements Acti
321
299
  Toast.makeText(getCurrentActivity().getApplicationContext(), downloadingMessage, Toast.LENGTH_LONG).show();
322
300
  }
323
301
 
324
- public boolean grantFileDownloaderPermissions(String downloadingMessage, String lackPermissionToDownloadMessage) {
325
- // Permission not required for Android Q and above
326
- if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
327
- return true;
328
- }
329
-
330
- boolean result = ContextCompat.checkSelfPermission(getCurrentActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
331
- if (!result && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
332
- PermissionAwareActivity activity = getPermissionAwareActivity();
333
- activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, FILE_DOWNLOAD_PERMISSION_REQUEST, getWebviewFileDownloaderPermissionListener(downloadingMessage, lackPermissionToDownloadMessage));
334
- }
335
-
336
- return result;
337
- }
338
-
339
302
  protected boolean needsCameraPermission() {
340
303
  boolean needed = false;
341
304
 
@@ -872,7 +872,7 @@ RCTAutoInsetsProtocol>
872
872
  {
873
873
  NSDictionary *eventInitDict = @{@"data": message};
874
874
  NSString *source = [NSString
875
- stringWithFormat:@"window.dispatchEvent(new MessageEvent('message', %@));",
875
+ stringWithFormat:@"document.dispatchEvent(new MessageEvent('message', %@));",
876
876
  RCTJSONStringify(eventInitDict, NULL)
877
877
  ];
878
878
  [self injectJavaScript: source];
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
2
- import { Image, View, NativeModules, } from 'react-native';
2
+ import { View, NativeModules, } from 'react-native';
3
3
  import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
4
4
  // @ts-expect-error react-native doesn't have this type
5
5
  import codegenNativeCommandsUntyped from 'react-native/Libraries/Utilities/codegenNativeCommands';
@@ -11,7 +11,6 @@ const codegenNativeCommands = codegenNativeCommandsUntyped;
11
11
  const Commands = codegenNativeCommands({
12
12
  supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'clearFormData', 'clearCache', 'clearHistory', 'loadUrl'],
13
13
  });
14
- const { resolveAssetSource } = Image;
15
14
  /**
16
15
  * A simple counter to uniquely identify WebView instances. Do not use this for anything else.
17
16
  */
@@ -101,7 +100,7 @@ const WebViewComponent = forwardRef(({ overScrollMode = 'always', javaScriptEnab
101
100
  const NativeWebView = RNCWebView;
102
101
  const webView = <NativeWebView key="webViewKey" {...otherProps} messagingEnabled={typeof onMessageProp === 'function'} messagingModuleName={messagingModuleName} onLoadingError={onLoadingError} onLoadingFinish={onLoadingFinish} onLoadingProgress={onLoadingProgress} onLoadingStart={onLoadingStart} onHttpError={onHttpError} onRenderProcessGone={onRenderProcessGone} onMessage={onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} injectedJavaScriptForMainFrameOnly={injectedJavaScriptForMainFrameOnly} injectedJavaScriptBeforeContentLoadedForMainFrameOnly={injectedJavaScriptBeforeContentLoadedForMainFrameOnly} ref={webViewRef}
103
102
  // TODO: find a better way to type this.
104
- source={resolveAssetSource(source)} style={webViewStyles} overScrollMode={overScrollMode} javaScriptEnabled={javaScriptEnabled} thirdPartyCookiesEnabled={thirdPartyCookiesEnabled} scalesPageToFit={scalesPageToFit} allowsFullscreenVideo={allowsFullscreenVideo} allowFileAccess={allowFileAccess} allowFileAccessFromFileURLs={allowFileAccessFromFileURLs} allowUniversalAccessFromFileURLs={allowUniversalAccessFromFileURLs} saveFormDataDisabled={saveFormDataDisabled} cacheEnabled={cacheEnabled} androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled} androidLayerType={androidLayerType} setSupportMultipleWindows={setSupportMultipleWindows} setBuiltInZoomControls={setBuiltInZoomControls} setDisplayZoomControls={setDisplayZoomControls} mixedContentMode={mixedContentMode} nestedScrollEnabled={nestedScrollEnabled} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}/>;
103
+ source={source} style={webViewStyles} overScrollMode={overScrollMode} javaScriptEnabled={javaScriptEnabled} thirdPartyCookiesEnabled={thirdPartyCookiesEnabled} scalesPageToFit={scalesPageToFit} allowsFullscreenVideo={allowsFullscreenVideo} allowFileAccess={allowFileAccess} allowFileAccessFromFileURLs={allowFileAccessFromFileURLs} allowUniversalAccessFromFileURLs={allowUniversalAccessFromFileURLs} saveFormDataDisabled={saveFormDataDisabled} cacheEnabled={cacheEnabled} androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled} androidLayerType={androidLayerType} setSupportMultipleWindows={setSupportMultipleWindows} setBuiltInZoomControls={setBuiltInZoomControls} setDisplayZoomControls={setDisplayZoomControls} mixedContentMode={mixedContentMode} nestedScrollEnabled={nestedScrollEnabled} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}/>;
105
104
  return (<View style={webViewContainerStyle}>
106
105
  {webView}
107
106
  {otherView}
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
2
- import { Image, View, NativeModules, } from 'react-native';
2
+ import { View, NativeModules, } from 'react-native';
3
3
  import invariant from 'invariant';
4
4
  // @ts-expect-error react-native doesn't have this type
5
5
  import codegenNativeCommandsUntyped from 'react-native/Libraries/Utilities/codegenNativeCommands';
@@ -10,7 +10,6 @@ const codegenNativeCommands = codegenNativeCommandsUntyped;
10
10
  const Commands = codegenNativeCommands({
11
11
  supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'loadUrl'],
12
12
  });
13
- const { resolveAssetSource } = Image;
14
13
  const processDecelerationRate = (decelerationRate) => {
15
14
  let newDecelerationRate = decelerationRate;
16
15
  if (newDecelerationRate === 'normal') {
@@ -100,7 +99,7 @@ const WebViewComponent = forwardRef(({ javaScriptEnabled = true, cacheEnabled =
100
99
  const NativeWebView = RNCWebView;
101
100
  const webView = (<NativeWebView key="webViewKey" {...otherProps} allowFileAccessFromFileURLs={allowFileAccessFromFileURLs} allowUniversalAccessFromFileURLs={allowUniversalAccessFromFileURLs} enableApplePay={enableApplePay} javaScriptEnabled={javaScriptEnabled} cacheEnabled={cacheEnabled} dataDetectorTypes={dataDetectorTypes} useSharedProcessPool={useSharedProcessPool} textInteractionEnabled={textInteractionEnabled} decelerationRate={decelerationRate} messagingEnabled={typeof onMessageProp === 'function'} onLoadingError={onLoadingError} onLoadingFinish={onLoadingFinish} onLoadingProgress={onLoadingProgress} onFileDownload={onFileDownload} onLoadingStart={onLoadingStart} onHttpError={onHttpError} onMessage={onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} onContentProcessDidTerminate={onContentProcessDidTerminate} injectedJavaScript={injectedJavaScript} injectedJavaScriptBeforeContentLoaded={injectedJavaScriptBeforeContentLoaded} injectedJavaScriptForMainFrameOnly={injectedJavaScriptForMainFrameOnly} injectedJavaScriptBeforeContentLoadedForMainFrameOnly={injectedJavaScriptBeforeContentLoadedForMainFrameOnly} allowsAirPlayForMediaPlayback={allowsAirPlayForMediaPlayback} allowsInlineMediaPlayback={allowsInlineMediaPlayback} incognito={incognito} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction} ref={webViewRef} sharedCookiesEnabled={sharedCookiesEnabled}
102
101
  // TODO: find a better way to type this.
103
- source={resolveAssetSource(source)} style={webViewStyles}/>);
102
+ source={source} style={webViewStyles}/>);
104
103
  return (<View style={webViewContainerStyle}>
105
104
  {webView}
106
105
  {otherView}
@@ -1,6 +1,6 @@
1
1
  import escapeStringRegexp from 'escape-string-regexp';
2
2
  import React, { useCallback, useMemo, useRef, useState } from 'react';
3
- import { Linking, View, ActivityIndicator, Text, Platform } from 'react-native';
3
+ import { View, ActivityIndicator, Text, Platform } from 'react-native';
4
4
  import styles from './WebView.styles';
5
5
  const defaultOriginWhitelist = ['http://*', 'https://*'];
6
6
  const extractOrigin = (url) => {
@@ -18,15 +18,6 @@ const createOnShouldStartLoadWithRequest = (loadRequest, originWhitelist, onShou
18
18
  let shouldStart = true;
19
19
  const { url, lockIdentifier } = nativeEvent;
20
20
  if (!passesWhitelist(compileWhitelist(originWhitelist), url)) {
21
- Linking.canOpenURL(url).then((supported) => {
22
- if (supported) {
23
- return Linking.openURL(url);
24
- }
25
- console.warn(`Can't open url: ${url}`);
26
- return undefined;
27
- }).catch(e => {
28
- console.warn('Error opening URL: ', e);
29
- });
30
21
  shouldStart = false;
31
22
  }
32
23
  else if (onShouldStartLoadWithRequest) {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "Thibault Malbranche <malbranche.thibault@gmail.com>"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "11.26.1-exodus.2",
12
+ "version": "11.26.1-exodus.4",
13
13
  "homepage": "https://github.com/ExodusMovement/react-native-webview#readme",
14
14
  "scripts": {
15
15
  "android": "react-native run-android",