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.
- package/README.md +53 -69
- package/android/build.gradle +1 -11
- package/android/gradle.properties +5 -47
- package/android/src/main/AndroidManifest.xml +9 -5
- package/android/src/main/AndroidManifestNew.xml +97 -0
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +57 -11
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebView.java +101 -68
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +70 -56
- 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 +91 -75
- 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 +21 -12
- 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.macos.tsx
CHANGED
|
@@ -1,177 +1,245 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from 'react
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
} from 'react';
|
|
7
|
+
import { Image, View, ImageSourcePropType, HostComponent } from 'react-native';
|
|
7
8
|
import invariant from 'invariant';
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import BPCWebView from "./WebViewNativeComponent.macos";
|
|
11
|
-
import BPCWebViewModule from "./NativeBPCWebView";
|
|
9
|
+
import BPCWebView, { Commands, NativeProps } from './BPCWebViewNativeComponent';
|
|
10
|
+
import BPCWebViewModule from './NativeBPCWebViewModule';
|
|
12
11
|
import {
|
|
13
12
|
defaultOriginWhitelist,
|
|
14
13
|
defaultRenderError,
|
|
15
14
|
defaultRenderLoading,
|
|
16
15
|
useWebViewLogic,
|
|
17
16
|
} from './WebViewShared';
|
|
18
|
-
import {
|
|
19
|
-
MacOSWebViewProps,
|
|
20
|
-
NativeWebViewMacOS,
|
|
21
|
-
} from './WebViewTypes';
|
|
17
|
+
import { MacOSWebViewProps, WebViewSourceUri } from './WebViewTypes';
|
|
22
18
|
|
|
23
19
|
import styles from './WebView.styles';
|
|
24
20
|
|
|
25
|
-
const Commands = codegenNativeCommands({
|
|
26
|
-
supportedCommands: ['goBack', 'goForward', 'reload', 'stopLoading', 'injectJavaScript', 'requestFocus', 'postMessage', 'loadUrl'],
|
|
27
|
-
});
|
|
28
|
-
|
|
29
21
|
const { resolveAssetSource } = Image;
|
|
30
22
|
|
|
31
23
|
const useWarnIfChanges = <T extends unknown>(value: T, name: string) => {
|
|
32
24
|
const ref = useRef(value);
|
|
33
25
|
if (ref.current !== value) {
|
|
34
|
-
console.warn(
|
|
26
|
+
console.warn(
|
|
27
|
+
`Changes to property ${name} do nothing after the initial render.`
|
|
28
|
+
);
|
|
35
29
|
ref.current = value;
|
|
36
30
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const WebViewComponent = forwardRef<{}, MacOSWebViewProps>(
|
|
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
|
-
const onShouldStartLoadWithRequestCallback = useCallback((
|
|
71
|
-
shouldStart: boolean,
|
|
72
|
-
_url: string,
|
|
73
|
-
lockIdentifier = 0,
|
|
74
|
-
) => {
|
|
75
|
-
BPCWebViewModule.shouldStartLoadWithLockIdentifier(!!shouldStart, lockIdentifier);
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onContentProcessDidTerminate } = useWebViewLogic({
|
|
79
|
-
onNavigationStateChange,
|
|
80
|
-
onLoad,
|
|
81
|
-
onError,
|
|
82
|
-
onHttpErrorProp,
|
|
83
|
-
onLoadEnd,
|
|
84
|
-
onLoadProgress,
|
|
85
|
-
onLoadStart,
|
|
86
|
-
onMessageProp,
|
|
87
|
-
startInLoadingState,
|
|
88
|
-
originWhitelist,
|
|
89
|
-
onShouldStartLoadWithRequestProp,
|
|
90
|
-
onShouldStartLoadWithRequestCallback,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
useImperativeHandle(ref, () => ({
|
|
94
|
-
goForward: () => Commands.goForward(webViewRef.current),
|
|
95
|
-
goBack: () => Commands.goBack(webViewRef.current),
|
|
96
|
-
reload: () => {
|
|
97
|
-
setViewState(
|
|
98
|
-
'LOADING',
|
|
99
|
-
); Commands.reload(webViewRef.current)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const WebViewComponent = forwardRef<{}, MacOSWebViewProps>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
javaScriptEnabled = true,
|
|
37
|
+
cacheEnabled = true,
|
|
38
|
+
originWhitelist = defaultOriginWhitelist,
|
|
39
|
+
useSharedProcessPool = true,
|
|
40
|
+
injectedJavaScript,
|
|
41
|
+
injectedJavaScriptBeforeContentLoaded,
|
|
42
|
+
startInLoadingState,
|
|
43
|
+
onNavigationStateChange,
|
|
44
|
+
onLoadStart,
|
|
45
|
+
onError,
|
|
46
|
+
onLoad,
|
|
47
|
+
onLoadEnd,
|
|
48
|
+
onLoadProgress,
|
|
49
|
+
onHttpError: onHttpErrorProp,
|
|
50
|
+
onMessage: onMessageProp,
|
|
51
|
+
renderLoading,
|
|
52
|
+
renderError,
|
|
53
|
+
style,
|
|
54
|
+
containerStyle,
|
|
55
|
+
source,
|
|
56
|
+
nativeConfig,
|
|
57
|
+
allowsInlineMediaPlayback,
|
|
58
|
+
allowsPictureInPictureMediaPlayback = true,
|
|
59
|
+
allowsAirPlayForMediaPlayback,
|
|
60
|
+
mediaPlaybackRequiresUserAction,
|
|
61
|
+
incognito,
|
|
62
|
+
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
63
|
+
...otherProps
|
|
100
64
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
65
|
+
ref
|
|
66
|
+
) => {
|
|
67
|
+
const webViewRef = useRef<React.ComponentRef<
|
|
68
|
+
HostComponent<NativeProps>
|
|
69
|
+
> | null>(null);
|
|
70
|
+
|
|
71
|
+
const onShouldStartLoadWithRequestCallback = useCallback(
|
|
72
|
+
(shouldStart: boolean, _url: string, lockIdentifier = 0) => {
|
|
73
|
+
BPCWebViewModule.shouldStartLoadWithLockIdentifier(
|
|
74
|
+
!!shouldStart,
|
|
75
|
+
lockIdentifier
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
[]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const {
|
|
82
|
+
onLoadingStart,
|
|
83
|
+
onShouldStartLoadWithRequest,
|
|
84
|
+
onMessage,
|
|
85
|
+
viewState,
|
|
86
|
+
setViewState,
|
|
87
|
+
lastErrorEvent,
|
|
88
|
+
onHttpError,
|
|
89
|
+
onLoadingError,
|
|
90
|
+
onLoadingFinish,
|
|
91
|
+
onLoadingProgress,
|
|
92
|
+
onContentProcessDidTerminate,
|
|
93
|
+
} = useWebViewLogic({
|
|
94
|
+
onNavigationStateChange,
|
|
95
|
+
onLoad,
|
|
96
|
+
onError,
|
|
97
|
+
onHttpErrorProp,
|
|
98
|
+
onLoadEnd,
|
|
99
|
+
onLoadProgress,
|
|
100
|
+
onLoadStart,
|
|
101
|
+
onMessageProp,
|
|
102
|
+
startInLoadingState,
|
|
103
|
+
originWhitelist,
|
|
104
|
+
onShouldStartLoadWithRequestProp,
|
|
105
|
+
onShouldStartLoadWithRequestCallback,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
useImperativeHandle(
|
|
109
|
+
ref,
|
|
110
|
+
() => ({
|
|
111
|
+
goForward: () =>
|
|
112
|
+
webViewRef.current && Commands.goForward(webViewRef.current),
|
|
113
|
+
goBack: () => webViewRef.current && Commands.goBack(webViewRef.current),
|
|
114
|
+
reload: () => {
|
|
115
|
+
setViewState('LOADING');
|
|
116
|
+
if (webViewRef.current) {
|
|
117
|
+
Commands.reload(webViewRef.current);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
stopLoading: () =>
|
|
121
|
+
webViewRef.current && Commands.stopLoading(webViewRef.current),
|
|
122
|
+
postMessage: (data: string) =>
|
|
123
|
+
webViewRef.current && Commands.postMessage(webViewRef.current, data),
|
|
124
|
+
injectJavaScript: (data: string) =>
|
|
125
|
+
webViewRef.current &&
|
|
126
|
+
Commands.injectJavaScript(webViewRef.current, data),
|
|
127
|
+
requestFocus: () =>
|
|
128
|
+
webViewRef.current && Commands.requestFocus(webViewRef.current),
|
|
129
|
+
}),
|
|
130
|
+
[setViewState, webViewRef]
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
useWarnIfChanges(allowsInlineMediaPlayback, 'allowsInlineMediaPlayback');
|
|
134
|
+
useWarnIfChanges(
|
|
135
|
+
allowsPictureInPictureMediaPlayback,
|
|
136
|
+
'allowsPictureInPictureMediaPlayback'
|
|
137
|
+
);
|
|
138
|
+
useWarnIfChanges(
|
|
139
|
+
allowsAirPlayForMediaPlayback,
|
|
140
|
+
'allowsAirPlayForMediaPlayback'
|
|
141
|
+
);
|
|
142
|
+
useWarnIfChanges(incognito, 'incognito');
|
|
143
|
+
useWarnIfChanges(
|
|
144
|
+
mediaPlaybackRequiresUserAction,
|
|
145
|
+
'mediaPlaybackRequiresUserAction'
|
|
122
146
|
);
|
|
123
|
-
} else if (viewState !== 'IDLE') {
|
|
124
|
-
console.error(`BPCWebView invalid state encountered: ${viewState}`);
|
|
125
|
-
}
|
|
126
147
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
148
|
+
let otherView = null;
|
|
149
|
+
if (viewState === 'LOADING') {
|
|
150
|
+
otherView = (renderLoading || defaultRenderLoading)();
|
|
151
|
+
} else if (viewState === 'ERROR') {
|
|
152
|
+
invariant(
|
|
153
|
+
lastErrorEvent != null,
|
|
154
|
+
'lastErrorEvent expected to be non-null'
|
|
155
|
+
);
|
|
156
|
+
otherView = (renderError || defaultRenderError)(
|
|
157
|
+
lastErrorEvent?.domain,
|
|
158
|
+
lastErrorEvent?.code || 0,
|
|
159
|
+
lastErrorEvent?.description ?? ''
|
|
160
|
+
);
|
|
161
|
+
} else if (viewState !== 'IDLE') {
|
|
162
|
+
console.error(`BPCWebView invalid state encountered: ${viewState}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const webViewStyles = [styles.container, styles.webView, style];
|
|
166
|
+
const webViewContainerStyle = [styles.container, containerStyle];
|
|
167
|
+
|
|
168
|
+
const NativeWebView =
|
|
169
|
+
(nativeConfig?.component as typeof BPCWebView | undefined) || BPCWebView;
|
|
170
|
+
|
|
171
|
+
const sourceResolved = resolveAssetSource(source as ImageSourcePropType);
|
|
172
|
+
const newSource =
|
|
173
|
+
typeof sourceResolved === 'object'
|
|
174
|
+
? Object.entries(sourceResolved as WebViewSourceUri).reduce(
|
|
175
|
+
(prev, [currKey, currValue]) => {
|
|
176
|
+
return {
|
|
177
|
+
...prev,
|
|
178
|
+
[currKey]:
|
|
179
|
+
currKey === 'headers' &&
|
|
180
|
+
currValue &&
|
|
181
|
+
typeof currValue === 'object'
|
|
182
|
+
? Object.entries(currValue).map(([key, value]) => {
|
|
183
|
+
return {
|
|
184
|
+
name: key,
|
|
185
|
+
value,
|
|
186
|
+
};
|
|
187
|
+
})
|
|
188
|
+
: currValue,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
{}
|
|
192
|
+
)
|
|
193
|
+
: sourceResolved;
|
|
194
|
+
|
|
195
|
+
const webView = (
|
|
196
|
+
<NativeWebView
|
|
197
|
+
key="webViewKey"
|
|
198
|
+
{...otherProps}
|
|
199
|
+
javaScriptEnabled={javaScriptEnabled}
|
|
200
|
+
cacheEnabled={cacheEnabled}
|
|
201
|
+
useSharedProcessPool={useSharedProcessPool}
|
|
202
|
+
messagingEnabled={typeof onMessageProp === 'function'}
|
|
203
|
+
newSource={newSource}
|
|
204
|
+
onLoadingError={onLoadingError}
|
|
205
|
+
onLoadingFinish={onLoadingFinish}
|
|
206
|
+
onLoadingProgress={onLoadingProgress}
|
|
207
|
+
onLoadingStart={onLoadingStart}
|
|
208
|
+
onHttpError={onHttpError}
|
|
209
|
+
onMessage={onMessage}
|
|
210
|
+
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
211
|
+
onContentProcessDidTerminate={onContentProcessDidTerminate}
|
|
212
|
+
injectedJavaScript={injectedJavaScript}
|
|
213
|
+
injectedJavaScriptBeforeContentLoaded={
|
|
214
|
+
injectedJavaScriptBeforeContentLoaded
|
|
215
|
+
}
|
|
216
|
+
allowsAirPlayForMediaPlayback={allowsAirPlayForMediaPlayback}
|
|
217
|
+
allowsInlineMediaPlayback={allowsInlineMediaPlayback}
|
|
218
|
+
allowsPictureInPictureMediaPlayback={
|
|
219
|
+
allowsPictureInPictureMediaPlayback
|
|
220
|
+
}
|
|
221
|
+
incognito={incognito}
|
|
222
|
+
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
223
|
+
ref={webViewRef}
|
|
224
|
+
// @ts-expect-error old arch only
|
|
225
|
+
source={sourceResolved}
|
|
226
|
+
style={webViewStyles}
|
|
227
|
+
{...nativeConfig?.props}
|
|
228
|
+
/>
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<View style={webViewContainerStyle}>
|
|
233
|
+
{webView}
|
|
234
|
+
{otherView}
|
|
235
|
+
</View>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
);
|
|
170
239
|
|
|
171
240
|
// no native implementation for macOS, depends only on permissions
|
|
172
|
-
const isFileUploadSupported: () => Promise<boolean>
|
|
173
|
-
= async () => true;
|
|
241
|
+
const isFileUploadSupported: () => Promise<boolean> = async () => true;
|
|
174
242
|
|
|
175
|
-
const WebView = Object.assign(WebViewComponent, {isFileUploadSupported});
|
|
243
|
+
const WebView = Object.assign(WebViewComponent, { isFileUploadSupported });
|
|
176
244
|
|
|
177
245
|
export default WebView;
|
package/src/WebView.styles.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { StyleSheet
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
-
|
|
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>({
|
|
3
|
+
const styles = StyleSheet.create({
|
|
13
4
|
container: {
|
|
14
5
|
flex: 1,
|
|
15
6
|
overflow: 'hidden',
|
|
@@ -21,7 +12,7 @@ const styles = StyleSheet.create<Styles>({
|
|
|
21
12
|
alignItems: 'center',
|
|
22
13
|
height: '100%',
|
|
23
14
|
width: '100%',
|
|
24
|
-
backgroundColor: 'white'
|
|
15
|
+
backgroundColor: 'white',
|
|
25
16
|
},
|
|
26
17
|
loadingProgressBar: {
|
|
27
18
|
height: 20,
|
|
@@ -39,6 +30,12 @@ const styles = StyleSheet.create<Styles>({
|
|
|
39
30
|
webView: {
|
|
40
31
|
backgroundColor: '#ffffff',
|
|
41
32
|
},
|
|
33
|
+
flexStart: {
|
|
34
|
+
alignSelf: 'flex-start',
|
|
35
|
+
},
|
|
36
|
+
colorRed: {
|
|
37
|
+
color: 'red',
|
|
38
|
+
},
|
|
42
39
|
});
|
|
43
40
|
|
|
44
41
|
export default styles;
|
package/src/WebView.tsx
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IOSWebViewProps,
|
|
5
|
+
AndroidWebViewProps,
|
|
6
|
+
WindowsWebViewProps,
|
|
7
|
+
} from './WebViewTypes';
|
|
8
|
+
import styles from './WebView.styles';
|
|
4
9
|
|
|
5
|
-
export type WebViewProps = IOSWebViewProps &
|
|
10
|
+
export type WebViewProps = IOSWebViewProps &
|
|
11
|
+
AndroidWebViewProps &
|
|
12
|
+
WindowsWebViewProps;
|
|
6
13
|
|
|
7
14
|
// This "dummy" WebView is to render something for unsupported platforms,
|
|
8
15
|
// like for example Expo SDK "web" platform.
|
|
9
16
|
const WebView: React.FunctionComponent<WebViewProps> = () => (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
<View style={styles.flexStart}>
|
|
18
|
+
<Text style={styles.colorRed}>
|
|
19
|
+
React Native WebView does not support this platform.
|
|
20
|
+
</Text>
|
|
21
|
+
</View>
|
|
15
22
|
);
|
|
16
23
|
|
|
17
24
|
export { WebView };
|