react-native-webview-bootpay 13.8.41 → 13.13.4-4.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.
Files changed (101) hide show
  1. package/README.md +53 -69
  2. package/android/build.gradle +1 -11
  3. package/android/gradle.properties +5 -47
  4. package/android/src/main/AndroidManifest.xml +9 -5
  5. package/android/src/main/AndroidManifestNew.xml +97 -0
  6. package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +57 -11
  7. package/android/src/main/java/kr/co/bootpay/webview/BPCWebView.java +101 -68
  8. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +70 -56
  9. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewManagerImpl.kt +119 -65
  10. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewMessagingModule.kt +9 -0
  11. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewModuleImpl.java +1 -1
  12. package/android/src/main/java/kr/co/bootpay/webview/BootpayUrlHelper.java +91 -75
  13. package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewManager.java +118 -109
  14. package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewModule.java +1 -1
  15. package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewManager.java +63 -58
  16. package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewModule.java +1 -1
  17. package/apple/BPCWebView.mm +21 -12
  18. package/apple/BPCWebViewImpl.h +10 -0
  19. package/apple/BPCWebViewImpl.m +267 -205
  20. package/apple/BPCWebViewManager.mm +5 -24
  21. package/apple/BPCWebViewModule.h +23 -0
  22. package/apple/BPCWebViewModule.mm +34 -0
  23. package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
  24. package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
  25. package/index.d.ts +54 -48
  26. package/ios/RNCWebView.xcodeproj/project.pbxproj +24 -24
  27. package/ios/RNCWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  28. package/ios/RNCWebView.xcodeproj/project.xcworkspace/xcuserdata/taesupyoon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  29. package/ios/RNCWebView.xcodeproj/xcuserdata/taesupyoon.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  30. package/lib/BPCWebViewNativeComponent.d.ts +24 -25
  31. package/lib/BPCWebViewNativeComponent.js +1 -1
  32. package/lib/{NativeBPCWebView.d.ts → NativeBPCWebViewModule.d.ts} +2 -5
  33. package/lib/{NativeBPCWebView.js → NativeBPCWebViewModule.js} +1 -1
  34. package/lib/WebView.android.d.ts +0 -1
  35. package/lib/WebView.android.js +1 -1
  36. package/lib/WebView.d.ts +0 -1
  37. package/lib/WebView.ios.d.ts +0 -1
  38. package/lib/WebView.ios.js +1 -1
  39. package/lib/WebView.js +1 -1
  40. package/lib/WebView.macos.d.ts +0 -1
  41. package/lib/WebView.macos.js +1 -1
  42. package/lib/WebView.styles.d.ts +37 -11
  43. package/lib/WebView.styles.js +1 -1
  44. package/lib/WebView.windows.d.ts +0 -1
  45. package/lib/WebView.windows.js +1 -1
  46. package/lib/WebViewNativeComponent.macos.d.ts +1 -2
  47. package/lib/WebViewNativeComponent.windows.d.ts +1 -2
  48. package/lib/WebViewShared.d.ts +0 -1
  49. package/lib/WebViewShared.js +1 -1
  50. package/lib/WebViewTypes.d.ts +51 -3
  51. package/lib/WebViewTypes.js +1 -1
  52. package/lib/index.d.ts +0 -1
  53. package/macos/RNCWebView.xcodeproj/project.pbxproj +36 -36
  54. package/package.json +12 -11
  55. package/react-native-webview-bootpay.podspec +2 -2
  56. package/react-native.config.js +1 -5
  57. package/src/BPCWebViewNativeComponent.ts +143 -79
  58. package/src/NativeBPCWebViewModule.ts +13 -0
  59. package/src/WebView.android.tsx +295 -190
  60. package/src/WebView.ios.tsx +253 -186
  61. package/src/WebView.macos.tsx +220 -152
  62. package/src/WebView.styles.ts +9 -12
  63. package/src/WebView.tsx +14 -7
  64. package/src/WebView.windows.tsx +180 -126
  65. package/src/WebViewNativeComponent.macos.ts +4 -5
  66. package/src/WebViewNativeComponent.windows.ts +6 -8
  67. package/src/WebViewShared.tsx +139 -91
  68. package/src/WebViewTypes.ts +80 -35
  69. package/src/__tests__/WebViewShared-test.js +170 -55
  70. package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +8 -17
  71. package/windows/ReactNativeWebView/ReactPackageProvider.cpp +5 -1
  72. package/windows/ReactNativeWebView/ReactWebView.cpp +73 -6
  73. package/windows/ReactNativeWebView/ReactWebView.h +11 -1
  74. package/windows/ReactNativeWebView/ReactWebView.idl +12 -3
  75. package/windows/ReactNativeWebView/ReactWebView2.cpp +294 -129
  76. package/windows/ReactNativeWebView/ReactWebView2.h +42 -5
  77. package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +60 -34
  78. package/windows/ReactNativeWebView/ReactWebView2Manager.h +4 -4
  79. package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
  80. package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
  81. package/windows/ReactNativeWebView/ReactWebViewManager.cpp +22 -3
  82. package/windows/ReactNativeWebView/ReactWebViewManager.h +6 -1
  83. package/windows/ReactNativeWebView/pch.h +11 -7
  84. package/windows/ReactNativeWebView.sln +14 -14
  85. package/ios/main.jsbundle +0 -457
  86. package/lib/BPCWebViewNativeComponent.d.ts.map +0 -1
  87. package/lib/NativeBPCWebView.d.ts.map +0 -1
  88. package/lib/WebView.android.d.ts.map +0 -1
  89. package/lib/WebView.d.ts.map +0 -1
  90. package/lib/WebView.ios.d.ts.map +0 -1
  91. package/lib/WebView.macos.d.ts.map +0 -1
  92. package/lib/WebView.styles.d.ts.map +0 -1
  93. package/lib/WebView.windows.d.ts.map +0 -1
  94. package/lib/WebViewNativeComponent.macos.d.ts.map +0 -1
  95. package/lib/WebViewNativeComponent.windows.d.ts.map +0 -1
  96. package/lib/WebViewShared.d.ts.map +0 -1
  97. package/lib/WebViewTypes.d.ts.map +0 -1
  98. package/lib/index.d.ts.map +0 -1
  99. package/src/NativeBPCWebView.ts +0 -14
  100. package/windows/ReactNativeWebView/packages.config +0 -5
  101. /package/android/src/main/java/kr/co/bootpay/webview/{BPCWebviewWrapper.kt → BPCWebViewWrapper.kt} +0 -0
