|
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+/**
|
|
|
2
|
+ * Copyright (c) 2015-present, Facebook, Inc.
|
|
|
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
|
+ */
|
|
|
8
|
+
|
|
|
9
|
+import { ReactNode, ReactElement, Component } from 'react';
|
|
|
10
|
+import {
|
|
|
11
|
+ NativeSyntheticEvent,
|
|
|
12
|
+ ViewStyle,
|
|
|
13
|
+ ViewProps,
|
|
|
14
|
+ StyleProp,
|
|
|
15
|
+ NativeMethodsMixin,
|
|
|
16
|
+ Constructor,
|
|
|
17
|
+ UIManagerStatic,
|
|
|
18
|
+} from 'react-native';
|
|
|
19
|
+
|
|
|
20
|
+interface WebViewCommands {
|
|
|
21
|
+ goForward: Function;
|
|
|
22
|
+ goBack: Function;
|
|
|
23
|
+ reload: Function;
|
|
|
24
|
+ stopLoading: Function;
|
|
|
25
|
+ postMessage: Function;
|
|
|
26
|
+ injectJavaScript: Function;
|
|
|
27
|
+ loadUrl: Function;
|
|
|
28
|
+}
|
|
|
29
|
+
|
|
|
30
|
+export interface CustomUIManager extends UIManagerStatic {
|
|
|
31
|
+ getViewManagerConfig?: (
|
|
|
32
|
+ name: string,
|
|
|
33
|
+ ) => {
|
|
|
34
|
+ Commands: WebViewCommands;
|
|
|
35
|
+ };
|
|
|
36
|
+ dispatchViewManagerCommand: (
|
|
|
37
|
+ viewHandle: number,
|
|
|
38
|
+ command: any,
|
|
|
39
|
+ params: any,
|
|
|
40
|
+ ) => void;
|
|
|
41
|
+ RNCUIWebView: {
|
|
|
42
|
+ Commands: WebViewCommands;
|
|
|
43
|
+ };
|
|
|
44
|
+ RNCWKWebView: {
|
|
|
45
|
+ Commands: WebViewCommands;
|
|
|
46
|
+ };
|
|
|
47
|
+ RNCWebView: {
|
|
|
48
|
+ Commands: WebViewCommands;
|
|
|
49
|
+ };
|
|
|
50
|
+}
|
|
|
51
|
+
|
|
|
52
|
+type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
|
|
|
53
|
+
|
|
|
54
|
+interface BaseState {
|
|
|
55
|
+ viewState: WebViewState;
|
|
|
56
|
+}
|
|
|
57
|
+
|
|
|
58
|
+interface NormalState extends BaseState {
|
|
|
59
|
+ viewState: 'IDLE' | 'LOADING';
|
|
|
60
|
+ lastErrorEvent: WebViewError | null;
|
|
|
61
|
+}
|
|
|
62
|
+
|
|
|
63
|
+interface ErrorState extends BaseState {
|
|
|
64
|
+ viewState: 'ERROR';
|
|
|
65
|
+ lastErrorEvent: WebViewError;
|
|
|
66
|
+}
|
|
|
67
|
+
|
|
|
68
|
+export type State = NormalState | ErrorState;
|
|
|
69
|
+
|
|
|
70
|
+declare class NativeWebViewIOSComponent extends Component<
|
|
|
71
|
+ IOSNativeWebViewProps
|
|
|
72
|
+> {}
|
|
|
73
|
+declare const NativeWebViewIOSBase: Constructor<NativeMethodsMixin> &
|
|
|
74
|
+ typeof NativeWebViewIOSComponent;
|
|
|
75
|
+export class NativeWebViewIOS extends NativeWebViewIOSBase {}
|
|
|
76
|
+
|
|
|
77
|
+declare class NativeWebViewAndroidComponent extends Component<
|
|
|
78
|
+ AndroidNativeWebViewProps
|
|
|
79
|
+> {}
|
|
|
80
|
+declare const NativeWebViewAndroidBase: Constructor<NativeMethodsMixin> &
|
|
|
81
|
+ typeof NativeWebViewAndroidComponent;
|
|
|
82
|
+export class NativeWebViewAndroid extends NativeWebViewAndroidBase {}
|
|
|
83
|
+
|
|
|
84
|
+export interface ContentInsetProp {
|
|
|
85
|
+ top?: number;
|
|
|
86
|
+ left?: number;
|
|
|
87
|
+ bottom?: number;
|
|
|
88
|
+ right?: number;
|
|
|
89
|
+}
|
|
|
90
|
+
|
|
|
91
|
+export interface WebViewNativeEvent {
|
|
|
92
|
+ url: string;
|
|
|
93
|
+ loading: boolean;
|
|
|
94
|
+ title: string;
|
|
|
95
|
+ canGoBack: boolean;
|
|
|
96
|
+ canGoForward: boolean;
|
|
|
97
|
+ lockIdentifier: number;
|
|
|
98
|
+}
|
|
|
99
|
+
|
|
|
100
|
+export interface WebViewProgressEvent extends WebViewNativeEvent {
|
|
|
101
|
+ progress: number;
|
|
|
102
|
+}
|
|
|
103
|
+
|
|
|
104
|
+export interface WebViewNavigation extends WebViewNativeEvent {
|
|
|
105
|
+ navigationType:
|
|
|
106
|
+ | 'click'
|
|
|
107
|
+ | 'formsubmit'
|
|
|
108
|
+ | 'backforward'
|
|
|
109
|
+ | 'reload'
|
|
|
110
|
+ | 'formresubmit'
|
|
|
111
|
+ | 'other';
|
|
|
112
|
+}
|
|
|
113
|
+
|
|
|
114
|
+export type DecelerationRateConstant = 'normal' | 'fast';
|
|
|
115
|
+
|
|
|
116
|
+export interface WebViewMessage extends WebViewNativeEvent {
|
|
|
117
|
+ data: string;
|
|
|
118
|
+}
|
|
|
119
|
+
|
|
|
120
|
+export interface WebViewError extends WebViewNativeEvent {
|
|
|
121
|
+ /**
|
|
|
122
|
+ * `domain` is only used on iOS
|
|
|
123
|
+ */
|
|
|
124
|
+ domain?: string;
|
|
|
125
|
+ code: number;
|
|
|
126
|
+ description: string;
|
|
|
127
|
+}
|
|
|
128
|
+
|
|
|
129
|
+export type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
|
|
|
130
|
+
|
|
|
131
|
+export type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
|
|
|
132
|
+
|
|
|
133
|
+export type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
|
|
|
134
|
+
|
|
|
135
|
+export type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
|
|
|
136
|
+
|
|
|
137
|
+export type DataDetectorTypes =
|
|
|
138
|
+ | 'phoneNumber'
|
|
|
139
|
+ | 'link'
|
|
|
140
|
+ | 'address'
|
|
|
141
|
+ | 'calendarEvent'
|
|
|
142
|
+ | 'trackingNumber'
|
|
|
143
|
+ | 'flightNumber'
|
|
|
144
|
+ | 'lookupSuggestion'
|
|
|
145
|
+ | 'none'
|
|
|
146
|
+ | 'all';
|
|
|
147
|
+
|
|
|
148
|
+export type OverScrollModeType = 'always' | 'content' | 'never';
|
|
|
149
|
+
|
|
|
150
|
+export interface WebViewSourceUri {
|
|
|
151
|
+ /**
|
|
|
152
|
+ * The URI to load in the `WebView`. Can be a local or remote file.
|
|
|
153
|
+ */
|
|
|
154
|
+ uri: string;
|
|
|
155
|
+
|
|
|
156
|
+ /**
|
|
|
157
|
+ * The HTTP Method to use. Defaults to GET if not specified.
|
|
|
158
|
+ * NOTE: On Android, only GET and POST are supported.
|
|
|
159
|
+ */
|
|
|
160
|
+ method?: string;
|
|
|
161
|
+
|
|
|
162
|
+ /**
|
|
|
163
|
+ * Additional HTTP headers to send with the request.
|
|
|
164
|
+ * NOTE: On Android, this can only be used with GET requests.
|
|
|
165
|
+ */
|
|
|
166
|
+ headers?: Object;
|
|
|
167
|
+
|
|
|
168
|
+ /**
|
|
|
169
|
+ * The HTTP body to send with the request. This must be a valid
|
|
|
170
|
+ * UTF-8 string, and will be sent exactly as specified, with no
|
|
|
171
|
+ * additional encoding (e.g. URL-escaping or base64) applied.
|
|
|
172
|
+ * NOTE: On Android, this can only be used with POST requests.
|
|
|
173
|
+ */
|
|
|
174
|
+ body?: string;
|
|
|
175
|
+}
|
|
|
176
|
+
|
|
|
177
|
+export interface WebViewSourceHtml {
|
|
|
178
|
+ /**
|
|
|
179
|
+ * A static HTML page to display in the WebView.
|
|
|
180
|
+ */
|
|
|
181
|
+ html: string;
|
|
|
182
|
+ /**
|
|
|
183
|
+ * The base URL to be used for any relative links in the HTML.
|
|
|
184
|
+ */
|
|
|
185
|
+ baseUrl: string;
|
|
|
186
|
+}
|
|
|
187
|
+
|
|
|
188
|
+export type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
|
|
|
189
|
+
|
|
|
190
|
+export interface ViewManager {
|
|
|
191
|
+ startLoadWithResult: Function;
|
|
|
192
|
+}
|
|
|
193
|
+
|
|
|
194
|
+export type WebViewNativeConfig = {
|
|
|
195
|
+ /**
|
|
|
196
|
+ * The native component used to render the WebView.
|
|
|
197
|
+ */
|
|
|
198
|
+ component?: typeof NativeWebViewIOS | typeof NativeWebViewAndroid;
|
|
|
199
|
+ /**
|
|
|
200
|
+ * Set props directly on the native component WebView. Enables custom props which the
|
|
|
201
|
+ * original WebView doesn't pass through.
|
|
|
202
|
+ */
|
|
|
203
|
+ props?: Object;
|
|
|
204
|
+ /**
|
|
|
205
|
+ * Set the ViewManager to use for communication with the native side.
|
|
|
206
|
+ * @platform ios
|
|
|
207
|
+ */
|
|
|
208
|
+ viewManager?: ViewManager;
|
|
|
209
|
+};
|
|
|
210
|
+
|
|
|
211
|
+export type OnShouldStartLoadWithRequest = (
|
|
|
212
|
+ event: WebViewNavigation,
|
|
|
213
|
+) => boolean;
|
|
|
214
|
+
|
|
|
215
|
+export interface CommonNativeWebViewProps extends ViewProps {
|
|
|
216
|
+ cacheEnabled?: boolean;
|
|
|
217
|
+ injectedJavaScript?: string;
|
|
|
218
|
+ mediaPlaybackRequiresUserAction?: boolean;
|
|
|
219
|
+ messagingEnabled: boolean;
|
|
|
220
|
+ onLoadingError: (event: WebViewErrorEvent) => void;
|
|
|
221
|
+ onLoadingFinish: (event: WebViewNavigationEvent) => void;
|
|
|
222
|
+ onLoadingProgress: (event: WebViewProgressEvent) => void;
|
|
|
223
|
+ onLoadingStart: (event: WebViewNavigationEvent) => void;
|
|
|
224
|
+ onMessage: (event: WebViewMessageEvent) => void;
|
|
|
225
|
+ onShouldStartLoadWithRequest: (event: WebViewNavigationEvent) => void;
|
|
|
226
|
+ scalesPageToFit?: boolean;
|
|
|
227
|
+ showsHorizontalScrollIndicator?: boolean;
|
|
|
228
|
+ showsVerticalScrollIndicator?: boolean;
|
|
|
229
|
+ // TODO: find a better way to type this.
|
|
|
230
|
+ source: any;
|
|
|
231
|
+ userAgent?: string;
|
|
|
232
|
+}
|
|
|
233
|
+
|
|
|
234
|
+export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
|
|
|
235
|
+ allowFileAccess?: boolean;
|
|
|
236
|
+ allowUniversalAccessFromFileURLs?: boolean;
|
|
|
237
|
+ androidHardwareAccelerationDisabled?: boolean;
|
|
|
238
|
+ domStorageEnabled?: boolean;
|
|
|
239
|
+ geolocationEnabled?: boolean;
|
|
|
240
|
+ javaScriptEnabled?: boolean;
|
|
|
241
|
+ mixedContentMode?: 'never' | 'always' | 'compatibility';
|
|
|
242
|
+ onContentSizeChange?: (event: WebViewEvent) => void;
|
|
|
243
|
+ overScrollMode?: OverScrollModeType;
|
|
|
244
|
+ saveFormDataDisabled?: boolean;
|
|
|
245
|
+ thirdPartyCookiesEnabled?: boolean;
|
|
|
246
|
+ urlPrefixesForDefaultIntent?: string[];
|
|
|
247
|
+}
|
|
|
248
|
+
|
|
|
249
|
+export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
|
|
|
250
|
+ allowsBackForwardNavigationGestures?: boolean;
|
|
|
251
|
+ allowsInlineMediaPlayback?: boolean;
|
|
|
252
|
+ allowsLinkPreview?: boolean;
|
|
|
253
|
+ automaticallyAdjustContentInsets?: boolean;
|
|
|
254
|
+ bounces?: boolean;
|
|
|
255
|
+ contentInset?: ContentInsetProp;
|
|
|
256
|
+ dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
|
|
|
257
|
+ decelerationRate?: number;
|
|
|
258
|
+ directionalLockEnabled?: boolean;
|
|
|
259
|
+ hideKeyboardAccessoryView?: boolean;
|
|
|
260
|
+ incognito?: boolean;
|
|
|
261
|
+ pagingEnabled?: boolean;
|
|
|
262
|
+ scrollEnabled?: boolean;
|
|
|
263
|
+ useSharedProcessPool?: boolean;
|
|
|
264
|
+}
|
|
|
265
|
+
|
|
|
266
|
+export interface IOSWebViewProps extends WebViewSharedProps {
|
|
|
267
|
+ /**
|
|
|
268
|
+ * If true, use WKWebView instead of UIWebView.
|
|
|
269
|
+ * @platform ios
|
|
|
270
|
+ */
|
|
|
271
|
+ useWebKit?: boolean;
|
|
|
272
|
+
|
|
|
273
|
+ /**
|
|
|
274
|
+ * Does not store any data within the lifetime of the WebView.
|
|
|
275
|
+ */
|
|
|
276
|
+ incognito?: boolean;
|
|
|
277
|
+
|
|
|
278
|
+ /**
|
|
|
279
|
+ * Boolean value that determines whether the web view bounces
|
|
|
280
|
+ * when it reaches the edge of the content. The default value is `true`.
|
|
|
281
|
+ * @platform ios
|
|
|
282
|
+ */
|
|
|
283
|
+ bounces?: boolean;
|
|
|
284
|
+
|
|
|
285
|
+ /**
|
|
|
286
|
+ * A floating-point number that determines how quickly the scroll view
|
|
|
287
|
+ * decelerates after the user lifts their finger. You may also use the
|
|
|
288
|
+ * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
|
|
|
289
|
+ * settings for `UIScrollViewDecelerationRateNormal` and
|
|
|
290
|
+ * `UIScrollViewDecelerationRateFast` respectively:
|
|
|
291
|
+ *
|
|
|
292
|
+ * - normal: 0.998
|
|
|
293
|
+ * - fast: 0.99 (the default for iOS web view)
|
|
|
294
|
+ * @platform ios
|
|
|
295
|
+ */
|
|
|
296
|
+ decelerationRate?: DecelerationRateConstant | number;
|
|
|
297
|
+
|
|
|
298
|
+ /**
|
|
|
299
|
+ * Boolean value that determines whether scrolling is enabled in the
|
|
|
300
|
+ * `WebView`. The default value is `true`.
|
|
|
301
|
+ * @platform ios
|
|
|
302
|
+ */
|
|
|
303
|
+ scrollEnabled?: boolean;
|
|
|
304
|
+
|
|
|
305
|
+ /**
|
|
|
306
|
+ * If the value of this property is true, the scroll view stops on multiples
|
|
|
307
|
+ * of the scroll view’s bounds when the user scrolls.
|
|
|
308
|
+ * The default value is false.
|
|
|
309
|
+ * @platform ios
|
|
|
310
|
+ */
|
|
|
311
|
+ pagingEnabled?: boolean;
|
|
|
312
|
+
|
|
|
313
|
+ /**
|
|
|
314
|
+ * Controls whether to adjust the content inset for web views that are
|
|
|
315
|
+ * placed behind a navigation bar, tab bar, or toolbar. The default value
|
|
|
316
|
+ * is `true`.
|
|
|
317
|
+ * @platform ios
|
|
|
318
|
+ */
|
|
|
319
|
+ automaticallyAdjustContentInsets?: boolean;
|
|
|
320
|
+
|
|
|
321
|
+ /**
|
|
|
322
|
+ * The amount by which the web view content is inset from the edges of
|
|
|
323
|
+ * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
|
|
|
324
|
+ * @platform ios
|
|
|
325
|
+ */
|
|
|
326
|
+ contentInset?: ContentInsetProp;
|
|
|
327
|
+
|
|
|
328
|
+ /**
|
|
|
329
|
+ * Determines the types of data converted to clickable URLs in the web view's content.
|
|
|
330
|
+ * By default only phone numbers are detected.
|
|
|
331
|
+ *
|
|
|
332
|
+ * You can provide one type or an array of many types.
|
|
|
333
|
+ *
|
|
|
334
|
+ * Possible values for `dataDetectorTypes` are:
|
|
|
335
|
+ *
|
|
|
336
|
+ * - `'phoneNumber'`
|
|
|
337
|
+ * - `'link'`
|
|
|
338
|
+ * - `'address'`
|
|
|
339
|
+ * - `'calendarEvent'`
|
|
|
340
|
+ * - `'none'`
|
|
|
341
|
+ * - `'all'`
|
|
|
342
|
+ *
|
|
|
343
|
+ * With the new WebKit implementation, we have three new values:
|
|
|
344
|
+ * - `'trackingNumber'`,
|
|
|
345
|
+ * - `'flightNumber'`,
|
|
|
346
|
+ * - `'lookupSuggestion'`,
|
|
|
347
|
+ *
|
|
|
348
|
+ * @platform ios
|
|
|
349
|
+ */
|
|
|
350
|
+ dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
|
|
|
351
|
+
|
|
|
352
|
+ /**
|
|
|
353
|
+ * Boolean that determines whether HTML5 videos play inline or use the
|
|
|
354
|
+ * native full-screen controller. The default value is `false`.
|
|
|
355
|
+ *
|
|
|
356
|
+ * **NOTE** : In order for video to play inline, not only does this
|
|
|
357
|
+ * property need to be set to `true`, but the video element in the HTML
|
|
|
358
|
+ * document must also include the `webkit-playsinline` attribute.
|
|
|
359
|
+ * @platform ios
|
|
|
360
|
+ */
|
|
|
361
|
+ allowsInlineMediaPlayback?: boolean;
|
|
|
362
|
+ /**
|
|
|
363
|
+ * Hide the accessory view when the keyboard is open. Default is false to be
|
|
|
364
|
+ * backward compatible.
|
|
|
365
|
+ */
|
|
|
366
|
+ hideKeyboardAccessoryView?: boolean;
|
|
|
367
|
+ /**
|
|
|
368
|
+ * A Boolean value indicating whether horizontal swipe gestures will trigger
|
|
|
369
|
+ * back-forward list navigations.
|
|
|
370
|
+ */
|
|
|
371
|
+ allowsBackForwardNavigationGestures?: boolean;
|
|
|
372
|
+ /**
|
|
|
373
|
+ * A Boolean value indicating whether WebKit WebView should be created using a shared
|
|
|
374
|
+ * process pool, enabling WebViews to share cookies and localStorage between each other.
|
|
|
375
|
+ * Default is true but can be set to false for backwards compatibility.
|
|
|
376
|
+ * @platform ios
|
|
|
377
|
+ */
|
|
|
378
|
+ useSharedProcessPool?: boolean;
|
|
|
379
|
+ /**
|
|
|
380
|
+ * The custom user agent string.
|
|
|
381
|
+ */
|
|
|
382
|
+ userAgent?: string;
|
|
|
383
|
+
|
|
|
384
|
+ /**
|
|
|
385
|
+ * A Boolean value that determines whether pressing on a link
|
|
|
386
|
+ * displays a preview of the destination for the link.
|
|
|
387
|
+ *
|
|
|
388
|
+ * This property is available on devices that support 3D Touch.
|
|
|
389
|
+ * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
|
|
|
390
|
+ * @platform ios
|
|
|
391
|
+ */
|
|
|
392
|
+ allowsLinkPreview?: boolean;
|
|
|
393
|
+
|
|
|
394
|
+ /**
|
|
|
395
|
+ * A Boolean value that determines whether scrolling is disabled in a particular direction.
|
|
|
396
|
+ * The default value is `true`.
|
|
|
397
|
+ * @platform ios
|
|
|
398
|
+ */
|
|
|
399
|
+ directionalLockEnabled?: boolean;
|
|
|
400
|
+}
|
|
|
401
|
+
|
|
|
402
|
+export interface AndroidWebViewProps extends WebViewSharedProps {
|
|
|
403
|
+ onNavigationStateChange?: (event: WebViewNavigation) => void;
|
|
|
404
|
+ onContentSizeChange?: (event: WebViewEvent) => void;
|
|
|
405
|
+
|
|
|
406
|
+ /**
|
|
|
407
|
+ * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
|
|
|
408
|
+ * Sets the overScrollMode. Possible values are:
|
|
|
409
|
+ *
|
|
|
410
|
+ * - `'always'` (default)
|
|
|
411
|
+ * - `'content'`
|
|
|
412
|
+ * - `'never'`
|
|
|
413
|
+ *
|
|
|
414
|
+ * @platform android
|
|
|
415
|
+ */
|
|
|
416
|
+ overScrollMode?: OverScrollModeType;
|
|
|
417
|
+
|
|
|
418
|
+ /**
|
|
|
419
|
+ * Sets whether Geolocation is enabled. The default is false.
|
|
|
420
|
+ * @platform android
|
|
|
421
|
+ */
|
|
|
422
|
+ geolocationEnabled?: boolean;
|
|
|
423
|
+
|
|
|
424
|
+ /**
|
|
|
425
|
+ * Boolean that sets whether JavaScript running in the context of a file
|
|
|
426
|
+ * scheme URL should be allowed to access content from any origin.
|
|
|
427
|
+ * Including accessing content from other file scheme URLs
|
|
|
428
|
+ * @platform android
|
|
|
429
|
+ */
|
|
|
430
|
+ allowUniversalAccessFromFileURLs?: boolean;
|
|
|
431
|
+
|
|
|
432
|
+ /**
|
|
|
433
|
+ * Sets whether the webview allow access to file system.
|
|
|
434
|
+ * @platform android
|
|
|
435
|
+ */
|
|
|
436
|
+ allowFileAccess?: boolean;
|
|
|
437
|
+
|
|
|
438
|
+ /**
|
|
|
439
|
+ * Used on Android only, controls whether form autocomplete data should be saved
|
|
|
440
|
+ * @platform android
|
|
|
441
|
+ */
|
|
|
442
|
+ saveFormDataDisabled?: boolean;
|
|
|
443
|
+
|
|
|
444
|
+ /**
|
|
|
445
|
+ * Used on Android only, controls whether the given list of URL prefixes should
|
|
|
446
|
+ * make {@link com.facebook.react.views.webview.ReactWebViewClient} to launch a
|
|
|
447
|
+ * default activity intent for those URL instead of loading it within the webview.
|
|
|
448
|
+ * Use this to list URLs that WebView cannot handle, e.g. a PDF url.
|
|
|
449
|
+ * @platform android
|
|
|
450
|
+ */
|
|
|
451
|
+ urlPrefixesForDefaultIntent?: string[];
|
|
|
452
|
+
|
|
|
453
|
+ /**
|
|
|
454
|
+ * Boolean value to enable JavaScript in the `WebView`. Used on Android only
|
|
|
455
|
+ * as JavaScript is enabled by default on iOS. The default value is `true`.
|
|
|
456
|
+ * @platform android
|
|
|
457
|
+ */
|
|
|
458
|
+ javaScriptEnabled?: boolean;
|
|
|
459
|
+
|
|
|
460
|
+ /**
|
|
|
461
|
+ * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
|
|
|
462
|
+ * as Hardware Acceleration is a feature only for Android. The default value is `false`.
|
|
|
463
|
+ * @platform android
|
|
|
464
|
+ */
|
|
|
465
|
+ androidHardwareAccelerationDisabled?: boolean;
|
|
|
466
|
+
|
|
|
467
|
+ /**
|
|
|
468
|
+ * Boolean value to enable third party cookies in the `WebView`. Used on
|
|
|
469
|
+ * Android Lollipop and above only as third party cookies are enabled by
|
|
|
470
|
+ * default on Android Kitkat and below and on iOS. The default value is `true`.
|
|
|
471
|
+ * @platform android
|
|
|
472
|
+ */
|
|
|
473
|
+ thirdPartyCookiesEnabled?: boolean;
|
|
|
474
|
+
|
|
|
475
|
+ /**
|
|
|
476
|
+ * Boolean value to control whether DOM Storage is enabled. Used only in
|
|
|
477
|
+ * Android.
|
|
|
478
|
+ * @platform android
|
|
|
479
|
+ */
|
|
|
480
|
+ domStorageEnabled?: boolean;
|
|
|
481
|
+
|
|
|
482
|
+ /**
|
|
|
483
|
+ * Sets the user-agent for the `WebView`.
|
|
|
484
|
+ * @platform android
|
|
|
485
|
+ */
|
|
|
486
|
+ userAgent?: string;
|
|
|
487
|
+
|
|
|
488
|
+ /**
|
|
|
489
|
+ * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
|
|
|
490
|
+ *
|
|
|
491
|
+ * Possible values for `mixedContentMode` are:
|
|
|
492
|
+ *
|
|
|
493
|
+ * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
|
|
|
494
|
+ * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
|
|
|
495
|
+ * - `'compatibility'` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
|
|
|
496
|
+ * @platform android
|
|
|
497
|
+ */
|
|
|
498
|
+ mixedContentMode?: 'never' | 'always' | 'compatibility';
|
|
|
499
|
+}
|
|
|
500
|
+
|
|
|
501
|
+export interface WebViewSharedProps extends ViewProps {
|
|
|
502
|
+ /**
|
|
|
503
|
+ * Loads static html or a uri (with optional headers) in the WebView.
|
|
|
504
|
+ */
|
|
|
505
|
+ source?: WebViewSource;
|
|
|
506
|
+
|
|
|
507
|
+ /**
|
|
|
508
|
+ * Function that returns a view to show if there's an error.
|
|
|
509
|
+ */
|
|
|
510
|
+ renderError: (
|
|
|
511
|
+ errorDomain: string | undefined,
|
|
|
512
|
+ errorCode: number,
|
|
|
513
|
+ errorDesc: string,
|
|
|
514
|
+ ) => ReactElement<any>; // view to show if there's an error
|
|
|
515
|
+
|
|
|
516
|
+ /**
|
|
|
517
|
+ * Function that returns a loading indicator.
|
|
|
518
|
+ */
|
|
|
519
|
+ renderLoading: () => ReactElement<any>;
|
|
|
520
|
+
|
|
|
521
|
+ /**
|
|
|
522
|
+ * Function that is invoked when the `WebView` has finished loading.
|
|
|
523
|
+ */
|
|
|
524
|
+ onLoad: (event: WebViewNavigationEvent) => void;
|
|
|
525
|
+
|
|
|
526
|
+ /**
|
|
|
527
|
+ * Function that is invoked when the `WebView` load succeeds or fails.
|
|
|
528
|
+ */
|
|
|
529
|
+ onLoadEnd: (event: WebViewNavigationEvent | WebViewErrorEvent) => void;
|
|
|
530
|
+
|
|
|
531
|
+ /**
|
|
|
532
|
+ * Function that is invoked when the `WebView` starts loading.
|
|
|
533
|
+ */
|
|
|
534
|
+ onLoadStart: (event: WebViewNavigationEvent) => void;
|
|
|
535
|
+
|
|
|
536
|
+ /**
|
|
|
537
|
+ * Function that is invoked when the `WebView` load fails.
|
|
|
538
|
+ */
|
|
|
539
|
+ onError: (event: WebViewErrorEvent) => void;
|
|
|
540
|
+
|
|
|
541
|
+ /**
|
|
|
542
|
+ * Function that is invoked when the `WebView` loading starts or ends.
|
|
|
543
|
+ */
|
|
|
544
|
+ onNavigationStateChange?: (event: WebViewNavigation) => void;
|
|
|
545
|
+
|
|
|
546
|
+ /**
|
|
|
547
|
+ * Function that is invoked when the webview calls `window.ReactNativeWebView.postMessage`.
|
|
|
548
|
+ * Setting this property will inject this global into your webview.
|
|
|
549
|
+ *
|
|
|
550
|
+ * `window.ReactNativeWebView.postMessage` accepts one argument, `data`, which will be
|
|
|
551
|
+ * available on the event object, `event.nativeEvent.data`. `data` must be a string.
|
|
|
552
|
+ */
|
|
|
553
|
+ onMessage?: (event: WebViewMessageEvent) => void;
|
|
|
554
|
+
|
|
|
555
|
+ /**
|
|
|
556
|
+ * Function that is invoked when the `WebView` is loading.
|
|
|
557
|
+ */
|
|
|
558
|
+ onLoadProgress?: (event: WebViewProgressEvent) => void;
|
|
|
559
|
+
|
|
|
560
|
+ /**
|
|
|
561
|
+ * Boolean value that forces the `WebView` to show the loading view
|
|
|
562
|
+ * on the first load.
|
|
|
563
|
+ */
|
|
|
564
|
+ startInLoadingState?: boolean;
|
|
|
565
|
+
|
|
|
566
|
+ /**
|
|
|
567
|
+ * Set this to provide JavaScript that will be injected into the web page
|
|
|
568
|
+ * when the view loads.
|
|
|
569
|
+ */
|
|
|
570
|
+ injectedJavaScript?: string;
|
|
|
571
|
+
|
|
|
572
|
+ /**
|
|
|
573
|
+ * Boolean value that determines whether a horizontal scroll indicator is
|
|
|
574
|
+ * shown in the `WebView`. The default value is `true`.
|
|
|
575
|
+ */
|
|
|
576
|
+ showsHorizontalScrollIndicator?: boolean;
|
|
|
577
|
+
|
|
|
578
|
+ /**
|
|
|
579
|
+ * Boolean value that determines whether a vertical scroll indicator is
|
|
|
580
|
+ * shown in the `WebView`. The default value is `true`.
|
|
|
581
|
+ */
|
|
|
582
|
+ showsVerticalScrollIndicator?: boolean;
|
|
|
583
|
+
|
|
|
584
|
+ /**
|
|
|
585
|
+ * Boolean that controls whether the web content is scaled to fit
|
|
|
586
|
+ * the view and enables the user to change the scale. The default value
|
|
|
587
|
+ * is `true`.
|
|
|
588
|
+ *
|
|
|
589
|
+ * On iOS, when `useWebKit=true`, this prop will not work.
|
|
|
590
|
+ */
|
|
|
591
|
+ scalesPageToFit?: boolean;
|
|
|
592
|
+
|
|
|
593
|
+ /**
|
|
|
594
|
+ * Boolean that determines whether HTML5 audio and video requires the user
|
|
|
595
|
+ * to tap them before they start playing. The default value is `true`.
|
|
|
596
|
+ */
|
|
|
597
|
+ mediaPlaybackRequiresUserAction?: boolean;
|
|
|
598
|
+
|
|
|
599
|
+ /**
|
|
|
600
|
+ * List of origin strings to allow being navigated to. The strings allow
|
|
|
601
|
+ * wildcards and get matched against *just* the origin (not the full URL).
|
|
|
602
|
+ * If the user taps to navigate to a new page but the new page is not in
|
|
|
603
|
+ * this whitelist, we will open the URL in Safari.
|
|
|
604
|
+ * The default whitelisted origins are "http://*" and "https://*".
|
|
|
605
|
+ */
|
|
|
606
|
+ originWhitelist: string[];
|
|
|
607
|
+
|
|
|
608
|
+ /**
|
|
|
609
|
+ * Function that allows custom handling of any web view requests. Return
|
|
|
610
|
+ * `true` from the function to continue loading the request and `false`
|
|
|
611
|
+ * to stop loading. The `navigationType` is always `other` on android.
|
|
|
612
|
+ */
|
|
|
613
|
+ onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest;
|
|
|
614
|
+
|
|
|
615
|
+ /**
|
|
|
616
|
+ * Override the native component used to render the WebView. Enables a custom native
|
|
|
617
|
+ * WebView which uses the same JavaScript as the original WebView.
|
|
|
618
|
+ */
|
|
|
619
|
+ nativeConfig?: WebViewNativeConfig;
|
|
|
620
|
+
|
|
|
621
|
+ /**
|
|
|
622
|
+ * Should caching be enabled. Default is true.
|
|
|
623
|
+ */
|
|
|
624
|
+ cacheEnabled?: boolean;
|
|
|
625
|
+
|
|
|
626
|
+ style?: StyleProp<ViewStyle>;
|
|
|
627
|
+ children: ReactNode;
|
|
|
628
|
+}
|