react-native-webview-bootpay 13.8.42 → 13.13.4-6.alpha.1
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/README.md +53 -69
- package/android/build.gradle +1 -11
- package/android/gradle.properties +0 -42
- package/android/src/main/AndroidManifest.xml +3 -1
- package/android/src/main/AndroidManifestNew.xml +97 -0
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +54 -10
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebView.java +101 -68
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +68 -60
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewManagerImpl.kt +119 -65
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewMessagingModule.kt +9 -0
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewModuleImpl.java +1 -1
- package/android/src/main/java/kr/co/bootpay/webview/BootpayUrlHelper.java +4 -12
- package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewManager.java +118 -109
- package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewModule.java +1 -1
- package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewManager.java +63 -58
- package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewModule.java +1 -1
- package/apple/BPCWebView.mm +39 -30
- package/apple/BPCWebViewImpl.h +10 -0
- package/apple/BPCWebViewImpl.m +267 -205
- package/apple/BPCWebViewManager.mm +5 -24
- package/apple/BPCWebViewModule.h +23 -0
- package/apple/BPCWebViewModule.mm +34 -0
- package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
- package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
- package/index.d.ts +54 -48
- package/ios/RNCWebView.xcodeproj/project.pbxproj +24 -24
- package/ios/RNCWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/RNCWebView.xcodeproj/project.xcworkspace/xcuserdata/taesupyoon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNCWebView.xcodeproj/xcuserdata/taesupyoon.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/BPCWebViewNativeComponent.d.ts +24 -25
- package/lib/BPCWebViewNativeComponent.js +1 -1
- package/lib/{NativeBPCWebView.d.ts → NativeBPCWebViewModule.d.ts} +2 -5
- package/lib/{NativeBPCWebView.js → NativeBPCWebViewModule.js} +1 -1
- package/lib/WebView.android.d.ts +0 -1
- package/lib/WebView.android.js +1 -1
- package/lib/WebView.d.ts +0 -1
- package/lib/WebView.ios.d.ts +0 -1
- package/lib/WebView.ios.js +1 -1
- package/lib/WebView.js +1 -1
- package/lib/WebView.macos.d.ts +0 -1
- package/lib/WebView.macos.js +1 -1
- package/lib/WebView.styles.d.ts +37 -11
- package/lib/WebView.styles.js +1 -1
- package/lib/WebView.windows.d.ts +0 -1
- package/lib/WebView.windows.js +1 -1
- package/lib/WebViewNativeComponent.macos.d.ts +1 -2
- package/lib/WebViewNativeComponent.windows.d.ts +1 -2
- package/lib/WebViewShared.d.ts +0 -1
- package/lib/WebViewShared.js +1 -1
- package/lib/WebViewTypes.d.ts +51 -3
- package/lib/WebViewTypes.js +1 -1
- package/lib/index.d.ts +0 -1
- package/macos/RNCWebView.xcodeproj/project.pbxproj +36 -36
- package/package.json +12 -11
- package/react-native-webview-bootpay.podspec +2 -2
- package/react-native.config.js +1 -5
- package/src/BPCWebViewNativeComponent.ts +143 -79
- package/src/NativeBPCWebViewModule.ts +13 -0
- package/src/WebView.android.tsx +295 -190
- package/src/WebView.ios.tsx +253 -186
- package/src/WebView.macos.tsx +220 -152
- package/src/WebView.styles.ts +9 -12
- package/src/WebView.tsx +14 -7
- package/src/WebView.windows.tsx +180 -126
- package/src/WebViewNativeComponent.macos.ts +4 -5
- package/src/WebViewNativeComponent.windows.ts +6 -8
- package/src/WebViewShared.tsx +139 -91
- package/src/WebViewTypes.ts +80 -35
- package/src/__tests__/WebViewShared-test.js +170 -55
- package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +8 -17
- package/windows/ReactNativeWebView/ReactPackageProvider.cpp +5 -1
- package/windows/ReactNativeWebView/ReactWebView.cpp +73 -6
- package/windows/ReactNativeWebView/ReactWebView.h +11 -1
- package/windows/ReactNativeWebView/ReactWebView.idl +12 -3
- package/windows/ReactNativeWebView/ReactWebView2.cpp +294 -129
- package/windows/ReactNativeWebView/ReactWebView2.h +42 -5
- package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +60 -34
- package/windows/ReactNativeWebView/ReactWebView2Manager.h +4 -4
- package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
- package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
- package/windows/ReactNativeWebView/ReactWebViewManager.cpp +22 -3
- package/windows/ReactNativeWebView/ReactWebViewManager.h +6 -1
- package/windows/ReactNativeWebView/pch.h +11 -7
- package/windows/ReactNativeWebView.sln +14 -14
- package/ios/main.jsbundle +0 -457
- package/lib/BPCWebViewNativeComponent.d.ts.map +0 -1
- package/lib/NativeBPCWebView.d.ts.map +0 -1
- package/lib/WebView.android.d.ts.map +0 -1
- package/lib/WebView.d.ts.map +0 -1
- package/lib/WebView.ios.d.ts.map +0 -1
- package/lib/WebView.macos.d.ts.map +0 -1
- package/lib/WebView.styles.d.ts.map +0 -1
- package/lib/WebView.windows.d.ts.map +0 -1
- package/lib/WebViewNativeComponent.macos.d.ts.map +0 -1
- package/lib/WebViewNativeComponent.windows.d.ts.map +0 -1
- package/lib/WebViewShared.d.ts.map +0 -1
- package/lib/WebViewTypes.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/src/NativeBPCWebView.ts +0 -14
- package/windows/ReactNativeWebView/packages.config +0 -5
- /package/android/src/main/java/kr/co/bootpay/webview/{BPCWebviewWrapper.kt → BPCWebViewWrapper.kt} +0 -0
package/src/WebView.android.tsx
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
ReactElement,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
} from 'react';
|
|
2
9
|
|
|
3
|
-
import {
|
|
4
|
-
Image,
|
|
5
|
-
View,
|
|
6
|
-
ImageSourcePropType,
|
|
7
|
-
HostComponent,
|
|
8
|
-
} from 'react-native';
|
|
10
|
+
import { Image, View, ImageSourcePropType, HostComponent } from 'react-native';
|
|
9
11
|
|
|
10
12
|
import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
|
|
13
|
+
import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
|
11
14
|
|
|
12
15
|
import invariant from 'invariant';
|
|
13
16
|
|
|
14
|
-
import BPCWebView, {Commands, NativeProps} from
|
|
15
|
-
import BPCWebViewModule from
|
|
17
|
+
import BPCWebView, { Commands, NativeProps } from './BPCWebViewNativeComponent';
|
|
18
|
+
import BPCWebViewModule from './NativeBPCWebViewModule';
|
|
16
19
|
import {
|
|
17
20
|
defaultOriginWhitelist,
|
|
18
21
|
defaultRenderError,
|
|
@@ -20,206 +23,308 @@ import {
|
|
|
20
23
|
useWebViewLogic,
|
|
21
24
|
} from './WebViewShared';
|
|
22
25
|
import {
|
|
23
|
-
AndroidWebViewProps,
|
|
26
|
+
AndroidWebViewProps,
|
|
27
|
+
WebViewSourceUri,
|
|
28
|
+
type WebViewMessageEvent,
|
|
29
|
+
type ShouldStartLoadRequestEvent,
|
|
24
30
|
} from './WebViewTypes';
|
|
25
31
|
|
|
26
32
|
import styles from './WebView.styles';
|
|
27
33
|
|
|
28
34
|
const { resolveAssetSource } = Image;
|
|
29
35
|
|
|
36
|
+
const directEventEmitter = new EventEmitter();
|
|
37
|
+
|
|
38
|
+
const registerCallableModule: (name: string, module: Object) => void =
|
|
39
|
+
// `registerCallableModule()` is available in React Native 0.74 and above.
|
|
40
|
+
// Fallback to use `BatchedBridge.registerCallableModule()` for older versions.
|
|
41
|
+
|
|
42
|
+
require('react-native').registerCallableModule ??
|
|
43
|
+
BatchedBridge.registerCallableModule.bind(BatchedBridge);
|
|
44
|
+
|
|
45
|
+
registerCallableModule('BPCWebViewMessagingModule', {
|
|
46
|
+
onShouldStartLoadWithRequest: (
|
|
47
|
+
event: ShouldStartLoadRequestEvent & { messagingModuleName?: string }
|
|
48
|
+
) => {
|
|
49
|
+
directEventEmitter.emit('onShouldStartLoadWithRequest', event);
|
|
50
|
+
},
|
|
51
|
+
onMessage: (
|
|
52
|
+
event: WebViewMessageEvent & { messagingModuleName?: string }
|
|
53
|
+
) => {
|
|
54
|
+
directEventEmitter.emit('onMessage', event);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
30
58
|
/**
|
|
31
59
|
* A simple counter to uniquely identify WebView instances. Do not use this for anything else.
|
|
32
60
|
*/
|
|
33
61
|
let uniqueRef = 0;
|
|
34
62
|
|
|
35
|
-
const WebViewComponent = forwardRef<{}, AndroidWebViewProps>(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const webViewRef = useRef<React.ComponentRef<HostComponent<NativeProps>> | null>(null);
|
|
73
|
-
|
|
74
|
-
const onShouldStartLoadWithRequestCallback = useCallback((shouldStart: boolean,
|
|
75
|
-
url: string,
|
|
76
|
-
lockIdentifier?: number) => {
|
|
77
|
-
if (lockIdentifier) {
|
|
78
|
-
BPCWebViewModule.shouldStartLoadWithLockIdentifier(shouldStart, lockIdentifier);
|
|
79
|
-
} else if (shouldStart && webViewRef.current) {
|
|
80
|
-
Commands.loadUrl(webViewRef.current, url);
|
|
81
|
-
}
|
|
82
|
-
}, []);
|
|
83
|
-
|
|
84
|
-
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onOpenWindow, onRenderProcessGone } = useWebViewLogic({
|
|
85
|
-
onNavigationStateChange,
|
|
86
|
-
onLoad,
|
|
87
|
-
onError,
|
|
88
|
-
onHttpErrorProp,
|
|
89
|
-
onLoadEnd,
|
|
90
|
-
onLoadProgress,
|
|
91
|
-
onLoadStart,
|
|
92
|
-
onRenderProcessGoneProp,
|
|
93
|
-
onMessageProp,
|
|
94
|
-
onOpenWindowProp,
|
|
95
|
-
startInLoadingState,
|
|
96
|
-
originWhitelist,
|
|
97
|
-
onShouldStartLoadWithRequestProp,
|
|
98
|
-
onShouldStartLoadWithRequestCallback,
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
useImperativeHandle(ref, () => ({
|
|
102
|
-
goForward: () => webViewRef.current && Commands.goForward(webViewRef.current),
|
|
103
|
-
goBack: () => webViewRef.current && Commands.goBack(webViewRef.current),
|
|
104
|
-
reload: () => {
|
|
105
|
-
setViewState(
|
|
106
|
-
'LOADING',
|
|
107
|
-
);
|
|
108
|
-
if (webViewRef.current) {
|
|
109
|
-
Commands.reload(webViewRef.current)
|
|
110
|
-
}
|
|
63
|
+
const WebViewComponent = forwardRef<{}, AndroidWebViewProps>(
|
|
64
|
+
(
|
|
65
|
+
{
|
|
66
|
+
overScrollMode = 'always',
|
|
67
|
+
javaScriptEnabled = true,
|
|
68
|
+
thirdPartyCookiesEnabled = true,
|
|
69
|
+
scalesPageToFit = true,
|
|
70
|
+
allowsFullscreenVideo = false,
|
|
71
|
+
allowFileAccess = false,
|
|
72
|
+
saveFormDataDisabled = false,
|
|
73
|
+
cacheEnabled = true,
|
|
74
|
+
androidLayerType = 'none',
|
|
75
|
+
originWhitelist = defaultOriginWhitelist,
|
|
76
|
+
setSupportMultipleWindows = true,
|
|
77
|
+
setBuiltInZoomControls = true,
|
|
78
|
+
setDisplayZoomControls = false,
|
|
79
|
+
nestedScrollEnabled = false,
|
|
80
|
+
startInLoadingState,
|
|
81
|
+
onNavigationStateChange,
|
|
82
|
+
onLoadStart,
|
|
83
|
+
onError,
|
|
84
|
+
onLoad,
|
|
85
|
+
onLoadEnd,
|
|
86
|
+
onLoadProgress,
|
|
87
|
+
onHttpError: onHttpErrorProp,
|
|
88
|
+
onRenderProcessGone: onRenderProcessGoneProp,
|
|
89
|
+
onMessage: onMessageProp,
|
|
90
|
+
onOpenWindow: onOpenWindowProp,
|
|
91
|
+
renderLoading,
|
|
92
|
+
renderError,
|
|
93
|
+
style,
|
|
94
|
+
containerStyle,
|
|
95
|
+
source,
|
|
96
|
+
nativeConfig,
|
|
97
|
+
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
98
|
+
injectedJavaScriptObject,
|
|
99
|
+
...otherProps
|
|
111
100
|
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
101
|
+
ref
|
|
102
|
+
) => {
|
|
103
|
+
const messagingModuleName = useRef<string>(
|
|
104
|
+
`WebViewMessageHandler${(uniqueRef += 1)}`
|
|
105
|
+
).current;
|
|
106
|
+
const webViewRef = useRef<React.ComponentRef<
|
|
107
|
+
HostComponent<NativeProps>
|
|
108
|
+
> | null>(null);
|
|
109
|
+
|
|
110
|
+
const onShouldStartLoadWithRequestCallback = useCallback(
|
|
111
|
+
(shouldStart: boolean, url: string, lockIdentifier?: number) => {
|
|
112
|
+
if (lockIdentifier) {
|
|
113
|
+
BPCWebViewModule.shouldStartLoadWithLockIdentifier(
|
|
114
|
+
shouldStart,
|
|
115
|
+
lockIdentifier
|
|
116
|
+
);
|
|
117
|
+
} else if (shouldStart && webViewRef.current) {
|
|
118
|
+
Commands.loadUrl(webViewRef.current, url);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[]
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const {
|
|
125
|
+
onLoadingStart,
|
|
126
|
+
onShouldStartLoadWithRequest,
|
|
127
|
+
onMessage,
|
|
128
|
+
viewState,
|
|
129
|
+
setViewState,
|
|
130
|
+
lastErrorEvent,
|
|
131
|
+
onHttpError,
|
|
132
|
+
onLoadingError,
|
|
133
|
+
onLoadingFinish,
|
|
134
|
+
onLoadingProgress,
|
|
135
|
+
onOpenWindow,
|
|
136
|
+
onRenderProcessGone,
|
|
137
|
+
} = useWebViewLogic({
|
|
138
|
+
onNavigationStateChange,
|
|
139
|
+
onLoad,
|
|
140
|
+
onError,
|
|
141
|
+
onHttpErrorProp,
|
|
142
|
+
onLoadEnd,
|
|
143
|
+
onLoadProgress,
|
|
144
|
+
onLoadStart,
|
|
145
|
+
onRenderProcessGoneProp,
|
|
146
|
+
onMessageProp,
|
|
147
|
+
onOpenWindowProp,
|
|
148
|
+
startInLoadingState,
|
|
149
|
+
originWhitelist,
|
|
150
|
+
onShouldStartLoadWithRequestProp,
|
|
151
|
+
onShouldStartLoadWithRequestCallback,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
useImperativeHandle(
|
|
155
|
+
ref,
|
|
156
|
+
() => ({
|
|
157
|
+
goForward: () =>
|
|
158
|
+
webViewRef.current && Commands.goForward(webViewRef.current),
|
|
159
|
+
goBack: () => webViewRef.current && Commands.goBack(webViewRef.current),
|
|
160
|
+
reload: () => {
|
|
161
|
+
setViewState('LOADING');
|
|
162
|
+
if (webViewRef.current) {
|
|
163
|
+
Commands.reload(webViewRef.current);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
stopLoading: () =>
|
|
167
|
+
webViewRef.current && Commands.stopLoading(webViewRef.current),
|
|
168
|
+
postMessage: (data: string) =>
|
|
169
|
+
webViewRef.current && Commands.postMessage(webViewRef.current, data),
|
|
170
|
+
injectJavaScript: (data: string) =>
|
|
171
|
+
webViewRef.current &&
|
|
172
|
+
Commands.injectJavaScript(webViewRef.current, data),
|
|
173
|
+
requestFocus: () =>
|
|
174
|
+
webViewRef.current && Commands.requestFocus(webViewRef.current),
|
|
175
|
+
clearFormData: () =>
|
|
176
|
+
webViewRef.current && Commands.clearFormData(webViewRef.current),
|
|
177
|
+
clearCache: (includeDiskFiles: boolean) =>
|
|
178
|
+
webViewRef.current &&
|
|
179
|
+
Commands.clearCache(webViewRef.current, includeDiskFiles),
|
|
180
|
+
clearHistory: () =>
|
|
181
|
+
webViewRef.current && Commands.clearHistory(webViewRef.current),
|
|
182
|
+
}),
|
|
183
|
+
[setViewState, webViewRef]
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
const onShouldStartLoadWithRequestSubscription =
|
|
188
|
+
directEventEmitter.addListener(
|
|
189
|
+
'onShouldStartLoadWithRequest',
|
|
190
|
+
(
|
|
191
|
+
event: ShouldStartLoadRequestEvent & {
|
|
192
|
+
messagingModuleName?: string;
|
|
193
|
+
}
|
|
194
|
+
) => {
|
|
195
|
+
if (event.messagingModuleName === messagingModuleName) {
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
197
|
+
const { messagingModuleName: _, ...rest } = event;
|
|
198
|
+
onShouldStartLoadWithRequest(rest);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const onMessageSubscription = directEventEmitter.addListener(
|
|
204
|
+
'onMessage',
|
|
205
|
+
(event: WebViewMessageEvent & { messagingModuleName?: string }) => {
|
|
206
|
+
if (event.messagingModuleName === messagingModuleName) {
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
208
|
+
const { messagingModuleName: _, ...rest } = event;
|
|
209
|
+
onMessage(rest);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
140
212
|
);
|
|
141
|
-
}
|
|
142
|
-
} else if (viewState !== 'IDLE') {
|
|
143
|
-
console.error(`BPCWebView invalid state encountered: ${viewState}`);
|
|
144
|
-
}
|
|
145
213
|
|
|
146
|
-
|
|
147
|
-
|
|
214
|
+
return () => {
|
|
215
|
+
onShouldStartLoadWithRequestSubscription.remove();
|
|
216
|
+
onMessageSubscription.remove();
|
|
217
|
+
};
|
|
218
|
+
}, [messagingModuleName, onMessage, onShouldStartLoadWithRequest]);
|
|
148
219
|
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
220
|
+
let otherView: ReactElement | undefined;
|
|
221
|
+
if (viewState === 'LOADING') {
|
|
222
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
223
|
+
} else if (viewState === 'ERROR') {
|
|
224
|
+
invariant(
|
|
225
|
+
lastErrorEvent != null,
|
|
226
|
+
'lastErrorEvent expected to be non-null'
|
|
153
227
|
);
|
|
154
|
-
|
|
155
|
-
|
|
228
|
+
if (lastErrorEvent) {
|
|
229
|
+
otherView = (renderError || defaultRenderError)(
|
|
230
|
+
lastErrorEvent.domain,
|
|
231
|
+
lastErrorEvent.code,
|
|
232
|
+
lastErrorEvent.description
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
} else if (viewState !== 'IDLE') {
|
|
236
|
+
console.error(`BPCWebView invalid state encountered: ${viewState}`);
|
|
156
237
|
}
|
|
157
|
-
}
|
|
158
238
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
value
|
|
171
|
-
}
|
|
172
|
-
}) : currValue
|
|
239
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
240
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
241
|
+
|
|
242
|
+
if (typeof source !== 'number' && source && 'method' in source) {
|
|
243
|
+
if (source.method === 'POST' && source.headers) {
|
|
244
|
+
console.warn(
|
|
245
|
+
'WebView: `source.headers` is not supported when using POST.'
|
|
246
|
+
);
|
|
247
|
+
} else if (source.method === 'GET' && source.body) {
|
|
248
|
+
console.warn('WebView: `source.body` is not supported when using GET.');
|
|
249
|
+
}
|
|
173
250
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
251
|
+
|
|
252
|
+
const NativeWebView =
|
|
253
|
+
(nativeConfig?.component as typeof BPCWebView | undefined) || BPCWebView;
|
|
254
|
+
|
|
255
|
+
const sourceResolved = resolveAssetSource(source as ImageSourcePropType);
|
|
256
|
+
const newSource =
|
|
257
|
+
typeof sourceResolved === 'object'
|
|
258
|
+
? Object.entries(sourceResolved as WebViewSourceUri).reduce(
|
|
259
|
+
(prev, [currKey, currValue]) => {
|
|
260
|
+
return {
|
|
261
|
+
...prev,
|
|
262
|
+
[currKey]:
|
|
263
|
+
currKey === 'headers' &&
|
|
264
|
+
currValue &&
|
|
265
|
+
typeof currValue === 'object'
|
|
266
|
+
? Object.entries(currValue).map(([key, value]) => {
|
|
267
|
+
return {
|
|
268
|
+
name: key,
|
|
269
|
+
value,
|
|
270
|
+
};
|
|
271
|
+
})
|
|
272
|
+
: currValue,
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
{}
|
|
276
|
+
)
|
|
277
|
+
: sourceResolved;
|
|
278
|
+
|
|
279
|
+
const webView = (
|
|
280
|
+
<NativeWebView
|
|
281
|
+
key="webViewKey"
|
|
282
|
+
{...otherProps}
|
|
283
|
+
messagingEnabled={typeof onMessageProp === 'function'}
|
|
284
|
+
messagingModuleName={messagingModuleName}
|
|
285
|
+
hasOnScroll={!!otherProps.onScroll}
|
|
286
|
+
onLoadingError={onLoadingError}
|
|
287
|
+
onLoadingFinish={onLoadingFinish}
|
|
288
|
+
onLoadingProgress={onLoadingProgress}
|
|
289
|
+
onLoadingStart={onLoadingStart}
|
|
290
|
+
onHttpError={onHttpError}
|
|
291
|
+
onRenderProcessGone={onRenderProcessGone}
|
|
292
|
+
onMessage={onMessage}
|
|
293
|
+
onOpenWindow={onOpenWindow}
|
|
294
|
+
hasOnOpenWindowEvent={onOpenWindowProp !== undefined}
|
|
295
|
+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
296
|
+
ref={webViewRef}
|
|
297
|
+
// TODO: find a better way to type this.
|
|
298
|
+
// @ts-expect-error source is old arch
|
|
299
|
+
source={sourceResolved}
|
|
300
|
+
newSource={newSource}
|
|
301
|
+
style={webViewStyles}
|
|
302
|
+
overScrollMode={overScrollMode}
|
|
303
|
+
javaScriptEnabled={javaScriptEnabled}
|
|
304
|
+
thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
|
|
305
|
+
scalesPageToFit={scalesPageToFit}
|
|
306
|
+
allowsFullscreenVideo={allowsFullscreenVideo}
|
|
307
|
+
allowFileAccess={allowFileAccess}
|
|
308
|
+
saveFormDataDisabled={saveFormDataDisabled}
|
|
309
|
+
cacheEnabled={cacheEnabled}
|
|
310
|
+
androidLayerType={androidLayerType}
|
|
311
|
+
setSupportMultipleWindows={setSupportMultipleWindows}
|
|
312
|
+
setBuiltInZoomControls={setBuiltInZoomControls}
|
|
313
|
+
setDisplayZoomControls={setDisplayZoomControls}
|
|
314
|
+
nestedScrollEnabled={nestedScrollEnabled}
|
|
315
|
+
injectedJavaScriptObject={JSON.stringify(injectedJavaScriptObject)}
|
|
316
|
+
{...nativeConfig?.props}
|
|
317
|
+
/>
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
return (
|
|
321
|
+
<View style={webViewContainerStyle}>
|
|
322
|
+
{webView}
|
|
323
|
+
{otherView}
|
|
324
|
+
</View>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
);
|
|
223
328
|
|
|
224
329
|
// native implementation should return "true" only for Android 5+
|
|
225
330
|
const { isFileUploadSupported } = BPCWebViewModule;
|