@exodus/react-native-webview 11.26.1-exodus.26 → 11.26.1-exodus.28
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/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +1 -0
- package/apple/RNCWebView.m +10 -2
- 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/.gradle/7.3.3/checksums/checksums.lock +0 -0
- package/example/android/.gradle/7.3.3/checksums/md5-checksums.bin +0 -0
- package/example/android/.gradle/7.3.3/checksums/sha1-checksums.bin +0 -0
- package/example/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/example/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
- package/example/android/.gradle/7.3.3/executionHistory/executionHistory.lock +0 -0
- package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
- package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
- package/example/android/.gradle/7.3.3/gc.properties +0 -0
- package/example/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/example/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/example/android/.gradle/vcs-1/gc.properties +0 -0
- package/example/android/app/build/intermediates/cxx/abi_configuration_1a4zb4f4.json +14 -0
- package/example/android/app/build/intermediates/cxx/abi_configuration_1a4zb4f4.log +1 -0
- package/example/android/app/build/intermediates/cxx/abi_configuration_1a4zb4f4_key.json +18 -0
- package/example/android/app/build/intermediates/cxx/create_cxx_tasks_21_timing.txt +62 -0
- package/example/android/app/build/intermediates/cxx/ndk_locator_record_5i2h5t59.json +11 -0
- package/example/android/app/build/intermediates/cxx/ndk_locator_record_5i2h5t59.log +128 -0
- package/example/android/app/build/intermediates/cxx/ndk_locator_record_5i2h5t59_key.json +7 -0
- package/example/android/app/build/intermediates/cxx/ndk_locator_record_6n5y632q.json +11 -0
- package/example/android/app/build/intermediates/cxx/ndk_locator_record_6n5y632q.log +72 -0
- package/example/android/app/build/intermediates/cxx/ndk_locator_record_6n5y632q_key.json +8 -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 +1 -1
- package/lib/WebViewShared.d.ts.map +1 -0
- package/lib/WebViewShared.js +1 -3
- 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 +2 -2
- package/src/WebView.android.tsx +255 -0
- package/src/WebView.ios.tsx +227 -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 +318 -0
- package/src/WebViewTypes.ts +941 -0
- package/src/__tests__/WebViewShared-test.js +292 -0
- package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +13 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +24 -0
- package/yarn.lock +13397 -0
|
@@ -0,0 +1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AK,EAAE,kBAAkB,KAAK,kBAAkB,CAAC;IAEhE;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEvC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IAEH,2BAA2B,CAAC,EAAE,WAAW,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
|
package/metro.config.js
ADDED
|
@@ -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.28",
|
|
13
13
|
"homepage": "https://github.com/ExodusMovement/react-native-webview#readme",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"android": "react-native run-android",
|
|
@@ -80,4 +80,4 @@
|
|
|
80
80
|
"react-native.config.js",
|
|
81
81
|
"!**/*.map"
|
|
82
82
|
]
|
|
83
|
-
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
defaultDeeplinkWhitelist,
|
|
19
|
+
defaultRenderError,
|
|
20
|
+
defaultRenderLoading,
|
|
21
|
+
useWebWiewLogic,
|
|
22
|
+
versionPasses,
|
|
23
|
+
} from './WebViewShared';
|
|
24
|
+
import {
|
|
25
|
+
AndroidWebViewProps,
|
|
26
|
+
NativeWebViewAndroid,
|
|
27
|
+
} from './WebViewTypes';
|
|
28
|
+
|
|
29
|
+
import styles from './WebView.styles';
|
|
30
|
+
|
|
31
|
+
const { getWebViewDefaultUserAgent } = NativeModules.RNCWebViewUtils;
|
|
32
|
+
|
|
33
|
+
let userAgentPromise: Promise<string> | undefined
|
|
34
|
+
|
|
35
|
+
async function getUserAgent(): Promise<string> {
|
|
36
|
+
if (!userAgentPromise) userAgentPromise = getWebViewDefaultUserAgent()
|
|
37
|
+
const userAgent = await userAgentPromise
|
|
38
|
+
return userAgent || 'unknown'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const codegenNativeCommands = codegenNativeCommandsUntyped as <T extends {}>(options: { supportedCommands: (keyof T)[] }) => T;
|
|
42
|
+
|
|
43
|
+
const Commands = codegenNativeCommands({
|
|
44
|
+
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'clearFormData', 'clearCache', 'clearHistory', 'loadUrl'],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
|
49
|
+
*/
|
|
50
|
+
let uniqueRef = 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Harcoded default for security.
|
|
54
|
+
*/
|
|
55
|
+
const mediaPlaybackRequiresUserAction = true;
|
|
56
|
+
// Android only
|
|
57
|
+
const setSupportMultipleWindows = true;
|
|
58
|
+
const mixedContentMode = 'never'
|
|
59
|
+
const hardMinimumChromeVersion = '100.0' // TODO: determinime a good lower bound
|
|
60
|
+
|
|
61
|
+
const WebViewComponent = forwardRef<{}, AndroidWebViewProps>(({
|
|
62
|
+
overScrollMode = 'always',
|
|
63
|
+
javaScriptEnabled = true,
|
|
64
|
+
thirdPartyCookiesEnabled = true,
|
|
65
|
+
scalesPageToFit = true,
|
|
66
|
+
saveFormDataDisabled = false,
|
|
67
|
+
cacheEnabled = true,
|
|
68
|
+
androidHardwareAccelerationDisabled = false,
|
|
69
|
+
androidLayerType = "none",
|
|
70
|
+
originWhitelist = defaultOriginWhitelist,
|
|
71
|
+
deeplinkWhitelist = defaultDeeplinkWhitelist,
|
|
72
|
+
setBuiltInZoomControls = true,
|
|
73
|
+
setDisplayZoomControls = false,
|
|
74
|
+
nestedScrollEnabled = false,
|
|
75
|
+
startInLoadingState,
|
|
76
|
+
onLoadStart,
|
|
77
|
+
onError,
|
|
78
|
+
onLoad,
|
|
79
|
+
onLoadEnd,
|
|
80
|
+
onMessage: onMessageProp,
|
|
81
|
+
onOpenWindow: onOpenWindowProp,
|
|
82
|
+
renderLoading,
|
|
83
|
+
renderError,
|
|
84
|
+
style,
|
|
85
|
+
containerStyle,
|
|
86
|
+
source,
|
|
87
|
+
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
88
|
+
validateMeta,
|
|
89
|
+
validateData,
|
|
90
|
+
minimumChromeVersion,
|
|
91
|
+
unsupportedVersionComponent: UnsupportedVersionComponent,
|
|
92
|
+
...otherProps
|
|
93
|
+
}, ref) => {
|
|
94
|
+
const messagingModuleName = useRef<string>(`WebViewMessageHandler${uniqueRef += 1}`).current;
|
|
95
|
+
const webViewRef = useRef<NativeWebViewAndroid | null>(null);
|
|
96
|
+
|
|
97
|
+
const onShouldStartLoadWithRequestCallback = useCallback((shouldStart: boolean,
|
|
98
|
+
url: string,
|
|
99
|
+
lockIdentifier?: number) => {
|
|
100
|
+
if (lockIdentifier) {
|
|
101
|
+
NativeModules.RNCWebView.onShouldStartLoadWithRequestCallback(shouldStart, lockIdentifier);
|
|
102
|
+
} else if (shouldStart) {
|
|
103
|
+
Commands.loadUrl(webViewRef.current, url);
|
|
104
|
+
}
|
|
105
|
+
}, []);
|
|
106
|
+
|
|
107
|
+
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onLoadingError, onLoadingFinish, onLoadingProgress, onOpenWindow, passesWhitelist } = useWebWiewLogic({
|
|
108
|
+
onLoad,
|
|
109
|
+
onError,
|
|
110
|
+
onLoadEnd,
|
|
111
|
+
onLoadStart,
|
|
112
|
+
onMessageProp,
|
|
113
|
+
onOpenWindowProp,
|
|
114
|
+
startInLoadingState,
|
|
115
|
+
originWhitelist,
|
|
116
|
+
deeplinkWhitelist,
|
|
117
|
+
onShouldStartLoadWithRequestProp,
|
|
118
|
+
onShouldStartLoadWithRequestCallback,
|
|
119
|
+
validateMeta,
|
|
120
|
+
validateData,
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
useImperativeHandle(ref, () => ({
|
|
124
|
+
goForward: () => webViewRef.current && Commands.goForward(webViewRef.current),
|
|
125
|
+
goBack: () => webViewRef.current && Commands.goBack(webViewRef.current),
|
|
126
|
+
reload: () => {
|
|
127
|
+
setViewState(
|
|
128
|
+
'LOADING',
|
|
129
|
+
);
|
|
130
|
+
if (webViewRef.current) {
|
|
131
|
+
Commands.reload(webViewRef.current)
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
stopLoading: () => webViewRef.current && Commands.stopLoading(webViewRef.current),
|
|
135
|
+
postMessage: (data: string) => webViewRef.current && Commands.postMessage(webViewRef.current, data),
|
|
136
|
+
// injectJavaScript: (data: string) => Commands.injectJavaScript(webViewRef.current, data),
|
|
137
|
+
requestFocus: () => webViewRef.current && Commands.requestFocus(webViewRef.current),
|
|
138
|
+
clearFormData: () => webViewRef.current && Commands.clearFormData(webViewRef.current),
|
|
139
|
+
clearCache: (includeDiskFiles: boolean) => webViewRef.current && Commands.clearCache(webViewRef.current, includeDiskFiles),
|
|
140
|
+
clearHistory: () => webViewRef.current && Commands.clearHistory(webViewRef.current),
|
|
141
|
+
}), [setViewState, webViewRef]);
|
|
142
|
+
|
|
143
|
+
const directEventCallbacks = useMemo(() => ({
|
|
144
|
+
onShouldStartLoadWithRequest,
|
|
145
|
+
onMessage,
|
|
146
|
+
}), [onMessage, onShouldStartLoadWithRequest]);
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
BatchedBridge.registerCallableModule(messagingModuleName, directEventCallbacks);
|
|
150
|
+
}, [messagingModuleName, directEventCallbacks])
|
|
151
|
+
|
|
152
|
+
const [userAgent, setUserAgent] = useState<string>()
|
|
153
|
+
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
getUserAgent().then(setUserAgent)
|
|
156
|
+
}, [])
|
|
157
|
+
|
|
158
|
+
if (!userAgent) return null // stop the rendering until userAgent is known
|
|
159
|
+
const version = userAgent.match(/chrome\/((?:[0-9]+\.)+[0-9]+)/i)?.[1]
|
|
160
|
+
if (!(versionPasses(version, minimumChromeVersion) && versionPasses(version, hardMinimumChromeVersion))) {
|
|
161
|
+
if (UnsupportedVersionComponent) {
|
|
162
|
+
return <UnsupportedVersionComponent />
|
|
163
|
+
}
|
|
164
|
+
return (
|
|
165
|
+
<View style={{ alignSelf: 'flex-start' }}>
|
|
166
|
+
<Text style={{ color: 'red' }}>
|
|
167
|
+
Chrome version is outdated and insecure. Update it to continue.
|
|
168
|
+
</Text>
|
|
169
|
+
</View>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let otherView = null;
|
|
174
|
+
if (viewState === 'LOADING') {
|
|
175
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
176
|
+
} else if (viewState === 'ERROR') {
|
|
177
|
+
invariant(lastErrorEvent != null, 'lastErrorEvent expected to be non-null');
|
|
178
|
+
otherView = (renderError || defaultRenderError)(
|
|
179
|
+
lastErrorEvent.domain,
|
|
180
|
+
lastErrorEvent.code,
|
|
181
|
+
lastErrorEvent.description,
|
|
182
|
+
);
|
|
183
|
+
} else if (viewState !== 'IDLE') {
|
|
184
|
+
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
188
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
189
|
+
|
|
190
|
+
if (typeof source !== "number" && source && 'method' in source) {
|
|
191
|
+
if (source.method === 'POST' && source.headers) {
|
|
192
|
+
console.warn(
|
|
193
|
+
'WebView: `source.headers` is not supported when using POST.',
|
|
194
|
+
);
|
|
195
|
+
} else if (source.method === 'GET' && source.body) {
|
|
196
|
+
console.warn('WebView: `source.body` is not supported when using GET.');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (typeof source === "object" && 'uri' in source && !passesWhitelist(source.uri)){
|
|
201
|
+
// eslint-disable-next-line
|
|
202
|
+
source = {uri: "about:blank"};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const NativeWebView = RNCWebView;
|
|
206
|
+
|
|
207
|
+
const webView = <NativeWebView
|
|
208
|
+
key="webViewKey"
|
|
209
|
+
{...otherProps}
|
|
210
|
+
messagingEnabled={typeof onMessageProp === 'function'}
|
|
211
|
+
messagingModuleName={messagingModuleName}
|
|
212
|
+
|
|
213
|
+
onLoadingError={onLoadingError}
|
|
214
|
+
onLoadingFinish={onLoadingFinish}
|
|
215
|
+
onLoadingProgress={onLoadingProgress}
|
|
216
|
+
onLoadingStart={onLoadingStart}
|
|
217
|
+
onMessage={onMessage}
|
|
218
|
+
onOpenWindow={onOpenWindow}
|
|
219
|
+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
220
|
+
|
|
221
|
+
ref={webViewRef}
|
|
222
|
+
// TODO: find a better way to type this.
|
|
223
|
+
source={source}
|
|
224
|
+
style={webViewStyles}
|
|
225
|
+
overScrollMode={overScrollMode}
|
|
226
|
+
javaScriptEnabled={javaScriptEnabled}
|
|
227
|
+
thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
|
|
228
|
+
scalesPageToFit={scalesPageToFit}
|
|
229
|
+
saveFormDataDisabled={saveFormDataDisabled}
|
|
230
|
+
cacheEnabled={cacheEnabled}
|
|
231
|
+
androidHardwareAccelerationDisabled={androidHardwareAccelerationDisabled}
|
|
232
|
+
androidLayerType={androidLayerType}
|
|
233
|
+
setSupportMultipleWindows={setSupportMultipleWindows}
|
|
234
|
+
setBuiltInZoomControls={setBuiltInZoomControls}
|
|
235
|
+
setDisplayZoomControls={setDisplayZoomControls}
|
|
236
|
+
mixedContentMode={mixedContentMode}
|
|
237
|
+
nestedScrollEnabled={nestedScrollEnabled}
|
|
238
|
+
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
239
|
+
/>
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<View style={webViewContainerStyle}>
|
|
243
|
+
{webView}
|
|
244
|
+
{otherView}
|
|
245
|
+
</View>
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// native implementation should return "true" only for Android 5+
|
|
250
|
+
const isFileUploadSupported: () => Promise<boolean>
|
|
251
|
+
= NativeModules.RNCWebView.isFileUploadSupported();
|
|
252
|
+
|
|
253
|
+
const WebView = Object.assign(WebViewComponent, {isFileUploadSupported});
|
|
254
|
+
|
|
255
|
+
export default WebView;
|
|
@@ -0,0 +1,227 @@
|
|
|
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
|
+
defaultDeeplinkWhitelist,
|
|
16
|
+
defaultRenderError,
|
|
17
|
+
defaultRenderLoading,
|
|
18
|
+
useWebWiewLogic,
|
|
19
|
+
versionPasses,
|
|
20
|
+
} from './WebViewShared';
|
|
21
|
+
import {
|
|
22
|
+
IOSWebViewProps,
|
|
23
|
+
DecelerationRateConstant,
|
|
24
|
+
NativeWebViewIOS,
|
|
25
|
+
ViewManager,
|
|
26
|
+
} from './WebViewTypes';
|
|
27
|
+
|
|
28
|
+
import styles from './WebView.styles';
|
|
29
|
+
|
|
30
|
+
const codegenNativeCommands = codegenNativeCommandsUntyped as <T extends {}>(options: { supportedCommands: (keyof T)[] }) => T;
|
|
31
|
+
|
|
32
|
+
const Commands = codegenNativeCommands({
|
|
33
|
+
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', /* 'injectJavaScript', */ 'requestFocus', 'postMessage', 'loadUrl'],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const processDecelerationRate = (
|
|
37
|
+
decelerationRate: DecelerationRateConstant | number | undefined,
|
|
38
|
+
) => {
|
|
39
|
+
let newDecelerationRate = decelerationRate;
|
|
40
|
+
if (newDecelerationRate === 'normal') {
|
|
41
|
+
newDecelerationRate = 0.998;
|
|
42
|
+
} else if (newDecelerationRate === 'fast') {
|
|
43
|
+
newDecelerationRate = 0.99;
|
|
44
|
+
}
|
|
45
|
+
return newDecelerationRate;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const RNCWebViewManager = NativeModules.RNCWebViewManager as ViewManager;
|
|
49
|
+
|
|
50
|
+
const useWarnIfChanges = <T extends unknown>(value: T, name: string) => {
|
|
51
|
+
const ref = useRef(value);
|
|
52
|
+
if (ref.current !== value) {
|
|
53
|
+
console.warn(`Changes to property ${name} do nothing after the initial render.`);
|
|
54
|
+
ref.current = value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Harcoded defaults for security.
|
|
60
|
+
*/
|
|
61
|
+
const mediaPlaybackRequiresUserAction = true;
|
|
62
|
+
// iOS only configs
|
|
63
|
+
const allowsInlineMediaPlayback = true;
|
|
64
|
+
const useSharedProcessPool = false;
|
|
65
|
+
const sharedCookiesEnabled = false;
|
|
66
|
+
const enableApplePay = false;
|
|
67
|
+
const dataDetectorTypes = 'none';
|
|
68
|
+
const hardMinimumIOSVersion = '12.5.6 <13, 13.6.1 <14, 14.8.1 <15, 15.7.1'
|
|
69
|
+
|
|
70
|
+
const WebViewComponent = forwardRef<{}, IOSWebViewProps>(({
|
|
71
|
+
javaScriptEnabled = true,
|
|
72
|
+
cacheEnabled = true,
|
|
73
|
+
originWhitelist = defaultOriginWhitelist,
|
|
74
|
+
deeplinkWhitelist = defaultDeeplinkWhitelist,
|
|
75
|
+
textInteractionEnabled= true,
|
|
76
|
+
injectedJavaScript,
|
|
77
|
+
injectedJavaScriptBeforeContentLoaded,
|
|
78
|
+
startInLoadingState,
|
|
79
|
+
onLoadStart,
|
|
80
|
+
onError,
|
|
81
|
+
onLoad,
|
|
82
|
+
onLoadEnd,
|
|
83
|
+
onMessage: onMessageProp,
|
|
84
|
+
renderLoading,
|
|
85
|
+
renderError,
|
|
86
|
+
style,
|
|
87
|
+
containerStyle,
|
|
88
|
+
source,
|
|
89
|
+
incognito,
|
|
90
|
+
validateMeta,
|
|
91
|
+
validateData,
|
|
92
|
+
decelerationRate: decelerationRateProp,
|
|
93
|
+
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
94
|
+
minimumIOSVersion,
|
|
95
|
+
unsupportedVersionComponent: UnsupportedVersionComponent,
|
|
96
|
+
...otherProps
|
|
97
|
+
}, ref) => {
|
|
98
|
+
const webViewRef = useRef<NativeWebViewIOS | null>(null);
|
|
99
|
+
|
|
100
|
+
const onShouldStartLoadWithRequestCallback = useCallback((
|
|
101
|
+
shouldStart: boolean,
|
|
102
|
+
_url: string,
|
|
103
|
+
lockIdentifier = 0,
|
|
104
|
+
) => {
|
|
105
|
+
const viewManager = RNCWebViewManager;
|
|
106
|
+
|
|
107
|
+
viewManager.startLoadWithResult(!!shouldStart, lockIdentifier);
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onLoadingError, onLoadingFinish, onLoadingProgress } = useWebWiewLogic({
|
|
111
|
+
onLoad,
|
|
112
|
+
onError,
|
|
113
|
+
onLoadEnd,
|
|
114
|
+
onLoadStart,
|
|
115
|
+
onMessageProp,
|
|
116
|
+
startInLoadingState,
|
|
117
|
+
originWhitelist,
|
|
118
|
+
deeplinkWhitelist,
|
|
119
|
+
onShouldStartLoadWithRequestProp,
|
|
120
|
+
onShouldStartLoadWithRequestCallback,
|
|
121
|
+
validateMeta,
|
|
122
|
+
validateData,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
useImperativeHandle(ref, () => ({
|
|
126
|
+
goForward: () => webViewRef.current && Commands.goForward(webViewRef.current),
|
|
127
|
+
goBack: () => webViewRef.current && Commands.goBack(webViewRef.current),
|
|
128
|
+
reload: () => {
|
|
129
|
+
setViewState(
|
|
130
|
+
'LOADING',
|
|
131
|
+
);
|
|
132
|
+
if (webViewRef.current) {
|
|
133
|
+
Commands.reload(webViewRef.current)
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
stopLoading: () => webViewRef.current && Commands.stopLoading(webViewRef.current),
|
|
137
|
+
postMessage: (data: string) => webViewRef.current && Commands.postMessage(webViewRef.current, data),
|
|
138
|
+
// injectJavaScript: (data: string) => Commands.injectJavaScript(webViewRef.current, data),
|
|
139
|
+
requestFocus: () => webViewRef.current && Commands.requestFocus(webViewRef.current),
|
|
140
|
+
}), [setViewState, webViewRef]);
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
useWarnIfChanges(allowsInlineMediaPlayback, 'allowsInlineMediaPlayback');
|
|
144
|
+
useWarnIfChanges(incognito, 'incognito');
|
|
145
|
+
useWarnIfChanges(mediaPlaybackRequiresUserAction, 'mediaPlaybackRequiresUserAction');
|
|
146
|
+
useWarnIfChanges(dataDetectorTypes, 'dataDetectorTypes');
|
|
147
|
+
|
|
148
|
+
const version = String(Platform.Version)
|
|
149
|
+
if (!(versionPasses(version, minimumIOSVersion) && versionPasses(version, hardMinimumIOSVersion))) {
|
|
150
|
+
if (UnsupportedVersionComponent) {
|
|
151
|
+
return <UnsupportedVersionComponent />
|
|
152
|
+
}
|
|
153
|
+
return (
|
|
154
|
+
<View style={{ alignSelf: 'flex-start' }}>
|
|
155
|
+
<Text style={{ color: 'red' }}>
|
|
156
|
+
iOS version is outdated and insecure. Update it to continue.
|
|
157
|
+
</Text>
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let otherView = null;
|
|
163
|
+
if (viewState === 'LOADING') {
|
|
164
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
165
|
+
} else if (viewState === 'ERROR') {
|
|
166
|
+
invariant(lastErrorEvent != null, 'lastErrorEvent expected to be non-null');
|
|
167
|
+
otherView = (renderError || defaultRenderError)(
|
|
168
|
+
lastErrorEvent.domain,
|
|
169
|
+
lastErrorEvent.code,
|
|
170
|
+
lastErrorEvent.description,
|
|
171
|
+
);
|
|
172
|
+
} else if (viewState !== 'IDLE') {
|
|
173
|
+
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
177
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
178
|
+
|
|
179
|
+
const decelerationRate = processDecelerationRate(decelerationRateProp);
|
|
180
|
+
|
|
181
|
+
const NativeWebView = RNCWebView;
|
|
182
|
+
|
|
183
|
+
const webView = (
|
|
184
|
+
<NativeWebView
|
|
185
|
+
key="webViewKey"
|
|
186
|
+
{...otherProps}
|
|
187
|
+
enableApplePay={enableApplePay}
|
|
188
|
+
javaScriptEnabled={javaScriptEnabled}
|
|
189
|
+
cacheEnabled={cacheEnabled}
|
|
190
|
+
dataDetectorTypes={dataDetectorTypes}
|
|
191
|
+
useSharedProcessPool={useSharedProcessPool}
|
|
192
|
+
textInteractionEnabled={textInteractionEnabled}
|
|
193
|
+
decelerationRate={decelerationRate}
|
|
194
|
+
messagingEnabled={typeof onMessageProp === 'function'}
|
|
195
|
+
onLoadingError={onLoadingError}
|
|
196
|
+
onLoadingFinish={onLoadingFinish}
|
|
197
|
+
onLoadingProgress={onLoadingProgress}
|
|
198
|
+
onLoadingStart={onLoadingStart}
|
|
199
|
+
onMessage={onMessage}
|
|
200
|
+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
201
|
+
injectedJavaScript={injectedJavaScript}
|
|
202
|
+
injectedJavaScriptBeforeContentLoaded={injectedJavaScriptBeforeContentLoaded}
|
|
203
|
+
allowsInlineMediaPlayback={allowsInlineMediaPlayback}
|
|
204
|
+
incognito={incognito}
|
|
205
|
+
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
206
|
+
ref={webViewRef}
|
|
207
|
+
sharedCookiesEnabled={sharedCookiesEnabled}
|
|
208
|
+
// TODO: find a better way to type this.
|
|
209
|
+
source={source}
|
|
210
|
+
style={webViewStyles}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<View style={webViewContainerStyle}>
|
|
216
|
+
{webView}
|
|
217
|
+
{otherView}
|
|
218
|
+
</View>
|
|
219
|
+
);})
|
|
220
|
+
|
|
221
|
+
// no native implementation for iOS, depends only on permissions
|
|
222
|
+
const isFileUploadSupported: () => Promise<boolean>
|
|
223
|
+
= async () => true;
|
|
224
|
+
|
|
225
|
+
const WebView = Object.assign(WebViewComponent, {isFileUploadSupported});
|
|
226
|
+
|
|
227
|
+
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;
|