@exodus/react-native-webview 13.16.0-exodus.3 → 13.16.0-exodus.4
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/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 -8
- package/apple/RNCWebViewDecisionManager.m +17 -0
- package/apple/RNCWebViewImpl.h +0 -10
- package/apple/RNCWebViewImpl.m +24 -72
- package/apple/RNCWebViewManager.mm +0 -8
- 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/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 +4 -11
- 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/src/__tests__/WebViewShared-test.js +40 -62
- package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +0 -1
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +0 -25
- 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/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');
|