@exodus/react-native-webview 11.26.1-exodus.10 → 11.26.1-exodus.12
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.
|
@@ -430,6 +430,12 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
|
|
430
430
|
@ReactProp(name = "source")
|
|
431
431
|
public void setSource(WebView view, @Nullable ReadableMap source) {
|
|
432
432
|
if (source != null) {
|
|
433
|
+
if (source.hasKey("html")) {
|
|
434
|
+
String html = source.getString("html");
|
|
435
|
+
String baseUrl = source.hasKey("baseUrl") ? source.getString("baseUrl") : "";
|
|
436
|
+
view.loadDataWithBaseURL(baseUrl, html, HTML_MIME_TYPE, HTML_ENCODING, null);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
433
439
|
if (source.hasKey("uri")) {
|
|
434
440
|
String url = source.getString("uri");
|
|
435
441
|
String previousUrl = view.getUrl();
|
|
@@ -749,6 +755,8 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
|
|
749
755
|
|
|
750
756
|
final WritableMap event = createWebViewEvent(view, url);
|
|
751
757
|
event.putInt("lockIdentifier", lockIdentifier);
|
|
758
|
+
// Android does not raise shouldOverrideUrlLoading for inner frames
|
|
759
|
+
event.putBoolean("isTopFrame", true);
|
|
752
760
|
rncWebView.sendDirectMessage("onShouldStartLoadWithRequest", event);
|
|
753
761
|
|
|
754
762
|
try {
|
package/apple/RNCWebView.m
CHANGED
|
@@ -615,6 +615,16 @@ RCTAutoInsetsProtocol>
|
|
|
615
615
|
|
|
616
616
|
- (void)visitSource
|
|
617
617
|
{
|
|
618
|
+
// Check for a static html source first
|
|
619
|
+
NSString *html = [RCTConvert NSString:_source[@"html"]];
|
|
620
|
+
if (html) {
|
|
621
|
+
NSURL *baseURL = [RCTConvert NSURL:_source[@"baseUrl"]];
|
|
622
|
+
if (!baseURL) {
|
|
623
|
+
baseURL = [NSURL URLWithString:@"about:blank"];
|
|
624
|
+
}
|
|
625
|
+
[_webView loadHTMLString:html baseURL:baseURL];
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
618
628
|
// Add cookie for subsequent resource requests sent by page itself, if cookie was set in headers on WebView
|
|
619
629
|
NSString *headerCookie = [RCTConvert NSString:_source[@"headers"][@"cookie"]];
|
|
620
630
|
if(headerCookie) {
|
package/lib/WebView.android.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { Text, View, NativeModules, } from 'react-native';
|
|
2
|
+
import { Text, Image, 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';
|
|
@@ -19,6 +19,7 @@ const codegenNativeCommands = codegenNativeCommandsUntyped;
|
|
|
19
19
|
const Commands = codegenNativeCommands({
|
|
20
20
|
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'clearFormData', 'clearCache', 'clearHistory', 'loadUrl'],
|
|
21
21
|
});
|
|
22
|
+
const { resolveAssetSource } = Image;
|
|
22
23
|
/**
|
|
23
24
|
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
|
24
25
|
*/
|
|
@@ -123,7 +124,7 @@ const WebViewComponent = forwardRef(({ overScrollMode = 'always', javaScriptEnab
|
|
|
123
124
|
const NativeWebView = RNCWebView;
|
|
124
125
|
const webView = <NativeWebView key="webViewKey" {...otherProps} messagingEnabled={typeof onMessageProp === 'function'} messagingModuleName={messagingModuleName} onLoadingError={onLoadingError} onLoadingFinish={onLoadingFinish} onLoadingProgress={onLoadingProgress} onLoadingStart={onLoadingStart} onMessage={onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} ref={webViewRef}
|
|
125
126
|
// TODO: find a better way to type this.
|
|
126
|
-
source={source} style={webViewStyles} overScrollMode={overScrollMode} javaScriptEnabled={javaScriptEnabled} thirdPartyCookiesEnabled={thirdPartyCookiesEnabled} scalesPageToFit={scalesPageToFit} saveFormDataDisabled={saveFormDataDisabled} cacheEnabled={cacheEnabled} androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled} androidLayerType={androidLayerType} setSupportMultipleWindows={setSupportMultipleWindows} setBuiltInZoomControls={setBuiltInZoomControls} setDisplayZoomControls={setDisplayZoomControls} mixedContentMode={mixedContentMode} nestedScrollEnabled={nestedScrollEnabled} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}/>;
|
|
127
|
+
source={resolveAssetSource(source)} style={webViewStyles} overScrollMode={overScrollMode} javaScriptEnabled={javaScriptEnabled} thirdPartyCookiesEnabled={thirdPartyCookiesEnabled} scalesPageToFit={scalesPageToFit} saveFormDataDisabled={saveFormDataDisabled} cacheEnabled={cacheEnabled} androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled} androidLayerType={androidLayerType} setSupportMultipleWindows={setSupportMultipleWindows} setBuiltInZoomControls={setBuiltInZoomControls} setDisplayZoomControls={setDisplayZoomControls} mixedContentMode={mixedContentMode} nestedScrollEnabled={nestedScrollEnabled} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}/>;
|
|
127
128
|
return (<View style={webViewContainerStyle}>
|
|
128
129
|
{webView}
|
|
129
130
|
{otherView}
|
package/lib/WebView.ios.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
|
2
|
-
import { Text, View, NativeModules, Platform, } from 'react-native';
|
|
2
|
+
import { Text, Image, View, NativeModules, Platform, } 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,6 +10,7 @@ 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;
|
|
13
14
|
const processDecelerationRate = (decelerationRate) => {
|
|
14
15
|
let newDecelerationRate = decelerationRate;
|
|
15
16
|
if (newDecelerationRate === 'normal') {
|
|
@@ -102,7 +103,7 @@ const WebViewComponent = forwardRef(({ javaScriptEnabled = true, cacheEnabled =
|
|
|
102
103
|
const NativeWebView = RNCWebView;
|
|
103
104
|
const webView = (<NativeWebView key="webViewKey" {...otherProps} enableApplePay={enableApplePay} javaScriptEnabled={javaScriptEnabled} cacheEnabled={cacheEnabled} dataDetectorTypes={dataDetectorTypes} useSharedProcessPool={useSharedProcessPool} textInteractionEnabled={textInteractionEnabled} decelerationRate={decelerationRate} messagingEnabled={typeof onMessageProp === 'function'} onLoadingError={onLoadingError} onLoadingFinish={onLoadingFinish} onLoadingProgress={onLoadingProgress} onLoadingStart={onLoadingStart} onMessage={onMessage} onShouldStartLoadWithRequest={onShouldStartLoadWithRequest} injectedJavaScript={injectedJavaScript} injectedJavaScriptBeforeContentLoaded={injectedJavaScriptBeforeContentLoaded} allowsInlineMediaPlayback={allowsInlineMediaPlayback} incognito={incognito} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction} ref={webViewRef} sharedCookiesEnabled={sharedCookiesEnabled}
|
|
104
105
|
// TODO: find a better way to type this.
|
|
105
|
-
source={source} style={webViewStyles}/>);
|
|
106
|
+
source={resolveAssetSource(source)} style={webViewStyles}/>);
|
|
106
107
|
return (<View style={webViewContainerStyle}>
|
|
107
108
|
{webView}
|
|
108
109
|
{otherView}
|
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.
|
|
12
|
+
"version": "11.26.1-exodus.12",
|
|
13
13
|
"homepage": "https://github.com/ExodusMovement/react-native-webview#readme",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"android": "react-native run-android",
|