@@ -1,18 +1,21 @@
1
- import React, { forwardRef, ReactElement, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from '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 "./BPCWebViewNativeComponent";
15
- import BPCWebViewModule from "./NativeBPCWebView";
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, WebViewSourceUri,
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
- overScrollMode = 'always',
37
- javaScriptEnabled = true,
38
- thirdPartyCookiesEnabled = true,
39
- scalesPageToFit = true,
40
- allowsFullscreenVideo = false,
41
- allowFileAccess = false,
42
- saveFormDataDisabled = false,
43
- cacheEnabled = true,
44
- androidLayerType = "none",
45
- originWhitelist = defaultOriginWhitelist,
46
- setSupportMultipleWindows = true,
47
- setBuiltInZoomControls = true,
48
- setDisplayZoomControls = false,
49
- nestedScrollEnabled = false,
50
- startInLoadingState,
51
- onNavigationStateChange,
52
- onLoadStart,
53
- onError,
54
- onLoad,
55
- onLoadEnd,
56
- onLoadProgress,
57
- onHttpError: onHttpErrorProp,
58
- onRenderProcessGone: onRenderProcessGoneProp,
59
- onMessage: onMessageProp,
60
- onOpenWindow: onOpenWindowProp,
61
- renderLoading,
62
- renderError,
63
- style,
64
- containerStyle,
65
- source,
66
- nativeConfig,
67
- onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
68
- injectedJavaScriptObject,
69
- ...otherProps
70
- }, ref) => {
71
- const messagingModuleName = useRef<string>(`WebViewMessageHandler${uniqueRef += 1}`).current;
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
- stopLoading: () => webViewRef.current && Commands.stopLoading(webViewRef.current),
113
- postMessage: (data: string) => webViewRef.current && Commands.postMessage(webViewRef.current, data),
114
- injectJavaScript: (data: string) => webViewRef.current && Commands.injectJavaScript(webViewRef.current, data),
115
- requestFocus: () => webViewRef.current && Commands.requestFocus(webViewRef.current),
116
- clearFormData: () => webViewRef.current && Commands.clearFormData(webViewRef.current),
117
- clearCache: (includeDiskFiles: boolean) => webViewRef.current && Commands.clearCache(webViewRef.current, includeDiskFiles),
118
- clearHistory: () => webViewRef.current && Commands.clearHistory(webViewRef.current),
119
- }), [setViewState, webViewRef]);
120
-
121
- const directEventCallbacks = useMemo(() => ({
122
- onShouldStartLoadWithRequest,
123
- onMessage,
124
- }), [onMessage, onShouldStartLoadWithRequest]);
125
-
126
- useEffect(() => {
127
- BatchedBridge.registerCallableModule(messagingModuleName, directEventCallbacks);
128
- }, [messagingModuleName, directEventCallbacks])
129
-
130
- let otherView: ReactElement | undefined;
131
- if (viewState === 'LOADING') {
132
- otherView = (renderLoading || defaultRenderLoading)();
133
- } else if (viewState === 'ERROR') {
134
- invariant(lastErrorEvent != null, 'lastErrorEvent expected to be non-null');
135
- if (lastErrorEvent) {
136
- otherView = (renderError || defaultRenderError)(
137
- lastErrorEvent.domain,
138
- lastErrorEvent.code,
139
- lastErrorEvent.description,
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
- const webViewStyles = [styles.container, styles.webView, style];
147
- const webViewContainerStyle = [styles.container, containerStyle];
214
+ return () => {
215
+ onShouldStartLoadWithRequestSubscription.remove();
216
+ onMessageSubscription.remove();
217
+ };
218
+ }, [messagingModuleName, onMessage, onShouldStartLoadWithRequest]);
148
219
 
149
- if (typeof source !== "number" && source && 'method' in source) {
150
- if (source.method === 'POST' && source.headers) {
151
- console.warn(
152
- 'WebView: `source.headers` is not supported when using POST.',
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
- } else if (source.method === 'GET' && source.body) {
155
- console.warn('WebView: `source.body` is not supported when using GET.');
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
- const NativeWebView
160
- = (nativeConfig?.component as (typeof BPCWebView | undefined)) || BPCWebView;
161
-
162
- const sourceResolved = resolveAssetSource(source as ImageSourcePropType)
163
- const newSource = typeof sourceResolved === "object" ? Object.entries(sourceResolved as WebViewSourceUri).reduce((prev, [currKey, currValue]) => {
164
- return {
165
- ...prev,
166
- [currKey]: currKey === "headers" && currValue && typeof currValue === "object" ? Object.entries(currValue).map(
167
- ([key, value]) => {
168
- return {
169
- name: key,
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
- }, {}) : sourceResolved
175
-
176
- const webView = <NativeWebView
177
- key="webViewKey"
178
- {...otherProps}
179
- messagingEnabled={typeof onMessageProp === 'function'}
180
- messagingModuleName={messagingModuleName}
181
-
182
- hasOnScroll={!!otherProps.onScroll}
183
- onLoadingError={onLoadingError}
184
- onLoadingFinish={onLoadingFinish}
185
- onLoadingProgress={onLoadingProgress}
186
- onLoadingStart={onLoadingStart}
187
- onHttpError={onHttpError}
188
- onRenderProcessGone={onRenderProcessGone}
189
- onMessage={onMessage}
190
- onOpenWindow={onOpenWindow}
191
- hasOnOpenWindowEvent={onOpenWindowProp !== undefined}
192
- onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
193
- ref={webViewRef}
194
- // TODO: find a better way to type this.
195
- // @ts-expect-error source is old arch
196
- source={sourceResolved}
197
- newSource={newSource}
198
- style={webViewStyles}
199
- overScrollMode={overScrollMode}
200
- javaScriptEnabled={javaScriptEnabled}
201
- thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
202
- scalesPageToFit={scalesPageToFit}
203
- allowsFullscreenVideo={allowsFullscreenVideo}
204
- allowFileAccess={allowFileAccess}
205
- saveFormDataDisabled={saveFormDataDisabled}
206
- cacheEnabled={cacheEnabled}
207
- androidLayerType={androidLayerType}
208
- setSupportMultipleWindows={setSupportMultipleWindows}
209
- setBuiltInZoomControls={setBuiltInZoomControls}
210
- setDisplayZoomControls={setDisplayZoomControls}
211
- nestedScrollEnabled={nestedScrollEnabled}
212
- injectedJavaScriptObject={JSON.stringify(injectedJavaScriptObject)}
213
- {...nativeConfig?.props}
214
- />
215
-
216
- return (
217
- <View style={webViewContainerStyle}>
218
- {webView}
219
- {otherView}
220
- </View>
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;