@exodus/react-native-webview 13.16.0-exodus.3 → 13.16.0-exodus.5
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/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +15 -18
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java +0 -7
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java +0 -21
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +5 -50
- package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java +0 -58
- package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java +0 -40
- package/apple/RNCWebView.mm +0 -39
- package/apple/RNCWebViewDecisionManager.m +17 -0
- package/apple/RNCWebViewImpl.h +0 -10
- package/apple/RNCWebViewImpl.m +24 -72
- package/apple/RNCWebViewManager.mm +0 -11
- package/lib/RNCWebViewNativeComponent.d.ts +0 -26
- package/lib/RNCWebViewNativeComponent.js +1 -1
- package/lib/WebView.android.js +1 -1
- package/lib/WebView.d.ts +2 -2
- package/lib/WebView.ios.js +1 -1
- package/lib/WebView.js +1 -1
- package/lib/WebViewShared.d.ts +5 -5
- package/lib/WebViewShared.js +1 -1
- package/lib/WebViewTypes.d.ts +5 -358
- package/lib/WebViewTypes.js +1 -1
- package/package.json +6 -12
- package/react-native-webview.podspec +1 -1
- package/src/RNCWebViewNativeComponent.ts +0 -37
- package/src/WebView.android.tsx +293 -284
- package/src/WebView.ios.tsx +223 -256
- package/src/WebView.tsx +2 -8
- package/src/WebViewShared.tsx +2 -11
- package/src/WebViewTypes.ts +2 -396
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +0 -25
- package/lib/WebView.macos.d.ts +0 -6
- package/lib/WebView.macos.js +0 -1
- package/lib/WebView.windows.d.ts +0 -17
- package/lib/WebView.windows.js +0 -1
- package/lib/WebViewNativeComponent.windows.d.ts +0 -3
- package/lib/WebViewNativeComponent.windows.js +0 -1
- package/src/WebView.macos.tsx +0 -252
- package/src/WebView.windows.tsx +0 -217
- package/src/WebViewNativeComponent.macos.ts +0 -7
- package/src/WebViewNativeComponent.windows.ts +0 -8
- package/src/__tests__/WebViewShared-test.js +0 -323
- package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +0 -8
- package/src/__tests__/validation-test.js +0 -38
package/src/WebView.macos.tsx
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useCallback,
|
|
4
|
-
useImperativeHandle,
|
|
5
|
-
useRef,
|
|
6
|
-
} from 'react';
|
|
7
|
-
import { Image, View, ImageSourcePropType, HostComponent } from 'react-native';
|
|
8
|
-
import invariant from 'invariant';
|
|
9
|
-
import RNCWebView, { Commands, NativeProps } from './RNCWebViewNativeComponent';
|
|
10
|
-
import RNCWebViewModule from './NativeRNCWebViewModule';
|
|
11
|
-
import {
|
|
12
|
-
defaultOriginWhitelist,
|
|
13
|
-
defaultDeeplinkWhitelist,
|
|
14
|
-
defaultRenderError,
|
|
15
|
-
defaultRenderLoading,
|
|
16
|
-
useWebViewLogic,
|
|
17
|
-
} from './WebViewShared';
|
|
18
|
-
import { MacOSWebViewProps, WebViewSourceUri } from './WebViewTypes';
|
|
19
|
-
|
|
20
|
-
import styles from './WebView.styles';
|
|
21
|
-
|
|
22
|
-
const { resolveAssetSource } = Image;
|
|
23
|
-
|
|
24
|
-
const useWarnIfChanges = <T extends unknown>(value: T, name: string) => {
|
|
25
|
-
const ref = useRef(value);
|
|
26
|
-
if (ref.current !== value) {
|
|
27
|
-
console.warn(
|
|
28
|
-
`Changes to property ${name} do nothing after the initial render.`
|
|
29
|
-
);
|
|
30
|
-
ref.current = value;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const WebViewComponent = forwardRef<{}, MacOSWebViewProps>(
|
|
35
|
-
(
|
|
36
|
-
{
|
|
37
|
-
javaScriptEnabled = true,
|
|
38
|
-
cacheEnabled = true,
|
|
39
|
-
originWhitelist = defaultOriginWhitelist,
|
|
40
|
-
deeplinkWhitelist = defaultDeeplinkWhitelist,
|
|
41
|
-
useSharedProcessPool = true,
|
|
42
|
-
injectedJavaScript,
|
|
43
|
-
injectedJavaScriptBeforeContentLoaded,
|
|
44
|
-
startInLoadingState,
|
|
45
|
-
onNavigationStateChange,
|
|
46
|
-
onLoadStart,
|
|
47
|
-
onError,
|
|
48
|
-
onLoad,
|
|
49
|
-
onLoadEnd,
|
|
50
|
-
onLoadProgress,
|
|
51
|
-
onHttpError: onHttpErrorProp,
|
|
52
|
-
onMessage: onMessageProp,
|
|
53
|
-
renderLoading,
|
|
54
|
-
renderError,
|
|
55
|
-
style,
|
|
56
|
-
containerStyle,
|
|
57
|
-
source,
|
|
58
|
-
nativeConfig,
|
|
59
|
-
allowsInlineMediaPlayback,
|
|
60
|
-
allowsPictureInPictureMediaPlayback = true,
|
|
61
|
-
allowsAirPlayForMediaPlayback,
|
|
62
|
-
mediaPlaybackRequiresUserAction,
|
|
63
|
-
incognito,
|
|
64
|
-
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
65
|
-
validateMeta,
|
|
66
|
-
validateData,
|
|
67
|
-
...otherProps
|
|
68
|
-
},
|
|
69
|
-
ref
|
|
70
|
-
) => {
|
|
71
|
-
const webViewRef = useRef<React.ComponentRef<
|
|
72
|
-
HostComponent<NativeProps>
|
|
73
|
-
> | null>(null);
|
|
74
|
-
|
|
75
|
-
const onShouldStartLoadWithRequestCallback = useCallback(
|
|
76
|
-
(shouldStart: boolean, _url: string, lockIdentifier = 0) => {
|
|
77
|
-
RNCWebViewModule.shouldStartLoadWithLockIdentifier(
|
|
78
|
-
!!shouldStart,
|
|
79
|
-
lockIdentifier
|
|
80
|
-
);
|
|
81
|
-
},
|
|
82
|
-
[]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const {
|
|
86
|
-
onLoadingStart,
|
|
87
|
-
onShouldStartLoadWithRequest,
|
|
88
|
-
onMessage,
|
|
89
|
-
viewState,
|
|
90
|
-
setViewState,
|
|
91
|
-
lastErrorEvent,
|
|
92
|
-
onHttpError,
|
|
93
|
-
onLoadingError,
|
|
94
|
-
onLoadingFinish,
|
|
95
|
-
onLoadingProgress,
|
|
96
|
-
onContentProcessDidTerminate,
|
|
97
|
-
} = useWebViewLogic({
|
|
98
|
-
onNavigationStateChange,
|
|
99
|
-
onLoad,
|
|
100
|
-
onError,
|
|
101
|
-
onHttpErrorProp,
|
|
102
|
-
onLoadEnd,
|
|
103
|
-
onLoadProgress,
|
|
104
|
-
onLoadStart,
|
|
105
|
-
onMessageProp,
|
|
106
|
-
startInLoadingState,
|
|
107
|
-
originWhitelist,
|
|
108
|
-
deeplinkWhitelist,
|
|
109
|
-
onShouldStartLoadWithRequestProp,
|
|
110
|
-
onShouldStartLoadWithRequestCallback,
|
|
111
|
-
validateMeta,
|
|
112
|
-
validateData,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
useImperativeHandle(
|
|
116
|
-
ref,
|
|
117
|
-
() => ({
|
|
118
|
-
goForward: () =>
|
|
119
|
-
webViewRef.current && Commands.goForward(webViewRef.current),
|
|
120
|
-
goBack: () => webViewRef.current && Commands.goBack(webViewRef.current),
|
|
121
|
-
reload: () => {
|
|
122
|
-
setViewState('LOADING');
|
|
123
|
-
if (webViewRef.current) {
|
|
124
|
-
Commands.reload(webViewRef.current);
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
stopLoading: () =>
|
|
128
|
-
webViewRef.current && Commands.stopLoading(webViewRef.current),
|
|
129
|
-
postMessage: (data: string) =>
|
|
130
|
-
webViewRef.current && Commands.postMessage(webViewRef.current, data),
|
|
131
|
-
injectJavaScript: (data: string) =>
|
|
132
|
-
webViewRef.current &&
|
|
133
|
-
Commands.injectJavaScript(webViewRef.current, data),
|
|
134
|
-
requestFocus: () =>
|
|
135
|
-
webViewRef.current && Commands.requestFocus(webViewRef.current),
|
|
136
|
-
}),
|
|
137
|
-
[setViewState, webViewRef]
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
useWarnIfChanges(allowsInlineMediaPlayback, 'allowsInlineMediaPlayback');
|
|
141
|
-
useWarnIfChanges(
|
|
142
|
-
allowsPictureInPictureMediaPlayback,
|
|
143
|
-
'allowsPictureInPictureMediaPlayback'
|
|
144
|
-
);
|
|
145
|
-
useWarnIfChanges(
|
|
146
|
-
allowsAirPlayForMediaPlayback,
|
|
147
|
-
'allowsAirPlayForMediaPlayback'
|
|
148
|
-
);
|
|
149
|
-
useWarnIfChanges(incognito, 'incognito');
|
|
150
|
-
useWarnIfChanges(
|
|
151
|
-
mediaPlaybackRequiresUserAction,
|
|
152
|
-
'mediaPlaybackRequiresUserAction'
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
let otherView = null;
|
|
156
|
-
if (viewState === 'LOADING') {
|
|
157
|
-
otherView = (renderLoading || defaultRenderLoading)();
|
|
158
|
-
} else if (viewState === 'ERROR') {
|
|
159
|
-
invariant(
|
|
160
|
-
lastErrorEvent != null,
|
|
161
|
-
'lastErrorEvent expected to be non-null'
|
|
162
|
-
);
|
|
163
|
-
otherView = (renderError || defaultRenderError)(
|
|
164
|
-
lastErrorEvent?.domain,
|
|
165
|
-
lastErrorEvent?.code || 0,
|
|
166
|
-
lastErrorEvent?.description ?? ''
|
|
167
|
-
);
|
|
168
|
-
} else if (viewState !== 'IDLE') {
|
|
169
|
-
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const webViewStyles = [styles.container, styles.webView, style];
|
|
173
|
-
const webViewContainerStyle = [styles.container, containerStyle];
|
|
174
|
-
|
|
175
|
-
const NativeWebView =
|
|
176
|
-
(nativeConfig?.component as typeof RNCWebView | undefined) || RNCWebView;
|
|
177
|
-
|
|
178
|
-
const sourceResolved = resolveAssetSource(source as ImageSourcePropType);
|
|
179
|
-
const newSource =
|
|
180
|
-
typeof sourceResolved === 'object'
|
|
181
|
-
? Object.entries(sourceResolved as WebViewSourceUri).reduce(
|
|
182
|
-
(prev, [currKey, currValue]) => {
|
|
183
|
-
return {
|
|
184
|
-
...prev,
|
|
185
|
-
[currKey]:
|
|
186
|
-
currKey === 'headers' &&
|
|
187
|
-
currValue &&
|
|
188
|
-
typeof currValue === 'object'
|
|
189
|
-
? Object.entries(currValue).map(([key, value]) => {
|
|
190
|
-
return {
|
|
191
|
-
name: key,
|
|
192
|
-
value,
|
|
193
|
-
};
|
|
194
|
-
})
|
|
195
|
-
: currValue,
|
|
196
|
-
};
|
|
197
|
-
},
|
|
198
|
-
{}
|
|
199
|
-
)
|
|
200
|
-
: sourceResolved;
|
|
201
|
-
|
|
202
|
-
const webView = (
|
|
203
|
-
<NativeWebView
|
|
204
|
-
key="webViewKey"
|
|
205
|
-
{...otherProps}
|
|
206
|
-
javaScriptEnabled={javaScriptEnabled}
|
|
207
|
-
cacheEnabled={cacheEnabled}
|
|
208
|
-
useSharedProcessPool={useSharedProcessPool}
|
|
209
|
-
messagingEnabled={typeof onMessageProp === 'function'}
|
|
210
|
-
newSource={newSource}
|
|
211
|
-
onLoadingError={onLoadingError}
|
|
212
|
-
onLoadingFinish={onLoadingFinish}
|
|
213
|
-
onLoadingProgress={onLoadingProgress}
|
|
214
|
-
onLoadingStart={onLoadingStart}
|
|
215
|
-
onHttpError={onHttpError}
|
|
216
|
-
onMessage={onMessage}
|
|
217
|
-
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
218
|
-
onContentProcessDidTerminate={onContentProcessDidTerminate}
|
|
219
|
-
injectedJavaScript={injectedJavaScript}
|
|
220
|
-
injectedJavaScriptBeforeContentLoaded={
|
|
221
|
-
injectedJavaScriptBeforeContentLoaded
|
|
222
|
-
}
|
|
223
|
-
allowsAirPlayForMediaPlayback={allowsAirPlayForMediaPlayback}
|
|
224
|
-
allowsInlineMediaPlayback={allowsInlineMediaPlayback}
|
|
225
|
-
allowsPictureInPictureMediaPlayback={
|
|
226
|
-
allowsPictureInPictureMediaPlayback
|
|
227
|
-
}
|
|
228
|
-
incognito={incognito}
|
|
229
|
-
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
230
|
-
ref={webViewRef}
|
|
231
|
-
// @ts-expect-error old arch only
|
|
232
|
-
source={sourceResolved}
|
|
233
|
-
style={webViewStyles}
|
|
234
|
-
{...nativeConfig?.props}
|
|
235
|
-
/>
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<View style={webViewContainerStyle}>
|
|
240
|
-
{webView}
|
|
241
|
-
{otherView}
|
|
242
|
-
</View>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// no native implementation for macOS, depends only on permissions
|
|
248
|
-
const isFileUploadSupported: () => Promise<boolean> = async () => true;
|
|
249
|
-
|
|
250
|
-
const WebView = Object.assign(WebViewComponent, { isFileUploadSupported });
|
|
251
|
-
|
|
252
|
-
export default WebView;
|
package/src/WebView.windows.tsx
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* Portions copyright for react-native-windows:
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10
|
-
* Licensed under the MIT License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import React, {
|
|
14
|
-
forwardRef,
|
|
15
|
-
useCallback,
|
|
16
|
-
useImperativeHandle,
|
|
17
|
-
useRef,
|
|
18
|
-
} from 'react';
|
|
19
|
-
import { View, Image, ImageSourcePropType, NativeModules } from 'react-native';
|
|
20
|
-
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
21
|
-
import invariant from 'invariant';
|
|
22
|
-
import { RCTWebView, RCTWebView2 } from './WebViewNativeComponent.windows';
|
|
23
|
-
import {
|
|
24
|
-
useWebViewLogic,
|
|
25
|
-
defaultOriginWhitelist,
|
|
26
|
-
defaultDeeplinkWhitelist,
|
|
27
|
-
defaultRenderError,
|
|
28
|
-
defaultRenderLoading,
|
|
29
|
-
} from './WebViewShared';
|
|
30
|
-
import { NativeWebViewWindows, WindowsWebViewProps } from './WebViewTypes';
|
|
31
|
-
|
|
32
|
-
import styles from './WebView.styles';
|
|
33
|
-
|
|
34
|
-
const Commands = codegenNativeCommands({
|
|
35
|
-
supportedCommands: [
|
|
36
|
-
'goBack',
|
|
37
|
-
'goForward',
|
|
38
|
-
'reload',
|
|
39
|
-
'stopLoading',
|
|
40
|
-
'injectJavaScript',
|
|
41
|
-
'requestFocus',
|
|
42
|
-
'clearCache',
|
|
43
|
-
'postMessage',
|
|
44
|
-
'loadUrl',
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
const { resolveAssetSource } = Image;
|
|
48
|
-
|
|
49
|
-
const WebViewComponent = forwardRef<{}, WindowsWebViewProps>(
|
|
50
|
-
(
|
|
51
|
-
{
|
|
52
|
-
cacheEnabled = true,
|
|
53
|
-
originWhitelist = defaultOriginWhitelist,
|
|
54
|
-
deeplinkWhitelist = defaultDeeplinkWhitelist,
|
|
55
|
-
startInLoadingState,
|
|
56
|
-
onNavigationStateChange,
|
|
57
|
-
onLoadStart,
|
|
58
|
-
onError,
|
|
59
|
-
onLoad,
|
|
60
|
-
onLoadEnd,
|
|
61
|
-
onLoadProgress,
|
|
62
|
-
onOpenWindow: onOpenWindowProp,
|
|
63
|
-
onSourceChanged,
|
|
64
|
-
onHttpError: onHttpErrorProp,
|
|
65
|
-
onMessage: onMessageProp,
|
|
66
|
-
renderLoading,
|
|
67
|
-
renderError,
|
|
68
|
-
style,
|
|
69
|
-
containerStyle,
|
|
70
|
-
source,
|
|
71
|
-
nativeConfig,
|
|
72
|
-
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
73
|
-
useWebView2,
|
|
74
|
-
validateMeta,
|
|
75
|
-
validateData,
|
|
76
|
-
...otherProps
|
|
77
|
-
},
|
|
78
|
-
ref
|
|
79
|
-
) => {
|
|
80
|
-
const webViewRef = useRef<NativeWebViewWindows | null>(null);
|
|
81
|
-
|
|
82
|
-
const RCTWebViewString = useWebView2 ? 'RCTWebView2' : 'RCTWebView';
|
|
83
|
-
|
|
84
|
-
const onShouldStartLoadWithRequestCallback = useCallback(
|
|
85
|
-
(shouldStart: boolean, url: string, lockIdentifier?: number) => {
|
|
86
|
-
if (lockIdentifier) {
|
|
87
|
-
if (RCTWebViewString === 'RCTWebView') {
|
|
88
|
-
NativeModules.RCTWebView.onShouldStartLoadWithRequestCallback(
|
|
89
|
-
shouldStart,
|
|
90
|
-
lockIdentifier
|
|
91
|
-
);
|
|
92
|
-
} else {
|
|
93
|
-
NativeModules.RCTWebView2.onShouldStartLoadWithRequestCallback(
|
|
94
|
-
shouldStart,
|
|
95
|
-
lockIdentifier
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
} else if (shouldStart) {
|
|
99
|
-
Commands.loadUrl(webViewRef, url);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
[RCTWebViewString]
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const {
|
|
106
|
-
onLoadingStart,
|
|
107
|
-
onShouldStartLoadWithRequest,
|
|
108
|
-
onMessage,
|
|
109
|
-
viewState,
|
|
110
|
-
setViewState,
|
|
111
|
-
lastErrorEvent,
|
|
112
|
-
onHttpError,
|
|
113
|
-
onLoadingError,
|
|
114
|
-
onLoadingFinish,
|
|
115
|
-
onLoadingProgress,
|
|
116
|
-
onOpenWindow,
|
|
117
|
-
} = useWebViewLogic({
|
|
118
|
-
onNavigationStateChange,
|
|
119
|
-
onLoad,
|
|
120
|
-
onError,
|
|
121
|
-
onHttpErrorProp,
|
|
122
|
-
onLoadEnd,
|
|
123
|
-
onLoadProgress,
|
|
124
|
-
onLoadStart,
|
|
125
|
-
onMessageProp,
|
|
126
|
-
startInLoadingState,
|
|
127
|
-
originWhitelist,
|
|
128
|
-
deeplinkWhitelist,
|
|
129
|
-
onShouldStartLoadWithRequestProp,
|
|
130
|
-
onShouldStartLoadWithRequestCallback,
|
|
131
|
-
onOpenWindowProp,
|
|
132
|
-
validateMeta,
|
|
133
|
-
validateData,
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
useImperativeHandle(
|
|
137
|
-
ref,
|
|
138
|
-
() => ({
|
|
139
|
-
goForward: () => Commands.goForward(webViewRef.current),
|
|
140
|
-
goBack: () => Commands.goBack(webViewRef.current),
|
|
141
|
-
reload: () => {
|
|
142
|
-
setViewState('LOADING');
|
|
143
|
-
Commands.reload(webViewRef.current);
|
|
144
|
-
},
|
|
145
|
-
stopLoading: () => Commands.stopLoading(webViewRef.current),
|
|
146
|
-
postMessage: (data: string) =>
|
|
147
|
-
Commands.postMessage(webViewRef.current, data),
|
|
148
|
-
injectJavaScript: (data: string) =>
|
|
149
|
-
Commands.injectJavaScript(webViewRef.current, data),
|
|
150
|
-
requestFocus: () => Commands.requestFocus(webViewRef.current),
|
|
151
|
-
clearCache: () => Commands.clearCache(webViewRef.current),
|
|
152
|
-
loadUrl: (url: string) => Commands.loadUrl(webViewRef.current, url),
|
|
153
|
-
}),
|
|
154
|
-
[setViewState, webViewRef]
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
let otherView = null;
|
|
158
|
-
if (viewState === 'LOADING') {
|
|
159
|
-
otherView = (renderLoading || defaultRenderLoading)();
|
|
160
|
-
} else if (viewState === 'ERROR') {
|
|
161
|
-
invariant(
|
|
162
|
-
lastErrorEvent != null,
|
|
163
|
-
'lastErrorEvent expected to be non-null'
|
|
164
|
-
);
|
|
165
|
-
otherView = (renderError || defaultRenderError)(
|
|
166
|
-
lastErrorEvent.domain,
|
|
167
|
-
lastErrorEvent.code,
|
|
168
|
-
lastErrorEvent.description
|
|
169
|
-
);
|
|
170
|
-
} else if (viewState !== 'IDLE') {
|
|
171
|
-
console.error(`RNCWebView invalid state encountered: ${viewState}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const webViewStyles = [styles.container, styles.webView, style];
|
|
175
|
-
const webViewContainerStyle = [styles.container, containerStyle];
|
|
176
|
-
|
|
177
|
-
const NativeWebView = useWebView2 ? RCTWebView2 : RCTWebView;
|
|
178
|
-
|
|
179
|
-
const webView = (
|
|
180
|
-
<NativeWebView
|
|
181
|
-
key="webViewKey"
|
|
182
|
-
{...otherProps}
|
|
183
|
-
messagingEnabled={typeof onMessageProp === 'function'}
|
|
184
|
-
linkHandlingEnabled={typeof onOpenWindowProp === 'function'}
|
|
185
|
-
onLoadingError={onLoadingError}
|
|
186
|
-
onLoadingFinish={onLoadingFinish}
|
|
187
|
-
onLoadingProgress={onLoadingProgress}
|
|
188
|
-
onLoadingStart={onLoadingStart}
|
|
189
|
-
onHttpError={onHttpError}
|
|
190
|
-
onMessage={onMessage}
|
|
191
|
-
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
192
|
-
onOpenWindow={onOpenWindow}
|
|
193
|
-
onSourceChanged={onSourceChanged}
|
|
194
|
-
ref={webViewRef}
|
|
195
|
-
// TODO: find a better way to type this.
|
|
196
|
-
source={resolveAssetSource(source as ImageSourcePropType)}
|
|
197
|
-
style={webViewStyles}
|
|
198
|
-
cacheEnabled={cacheEnabled}
|
|
199
|
-
{...nativeConfig?.props}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<View style={webViewContainerStyle}>
|
|
205
|
-
{webView}
|
|
206
|
-
{otherView}
|
|
207
|
-
</View>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
// native implementation should return "true" only for Android 5+
|
|
213
|
-
const isFileUploadSupported: () => Promise<boolean> = async () => false;
|
|
214
|
-
|
|
215
|
-
const WebView = Object.assign(WebViewComponent, { isFileUploadSupported });
|
|
216
|
-
|
|
217
|
-
export default WebView;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { requireNativeComponent } from 'react-native';
|
|
2
|
-
import type { NativeWebViewWindows } from './WebViewTypes';
|
|
3
|
-
|
|
4
|
-
export const RCTWebView: typeof NativeWebViewWindows =
|
|
5
|
-
requireNativeComponent('RCTWebView');
|
|
6
|
-
|
|
7
|
-
export const RCTWebView2: typeof NativeWebViewWindows =
|
|
8
|
-
requireNativeComponent('RCTWebView2');
|