@exodus/react-native-webview 11.26.1-exodus.0 → 11.26.1-exodus.2
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.
- package/apple/RNCWebView.m +1 -1
- package/lib/WebView.android.js +63 -62
- package/lib/WebView.ios.js +65 -102
- package/lib/WebView.js +2 -2
- package/lib/WebView.styles.js +7 -7
- package/lib/WebViewNativeComponent.android.js +1 -1
- package/lib/WebViewNativeComponent.ios.js +1 -1
- package/lib/WebViewShared.js +51 -66
- package/lib/WebViewTypes.d.ts +3 -23
- package/lib/WebViewTypes.js +4 -31
- package/package.json +1 -1
- package/react-native-webview.podspec +1 -1
package/apple/RNCWebView.m
CHANGED
|
@@ -306,7 +306,7 @@ RCTAutoInsetsProtocol>
|
|
|
306
306
|
{
|
|
307
307
|
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
|
308
308
|
WKPreferences *prefs = [[WKPreferences alloc]init];
|
|
309
|
-
BOOL _prefsUsed =
|
|
309
|
+
BOOL _prefsUsed = YES;
|
|
310
310
|
if (!_javaScriptEnabled) {
|
|
311
311
|
prefs.javaScriptEnabled = NO;
|
|
312
312
|
_prefsUsed = YES;
|
package/lib/WebView.android.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
13
2
|
import { Image, View, NativeModules, } from 'react-native';
|
|
14
3
|
import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
|
|
@@ -18,20 +7,32 @@ import invariant from 'invariant';
|
|
|
18
7
|
import RNCWebView from "./WebViewNativeComponent.android";
|
|
19
8
|
import { defaultOriginWhitelist, defaultRenderError, defaultRenderLoading, useWebWiewLogic, } from './WebViewShared';
|
|
20
9
|
import styles from './WebView.styles';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', 'injectJavaScript', 'requestFocus', 'postMessage', 'clearFormData', 'clearCache', 'clearHistory', 'loadUrl']
|
|
10
|
+
const codegenNativeCommands = codegenNativeCommandsUntyped;
|
|
11
|
+
const Commands = codegenNativeCommands({
|
|
12
|
+
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'clearFormData', 'clearCache', 'clearHistory', 'loadUrl'],
|
|
24
13
|
});
|
|
25
|
-
|
|
14
|
+
const { resolveAssetSource } = Image;
|
|
26
15
|
/**
|
|
27
16
|
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
|
28
17
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
let uniqueRef = 0;
|
|
19
|
+
/**
|
|
20
|
+
* Harcoded default for security.
|
|
21
|
+
*/
|
|
22
|
+
const allowFileAccessFromFileURLs = false;
|
|
23
|
+
const allowUniversalAccessFromFileURLs = false;
|
|
24
|
+
const injectedJavaScriptForMainFrameOnly = true;
|
|
25
|
+
const injectedJavaScriptBeforeContentLoadedForMainFrameOnly = true;
|
|
26
|
+
const mediaPlaybackRequiresUserAction = true;
|
|
27
|
+
// Android only
|
|
28
|
+
const allowsFullscreenVideo = false;
|
|
29
|
+
const allowFileAccess = false;
|
|
30
|
+
const setSupportMultipleWindows = true;
|
|
31
|
+
const mixedContentMode = 'never';
|
|
32
|
+
const WebViewComponent = forwardRef(({ overScrollMode = 'always', javaScriptEnabled = true, thirdPartyCookiesEnabled = true, scalesPageToFit = true, saveFormDataDisabled = false, cacheEnabled = true, androidHardwareAccelerationDisabled = false, androidLayerType = "none", originWhitelist = defaultOriginWhitelist, setBuiltInZoomControls = true, setDisplayZoomControls = false, nestedScrollEnabled = false, startInLoadingState, onNavigationStateChange, onLoadStart, onError, onLoad, onLoadEnd, onLoadProgress, onHttpError: onHttpErrorProp, onRenderProcessGone: onRenderProcessGoneProp, onMessage: onMessageProp, renderLoading, renderError, style, containerStyle, source, onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp, ...otherProps }, ref) => {
|
|
33
|
+
const messagingModuleName = useRef(`WebViewMessageHandler${uniqueRef += 1}`).current;
|
|
34
|
+
const webViewRef = useRef(null);
|
|
35
|
+
const onShouldStartLoadWithRequestCallback = useCallback((shouldStart, url, lockIdentifier) => {
|
|
35
36
|
if (lockIdentifier) {
|
|
36
37
|
NativeModules.RNCWebView.onShouldStartLoadWithRequestCallback(shouldStart, lockIdentifier);
|
|
37
38
|
}
|
|
@@ -39,44 +40,44 @@ var WebViewComponent = forwardRef(function (_a, ref) {
|
|
|
39
40
|
Commands.loadUrl(webViewRef.current, url);
|
|
40
41
|
}
|
|
41
42
|
}, []);
|
|
42
|
-
|
|
43
|
-
onNavigationStateChange
|
|
44
|
-
onLoad
|
|
45
|
-
onError
|
|
46
|
-
onHttpErrorProp
|
|
47
|
-
onLoadEnd
|
|
48
|
-
onLoadProgress
|
|
49
|
-
onLoadStart
|
|
50
|
-
onRenderProcessGoneProp
|
|
51
|
-
onMessageProp
|
|
52
|
-
startInLoadingState
|
|
53
|
-
originWhitelist
|
|
54
|
-
onShouldStartLoadWithRequestProp
|
|
55
|
-
onShouldStartLoadWithRequestCallback
|
|
56
|
-
})
|
|
57
|
-
useImperativeHandle(ref,
|
|
58
|
-
goForward:
|
|
59
|
-
goBack:
|
|
60
|
-
reload:
|
|
43
|
+
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onRenderProcessGone } = useWebWiewLogic({
|
|
44
|
+
onNavigationStateChange,
|
|
45
|
+
onLoad,
|
|
46
|
+
onError,
|
|
47
|
+
onHttpErrorProp,
|
|
48
|
+
onLoadEnd,
|
|
49
|
+
onLoadProgress,
|
|
50
|
+
onLoadStart,
|
|
51
|
+
onRenderProcessGoneProp,
|
|
52
|
+
onMessageProp,
|
|
53
|
+
startInLoadingState,
|
|
54
|
+
originWhitelist,
|
|
55
|
+
onShouldStartLoadWithRequestProp,
|
|
56
|
+
onShouldStartLoadWithRequestCallback,
|
|
57
|
+
});
|
|
58
|
+
useImperativeHandle(ref, () => ({
|
|
59
|
+
goForward: () => Commands.goForward(webViewRef.current),
|
|
60
|
+
goBack: () => Commands.goBack(webViewRef.current),
|
|
61
|
+
reload: () => {
|
|
61
62
|
setViewState('LOADING');
|
|
62
63
|
Commands.reload(webViewRef.current);
|
|
63
64
|
},
|
|
64
|
-
stopLoading:
|
|
65
|
-
postMessage:
|
|
66
|
-
injectJavaScript:
|
|
67
|
-
requestFocus:
|
|
68
|
-
clearFormData:
|
|
69
|
-
clearCache:
|
|
70
|
-
clearHistory:
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
onShouldStartLoadWithRequest
|
|
74
|
-
onMessage
|
|
75
|
-
})
|
|
76
|
-
useEffect(
|
|
65
|
+
stopLoading: () => Commands.stopLoading(webViewRef.current),
|
|
66
|
+
postMessage: (data) => Commands.postMessage(webViewRef.current, data),
|
|
67
|
+
// injectJavaScript: (data: string) => Commands.injectJavaScript(webViewRef.current, data),
|
|
68
|
+
requestFocus: () => Commands.requestFocus(webViewRef.current),
|
|
69
|
+
clearFormData: () => Commands.clearFormData(webViewRef.current),
|
|
70
|
+
clearCache: (includeDiskFiles) => Commands.clearCache(webViewRef.current, includeDiskFiles),
|
|
71
|
+
clearHistory: () => Commands.clearHistory(webViewRef.current),
|
|
72
|
+
}), [setViewState, webViewRef]);
|
|
73
|
+
const directEventCallbacks = useMemo(() => ({
|
|
74
|
+
onShouldStartLoadWithRequest,
|
|
75
|
+
onMessage,
|
|
76
|
+
}), [onMessage, onShouldStartLoadWithRequest]);
|
|
77
|
+
useEffect(() => {
|
|
77
78
|
BatchedBridge.registerCallableModule(messagingModuleName, directEventCallbacks);
|
|
78
79
|
}, [messagingModuleName, directEventCallbacks]);
|
|
79
|
-
|
|
80
|
+
let otherView = null;
|
|
80
81
|
if (viewState === 'LOADING') {
|
|
81
82
|
otherView = (renderLoading || defaultRenderLoading)();
|
|
82
83
|
}
|
|
@@ -85,10 +86,10 @@ var WebViewComponent = forwardRef(function (_a, ref) {
|
|
|
85
86
|
otherView = (renderError || defaultRenderError)(lastErrorEvent.domain, lastErrorEvent.code, lastErrorEvent.description);
|
|
86
87
|
}
|
|
87
88
|
else if (viewState !== 'IDLE') {
|
|
88
|
-
console.error(
|
|
89
|
+
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
92
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
92
93
|
if (typeof source !== "number" && source && 'method' in source) {
|
|
93
94
|
if (source.method === 'POST' && source.headers) {
|
|
94
95
|
console.warn('WebView: `source.headers` is not supported when using POST.');
|
|
@@ -97,16 +98,16 @@ var WebViewComponent = forwardRef(function (_a, ref) {
|
|
|
97
98
|
console.warn('WebView: `source.body` is not supported when using GET.');
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
const NativeWebView = RNCWebView;
|
|
102
|
+
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}
|
|
102
103
|
// TODO: find a better way to type this.
|
|
103
|
-
source={resolveAssetSource(source)} style={webViewStyles} overScrollMode={overScrollMode} javaScriptEnabled={javaScriptEnabled} thirdPartyCookiesEnabled={thirdPartyCookiesEnabled} scalesPageToFit={scalesPageToFit} allowsFullscreenVideo={allowsFullscreenVideo} allowFileAccess={allowFileAccess} saveFormDataDisabled={saveFormDataDisabled} cacheEnabled={cacheEnabled} androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled} androidLayerType={androidLayerType} setSupportMultipleWindows={setSupportMultipleWindows} setBuiltInZoomControls={setBuiltInZoomControls} setDisplayZoomControls={setDisplayZoomControls} nestedScrollEnabled={nestedScrollEnabled} {
|
|
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}/>;
|
|
104
105
|
return (<View style={webViewContainerStyle}>
|
|
105
106
|
{webView}
|
|
106
107
|
{otherView}
|
|
107
108
|
</View>);
|
|
108
109
|
});
|
|
109
110
|
// native implementation should return "true" only for Android 5+
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
const isFileUploadSupported = NativeModules.RNCWebView.isFileUploadSupported();
|
|
112
|
+
const WebView = Object.assign(WebViewComponent, { isFileUploadSupported });
|
|
112
113
|
export default WebView;
|
package/lib/WebView.ios.js
CHANGED
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
38
|
-
var t = {};
|
|
39
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
40
|
-
t[p] = s[p];
|
|
41
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
42
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
43
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
44
|
-
t[p[i]] = s[p[i]];
|
|
45
|
-
}
|
|
46
|
-
return t;
|
|
47
|
-
};
|
|
48
1
|
import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
|
49
2
|
import { Image, View, NativeModules, } from 'react-native';
|
|
50
3
|
import invariant from 'invariant';
|
|
@@ -53,13 +6,13 @@ import codegenNativeCommandsUntyped from 'react-native/Libraries/Utilities/codeg
|
|
|
53
6
|
import RNCWebView from "./WebViewNativeComponent.ios";
|
|
54
7
|
import { defaultOriginWhitelist, defaultRenderError, defaultRenderLoading, useWebWiewLogic, } from './WebViewShared';
|
|
55
8
|
import styles from './WebView.styles';
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', 'injectJavaScript', 'requestFocus', 'postMessage', 'loadUrl']
|
|
9
|
+
const codegenNativeCommands = codegenNativeCommandsUntyped;
|
|
10
|
+
const Commands = codegenNativeCommands({
|
|
11
|
+
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'loadUrl'],
|
|
59
12
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
13
|
+
const { resolveAssetSource } = Image;
|
|
14
|
+
const processDecelerationRate = (decelerationRate) => {
|
|
15
|
+
let newDecelerationRate = decelerationRate;
|
|
63
16
|
if (newDecelerationRate === 'normal') {
|
|
64
17
|
newDecelerationRate = 0.998;
|
|
65
18
|
}
|
|
@@ -68,56 +21,69 @@ var processDecelerationRate = function (decelerationRate) {
|
|
|
68
21
|
}
|
|
69
22
|
return newDecelerationRate;
|
|
70
23
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
24
|
+
const RNCWebViewManager = NativeModules.RNCWebViewManager;
|
|
25
|
+
const useWarnIfChanges = (value, name) => {
|
|
26
|
+
const ref = useRef(value);
|
|
74
27
|
if (ref.current !== value) {
|
|
75
|
-
console.warn(
|
|
28
|
+
console.warn(`Changes to property ${name} do nothing after the initial render.`);
|
|
76
29
|
ref.current = value;
|
|
77
30
|
}
|
|
78
31
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Harcoded defaults for security.
|
|
34
|
+
*/
|
|
35
|
+
const allowFileAccessFromFileURLs = false;
|
|
36
|
+
const allowUniversalAccessFromFileURLs = false;
|
|
37
|
+
const injectedJavaScriptForMainFrameOnly = true;
|
|
38
|
+
const injectedJavaScriptBeforeContentLoadedForMainFrameOnly = true;
|
|
39
|
+
const mediaPlaybackRequiresUserAction = true;
|
|
40
|
+
// iOS only configs
|
|
41
|
+
const allowsInlineMediaPlayback = true;
|
|
42
|
+
const allowsAirPlayForMediaPlayback = false;
|
|
43
|
+
const useSharedProcessPool = false;
|
|
44
|
+
const sharedCookiesEnabled = false;
|
|
45
|
+
const enableApplePay = false;
|
|
46
|
+
const onFileDownload = () => console.error('tried to download file');
|
|
47
|
+
const dataDetectorTypes = 'none';
|
|
48
|
+
const WebViewComponent = forwardRef(({ javaScriptEnabled = true, cacheEnabled = true, originWhitelist = defaultOriginWhitelist, textInteractionEnabled = true, injectedJavaScript, injectedJavaScriptBeforeContentLoaded, startInLoadingState, onNavigationStateChange, onLoadStart, onError, onLoad, onLoadEnd, onLoadProgress, onContentProcessDidTerminate: onContentProcessDidTerminateProp, onHttpError: onHttpErrorProp, onMessage: onMessageProp, renderLoading, renderError, style, containerStyle, source, incognito, decelerationRate: decelerationRateProp, onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp, ...otherProps }, ref) => {
|
|
49
|
+
const webViewRef = useRef(null);
|
|
50
|
+
const onShouldStartLoadWithRequestCallback = useCallback((shouldStart, _url, lockIdentifier = 0) => {
|
|
51
|
+
const viewManager = RNCWebViewManager;
|
|
86
52
|
viewManager.startLoadWithResult(!!shouldStart, lockIdentifier);
|
|
87
|
-
}, [
|
|
88
|
-
|
|
89
|
-
onNavigationStateChange
|
|
90
|
-
onLoad
|
|
91
|
-
onError
|
|
92
|
-
onHttpErrorProp
|
|
93
|
-
onLoadEnd
|
|
94
|
-
onLoadProgress
|
|
95
|
-
onLoadStart
|
|
96
|
-
onMessageProp
|
|
97
|
-
startInLoadingState
|
|
98
|
-
originWhitelist
|
|
99
|
-
onShouldStartLoadWithRequestProp
|
|
100
|
-
onShouldStartLoadWithRequestCallback
|
|
101
|
-
onContentProcessDidTerminateProp
|
|
102
|
-
})
|
|
103
|
-
useImperativeHandle(ref,
|
|
104
|
-
goForward:
|
|
105
|
-
goBack:
|
|
106
|
-
reload:
|
|
53
|
+
}, []);
|
|
54
|
+
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onContentProcessDidTerminate } = useWebWiewLogic({
|
|
55
|
+
onNavigationStateChange,
|
|
56
|
+
onLoad,
|
|
57
|
+
onError,
|
|
58
|
+
onHttpErrorProp,
|
|
59
|
+
onLoadEnd,
|
|
60
|
+
onLoadProgress,
|
|
61
|
+
onLoadStart,
|
|
62
|
+
onMessageProp,
|
|
63
|
+
startInLoadingState,
|
|
64
|
+
originWhitelist,
|
|
65
|
+
onShouldStartLoadWithRequestProp,
|
|
66
|
+
onShouldStartLoadWithRequestCallback,
|
|
67
|
+
onContentProcessDidTerminateProp,
|
|
68
|
+
});
|
|
69
|
+
useImperativeHandle(ref, () => ({
|
|
70
|
+
goForward: () => Commands.goForward(webViewRef.current),
|
|
71
|
+
goBack: () => Commands.goBack(webViewRef.current),
|
|
72
|
+
reload: () => {
|
|
107
73
|
setViewState('LOADING');
|
|
108
74
|
Commands.reload(webViewRef.current);
|
|
109
75
|
},
|
|
110
|
-
stopLoading:
|
|
111
|
-
postMessage:
|
|
112
|
-
injectJavaScript:
|
|
113
|
-
requestFocus:
|
|
114
|
-
})
|
|
76
|
+
stopLoading: () => Commands.stopLoading(webViewRef.current),
|
|
77
|
+
postMessage: (data) => Commands.postMessage(webViewRef.current, data),
|
|
78
|
+
// injectJavaScript: (data: string) => Commands.injectJavaScript(webViewRef.current, data),
|
|
79
|
+
requestFocus: () => Commands.requestFocus(webViewRef.current),
|
|
80
|
+
}), [setViewState, webViewRef]);
|
|
115
81
|
useWarnIfChanges(allowsInlineMediaPlayback, 'allowsInlineMediaPlayback');
|
|
116
82
|
useWarnIfChanges(allowsAirPlayForMediaPlayback, 'allowsAirPlayForMediaPlayback');
|
|
117
83
|
useWarnIfChanges(incognito, 'incognito');
|
|
118
84
|
useWarnIfChanges(mediaPlaybackRequiresUserAction, 'mediaPlaybackRequiresUserAction');
|
|
119
85
|
useWarnIfChanges(dataDetectorTypes, 'dataDetectorTypes');
|
|
120
|
-
|
|
86
|
+
let otherView = null;
|
|
121
87
|
if (viewState === 'LOADING') {
|
|
122
88
|
otherView = (renderLoading || defaultRenderLoading)();
|
|
123
89
|
}
|
|
@@ -126,24 +92,21 @@ var WebViewComponent = forwardRef(function (_a, ref) {
|
|
|
126
92
|
otherView = (renderError || defaultRenderError)(lastErrorEvent.domain, lastErrorEvent.code, lastErrorEvent.description);
|
|
127
93
|
}
|
|
128
94
|
else if (viewState !== 'IDLE') {
|
|
129
|
-
console.error(
|
|
95
|
+
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
130
96
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var webView = (<NativeWebView key="webViewKey" {...otherProps} javaScriptEnabled={javaScriptEnabled} cacheEnabled={cacheEnabled} 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} dataDetectorTypes={dataDetectorTypes} allowsAirPlayForMediaPlayback={allowsAirPlayForMediaPlayback} allowsInlineMediaPlayback={allowsInlineMediaPlayback} incognito={incognito} mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction} ref={webViewRef}
|
|
97
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
98
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
99
|
+
const decelerationRate = processDecelerationRate(decelerationRateProp);
|
|
100
|
+
const NativeWebView = RNCWebView;
|
|
101
|
+
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}
|
|
137
102
|
// TODO: find a better way to type this.
|
|
138
|
-
source={resolveAssetSource(source)} style={webViewStyles}
|
|
103
|
+
source={resolveAssetSource(source)} style={webViewStyles}/>);
|
|
139
104
|
return (<View style={webViewContainerStyle}>
|
|
140
105
|
{webView}
|
|
141
106
|
{otherView}
|
|
142
107
|
</View>);
|
|
143
108
|
});
|
|
144
109
|
// no native implementation for iOS, depends only on permissions
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}); }); };
|
|
148
|
-
var WebView = Object.assign(WebViewComponent, { isFileUploadSupported: isFileUploadSupported });
|
|
110
|
+
const isFileUploadSupported = async () => true;
|
|
111
|
+
const WebView = Object.assign(WebViewComponent, { isFileUploadSupported });
|
|
149
112
|
export default WebView;
|
package/lib/WebView.js
CHANGED
|
@@ -2,10 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
3
|
// This "dummy" WebView is to render something for unsupported platforms,
|
|
4
4
|
// like for example Expo SDK "web" platform.
|
|
5
|
-
|
|
5
|
+
const WebView = () => (<View style={{ alignSelf: 'flex-start' }}>
|
|
6
6
|
<Text style={{ color: 'red' }}>
|
|
7
7
|
React Native WebView does not support this platform.
|
|
8
8
|
</Text>
|
|
9
|
-
</View>);
|
|
9
|
+
</View>);
|
|
10
10
|
export { WebView };
|
|
11
11
|
export default WebView;
|
package/lib/WebView.styles.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
|
|
2
|
+
const styles = StyleSheet.create({
|
|
3
3
|
container: {
|
|
4
4
|
flex: 1,
|
|
5
|
-
overflow: 'hidden'
|
|
5
|
+
overflow: 'hidden',
|
|
6
6
|
},
|
|
7
7
|
loadingOrErrorView: {
|
|
8
8
|
position: 'absolute',
|
|
@@ -14,20 +14,20 @@ var styles = StyleSheet.create({
|
|
|
14
14
|
backgroundColor: 'white'
|
|
15
15
|
},
|
|
16
16
|
loadingProgressBar: {
|
|
17
|
-
height: 20
|
|
17
|
+
height: 20,
|
|
18
18
|
},
|
|
19
19
|
errorText: {
|
|
20
20
|
fontSize: 14,
|
|
21
21
|
textAlign: 'center',
|
|
22
|
-
marginBottom: 2
|
|
22
|
+
marginBottom: 2,
|
|
23
23
|
},
|
|
24
24
|
errorTextTitle: {
|
|
25
25
|
fontSize: 15,
|
|
26
26
|
fontWeight: '500',
|
|
27
|
-
marginBottom: 10
|
|
27
|
+
marginBottom: 10,
|
|
28
28
|
},
|
|
29
29
|
webView: {
|
|
30
|
-
backgroundColor: '#ffffff'
|
|
31
|
-
}
|
|
30
|
+
backgroundColor: '#ffffff',
|
|
31
|
+
},
|
|
32
32
|
});
|
|
33
33
|
export default styles;
|
package/lib/WebViewShared.js
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
1
|
import escapeStringRegexp from 'escape-string-regexp';
|
|
11
2
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
12
3
|
import { Linking, View, ActivityIndicator, Text, Platform } from 'react-native';
|
|
13
4
|
import styles from './WebView.styles';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
const defaultOriginWhitelist = ['http://*', 'https://*'];
|
|
6
|
+
const extractOrigin = (url) => {
|
|
7
|
+
const result = /^[A-Za-z][A-Za-z0-9+\-.]+:(\/\/)?[^/]*/.exec(url);
|
|
17
8
|
return result === null ? '' : result[0];
|
|
18
9
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var origin = extractOrigin(url);
|
|
24
|
-
return compiledWhitelist.some(function (x) { return new RegExp(x).test(origin); });
|
|
25
|
-
};
|
|
26
|
-
var compileWhitelist = function (originWhitelist) {
|
|
27
|
-
return __spreadArray(['about:blank'], (originWhitelist || []), true).map(originWhitelistToRegex);
|
|
10
|
+
const originWhitelistToRegex = (originWhitelist) => `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
|
|
11
|
+
const passesWhitelist = (compiledWhitelist, url) => {
|
|
12
|
+
const origin = extractOrigin(url);
|
|
13
|
+
return compiledWhitelist.some(x => new RegExp(x).test(origin));
|
|
28
14
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
const compileWhitelist = (originWhitelist) => ['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
|
|
16
|
+
const createOnShouldStartLoadWithRequest = (loadRequest, originWhitelist, onShouldStartLoadWithRequest) => {
|
|
17
|
+
return ({ nativeEvent }) => {
|
|
18
|
+
let shouldStart = true;
|
|
19
|
+
const { url, lockIdentifier } = nativeEvent;
|
|
34
20
|
if (!passesWhitelist(compileWhitelist(originWhitelist), url)) {
|
|
35
|
-
Linking.canOpenURL(url).then(
|
|
21
|
+
Linking.canOpenURL(url).then((supported) => {
|
|
36
22
|
if (supported) {
|
|
37
23
|
return Linking.openURL(url);
|
|
38
24
|
}
|
|
39
|
-
console.warn(
|
|
25
|
+
console.warn(`Can't open url: ${url}`);
|
|
40
26
|
return undefined;
|
|
41
|
-
})
|
|
27
|
+
}).catch(e => {
|
|
42
28
|
console.warn('Error opening URL: ', e);
|
|
43
29
|
});
|
|
44
30
|
shouldStart = false;
|
|
@@ -49,32 +35,31 @@ var createOnShouldStartLoadWithRequest = function (loadRequest, originWhitelist,
|
|
|
49
35
|
loadRequest(shouldStart, url, lockIdentifier);
|
|
50
36
|
};
|
|
51
37
|
};
|
|
52
|
-
|
|
38
|
+
const defaultRenderLoading = () => (<View style={styles.loadingOrErrorView}>
|
|
53
39
|
<ActivityIndicator />
|
|
54
|
-
</View>);
|
|
55
|
-
|
|
40
|
+
</View>);
|
|
41
|
+
const defaultRenderError = (errorDomain, errorCode, errorDesc) => (<View style={styles.loadingOrErrorView}>
|
|
56
42
|
<Text style={styles.errorTextTitle}>Error loading page</Text>
|
|
57
|
-
<Text style={styles.errorText}>{
|
|
58
|
-
<Text style={styles.errorText}>{
|
|
59
|
-
<Text style={styles.errorText}>{
|
|
60
|
-
</View>);
|
|
43
|
+
<Text style={styles.errorText}>{`Domain: ${errorDomain}`}</Text>
|
|
44
|
+
<Text style={styles.errorText}>{`Error Code: ${errorCode}`}</Text>
|
|
45
|
+
<Text style={styles.errorText}>{`Description: ${errorDesc}`}</Text>
|
|
46
|
+
</View>);
|
|
61
47
|
export { defaultOriginWhitelist, createOnShouldStartLoadWithRequest, defaultRenderLoading, defaultRenderError, };
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var updateNavigationState = useCallback(function (event) {
|
|
48
|
+
export const useWebWiewLogic = ({ startInLoadingState, onNavigationStateChange, onLoadStart, onLoad, onLoadProgress, onLoadEnd, onError, onHttpErrorProp, onMessageProp, onRenderProcessGoneProp, onContentProcessDidTerminateProp, originWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback, }) => {
|
|
49
|
+
const [viewState, setViewState] = useState(startInLoadingState ? "LOADING" : "IDLE");
|
|
50
|
+
const [lastErrorEvent, setLastErrorEvent] = useState(null);
|
|
51
|
+
const startUrl = useRef(null);
|
|
52
|
+
const updateNavigationState = useCallback((event) => {
|
|
68
53
|
onNavigationStateChange === null || onNavigationStateChange === void 0 ? void 0 : onNavigationStateChange(event.nativeEvent);
|
|
69
54
|
}, [onNavigationStateChange]);
|
|
70
|
-
|
|
55
|
+
const onLoadingStart = useCallback((event) => {
|
|
71
56
|
// Needed for android
|
|
72
57
|
startUrl.current = event.nativeEvent.url;
|
|
73
58
|
// !Needed for android
|
|
74
59
|
onLoadStart === null || onLoadStart === void 0 ? void 0 : onLoadStart(event);
|
|
75
60
|
updateNavigationState(event);
|
|
76
61
|
}, [onLoadStart, updateNavigationState]);
|
|
77
|
-
|
|
62
|
+
const onLoadingError = useCallback((event) => {
|
|
78
63
|
event.persist();
|
|
79
64
|
if (onError) {
|
|
80
65
|
onError(event);
|
|
@@ -90,23 +75,23 @@ export var useWebWiewLogic = function (_a) {
|
|
|
90
75
|
setViewState('ERROR');
|
|
91
76
|
setLastErrorEvent(event.nativeEvent);
|
|
92
77
|
}, [onError, onLoadEnd]);
|
|
93
|
-
|
|
78
|
+
const onHttpError = useCallback((event) => {
|
|
94
79
|
onHttpErrorProp === null || onHttpErrorProp === void 0 ? void 0 : onHttpErrorProp(event);
|
|
95
80
|
}, [onHttpErrorProp]);
|
|
96
81
|
// Android Only
|
|
97
|
-
|
|
82
|
+
const onRenderProcessGone = useCallback((event) => {
|
|
98
83
|
onRenderProcessGoneProp === null || onRenderProcessGoneProp === void 0 ? void 0 : onRenderProcessGoneProp(event);
|
|
99
84
|
}, [onRenderProcessGoneProp]);
|
|
100
85
|
// !Android Only
|
|
101
86
|
// iOS Only
|
|
102
|
-
|
|
87
|
+
const onContentProcessDidTerminate = useCallback((event) => {
|
|
103
88
|
onContentProcessDidTerminateProp === null || onContentProcessDidTerminateProp === void 0 ? void 0 : onContentProcessDidTerminateProp(event);
|
|
104
89
|
}, [onContentProcessDidTerminateProp]);
|
|
105
90
|
// !iOS Only
|
|
106
|
-
|
|
91
|
+
const onLoadingFinish = useCallback((event) => {
|
|
107
92
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(event);
|
|
108
93
|
onLoadEnd === null || onLoadEnd === void 0 ? void 0 : onLoadEnd(event);
|
|
109
|
-
|
|
94
|
+
const { nativeEvent: { url } } = event;
|
|
110
95
|
// on Android, only if url === startUrl
|
|
111
96
|
if (Platform.OS !== "android" || url === startUrl.current) {
|
|
112
97
|
setViewState('IDLE');
|
|
@@ -114,31 +99,31 @@ export var useWebWiewLogic = function (_a) {
|
|
|
114
99
|
// !on Android, only if url === startUrl
|
|
115
100
|
updateNavigationState(event);
|
|
116
101
|
}, [onLoad, onLoadEnd, updateNavigationState]);
|
|
117
|
-
|
|
102
|
+
const onMessage = useCallback((event) => {
|
|
118
103
|
onMessageProp === null || onMessageProp === void 0 ? void 0 : onMessageProp(event);
|
|
119
104
|
}, [onMessageProp]);
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
const onLoadingProgress = useCallback((event) => {
|
|
106
|
+
const { nativeEvent: { progress } } = event;
|
|
122
107
|
// patch for Android only
|
|
123
108
|
if (Platform.OS === "android" && progress === 1) {
|
|
124
|
-
setViewState(
|
|
109
|
+
setViewState(prevViewState => prevViewState === 'LOADING' ? 'IDLE' : prevViewState);
|
|
125
110
|
}
|
|
126
111
|
// !patch for Android only
|
|
127
112
|
onLoadProgress === null || onLoadProgress === void 0 ? void 0 : onLoadProgress(event);
|
|
128
113
|
}, [onLoadProgress]);
|
|
129
|
-
|
|
114
|
+
const onShouldStartLoadWithRequest = useMemo(() => createOnShouldStartLoadWithRequest(onShouldStartLoadWithRequestCallback, originWhitelist, onShouldStartLoadWithRequestProp), [originWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback]);
|
|
130
115
|
return {
|
|
131
|
-
onShouldStartLoadWithRequest
|
|
132
|
-
onLoadingStart
|
|
133
|
-
onLoadingProgress
|
|
134
|
-
onLoadingError
|
|
135
|
-
onLoadingFinish
|
|
136
|
-
onHttpError
|
|
137
|
-
onRenderProcessGone
|
|
138
|
-
onContentProcessDidTerminate
|
|
139
|
-
onMessage
|
|
140
|
-
viewState
|
|
141
|
-
setViewState
|
|
142
|
-
lastErrorEvent
|
|
116
|
+
onShouldStartLoadWithRequest,
|
|
117
|
+
onLoadingStart,
|
|
118
|
+
onLoadingProgress,
|
|
119
|
+
onLoadingError,
|
|
120
|
+
onLoadingFinish,
|
|
121
|
+
onHttpError,
|
|
122
|
+
onRenderProcessGone,
|
|
123
|
+
onContentProcessDidTerminate,
|
|
124
|
+
onMessage,
|
|
125
|
+
viewState,
|
|
126
|
+
setViewState,
|
|
127
|
+
lastErrorEvent,
|
|
143
128
|
};
|
|
144
129
|
};
|
package/lib/WebViewTypes.d.ts
CHANGED
|
@@ -143,22 +143,6 @@ export declare type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
|
|
|
143
143
|
export interface ViewManager {
|
|
144
144
|
startLoadWithResult: Function;
|
|
145
145
|
}
|
|
146
|
-
export interface WebViewNativeConfig {
|
|
147
|
-
/**
|
|
148
|
-
* The native component used to render the WebView.
|
|
149
|
-
*/
|
|
150
|
-
component?: typeof NativeWebViewIOS | typeof NativeWebViewAndroid;
|
|
151
|
-
/**
|
|
152
|
-
* Set props directly on the native component WebView. Enables custom props which the
|
|
153
|
-
* original WebView doesn't pass through.
|
|
154
|
-
*/
|
|
155
|
-
props?: Object;
|
|
156
|
-
/**
|
|
157
|
-
* Set the ViewManager to use for communication with the native side.
|
|
158
|
-
* @platform ios, macos
|
|
159
|
-
*/
|
|
160
|
-
viewManager?: ViewManager;
|
|
161
|
-
}
|
|
162
146
|
export declare type OnShouldStartLoadWithRequest = (event: ShouldStartLoadRequest) => boolean;
|
|
163
147
|
export interface BasicAuthCredential {
|
|
164
148
|
/**
|
|
@@ -171,6 +155,7 @@ export interface BasicAuthCredential {
|
|
|
171
155
|
password: string;
|
|
172
156
|
}
|
|
173
157
|
export interface CommonNativeWebViewProps extends ViewProps {
|
|
158
|
+
allowFileAccessFromFileURLs?: boolean;
|
|
174
159
|
cacheEnabled?: boolean;
|
|
175
160
|
incognito?: boolean;
|
|
176
161
|
injectedJavaScript?: string;
|
|
@@ -201,7 +186,6 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
|
|
|
201
186
|
cacheMode?: CacheMode;
|
|
202
187
|
allowFileAccess?: boolean;
|
|
203
188
|
scalesPageToFit?: boolean;
|
|
204
|
-
allowFileAccessFromFileURLs?: boolean;
|
|
205
189
|
allowsFullscreenVideo?: boolean;
|
|
206
190
|
allowUniversalAccessFromFileURLs?: boolean;
|
|
207
191
|
androidHardwareAccelerationDisabled?: boolean;
|
|
@@ -237,7 +221,6 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
|
|
|
237
221
|
allowsInlineMediaPlayback?: boolean;
|
|
238
222
|
allowsAirPlayForMediaPlayback?: boolean;
|
|
239
223
|
allowsLinkPreview?: boolean;
|
|
240
|
-
allowFileAccessFromFileURLs?: boolean;
|
|
241
224
|
allowUniversalAccessFromFileURLs?: boolean;
|
|
242
225
|
automaticallyAdjustContentInsets?: boolean;
|
|
243
226
|
autoManageStatusBarEnabled?: boolean;
|
|
@@ -258,6 +241,8 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
|
|
|
258
241
|
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
|
|
259
242
|
onFileDownload?: (event: FileDownloadEvent) => void;
|
|
260
243
|
limitsNavigationsToAppBoundDomains?: boolean;
|
|
244
|
+
sharedCookiesEnabled?: boolean;
|
|
245
|
+
enableApplePay?: boolean;
|
|
261
246
|
textInteractionEnabled?: boolean;
|
|
262
247
|
mediaCapturePermissionGrantType?: MediaCapturePermissionGrantType;
|
|
263
248
|
}
|
|
@@ -871,11 +856,6 @@ export interface WebViewSharedProps extends ViewProps {
|
|
|
871
856
|
* to stop loading. The `navigationType` is always `other` on android.
|
|
872
857
|
*/
|
|
873
858
|
onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest;
|
|
874
|
-
/**
|
|
875
|
-
* Override the native component used to render the WebView. Enables a custom native
|
|
876
|
-
* WebView which uses the same JavaScript as the original WebView.
|
|
877
|
-
*/
|
|
878
|
-
nativeConfig?: WebViewNativeConfig;
|
|
879
859
|
/**
|
|
880
860
|
* Should caching be enabled. Default is true.
|
|
881
861
|
*/
|
package/lib/WebViewTypes.js
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/no-multi-comp, max-classes-per-file */
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
import { Component } from 'react';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return NativeWebViewIOS;
|
|
24
|
-
}(NativeWebViewIOSBase));
|
|
25
|
-
export { NativeWebViewIOS };
|
|
26
|
-
var NativeWebViewAndroid = /** @class */ (function (_super) {
|
|
27
|
-
__extends(NativeWebViewAndroid, _super);
|
|
28
|
-
function NativeWebViewAndroid() {
|
|
29
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
30
|
-
}
|
|
31
|
-
return NativeWebViewAndroid;
|
|
32
|
-
}(NativeWebViewAndroidBase));
|
|
33
|
-
export { NativeWebViewAndroid };
|
|
3
|
+
export class NativeWebViewIOS extends NativeWebViewIOSBase {
|
|
4
|
+
}
|
|
5
|
+
export class NativeWebViewAndroid extends NativeWebViewAndroidBase {
|
|
6
|
+
}
|
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.2",
|
|
13
13
|
"homepage": "https://github.com/ExodusMovement/react-native-webview#readme",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"android": "react-native run-android",
|
|
@@ -3,7 +3,7 @@ require 'json'
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name =
|
|
6
|
+
s.name = 'react-native-webview'
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.license = package['license']
|