|
@@ -10,18 +10,53 @@
|
10
|
10
|
|
11
|
11
|
'use strict';
|
12
|
12
|
|
13
|
|
-import type {Node, Element} from 'react';
|
|
13
|
+import type {Node, Element, ComponentType} from 'react';
|
|
14
|
+import type {SyntheticEvent} from 'CoreEventTypes';
|
14
|
15
|
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
|
15
|
16
|
import type {ViewStyleProp} from 'StyleSheet';
|
16
|
17
|
import type {ViewProps} from 'ViewPropTypes';
|
17
|
18
|
|
18
|
|
-export type WebViewErrorEvent = {
|
19
|
|
- domain: any,
|
20
|
|
- code: any,
|
21
|
|
- description: any,
|
22
|
|
-};
|
|
19
|
+export type WebViewNativeEvent = $ReadOnly<{|
|
|
20
|
+ url: string,
|
|
21
|
+ loading: boolean,
|
|
22
|
+ title: string,
|
|
23
|
+ canGoBack: boolean,
|
|
24
|
+ canGoForward: boolean,
|
|
25
|
+|}>;
|
|
26
|
+
|
|
27
|
+export type WebViewNavigation = $ReadOnly<{|
|
|
28
|
+ ...WebViewNativeEvent,
|
|
29
|
+ navigationType:
|
|
30
|
+ | 'click'
|
|
31
|
+ | 'formsubmit'
|
|
32
|
+ | 'backforward'
|
|
33
|
+ | 'reload'
|
|
34
|
+ | 'formresubmit'
|
|
35
|
+ | 'other',
|
|
36
|
+|}>;
|
|
37
|
+
|
|
38
|
+export type WebViewMessage = $ReadOnly<{|
|
|
39
|
+ ...WebViewNativeEvent,
|
|
40
|
+ data: string,
|
|
41
|
+|}>;
|
|
42
|
+
|
|
43
|
+export type WebViewError = $ReadOnly<{|
|
|
44
|
+ ...WebViewNativeEvent,
|
|
45
|
+ /**
|
|
46
|
+ * `domain` is only used on iOS
|
|
47
|
+ */
|
|
48
|
+ domain: ?string,
|
|
49
|
+ code: number,
|
|
50
|
+ description: string,
|
|
51
|
+|}>;
|
|
52
|
+
|
|
53
|
+export type WebViewEvent = SyntheticEvent<WebViewNativeEvent>;
|
|
54
|
+
|
|
55
|
+export type WebViewNavigationEvent = SyntheticEvent<WebViewNavigation>;
|
23
|
56
|
|
24
|
|
-export type WebViewEvent = Object;
|
|
57
|
+export type WebViewMessageEvent = SyntheticEvent<WebViewMessage>;
|
|
58
|
+
|
|
59
|
+export type WebViewErrorEvent = SyntheticEvent<WebViewError>;
|
25
|
60
|
|
26
|
61
|
export type DataDetectorTypes =
|
27
|
62
|
| 'phoneNumber'
|
|
@@ -34,7 +69,7 @@ export type DataDetectorTypes =
|
34
|
69
|
| 'none'
|
35
|
70
|
| 'all';
|
36
|
71
|
|
37
|
|
-export type WebViewSourceUri = {|
|
|
72
|
+export type WebViewSourceUri = $ReadOnly<{|
|
38
|
73
|
/**
|
39
|
74
|
* The URI to load in the `WebView`. Can be a local or remote file.
|
40
|
75
|
*/
|
|
@@ -59,9 +94,9 @@ export type WebViewSourceUri = {|
|
59
|
94
|
* NOTE: On Android, this can only be used with POST requests.
|
60
|
95
|
*/
|
61
|
96
|
body?: string,
|
62
|
|
-|};
|
|
97
|
+|}>;
|
63
|
98
|
|
64
|
|
-export type WebViewSourceHtml = {|
|
|
99
|
+export type WebViewSourceHtml = $ReadOnly<{|
|
65
|
100
|
/**
|
66
|
101
|
* A static HTML page to display in the WebView.
|
67
|
102
|
*/
|
|
@@ -70,7 +105,7 @@ export type WebViewSourceHtml = {|
|
70
|
105
|
* The base URL to be used for any relative links in the HTML.
|
71
|
106
|
*/
|
72
|
107
|
baseUrl?: ?string,
|
73
|
|
-|};
|
|
108
|
+|}>;
|
74
|
109
|
|
75
|
110
|
export type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
|
76
|
111
|
|
|
@@ -78,7 +113,7 @@ export type WebViewNativeConfig = $ReadOnly<{|
|
78
|
113
|
/*
|
79
|
114
|
* The native component used to render the WebView.
|
80
|
115
|
*/
|
81
|
|
- component?: ?any,
|
|
116
|
+ component?: ComponentType<WebViewSharedProps>,
|
82
|
117
|
/*
|
83
|
118
|
* Set props directly on the native component WebView. Enables custom props which the
|
84
|
119
|
* original WebView doesn't pass through.
|
|
@@ -116,7 +151,7 @@ export type WebViewSharedProps = $ReadOnly<{|
|
116
|
151
|
/**
|
117
|
152
|
* Function that returns a view to show if there's an error.
|
118
|
153
|
*/
|
119
|
|
- renderError: (errorDomain: any, errorCode: any, errorDesc: any) => Element<any>, // view to show if there's an error
|
|
154
|
+ renderError: (errorDomain: ?string, errorCode: number, errorDesc: string) => Element<any>, // view to show if there's an error
|
120
|
155
|
|
121
|
156
|
/**
|
122
|
157
|
* Function that returns a loading indicator.
|
|
@@ -126,22 +161,22 @@ export type WebViewSharedProps = $ReadOnly<{|
|
126
|
161
|
/**
|
127
|
162
|
* Function that is invoked when the `WebView` has finished loading.
|
128
|
163
|
*/
|
129
|
|
- onLoad: (event: WebViewEvent) => any,
|
|
164
|
+ onLoad: (event: WebViewNavigationEvent) => mixed,
|
130
|
165
|
|
131
|
166
|
/**
|
132
|
167
|
* Function that is invoked when the `WebView` load succeeds or fails.
|
133
|
168
|
*/
|
134
|
|
- onLoadEnd: (event: WebViewEvent) => any,
|
|
169
|
+ onLoadEnd: (event: WebViewNavigationEvent | WebViewErrorEvent) => mixed,
|
135
|
170
|
|
136
|
171
|
/**
|
137
|
172
|
* Function that is invoked when the `WebView` starts loading.
|
138
|
173
|
*/
|
139
|
|
- onLoadStart: (event: WebViewEvent) => any,
|
|
174
|
+ onLoadStart: (event: WebViewNavigationEvent) => mixed,
|
140
|
175
|
|
141
|
176
|
/**
|
142
|
177
|
* Function that is invoked when the `WebView` load fails.
|
143
|
178
|
*/
|
144
|
|
- onError: (event: WebViewEvent) => any,
|
|
179
|
+ onError: (event: WebViewErrorEvent) => mixed,
|
145
|
180
|
|
146
|
181
|
/**
|
147
|
182
|
* Boolean value that determines whether the web view bounces
|
|
@@ -187,7 +222,7 @@ export type WebViewSharedProps = $ReadOnly<{|
|
187
|
222
|
/**
|
188
|
223
|
* Function that is invoked when the `WebView` loading starts or ends.
|
189
|
224
|
*/
|
190
|
|
- onNavigationStateChange?: (event: WebViewEvent) => any,
|
|
225
|
+ onNavigationStateChange?: (event: WebViewNavigation) => mixed,
|
191
|
226
|
|
192
|
227
|
/**
|
193
|
228
|
* A function that is invoked when the webview calls `window.postMessage`.
|
|
@@ -198,7 +233,7 @@ export type WebViewSharedProps = $ReadOnly<{|
|
198
|
233
|
* available on the event object, `event.nativeEvent.data`. `data`
|
199
|
234
|
* must be a string.
|
200
|
235
|
*/
|
201
|
|
- onMessage?: (event: WebViewEvent) => any,
|
|
236
|
+ onMessage?: (event: WebViewMessageEvent) => mixed,
|
202
|
237
|
|
203
|
238
|
/**
|
204
|
239
|
* Boolean value that forces the `WebView` to show the loading view
|
|
@@ -281,7 +316,7 @@ export type WebViewSharedProps = $ReadOnly<{|
|
281
|
316
|
* to stop loading.
|
282
|
317
|
* @platform ios
|
283
|
318
|
*/
|
284
|
|
- onShouldStartLoadWithRequest?: (event: WebViewEvent) => any,
|
|
319
|
+ onShouldStartLoadWithRequest?: (event: WebViewEvent) => mixed,
|
285
|
320
|
|
286
|
321
|
/**
|
287
|
322
|
* Boolean that determines whether HTML5 videos play inline or use the
|