@exodus/react-native-webview 11.26.1-exodus.11 → 11.26.1-exodus.13
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/.all-contributorsrc +185 -0
- package/.circleci/config.yml +66 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +94 -0
- package/.flowconfig +88 -0
- package/.flowconfig.android +88 -0
- package/.gitattributes +12 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug-report.md +42 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +30 -0
- package/.github/workflows/android-ci.yml +35 -0
- package/.github/workflows/detox.yml +20 -0
- package/.github/workflows/ios-ci.yml +31 -0
- package/.github/workflows/scripts/install-vs-features.ps1 +108 -0
- package/.github/workflows/stale.yml +17 -0
- package/.gitignore +62 -0
- package/.prettierrc.js +10 -0
- package/.releaserc +15 -0
- package/.vscode/settings.json +9 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +5 -0
- package/apple/RNCWebView.h +1 -0
- package/apple/RNCWebView.m +17 -0
- package/apple/RNCWebViewManager.m +1 -0
- package/babel.config.js +11 -0
- package/bin/setup +26 -0
- package/docs/Contributing.md +102 -0
- package/docs/Custom-Android.md +222 -0
- package/docs/Custom-iOS.md +236 -0
- package/docs/Debugging.md +101 -0
- package/docs/Getting-Started.md +142 -0
- package/docs/Guide.md +613 -0
- package/docs/Reference.md +1639 -0
- package/example/.gitignore +14 -0
- package/example/.watchmanconfig +1 -0
- package/example/App.tsx +262 -0
- package/example/android/build.gradle +15 -0
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/example/android/gradle.properties +34 -0
- package/example/android/gradlew +234 -0
- package/example/android/gradlew.bat +89 -0
- package/example/android/settings.gradle +12 -0
- package/example/app.json +20 -0
- package/example/assets/test.html +9 -0
- package/example/babel.config.js +3 -0
- package/example/examples/Alerts.tsx +72 -0
- package/example/examples/ApplePay.tsx +23 -0
- package/example/examples/Background.tsx +54 -0
- package/example/examples/Downloads.tsx +57 -0
- package/example/examples/Injection.tsx +161 -0
- package/example/examples/LocalPageLoad.tsx +16 -0
- package/example/examples/Messaging.tsx +63 -0
- package/example/examples/NativeWebpage.tsx +22 -0
- package/example/examples/Scrolling.tsx +68 -0
- package/example/examples/Uploads.tsx +69 -0
- package/example/index.js +9 -0
- package/example/ios/Podfile +8 -0
- package/example/ios/Podfile.lock +445 -0
- package/jest-setups/jest.setup.js +8 -0
- package/jest.config.js +184 -0
- package/lib/WebView.android.d.ts.map +1 -0
- package/lib/WebView.d.ts.map +1 -0
- package/lib/WebView.ios.d.ts.map +1 -0
- package/lib/WebView.styles.d.ts.map +1 -0
- package/lib/WebViewNativeComponent.android.d.ts.map +1 -0
- package/lib/WebViewNativeComponent.ios.d.ts.map +1 -0
- package/lib/WebViewShared.d.ts.map +1 -0
- package/lib/WebViewTypes.d.ts +5 -0
- package/lib/WebViewTypes.d.ts.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/metro.config.js +57 -0
- package/package.json +1 -1
- package/src/WebView.android.tsx +246 -0
- package/src/WebView.ios.tsx +221 -0
- package/src/WebView.styles.ts +44 -0
- package/src/WebView.tsx +18 -0
- package/src/WebViewNativeComponent.android.ts +8 -0
- package/src/WebViewNativeComponent.ios.ts +8 -0
- package/src/WebViewShared.tsx +257 -0
- package/src/WebViewTypes.ts +920 -0
- package/src/__tests__/WebViewShared-test.js +208 -0
- package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +24 -0
- package/yarn.lock +13397 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebViewTypes.d.ts","sourceRoot":"","sources":["../src/WebViewTypes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7D,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DED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metro configuration for React Native
|
|
3
|
+
* https://github.com/facebook/react-native
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const exclusionList = (() => {
|
|
11
|
+
try {
|
|
12
|
+
return require('metro-config/src/defaults/exclusionList');
|
|
13
|
+
} catch (_) {
|
|
14
|
+
// `blacklist` was renamed to `exclusionList` in 0.60
|
|
15
|
+
return require('metro-config/src/defaults/blacklist');
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
const blockList = exclusionList([
|
|
20
|
+
/node_modules\/.*\/node_modules\/react-native\/.*/,
|
|
21
|
+
|
|
22
|
+
// Workaround for `EPERM: operation not permitted, lstat '~\midl-MIDLRT-cl.read.1.tlog'`
|
|
23
|
+
/.*\.tlog/,
|
|
24
|
+
|
|
25
|
+
// This stops "react-native run-windows" from causing the metro server to
|
|
26
|
+
// crash if its already running
|
|
27
|
+
new RegExp(`${path.join(__dirname, 'windows').replace(/[/\\]+/g, '/')}.*`),
|
|
28
|
+
|
|
29
|
+
// Workaround for `EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'`
|
|
30
|
+
/.*\.ProjectImports\.zip/,
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This config is a bit exotic because our example app is not its own package
|
|
35
|
+
* (that would require setting this repo up as a monorepo). We need to tell
|
|
36
|
+
* Metro that the root of the project is our `example` folder (`projectRoot`),
|
|
37
|
+
* and that it should look for modules in repo root (`watchFolders`) as this is
|
|
38
|
+
* where the `node_modules` folder lives. Metro will otherwise fail to resolve
|
|
39
|
+
* anything.
|
|
40
|
+
*/
|
|
41
|
+
module.exports = {
|
|
42
|
+
projectRoot: path.join(__dirname, 'example'),
|
|
43
|
+
watchFolders: [__dirname],
|
|
44
|
+
resolver: {
|
|
45
|
+
resolverMainFields: ['main-internal', 'browser', 'main'],
|
|
46
|
+
blacklistRE: blockList,
|
|
47
|
+
blockList,
|
|
48
|
+
},
|
|
49
|
+
transformer: {
|
|
50
|
+
getTransformOptions: async () => ({
|
|
51
|
+
transform: {
|
|
52
|
+
experimentalImportSupport: false,
|
|
53
|
+
inlineRequires: false,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
};
|
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.13",
|
|
13
13
|
"homepage": "https://github.com/ExodusMovement/react-native-webview#readme",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"android": "react-native run-android",
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
NativeModules,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
|
|
10
|
+
// @ts-expect-error react-native doesn't have this type
|
|
11
|
+
import codegenNativeCommandsUntyped from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
12
|
+
|
|
13
|
+
import invariant from 'invariant';
|
|
14
|
+
|
|
15
|
+
import RNCWebView from "./WebViewNativeComponent.android";
|
|
16
|
+
import {
|
|
17
|
+
defaultOriginWhitelist,
|
|
18
|
+
defaultRenderError,
|
|
19
|
+
defaultRenderLoading,
|
|
20
|
+
useWebWiewLogic,
|
|
21
|
+
versionPasses,
|
|
22
|
+
} from './WebViewShared';
|
|
23
|
+
import {
|
|
24
|
+
AndroidWebViewProps,
|
|
25
|
+
NativeWebViewAndroid,
|
|
26
|
+
} from './WebViewTypes';
|
|
27
|
+
|
|
28
|
+
import styles from './WebView.styles';
|
|
29
|
+
|
|
30
|
+
const { getWebViewDefaultUserAgent } = NativeModules.RNCWebViewUtils;
|
|
31
|
+
|
|
32
|
+
let userAgentPromise: Promise<string> | undefined
|
|
33
|
+
|
|
34
|
+
async function getUserAgent(): Promise<string> {
|
|
35
|
+
if (!userAgentPromise) userAgentPromise = getWebViewDefaultUserAgent()
|
|
36
|
+
const userAgent = await userAgentPromise
|
|
37
|
+
return userAgent || 'unknown'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const codegenNativeCommands = codegenNativeCommandsUntyped as <T extends {}>(options: { supportedCommands: (keyof T)[] }) => T;
|
|
41
|
+
|
|
42
|
+
const Commands = codegenNativeCommands({
|
|
43
|
+
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'clearFormData', 'clearCache', 'clearHistory', 'loadUrl'],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
|
48
|
+
*/
|
|
49
|
+
let uniqueRef = 0;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Harcoded default for security.
|
|
53
|
+
*/
|
|
54
|
+
const mediaPlaybackRequiresUserAction = true;
|
|
55
|
+
// Android only
|
|
56
|
+
const setSupportMultipleWindows = true;
|
|
57
|
+
const mixedContentMode = 'never'
|
|
58
|
+
const hardMinimumChromeVersion = '100.0' // TODO: determinime a good lower bound
|
|
59
|
+
|
|
60
|
+
const WebViewComponent = forwardRef<{}, AndroidWebViewProps>(({
|
|
61
|
+
overScrollMode = 'always',
|
|
62
|
+
javaScriptEnabled = true,
|
|
63
|
+
thirdPartyCookiesEnabled = true,
|
|
64
|
+
scalesPageToFit = true,
|
|
65
|
+
saveFormDataDisabled = false,
|
|
66
|
+
cacheEnabled = true,
|
|
67
|
+
androidHardwareAccelerationDisabled = false,
|
|
68
|
+
androidLayerType = "none",
|
|
69
|
+
originWhitelist = defaultOriginWhitelist,
|
|
70
|
+
setBuiltInZoomControls = true,
|
|
71
|
+
setDisplayZoomControls = false,
|
|
72
|
+
nestedScrollEnabled = false,
|
|
73
|
+
startInLoadingState,
|
|
74
|
+
onLoadStart,
|
|
75
|
+
onError,
|
|
76
|
+
onLoad,
|
|
77
|
+
onLoadEnd,
|
|
78
|
+
onMessage: onMessageProp,
|
|
79
|
+
renderLoading,
|
|
80
|
+
renderError,
|
|
81
|
+
style,
|
|
82
|
+
containerStyle,
|
|
83
|
+
source,
|
|
84
|
+
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
85
|
+
validateMeta,
|
|
86
|
+
validateData,
|
|
87
|
+
minimumChromeVersion,
|
|
88
|
+
unsupportedVersionComponent: UnsupportedVersionComponent,
|
|
89
|
+
...otherProps
|
|
90
|
+
}, ref) => {
|
|
91
|
+
const messagingModuleName = useRef<string>(`WebViewMessageHandler${uniqueRef += 1}`).current;
|
|
92
|
+
const webViewRef = useRef<NativeWebViewAndroid | null>(null);
|
|
93
|
+
|
|
94
|
+
const onShouldStartLoadWithRequestCallback = useCallback((shouldStart: boolean,
|
|
95
|
+
url: string,
|
|
96
|
+
lockIdentifier?: number) => {
|
|
97
|
+
if (lockIdentifier) {
|
|
98
|
+
NativeModules.RNCWebView.onShouldStartLoadWithRequestCallback(shouldStart, lockIdentifier);
|
|
99
|
+
} else if (shouldStart) {
|
|
100
|
+
Commands.loadUrl(webViewRef.current, url);
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onLoadingError, onLoadingFinish, onLoadingProgress, passesWhitelist } = useWebWiewLogic({
|
|
105
|
+
onLoad,
|
|
106
|
+
onError,
|
|
107
|
+
onLoadEnd,
|
|
108
|
+
onLoadStart,
|
|
109
|
+
onMessageProp,
|
|
110
|
+
startInLoadingState,
|
|
111
|
+
originWhitelist,
|
|
112
|
+
onShouldStartLoadWithRequestProp,
|
|
113
|
+
onShouldStartLoadWithRequestCallback,
|
|
114
|
+
validateMeta,
|
|
115
|
+
validateData,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
useImperativeHandle(ref, () => ({
|
|
119
|
+
goForward: () => Commands.goForward(webViewRef.current),
|
|
120
|
+
goBack: () => Commands.goBack(webViewRef.current),
|
|
121
|
+
reload: () => {
|
|
122
|
+
setViewState(
|
|
123
|
+
'LOADING',
|
|
124
|
+
); Commands.reload(webViewRef.current)
|
|
125
|
+
},
|
|
126
|
+
stopLoading: () => Commands.stopLoading(webViewRef.current),
|
|
127
|
+
postMessage: (data: string) => Commands.postMessage(webViewRef.current, data),
|
|
128
|
+
// injectJavaScript: (data: string) => Commands.injectJavaScript(webViewRef.current, data),
|
|
129
|
+
requestFocus: () => Commands.requestFocus(webViewRef.current),
|
|
130
|
+
clearFormData: () => Commands.clearFormData(webViewRef.current),
|
|
131
|
+
clearCache: (includeDiskFiles: boolean) => Commands.clearCache(webViewRef.current, includeDiskFiles),
|
|
132
|
+
clearHistory: () => Commands.clearHistory(webViewRef.current),
|
|
133
|
+
}), [setViewState, webViewRef]);
|
|
134
|
+
|
|
135
|
+
const directEventCallbacks = useMemo(() => ({
|
|
136
|
+
onShouldStartLoadWithRequest,
|
|
137
|
+
onMessage,
|
|
138
|
+
}), [onMessage, onShouldStartLoadWithRequest]);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
BatchedBridge.registerCallableModule(messagingModuleName, directEventCallbacks);
|
|
142
|
+
}, [messagingModuleName, directEventCallbacks])
|
|
143
|
+
|
|
144
|
+
const [userAgent, setUserAgent] = useState<string>()
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
getUserAgent().then(setUserAgent)
|
|
148
|
+
}, [])
|
|
149
|
+
|
|
150
|
+
if (!userAgent) return null // stop the rendering until userAgent is known
|
|
151
|
+
const version = userAgent.match(/chrome\/((?:[0-9]+\.)+[0-9]+)/i)?.[1]
|
|
152
|
+
if (!(versionPasses(version, minimumChromeVersion) && versionPasses(version, hardMinimumChromeVersion))) {
|
|
153
|
+
if (UnsupportedVersionComponent) {
|
|
154
|
+
return <UnsupportedVersionComponent />
|
|
155
|
+
}
|
|
156
|
+
return (
|
|
157
|
+
<View style={{ alignSelf: 'flex-start' }}>
|
|
158
|
+
<Text style={{ color: 'red' }}>
|
|
159
|
+
Chrome version is outdated and insecure. Update it to continue.
|
|
160
|
+
</Text>
|
|
161
|
+
</View>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let otherView = null;
|
|
166
|
+
if (viewState === 'LOADING') {
|
|
167
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
168
|
+
} else if (viewState === 'ERROR') {
|
|
169
|
+
invariant(lastErrorEvent != null, 'lastErrorEvent expected to be non-null');
|
|
170
|
+
otherView = (renderError || defaultRenderError)(
|
|
171
|
+
lastErrorEvent.domain,
|
|
172
|
+
lastErrorEvent.code,
|
|
173
|
+
lastErrorEvent.description,
|
|
174
|
+
);
|
|
175
|
+
} else if (viewState !== 'IDLE') {
|
|
176
|
+
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
180
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
181
|
+
|
|
182
|
+
if (typeof source !== "number" && source && 'method' in source) {
|
|
183
|
+
if (source.method === 'POST' && source.headers) {
|
|
184
|
+
console.warn(
|
|
185
|
+
'WebView: `source.headers` is not supported when using POST.',
|
|
186
|
+
);
|
|
187
|
+
} else if (source.method === 'GET' && source.body) {
|
|
188
|
+
console.warn('WebView: `source.body` is not supported when using GET.');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (typeof source === "object" && 'uri' in source && !passesWhitelist(source.uri)){
|
|
193
|
+
// eslint-disable-next-line
|
|
194
|
+
source = {uri: "about:blank"};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const NativeWebView = RNCWebView;
|
|
198
|
+
|
|
199
|
+
const webView = <NativeWebView
|
|
200
|
+
key="webViewKey"
|
|
201
|
+
{...otherProps}
|
|
202
|
+
messagingEnabled={typeof onMessageProp === 'function'}
|
|
203
|
+
messagingModuleName={messagingModuleName}
|
|
204
|
+
|
|
205
|
+
onLoadingError={onLoadingError}
|
|
206
|
+
onLoadingFinish={onLoadingFinish}
|
|
207
|
+
onLoadingProgress={onLoadingProgress}
|
|
208
|
+
onLoadingStart={onLoadingStart}
|
|
209
|
+
onMessage={onMessage}
|
|
210
|
+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
211
|
+
|
|
212
|
+
ref={webViewRef}
|
|
213
|
+
// TODO: find a better way to type this.
|
|
214
|
+
source={source}
|
|
215
|
+
style={webViewStyles}
|
|
216
|
+
overScrollMode={overScrollMode}
|
|
217
|
+
javaScriptEnabled={javaScriptEnabled}
|
|
218
|
+
thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
|
|
219
|
+
scalesPageToFit={scalesPageToFit}
|
|
220
|
+
saveFormDataDisabled={saveFormDataDisabled}
|
|
221
|
+
cacheEnabled={cacheEnabled}
|
|
222
|
+
androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled}
|
|
223
|
+
androidLayerType={androidLayerType}
|
|
224
|
+
setSupportMultipleWindows={setSupportMultipleWindows}
|
|
225
|
+
setBuiltInZoomControls={setBuiltInZoomControls}
|
|
226
|
+
setDisplayZoomControls={setDisplayZoomControls}
|
|
227
|
+
mixedContentMode={mixedContentMode}
|
|
228
|
+
nestedScrollEnabled={nestedScrollEnabled}
|
|
229
|
+
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
230
|
+
/>
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<View style={webViewContainerStyle}>
|
|
234
|
+
{webView}
|
|
235
|
+
{otherView}
|
|
236
|
+
</View>
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// native implementation should return "true" only for Android 5+
|
|
241
|
+
const isFileUploadSupported: () => Promise<boolean>
|
|
242
|
+
= NativeModules.RNCWebView.isFileUploadSupported();
|
|
243
|
+
|
|
244
|
+
const WebView = Object.assign(WebViewComponent, {isFileUploadSupported});
|
|
245
|
+
|
|
246
|
+
export default WebView;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
NativeModules,
|
|
6
|
+
Platform,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import invariant from 'invariant';
|
|
9
|
+
|
|
10
|
+
// @ts-expect-error react-native doesn't have this type
|
|
11
|
+
import codegenNativeCommandsUntyped from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
12
|
+
import RNCWebView from "./WebViewNativeComponent.ios";
|
|
13
|
+
import {
|
|
14
|
+
defaultOriginWhitelist,
|
|
15
|
+
defaultRenderError,
|
|
16
|
+
defaultRenderLoading,
|
|
17
|
+
useWebWiewLogic,
|
|
18
|
+
versionPasses,
|
|
19
|
+
} from './WebViewShared';
|
|
20
|
+
import {
|
|
21
|
+
IOSWebViewProps,
|
|
22
|
+
DecelerationRateConstant,
|
|
23
|
+
NativeWebViewIOS,
|
|
24
|
+
ViewManager,
|
|
25
|
+
} from './WebViewTypes';
|
|
26
|
+
|
|
27
|
+
import styles from './WebView.styles';
|
|
28
|
+
|
|
29
|
+
const codegenNativeCommands = codegenNativeCommandsUntyped as <T extends {}>(options: { supportedCommands: (keyof T)[] }) => T;
|
|
30
|
+
|
|
31
|
+
const Commands = codegenNativeCommands({
|
|
32
|
+
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'loadUrl'],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const processDecelerationRate = (
|
|
36
|
+
decelerationRate: DecelerationRateConstant | number | undefined,
|
|
37
|
+
) => {
|
|
38
|
+
let newDecelerationRate = decelerationRate;
|
|
39
|
+
if (newDecelerationRate === 'normal') {
|
|
40
|
+
newDecelerationRate = 0.998;
|
|
41
|
+
} else if (newDecelerationRate === 'fast') {
|
|
42
|
+
newDecelerationRate = 0.99;
|
|
43
|
+
}
|
|
44
|
+
return newDecelerationRate;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const RNCWebViewManager = NativeModules.RNCWebViewManager as ViewManager;
|
|
48
|
+
|
|
49
|
+
const useWarnIfChanges = <T extends unknown>(value: T, name: string) => {
|
|
50
|
+
const ref = useRef(value);
|
|
51
|
+
if (ref.current !== value) {
|
|
52
|
+
console.warn(`Changes to property ${name} do nothing after the initial render.`);
|
|
53
|
+
ref.current = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Harcoded defaults for security.
|
|
59
|
+
*/
|
|
60
|
+
const mediaPlaybackRequiresUserAction = true;
|
|
61
|
+
// iOS only configs
|
|
62
|
+
const allowsInlineMediaPlayback = true;
|
|
63
|
+
const useSharedProcessPool = false;
|
|
64
|
+
const sharedCookiesEnabled = false;
|
|
65
|
+
const enableApplePay = false;
|
|
66
|
+
const dataDetectorTypes = 'none';
|
|
67
|
+
const hardMinimumIOSVersion = '12.5.6 <13, 13.6.1 <14, 14.8.1 <15, 15.7.1'
|
|
68
|
+
|
|
69
|
+
const WebViewComponent = forwardRef<{}, IOSWebViewProps>(({
|
|
70
|
+
javaScriptEnabled = true,
|
|
71
|
+
cacheEnabled = true,
|
|
72
|
+
originWhitelist = defaultOriginWhitelist,
|
|
73
|
+
textInteractionEnabled= true,
|
|
74
|
+
injectedJavaScript,
|
|
75
|
+
injectedJavaScriptBeforeContentLoaded,
|
|
76
|
+
startInLoadingState,
|
|
77
|
+
onLoadStart,
|
|
78
|
+
onError,
|
|
79
|
+
onLoad,
|
|
80
|
+
onLoadEnd,
|
|
81
|
+
onMessage: onMessageProp,
|
|
82
|
+
renderLoading,
|
|
83
|
+
renderError,
|
|
84
|
+
style,
|
|
85
|
+
containerStyle,
|
|
86
|
+
source,
|
|
87
|
+
incognito,
|
|
88
|
+
validateMeta,
|
|
89
|
+
validateData,
|
|
90
|
+
decelerationRate: decelerationRateProp,
|
|
91
|
+
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
92
|
+
minimumIOSVersion,
|
|
93
|
+
unsupportedVersionComponent: UnsupportedVersionComponent,
|
|
94
|
+
...otherProps
|
|
95
|
+
}, ref) => {
|
|
96
|
+
const webViewRef = useRef<NativeWebViewIOS | null>(null);
|
|
97
|
+
|
|
98
|
+
const onShouldStartLoadWithRequestCallback = useCallback((
|
|
99
|
+
shouldStart: boolean,
|
|
100
|
+
_url: string,
|
|
101
|
+
lockIdentifier = 0,
|
|
102
|
+
) => {
|
|
103
|
+
const viewManager = RNCWebViewManager;
|
|
104
|
+
|
|
105
|
+
viewManager.startLoadWithResult(!!shouldStart, lockIdentifier);
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onLoadingError, onLoadingFinish, onLoadingProgress } = useWebWiewLogic({
|
|
109
|
+
onLoad,
|
|
110
|
+
onError,
|
|
111
|
+
onLoadEnd,
|
|
112
|
+
onLoadStart,
|
|
113
|
+
onMessageProp,
|
|
114
|
+
startInLoadingState,
|
|
115
|
+
originWhitelist,
|
|
116
|
+
onShouldStartLoadWithRequestProp,
|
|
117
|
+
onShouldStartLoadWithRequestCallback,
|
|
118
|
+
validateMeta,
|
|
119
|
+
validateData,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
useImperativeHandle(ref, () => ({
|
|
123
|
+
goForward: () => Commands.goForward(webViewRef.current),
|
|
124
|
+
goBack: () => Commands.goBack(webViewRef.current),
|
|
125
|
+
reload: () => {
|
|
126
|
+
setViewState(
|
|
127
|
+
'LOADING',
|
|
128
|
+
); Commands.reload(webViewRef.current)
|
|
129
|
+
},
|
|
130
|
+
stopLoading: () => Commands.stopLoading(webViewRef.current),
|
|
131
|
+
postMessage: (data: string) => Commands.postMessage(webViewRef.current, data),
|
|
132
|
+
// injectJavaScript: (data: string) => Commands.injectJavaScript(webViewRef.current, data),
|
|
133
|
+
requestFocus: () => Commands.requestFocus(webViewRef.current),
|
|
134
|
+
}), [setViewState, webViewRef]);
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
useWarnIfChanges(allowsInlineMediaPlayback, 'allowsInlineMediaPlayback');
|
|
138
|
+
useWarnIfChanges(incognito, 'incognito');
|
|
139
|
+
useWarnIfChanges(mediaPlaybackRequiresUserAction, 'mediaPlaybackRequiresUserAction');
|
|
140
|
+
useWarnIfChanges(dataDetectorTypes, 'dataDetectorTypes');
|
|
141
|
+
|
|
142
|
+
const version = String(Platform.Version)
|
|
143
|
+
if (!(versionPasses(version, minimumIOSVersion) && versionPasses(version, hardMinimumIOSVersion))) {
|
|
144
|
+
if (UnsupportedVersionComponent) {
|
|
145
|
+
return <UnsupportedVersionComponent />
|
|
146
|
+
}
|
|
147
|
+
return (
|
|
148
|
+
<View style={{ alignSelf: 'flex-start' }}>
|
|
149
|
+
<Text style={{ color: 'red' }}>
|
|
150
|
+
iOS version is outdated and insecure. Update it to continue.
|
|
151
|
+
</Text>
|
|
152
|
+
</View>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let otherView = null;
|
|
157
|
+
if (viewState === 'LOADING') {
|
|
158
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
159
|
+
} else if (viewState === 'ERROR') {
|
|
160
|
+
invariant(lastErrorEvent != null, 'lastErrorEvent expected to be non-null');
|
|
161
|
+
otherView = (renderError || defaultRenderError)(
|
|
162
|
+
lastErrorEvent.domain,
|
|
163
|
+
lastErrorEvent.code,
|
|
164
|
+
lastErrorEvent.description,
|
|
165
|
+
);
|
|
166
|
+
} else if (viewState !== 'IDLE') {
|
|
167
|
+
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
171
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
172
|
+
|
|
173
|
+
const decelerationRate = processDecelerationRate(decelerationRateProp);
|
|
174
|
+
|
|
175
|
+
const NativeWebView = RNCWebView;
|
|
176
|
+
|
|
177
|
+
const webView = (
|
|
178
|
+
<NativeWebView
|
|
179
|
+
key="webViewKey"
|
|
180
|
+
{...otherProps}
|
|
181
|
+
enableApplePay={enableApplePay}
|
|
182
|
+
javaScriptEnabled={javaScriptEnabled}
|
|
183
|
+
cacheEnabled={cacheEnabled}
|
|
184
|
+
dataDetectorTypes={dataDetectorTypes}
|
|
185
|
+
useSharedProcessPool={useSharedProcessPool}
|
|
186
|
+
textInteractionEnabled={textInteractionEnabled}
|
|
187
|
+
decelerationRate={decelerationRate}
|
|
188
|
+
messagingEnabled={typeof onMessageProp === 'function'}
|
|
189
|
+
onLoadingError={onLoadingError}
|
|
190
|
+
onLoadingFinish={onLoadingFinish}
|
|
191
|
+
onLoadingProgress={onLoadingProgress}
|
|
192
|
+
onLoadingStart={onLoadingStart}
|
|
193
|
+
onMessage={onMessage}
|
|
194
|
+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
195
|
+
injectedJavaScript={injectedJavaScript}
|
|
196
|
+
injectedJavaScriptBeforeContentLoaded={injectedJavaScriptBeforeContentLoaded}
|
|
197
|
+
allowsInlineMediaPlayback={allowsInlineMediaPlayback}
|
|
198
|
+
incognito={incognito}
|
|
199
|
+
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
200
|
+
ref={webViewRef}
|
|
201
|
+
sharedCookiesEnabled={sharedCookiesEnabled}
|
|
202
|
+
// TODO: find a better way to type this.
|
|
203
|
+
source={source}
|
|
204
|
+
style={webViewStyles}
|
|
205
|
+
/>
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<View style={webViewContainerStyle}>
|
|
210
|
+
{webView}
|
|
211
|
+
{otherView}
|
|
212
|
+
</View>
|
|
213
|
+
);})
|
|
214
|
+
|
|
215
|
+
// no native implementation for iOS, depends only on permissions
|
|
216
|
+
const isFileUploadSupported: () => Promise<boolean>
|
|
217
|
+
= async () => true;
|
|
218
|
+
|
|
219
|
+
const WebView = Object.assign(WebViewComponent, {isFileUploadSupported});
|
|
220
|
+
|
|
221
|
+
export default WebView;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { StyleSheet, ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface Styles {
|
|
4
|
+
container: ViewStyle;
|
|
5
|
+
errorText: TextStyle;
|
|
6
|
+
errorTextTitle: TextStyle;
|
|
7
|
+
loadingOrErrorView: ViewStyle;
|
|
8
|
+
webView: ViewStyle;
|
|
9
|
+
loadingProgressBar: ViewStyle;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const styles = StyleSheet.create<Styles>({
|
|
13
|
+
container: {
|
|
14
|
+
flex: 1,
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
},
|
|
17
|
+
loadingOrErrorView: {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
flex: 1,
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
height: '100%',
|
|
23
|
+
width: '100%',
|
|
24
|
+
backgroundColor: 'white'
|
|
25
|
+
},
|
|
26
|
+
loadingProgressBar: {
|
|
27
|
+
height: 20,
|
|
28
|
+
},
|
|
29
|
+
errorText: {
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
textAlign: 'center',
|
|
32
|
+
marginBottom: 2,
|
|
33
|
+
},
|
|
34
|
+
errorTextTitle: {
|
|
35
|
+
fontSize: 15,
|
|
36
|
+
fontWeight: '500',
|
|
37
|
+
marginBottom: 10,
|
|
38
|
+
},
|
|
39
|
+
webView: {
|
|
40
|
+
backgroundColor: '#ffffff',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default styles;
|
package/src/WebView.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { IOSWebViewProps, AndroidWebViewProps } from './WebViewTypes';
|
|
4
|
+
|
|
5
|
+
export type WebViewProps = IOSWebViewProps & AndroidWebViewProps;
|
|
6
|
+
|
|
7
|
+
// This "dummy" WebView is to render something for unsupported platforms,
|
|
8
|
+
// like for example Expo SDK "web" platform.
|
|
9
|
+
const WebView: React.FunctionComponent<WebViewProps> = () => (
|
|
10
|
+
<View style={{ alignSelf: 'flex-start' }}>
|
|
11
|
+
<Text style={{ color: 'red' }}>
|
|
12
|
+
React Native WebView does not support this platform.
|
|
13
|
+
</Text>
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export { WebView };
|
|
18
|
+
export default WebView;
|