@javascriptcommon/react-native-webview 13.12.16

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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -0
  3. package/android/build.gradle +110 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +15 -0
  6. package/android/src/main/AndroidManifestNew.xml +13 -0
  7. package/android/src/main/java/com/reactnativecommunity/webview/RNCBasicAuthCredential.java +11 -0
  8. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +372 -0
  9. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java +450 -0
  10. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java +328 -0
  11. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewConfig.java +11 -0
  12. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java +14 -0
  13. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +720 -0
  14. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewMessagingModule.kt +19 -0
  15. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java +554 -0
  16. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java +56 -0
  17. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewWrapper.kt +39 -0
  18. package/android/src/main/java/com/reactnativecommunity/webview/URLUtil.java +179 -0
  19. package/android/src/main/java/com/reactnativecommunity/webview/events/TopCustomMenuSelectionEvent.kt +24 -0
  20. package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +25 -0
  21. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingErrorEvent.kt +25 -0
  22. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt +24 -0
  23. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt +24 -0
  24. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingStartEvent.kt +25 -0
  25. package/android/src/main/java/com/reactnativecommunity/webview/events/TopMessageEvent.kt +24 -0
  26. package/android/src/main/java/com/reactnativecommunity/webview/events/TopNewWindowEvent.kt +25 -0
  27. package/android/src/main/java/com/reactnativecommunity/webview/events/TopRenderProcessGoneEvent.kt +26 -0
  28. package/android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.kt +29 -0
  29. package/android/src/main/res/xml/file_provider_paths.xml +6 -0
  30. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java +553 -0
  31. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java +63 -0
  32. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java +328 -0
  33. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java +59 -0
  34. package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
  35. package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
  36. package/apple/RNCWKProcessPoolManager.h +15 -0
  37. package/apple/RNCWKProcessPoolManager.m +36 -0
  38. package/apple/RNCWebView.h +35 -0
  39. package/apple/RNCWebView.mm +546 -0
  40. package/apple/RNCWebViewDecisionManager.h +20 -0
  41. package/apple/RNCWebViewDecisionManager.m +47 -0
  42. package/apple/RNCWebViewImpl.h +161 -0
  43. package/apple/RNCWebViewImpl.m +1979 -0
  44. package/apple/RNCWebViewManager.h +9 -0
  45. package/apple/RNCWebViewManager.mm +215 -0
  46. package/apple/RNCWebViewModule.h +23 -0
  47. package/apple/RNCWebViewModule.mm +34 -0
  48. package/index.d.ts +65 -0
  49. package/index.js +4 -0
  50. package/ios/RNCWebView.xcodeproj/project.pbxproj +273 -0
  51. package/lib/NativeRNCWebViewModule.d.ts +10 -0
  52. package/lib/NativeRNCWebViewModule.js +1 -0
  53. package/lib/RNCWebViewNativeComponent.d.ts +242 -0
  54. package/lib/RNCWebViewNativeComponent.js +1 -0
  55. package/lib/WebView.android.d.ts +6 -0
  56. package/lib/WebView.android.js +1 -0
  57. package/lib/WebView.d.ts +6 -0
  58. package/lib/WebView.ios.d.ts +6 -0
  59. package/lib/WebView.ios.js +1 -0
  60. package/lib/WebView.js +1 -0
  61. package/lib/WebView.macos.d.ts +6 -0
  62. package/lib/WebView.macos.js +1 -0
  63. package/lib/WebView.styles.d.ts +38 -0
  64. package/lib/WebView.styles.js +1 -0
  65. package/lib/WebView.windows.d.ts +17 -0
  66. package/lib/WebView.windows.js +1 -0
  67. package/lib/WebViewNativeComponent.macos.d.ts +3 -0
  68. package/lib/WebViewNativeComponent.macos.js +1 -0
  69. package/lib/WebViewNativeComponent.windows.d.ts +3 -0
  70. package/lib/WebViewNativeComponent.windows.js +1 -0
  71. package/lib/WebViewShared.d.ts +38 -0
  72. package/lib/WebViewShared.js +1 -0
  73. package/lib/WebViewTypes.d.ts +1093 -0
  74. package/lib/WebViewTypes.js +1 -0
  75. package/lib/index.d.ts +3 -0
  76. package/lib/index.js +1 -0
  77. package/macos/RNCWebView.xcodeproj/project.pbxproj +363 -0
  78. package/package.json +101 -0
  79. package/react-native-webview.podspec +46 -0
  80. package/react-native.config.js +44 -0
  81. package/src/NativeRNCWebViewModule.ts +15 -0
  82. package/src/RNCWebViewNativeComponent.ts +342 -0
  83. package/src/WebView.android.tsx +317 -0
  84. package/src/WebView.ios.tsx +299 -0
  85. package/src/WebView.macos.tsx +245 -0
  86. package/src/WebView.styles.ts +41 -0
  87. package/src/WebView.tsx +25 -0
  88. package/src/WebView.windows.tsx +210 -0
  89. package/src/WebViewNativeComponent.macos.ts +7 -0
  90. package/src/WebViewNativeComponent.windows.ts +8 -0
  91. package/src/WebViewShared.tsx +283 -0
  92. package/src/WebViewTypes.ts +1332 -0
  93. package/src/__tests__/WebViewShared-test.js +323 -0
  94. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
  95. package/src/index.ts +4 -0
  96. package/windows/ExperimentalFeatures.props +11 -0
  97. package/windows/ReactNativeWebView/PropertySheet.props +16 -0
  98. package/windows/ReactNativeWebView/ReactNativeWebView.def +3 -0
  99. package/windows/ReactNativeWebView/ReactNativeWebView.filters +33 -0
  100. package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +189 -0
  101. package/windows/ReactNativeWebView/ReactPackageProvider.cpp +26 -0
  102. package/windows/ReactNativeWebView/ReactPackageProvider.h +20 -0
  103. package/windows/ReactNativeWebView/ReactPackageProvider.idl +7 -0
  104. package/windows/ReactNativeWebView/ReactWebView.cpp +242 -0
  105. package/windows/ReactNativeWebView/ReactWebView.h +56 -0
  106. package/windows/ReactNativeWebView/ReactWebView.idl +31 -0
  107. package/windows/ReactNativeWebView/ReactWebView2.cpp +473 -0
  108. package/windows/ReactNativeWebView/ReactWebView2.h +91 -0
  109. package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +205 -0
  110. package/windows/ReactNativeWebView/ReactWebView2Manager.h +57 -0
  111. package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
  112. package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
  113. package/windows/ReactNativeWebView/ReactWebViewManager.cpp +224 -0
  114. package/windows/ReactNativeWebView/ReactWebViewManager.h +58 -0
  115. package/windows/ReactNativeWebView/WebBridge.cpp +19 -0
  116. package/windows/ReactNativeWebView/WebBridge.h +24 -0
  117. package/windows/ReactNativeWebView/WebBridge.idl +11 -0
  118. package/windows/ReactNativeWebView/pch.cpp +1 -0
  119. package/windows/ReactNativeWebView/pch.h +37 -0
  120. package/windows/ReactNativeWebView.sln +185 -0
@@ -0,0 +1,1332 @@
1
+ import { ReactElement, Component, ComponentProps } from 'react';
2
+ import {
3
+ NativeSyntheticEvent,
4
+ ViewProps,
5
+ StyleProp,
6
+ ViewStyle,
7
+ NativeMethodsMixin,
8
+ UIManagerStatic,
9
+ NativeScrollEvent,
10
+ } from 'react-native';
11
+
12
+ import type NativeWebViewComponent from './RNCWebViewNativeComponent';
13
+
14
+ type WebViewCommands =
15
+ | 'goForward'
16
+ | 'goBack'
17
+ | 'reload'
18
+ | 'stopLoading'
19
+ | 'postMessage'
20
+ | 'injectJavaScript'
21
+ | 'loadUrl'
22
+ | 'requestFocus'
23
+ | 'clearCache';
24
+
25
+ type AndroidWebViewCommands = 'clearHistory' | 'clearFormData';
26
+
27
+ interface RNCWebViewUIManager<Commands extends string> extends UIManagerStatic {
28
+ getViewManagerConfig: (name: string) => {
29
+ Commands: { [key in Commands]: number };
30
+ };
31
+ }
32
+
33
+ export type RNCWebViewUIManagerAndroid = RNCWebViewUIManager<
34
+ WebViewCommands | AndroidWebViewCommands
35
+ >;
36
+ export type RNCWebViewUIManagerIOS = RNCWebViewUIManager<WebViewCommands>;
37
+ export type RNCWebViewUIManagerMacOS = RNCWebViewUIManager<WebViewCommands>;
38
+ export type RNCWebViewUIManagerWindows = RNCWebViewUIManager<WebViewCommands>;
39
+
40
+ type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
41
+
42
+ interface BaseState {
43
+ viewState: WebViewState;
44
+ }
45
+
46
+ interface NormalState extends BaseState {
47
+ viewState: 'IDLE' | 'LOADING';
48
+ lastErrorEvent: WebViewError | null;
49
+ }
50
+
51
+ interface ErrorState extends BaseState {
52
+ viewState: 'ERROR';
53
+ lastErrorEvent: WebViewError;
54
+ }
55
+
56
+ export type State = NormalState | ErrorState;
57
+
58
+ type Constructor<T> = new (...args: any[]) => T;
59
+
60
+ declare class NativeWebViewMacOSComponent extends Component<MacOSNativeWebViewProps> {}
61
+ declare const NativeWebViewMacOSBase: Constructor<NativeMethodsMixin> &
62
+ typeof NativeWebViewMacOSComponent;
63
+ export class NativeWebViewMacOS extends NativeWebViewMacOSBase {}
64
+
65
+ declare class NativeWebViewWindowsComponent extends Component<WindowsNativeWebViewProps> {}
66
+ declare const NativeWebViewWindowsBase: Constructor<NativeMethodsMixin> &
67
+ typeof NativeWebViewWindowsComponent;
68
+ export class NativeWebViewWindows extends NativeWebViewWindowsBase {}
69
+
70
+ export interface ContentInsetProp {
71
+ top?: number;
72
+ left?: number;
73
+ bottom?: number;
74
+ right?: number;
75
+ }
76
+
77
+ export interface WebViewNativeEvent {
78
+ url: string;
79
+ loading: boolean;
80
+ title: string;
81
+ canGoBack: boolean;
82
+ canGoForward: boolean;
83
+ lockIdentifier: number;
84
+ }
85
+
86
+ export interface WebViewNativeProgressEvent extends WebViewNativeEvent {
87
+ progress: number;
88
+ }
89
+
90
+ export interface WebViewNavigation extends WebViewNativeEvent {
91
+ navigationType:
92
+ | 'click'
93
+ | 'formsubmit'
94
+ | 'backforward'
95
+ | 'reload'
96
+ | 'formresubmit'
97
+ | 'other';
98
+ mainDocumentURL?: string;
99
+ }
100
+
101
+ export interface ShouldStartLoadRequest extends WebViewNavigation {
102
+ isTopFrame: boolean;
103
+ }
104
+
105
+ export interface FileDownload {
106
+ downloadUrl: string;
107
+ }
108
+
109
+ export type DecelerationRateConstant = 'normal' | 'fast';
110
+
111
+ export interface WebViewMessage extends WebViewNativeEvent {
112
+ data: string;
113
+ }
114
+
115
+ export interface WebViewError extends WebViewNativeEvent {
116
+ /**
117
+ * `domain` is only used on iOS and macOS
118
+ */
119
+ domain?: string;
120
+ code: number;
121
+ description: string;
122
+ }
123
+
124
+ export interface WebViewHttpError extends WebViewNativeEvent {
125
+ description: string;
126
+ statusCode: number;
127
+ }
128
+
129
+ export interface WebViewRenderProcessGoneDetail {
130
+ didCrash: boolean;
131
+ }
132
+
133
+ export interface WebViewOpenWindow {
134
+ targetUrl: string;
135
+ }
136
+
137
+ export type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
138
+
139
+ export type WebViewProgressEvent =
140
+ NativeSyntheticEvent<WebViewNativeProgressEvent>;
141
+
142
+ export type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
143
+
144
+ export type ShouldStartLoadRequestEvent =
145
+ NativeSyntheticEvent<ShouldStartLoadRequest>;
146
+
147
+ export type FileDownloadEvent = NativeSyntheticEvent<FileDownload>;
148
+
149
+ export type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
150
+
151
+ export type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
152
+
153
+ export type WebViewTerminatedEvent = NativeSyntheticEvent<WebViewNativeEvent>;
154
+
155
+ export type WebViewHttpErrorEvent = NativeSyntheticEvent<WebViewHttpError>;
156
+
157
+ export type WebViewRenderProcessGoneEvent =
158
+ NativeSyntheticEvent<WebViewRenderProcessGoneDetail>;
159
+
160
+ export type WebViewOpenWindowEvent = NativeSyntheticEvent<WebViewOpenWindow>;
161
+
162
+ export type WebViewScrollEvent = NativeSyntheticEvent<NativeScrollEvent>;
163
+
164
+ export type DataDetectorTypes =
165
+ | 'phoneNumber'
166
+ | 'link'
167
+ | 'address'
168
+ | 'calendarEvent'
169
+ | 'trackingNumber'
170
+ | 'flightNumber'
171
+ | 'lookupSuggestion'
172
+ | 'none'
173
+ | 'all';
174
+
175
+ export type OverScrollModeType = 'always' | 'content' | 'never';
176
+
177
+ export type CacheMode =
178
+ | 'LOAD_DEFAULT'
179
+ | 'LOAD_CACHE_ONLY'
180
+ | 'LOAD_CACHE_ELSE_NETWORK'
181
+ | 'LOAD_NO_CACHE';
182
+
183
+ export type AndroidLayerType = 'none' | 'software' | 'hardware';
184
+
185
+ export interface WebViewSourceUri {
186
+ /**
187
+ * The URI to load in the `WebView`. Can be a local or remote file.
188
+ */
189
+ uri: string;
190
+
191
+ /**
192
+ * The HTTP Method to use. Defaults to GET if not specified.
193
+ * NOTE: On Android, only GET and POST are supported.
194
+ */
195
+ method?: string;
196
+
197
+ /**
198
+ * Additional HTTP headers to send with the request.
199
+ * NOTE: On Android, this can only be used with GET requests.
200
+ */
201
+ headers?: Object;
202
+
203
+ /**
204
+ * The HTTP body to send with the request. This must be a valid
205
+ * UTF-8 string, and will be sent exactly as specified, with no
206
+ * additional encoding (e.g. URL-escaping or base64) applied.
207
+ * NOTE: On Android, this can only be used with POST requests.
208
+ */
209
+ body?: string;
210
+ }
211
+
212
+ export interface WebViewSourceHtml {
213
+ /**
214
+ * A static HTML page to display in the WebView.
215
+ */
216
+ html: string;
217
+ /**
218
+ * The base URL to be used for any relative links in the HTML.
219
+ */
220
+ baseUrl?: string;
221
+ }
222
+
223
+ export interface WebViewCustomMenuItems {
224
+ /**
225
+ * The unique key that will be added as a selector on the webview
226
+ * Returned by the `onCustomMenuSelection` callback
227
+ */
228
+ key: string;
229
+ /**
230
+ * The label to appear on the UI Menu when selecting text
231
+ */
232
+ label: string;
233
+ }
234
+
235
+ export declare type SuppressMenuItem =
236
+ | 'cut'
237
+ | 'copy'
238
+ | 'paste'
239
+ | 'replace'
240
+ | 'bold'
241
+ | 'italic'
242
+ | 'underline'
243
+ | 'select'
244
+ | 'selectAll'
245
+ | 'translate'
246
+ | 'lookup'
247
+ | 'share';
248
+
249
+ export type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
250
+
251
+ export interface ViewManager {
252
+ shouldStartLoadWithLockIdentifier: Function;
253
+ }
254
+
255
+ export interface WebViewNativeConfig {
256
+ /**
257
+ * The native component used to render the WebView.
258
+ */
259
+ component?: typeof NativeWebViewMacOS | typeof NativeWebViewComponent;
260
+ /**
261
+ * Set props directly on the native component WebView. Enables custom props which the
262
+ * original WebView doesn't pass through.
263
+ */
264
+ props?: Object;
265
+ /**
266
+ * Set the ViewManager to use for communication with the native side.
267
+ * @platform ios, macos
268
+ */
269
+ viewManager?: ViewManager;
270
+ }
271
+
272
+ export type OnShouldStartLoadWithRequest = (
273
+ event: ShouldStartLoadRequest
274
+ ) => boolean;
275
+
276
+ export interface BasicAuthCredential {
277
+ /**
278
+ * A username used for basic authentication.
279
+ */
280
+ username: string;
281
+
282
+ /**
283
+ * A password used for basic authentication.
284
+ */
285
+ password: string;
286
+ }
287
+
288
+ export interface CommonNativeWebViewProps extends ViewProps {
289
+ cacheEnabled?: boolean;
290
+ incognito?: boolean;
291
+ injectedJavaScript?: string;
292
+ injectedJavaScriptBeforeContentLoaded?: string;
293
+ injectedJavaScriptForMainFrameOnly?: boolean;
294
+ injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
295
+ javaScriptCanOpenWindowsAutomatically?: boolean;
296
+ mediaPlaybackRequiresUserAction?: boolean;
297
+ webviewDebuggingEnabled?: boolean;
298
+ messagingEnabled: boolean;
299
+ onScroll?: (event: WebViewScrollEvent) => void;
300
+ onLoadingError: (event: WebViewErrorEvent) => void;
301
+ onLoadingFinish: (event: WebViewNavigationEvent) => void;
302
+ onLoadingProgress: (event: WebViewProgressEvent) => void;
303
+ onLoadingStart: (event: WebViewNavigationEvent) => void;
304
+ onHttpError: (event: WebViewHttpErrorEvent) => void;
305
+ onMessage: (event: WebViewMessageEvent) => void;
306
+ onShouldStartLoadWithRequest: (event: ShouldStartLoadRequestEvent) => void;
307
+ showsHorizontalScrollIndicator?: boolean;
308
+ showsVerticalScrollIndicator?: boolean;
309
+ // TODO: find a better way to type this.
310
+
311
+ source: any;
312
+ userAgent?: string;
313
+ /**
314
+ * Append to the existing user-agent. Overridden if `userAgent` is set.
315
+ */
316
+ applicationNameForUserAgent?: string;
317
+ basicAuthCredential?: BasicAuthCredential;
318
+ }
319
+
320
+ export declare type ContentInsetAdjustmentBehavior =
321
+ | 'automatic'
322
+ | 'scrollableAxes'
323
+ | 'never'
324
+ | 'always';
325
+
326
+ export declare type MediaCapturePermissionGrantType =
327
+ | 'grantIfSameHostElsePrompt'
328
+ | 'grantIfSameHostElseDeny'
329
+ | 'deny'
330
+ | 'grant'
331
+ | 'prompt';
332
+
333
+ export declare type ContentMode = 'recommended' | 'mobile' | 'desktop';
334
+
335
+ export interface MacOSNativeWebViewProps extends CommonNativeWebViewProps {
336
+ allowingReadAccessToURL?: string;
337
+ allowFileAccessFromFileURLs?: boolean;
338
+ allowUniversalAccessFromFileURLs?: boolean;
339
+ allowsBackForwardNavigationGestures?: boolean;
340
+ allowsInlineMediaPlayback?: boolean;
341
+ allowsPictureInPictureMediaPlayback?: boolean;
342
+ allowsAirPlayForMediaPlayback?: boolean;
343
+ allowsLinkPreview?: boolean;
344
+ automaticallyAdjustContentInsets?: boolean;
345
+ bounces?: boolean;
346
+ contentInset?: ContentInsetProp;
347
+ contentInsetAdjustmentBehavior?: ContentInsetAdjustmentBehavior;
348
+ directionalLockEnabled?: boolean;
349
+ hideKeyboardAccessoryView?: boolean;
350
+ javaScriptEnabled?: boolean;
351
+ pagingEnabled?: boolean;
352
+ scrollEnabled?: boolean;
353
+ useSharedProcessPool?: boolean;
354
+ onContentProcessDidTerminate?: (event: WebViewTerminatedEvent) => void;
355
+ }
356
+
357
+ export interface WindowsNativeWebViewProps extends CommonNativeWebViewProps {
358
+ testID?: string;
359
+ linkHandlingEnabled?: boolean;
360
+ onOpenWindow?: (event: WebViewOpenWindowEvent) => void;
361
+ onSourceChanged?: (event: WebViewNavigationEvent) => void;
362
+ }
363
+
364
+ export interface WindowsWebViewProps extends WebViewSharedProps {
365
+ /**
366
+ * Boolean value that detenmines whether the web view should use the new chromium based edge webview.
367
+ */
368
+ useWebView2?: boolean;
369
+ /**
370
+ * Function that is invoked when the `WebView` should open a new window.
371
+ *
372
+ * This happens when the JS calls `window.open('http://someurl', '_blank')`
373
+ * or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
374
+ *
375
+ * Only works with `useWebView2` set to `true`.
376
+ *
377
+ * @platform windows
378
+ */
379
+ onOpenWindow?: (event: WebViewOpenWindowEvent) => void;
380
+
381
+ /**
382
+ * Function that is invoked when the `WebView` responds to a request to load a new resource.
383
+ * Works only on Windows.
384
+ *
385
+ * Only works with `useWebView2` set to `true`.
386
+ *
387
+ * @platform windows
388
+ */
389
+ onSourceChanged?: (event: WebViewNavigationEvent) => void;
390
+ }
391
+
392
+ export interface IOSWebViewProps extends WebViewSharedProps {
393
+ /**
394
+ * Does not store any data within the lifetime of the WebView.
395
+ */
396
+ incognito?: boolean;
397
+
398
+ /**
399
+ * Boolean value that determines whether the web view bounces
400
+ * when it reaches the edge of the content. The default value is `true`.
401
+ * @platform ios
402
+ */
403
+ bounces?: boolean;
404
+
405
+ /**
406
+ * A floating-point number that determines how quickly the scroll view
407
+ * decelerates after the user lifts their finger. You may also use the
408
+ * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
409
+ * settings for `UIScrollViewDecelerationRateNormal` and
410
+ * `UIScrollViewDecelerationRateFast` respectively:
411
+ *
412
+ * - normal: 0.998
413
+ * - fast: 0.99 (the default for iOS web view)
414
+ * @platform ios
415
+ */
416
+ decelerationRate?: DecelerationRateConstant | number;
417
+
418
+ /**
419
+ * Boolean value that determines whether scrolling is enabled in the
420
+ * `WebView`. The default value is `true`.
421
+ * @platform ios
422
+ */
423
+ scrollEnabled?: boolean;
424
+
425
+ /**
426
+ * If the value of this property is true, the scroll view stops on multiples
427
+ * of the scroll view’s bounds when the user scrolls.
428
+ * The default value is false.
429
+ * @platform ios
430
+ */
431
+ pagingEnabled?: boolean;
432
+
433
+ /**
434
+ * Controls whether to adjust the content inset for web views that are
435
+ * placed behind a navigation bar, tab bar, or toolbar. The default value
436
+ * is `true`.
437
+ * @platform ios
438
+ */
439
+ automaticallyAdjustContentInsets?: boolean;
440
+
441
+ /**
442
+ * Controls whether to adjust the scroll indicator inset for web views that are
443
+ * placed behind a navigation bar, tab bar, or toolbar. The default value
444
+ * is `false`. (iOS 13+)
445
+ * @platform ios
446
+ */
447
+ automaticallyAdjustsScrollIndicatorInsets?: boolean;
448
+
449
+ /**
450
+ * This property specifies how the safe area insets are used to modify the
451
+ * content area of the scroll view. The default value of this property is
452
+ * "never". Available on iOS 11 and later.
453
+ */
454
+ contentInsetAdjustmentBehavior?: ContentInsetAdjustmentBehavior;
455
+
456
+ /**
457
+ * The amount by which the web view content is inset from the edges of
458
+ * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
459
+ * @platform ios
460
+ */
461
+ contentInset?: ContentInsetProp;
462
+
463
+ /**
464
+ * Defaults to `recommended`, which loads mobile content on iPhone
465
+ * and iPad Mini but desktop content on other iPads.
466
+ *
467
+ * Possible values are:
468
+ * - `'recommended'`
469
+ * - `'mobile'`
470
+ * - `'desktop'`
471
+ * @platform ios
472
+ */
473
+ contentMode?: ContentMode;
474
+
475
+ /**
476
+ * Determines the types of data converted to clickable URLs in the web view's content.
477
+ * By default only phone numbers are detected.
478
+ *
479
+ * You can provide one type or an array of many types.
480
+ *
481
+ * Possible values for `dataDetectorTypes` are:
482
+ *
483
+ * - `'phoneNumber'`
484
+ * - `'link'`
485
+ * - `'address'`
486
+ * - `'calendarEvent'`
487
+ * - `'none'`
488
+ * - `'all'`
489
+ *
490
+ * With the new WebKit implementation, we have three new values:
491
+ * - `'trackingNumber'`,
492
+ * - `'flightNumber'`,
493
+ * - `'lookupSuggestion'`,
494
+ *
495
+ * @platform ios
496
+ */
497
+ readonly dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
498
+
499
+ /**
500
+ * Boolean that determines whether HTML5 videos play inline or use the
501
+ * native full-screen controller. The default value is `false`.
502
+ *
503
+ * **NOTE** : In order for video to play inline, not only does this
504
+ * property need to be set to `true`, but the video element in the HTML
505
+ * document must also include the `webkit-playsinline` attribute.
506
+ * @platform ios
507
+ */
508
+ allowsInlineMediaPlayback?: boolean;
509
+ /**
510
+ * Boolean value that indicates whether HTML5 videos can play Picture in Picture.
511
+ * The default value is `true`.
512
+ *
513
+ * @platform macos
514
+ */
515
+ allowsPictureInPictureMediaPlayback?: boolean;
516
+ /**
517
+ * A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
518
+ * @platform ios
519
+ */
520
+ allowsAirPlayForMediaPlayback?: boolean;
521
+ /**
522
+ * Hide the accessory view when the keyboard is open. Default is false to be
523
+ * backward compatible.
524
+ */
525
+ hideKeyboardAccessoryView?: boolean;
526
+ /**
527
+ * A Boolean value indicating whether horizontal swipe gestures will trigger
528
+ * back-forward list navigations.
529
+ */
530
+ allowsBackForwardNavigationGestures?: boolean;
531
+ /**
532
+ * A Boolean value indicating whether WebKit WebView should be created using a shared
533
+ * process pool, enabling WebViews to share cookies and localStorage between each other.
534
+ * Default is true but can be set to false for backwards compatibility.
535
+ * @platform ios
536
+ */
537
+ useSharedProcessPool?: boolean;
538
+
539
+ /**
540
+ * The custom user agent string.
541
+ * @platform ios
542
+ */
543
+ userAgent?: string;
544
+
545
+ /**
546
+ * A Boolean value that determines whether pressing on a link
547
+ * displays a preview of the destination for the link.
548
+ *
549
+ * This property is available on devices that support 3D Touch.
550
+ * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
551
+ * @platform ios
552
+ */
553
+ allowsLinkPreview?: boolean;
554
+
555
+ /**
556
+ * Set true if shared cookies from HTTPCookieStorage should used for every load request.
557
+ * The default value is `false`.
558
+ * @platform ios
559
+ */
560
+ sharedCookiesEnabled?: boolean;
561
+
562
+ /**
563
+ * When set to true the hardware silent switch is ignored.
564
+ * The default value is `false`.
565
+ * @platform ios
566
+ */
567
+ ignoreSilentHardwareSwitch?: boolean;
568
+
569
+ /**
570
+ * Set true if StatusBar should be light when user watch video fullscreen.
571
+ * The default value is `true`.
572
+ * @platform ios
573
+ */
574
+ autoManageStatusBarEnabled?: boolean;
575
+
576
+ /**
577
+ * A Boolean value that determines whether scrolling is disabled in a particular direction.
578
+ * The default value is `true`.
579
+ * @platform ios
580
+ */
581
+ directionalLockEnabled?: boolean;
582
+
583
+ /**
584
+ * A Boolean value indicating whether web content can programmatically display the keyboard.
585
+ *
586
+ * When this property is set to true, the user must explicitly tap the elements in the
587
+ * web view to display the keyboard (or other relevant input view) for that element.
588
+ * When set to false, a focus event on an element causes the input view to be displayed
589
+ * and associated with that element automatically.
590
+ *
591
+ * The default value is `true`.
592
+ * @platform ios
593
+ */
594
+ keyboardDisplayRequiresUserAction?: boolean;
595
+
596
+ /**
597
+ * A String value that indicates which URLs the WebView's file can then
598
+ * reference in scripts, AJAX requests, and CSS imports. This is only used
599
+ * for WebViews that are loaded with a source.uri set to a `'file://'` URL.
600
+ *
601
+ * If not provided, the default is to only allow read access to the URL
602
+ * provided in source.uri itself.
603
+ * @platform ios
604
+ */
605
+ allowingReadAccessToURL?: string;
606
+
607
+ /**
608
+ * Boolean that sets whether JavaScript running in the context of a file
609
+ * scheme URL should be allowed to access content from other file scheme URLs.
610
+ * Including accessing content from other file scheme URLs
611
+ * @platform ios
612
+ */
613
+ allowFileAccessFromFileURLs?: boolean;
614
+
615
+ /**
616
+ * Boolean that sets whether JavaScript running in the context of a file
617
+ * scheme URL should be allowed to access content from any origin.
618
+ * Including accessing content from other file scheme URLs
619
+ * @platform ios
620
+ */
621
+ allowUniversalAccessFromFileURLs?: boolean;
622
+
623
+ /**
624
+ * Function that is invoked when the WebKit WebView content process gets terminated.
625
+ * @platform ios
626
+ */
627
+ onContentProcessDidTerminate?: (event: WebViewTerminatedEvent) => void;
628
+
629
+ /**
630
+ * Function that is invoked when the `WebView` should open a new window.
631
+ *
632
+ * This happens when the JS calls `window.open('http://someurl', '_blank')`
633
+ * or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
634
+ *
635
+ * @platform ios
636
+ */
637
+ onOpenWindow?: (event: WebViewOpenWindowEvent) => void;
638
+
639
+ /**
640
+ * If `true` (default), loads the `injectedJavaScript` only into the main frame.
641
+ * If `false`, loads it into all frames (e.g. iframes).
642
+ * @platform ios
643
+ */
644
+ injectedJavaScriptForMainFrameOnly?: boolean;
645
+
646
+ /**
647
+ * If `true` (default), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame.
648
+ * If `false`, loads it into all frames (e.g. iframes).
649
+ * @platform ios
650
+ */
651
+ injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
652
+
653
+ /**
654
+ * Boolean value that determines whether a pull to refresh gesture is
655
+ * available in the `WebView`. The default value is `false`.
656
+ * If `true`, sets `bounces` automatically to `true`
657
+ * @platform ios
658
+ *
659
+ */
660
+ pullToRefreshEnabled?: boolean;
661
+
662
+ /**
663
+ * Boolean value that determines whether a pull to refresh gesture is
664
+ * available in the `WebView`. The default value is `false`.
665
+ * If `true`, sets `bounces` automatically to `true`
666
+ * @platform ios
667
+ *
668
+ */
669
+ refreshControlLightMode?: boolean;
670
+
671
+ /**
672
+ * Function that is invoked when the client needs to download a file.
673
+ *
674
+ * iOS 13+ only: If the webview navigates to a URL that results in an HTTP
675
+ * response with a Content-Disposition header 'attachment...', then
676
+ * this will be called.
677
+ *
678
+ * iOS 8+: If the MIME type indicates that the content is not renderable by the
679
+ * webview, that will also cause this to be called. On iOS versions before 13,
680
+ * this is the only condition that will cause this function to be called.
681
+ *
682
+ * The application will need to provide its own code to actually download
683
+ * the file.
684
+ *
685
+ * If not provided, the default is to let the webview try to render the file.
686
+ */
687
+ onFileDownload?: (event: FileDownloadEvent) => void;
688
+
689
+ /**
690
+ * A Boolean value which, when set to `true`, indicates to WebKit that a WKWebView
691
+ * will only navigate to app-bound domains. Once set, any attempt to navigate away
692
+ * from an app-bound domain will fail with the error “App-bound domain failure.”
693
+ *
694
+ * Applications can specify up to 10 “app-bound” domains using a new
695
+ * Info.plist key `WKAppBoundDomains`.
696
+ * @platform ios
697
+ */
698
+ limitsNavigationsToAppBoundDomains?: boolean;
699
+
700
+ /**
701
+ * If false indicates to WebKit that a WKWebView will not interact with text, thus
702
+ * not showing a text selection loop. Only applicable for iOS 14.5 or greater.
703
+ *
704
+ * Defaults to true.
705
+ * @platform ios
706
+ */
707
+ textInteractionEnabled?: boolean;
708
+
709
+ /**
710
+ * This property specifies how to handle media capture permission requests.
711
+ * Defaults to `prompt`, resulting in the user being prompted repeatedly.
712
+ * Available on iOS 15 and later.
713
+ */
714
+ mediaCapturePermissionGrantType?: MediaCapturePermissionGrantType;
715
+
716
+ /**
717
+ * A Boolean value which, when set to `true`, WebView will be rendered with Apple Pay support.
718
+ * Once set, websites will be able to invoke apple pay from React Native Webview.
719
+ * This comes with a cost features like `injectJavaScript`, html5 History,`sharedCookiesEnabled`,
720
+ * `injectedJavaScript`, `injectedJavaScriptBeforeContentLoaded` will not work
721
+ * {@link https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes#Payment-Request-API ApplePay Doc}
722
+ * if you require to send message to App , webpage has to explicitly call webkit message handler
723
+ * and receive it on `onMessage` handler on react native side
724
+ * @example
725
+ * window.webkit.messageHandlers.ReactNativeWebView.postMessage("hello apple pay")
726
+ * @platform ios
727
+ * The default value is false.
728
+ */
729
+ enableApplePay?: boolean;
730
+
731
+ /**
732
+ * An array of objects which will be shown when selecting text. An empty array will suppress the menu.
733
+ * These will appear after a long press to select text.
734
+ * @platform ios, android
735
+ */
736
+ menuItems?: WebViewCustomMenuItems[];
737
+
738
+ /**
739
+ * An array of strings which will be suppressed from the menu.
740
+ * @platform ios
741
+ */
742
+ suppressMenuItems?: SuppressMenuItem[];
743
+
744
+ /**
745
+ * The function fired when selecting a custom menu item created by `menuItems`.
746
+ * It passes a WebViewEvent with a `nativeEvent`, where custom keys are passed:
747
+ * `customMenuKey`: the string of the menu item
748
+ * `selectedText`: the text selected on the document
749
+ * @platform ios, android
750
+ */
751
+ onCustomMenuSelection?: (event: {
752
+ nativeEvent: {
753
+ label: string;
754
+ key: string;
755
+ selectedText: string;
756
+ };
757
+ }) => void;
758
+
759
+ /**
760
+ * A Boolean value that indicates whether the webview shows warnings for suspected
761
+ * fraudulent content, such as malware or phishing attempts.
762
+ * @platform ios
763
+ */
764
+ fraudulentWebsiteWarningEnabled?: boolean;
765
+ }
766
+
767
+ export interface MacOSWebViewProps extends WebViewSharedProps {
768
+ /**
769
+ * Does not store any data within the lifetime of the WebView.
770
+ */
771
+ incognito?: boolean;
772
+
773
+ /**
774
+ * Boolean value that determines whether the web view bounces
775
+ * when it reaches the edge of the content. The default value is `true`.
776
+ * @platform macos
777
+ */
778
+ bounces?: boolean;
779
+
780
+ /**
781
+ * Boolean value that determines whether scrolling is enabled in the
782
+ * `WebView`. The default value is `true`.
783
+ * @platform macos
784
+ */
785
+ scrollEnabled?: boolean;
786
+
787
+ /**
788
+ * If the value of this property is true, the scroll view stops on multiples
789
+ * of the scroll view’s bounds when the user scrolls.
790
+ * The default value is false.
791
+ * @platform macos
792
+ */
793
+ pagingEnabled?: boolean;
794
+
795
+ /**
796
+ * Controls whether to adjust the content inset for web views that are
797
+ * placed behind a navigation bar, tab bar, or toolbar. The default value
798
+ * is `true`.
799
+ * @platform macos
800
+ */
801
+ automaticallyAdjustContentInsets?: boolean;
802
+
803
+ /**
804
+ * This property specifies how the safe area insets are used to modify the
805
+ * content area of the scroll view. The default value of this property is
806
+ * "never". Available on iOS 11 and later.
807
+ */
808
+ contentInsetAdjustmentBehavior?: ContentInsetAdjustmentBehavior;
809
+
810
+ /**
811
+ * The amount by which the web view content is inset from the edges of
812
+ * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
813
+ * @platform macos
814
+ */
815
+ contentInset?: ContentInsetProp;
816
+
817
+ /**
818
+ * Boolean that determines whether HTML5 videos play inline or use the
819
+ * native full-screen controller. The default value is `false`.
820
+ *
821
+ * **NOTE** : In order for video to play inline, not only does this
822
+ * property need to be set to `true`, but the video element in the HTML
823
+ * document must also include the `webkit-playsinline` attribute.
824
+ * @platform macos
825
+ */
826
+ allowsInlineMediaPlayback?: boolean;
827
+ /**
828
+ * Boolean value that indicates whether HTML5 videos can play Picture in Picture.
829
+ * The default value is `true`.
830
+ *
831
+ * @platform ios
832
+ */
833
+ allowsPictureInPictureMediaPlayback?: boolean;
834
+ /**
835
+ * A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
836
+ * @platform macos
837
+ */
838
+ allowsAirPlayForMediaPlayback?: boolean;
839
+ /**
840
+ * Hide the accessory view when the keyboard is open. Default is false to be
841
+ * backward compatible.
842
+ */
843
+ hideKeyboardAccessoryView?: boolean;
844
+ /**
845
+ * A Boolean value indicating whether horizontal swipe gestures will trigger
846
+ * back-forward list navigations.
847
+ */
848
+ allowsBackForwardNavigationGestures?: boolean;
849
+ /**
850
+ * A Boolean value indicating whether WebKit WebView should be created using a shared
851
+ * process pool, enabling WebViews to share cookies and localStorage between each other.
852
+ * Default is true but can be set to false for backwards compatibility.
853
+ * @platform macos
854
+ */
855
+ useSharedProcessPool?: boolean;
856
+
857
+ /**
858
+ * The custom user agent string.
859
+ */
860
+ userAgent?: string;
861
+
862
+ /**
863
+ * A Boolean value that determines whether pressing on a link
864
+ * displays a preview of the destination for the link.
865
+ *
866
+ * This property is available on devices that support Force Touch trackpad.
867
+ * @platform macos
868
+ */
869
+ allowsLinkPreview?: boolean;
870
+
871
+ /**
872
+ * Set true if shared cookies from HTTPCookieStorage should used for every load request.
873
+ * The default value is `false`.
874
+ * @platform macos
875
+ */
876
+ sharedCookiesEnabled?: boolean;
877
+
878
+ /**
879
+ * A Boolean value that determines whether scrolling is disabled in a particular direction.
880
+ * The default value is `true`.
881
+ * @platform macos
882
+ */
883
+ directionalLockEnabled?: boolean;
884
+
885
+ /**
886
+ * A Boolean value indicating whether web content can programmatically display the keyboard.
887
+ *
888
+ * When this property is set to true, the user must explicitly tap the elements in the
889
+ * web view to display the keyboard (or other relevant input view) for that element.
890
+ * When set to false, a focus event on an element causes the input view to be displayed
891
+ * and associated with that element automatically.
892
+ *
893
+ * The default value is `true`.
894
+ * @platform macos
895
+ */
896
+ keyboardDisplayRequiresUserAction?: boolean;
897
+
898
+ /**
899
+ * A String value that indicates which URLs the WebView's file can then
900
+ * reference in scripts, AJAX requests, and CSS imports. This is only used
901
+ * for WebViews that are loaded with a source.uri set to a `'file://'` URL.
902
+ *
903
+ * If not provided, the default is to only allow read access to the URL
904
+ * provided in source.uri itself.
905
+ * @platform macos
906
+ */
907
+ allowingReadAccessToURL?: string;
908
+
909
+ /**
910
+ * Boolean that sets whether JavaScript running in the context of a file
911
+ * scheme URL should be allowed to access content from other file scheme URLs.
912
+ * Including accessing content from other file scheme URLs
913
+ * @platform macos
914
+ */
915
+ allowFileAccessFromFileURLs?: boolean;
916
+
917
+ /**
918
+ * Boolean that sets whether JavaScript running in the context of a file
919
+ * scheme URL should be allowed to access content from any origin.
920
+ * Including accessing content from other file scheme URLs
921
+ * @platform macos
922
+ */
923
+ allowUniversalAccessFromFileURLs?: boolean;
924
+
925
+ /**
926
+ * Function that is invoked when the WebKit WebView content process gets terminated.
927
+ * @platform macos
928
+ */
929
+ onContentProcessDidTerminate?: (event: WebViewTerminatedEvent) => void;
930
+ }
931
+
932
+ export interface AndroidWebViewProps extends WebViewSharedProps {
933
+ onNavigationStateChange?: (event: WebViewNavigation) => void;
934
+ onContentSizeChange?: (event: WebViewEvent) => void;
935
+
936
+ /**
937
+ * Function that is invoked when the `WebView` process crashes or is killed by the OS.
938
+ * Works only on Android (minimum API level 26).
939
+ */
940
+ onRenderProcessGone?: (event: WebViewRenderProcessGoneEvent) => void;
941
+
942
+ /**
943
+ * Function that is invoked when the `WebView` should open a new window.
944
+ *
945
+ * This happens when the JS calls `window.open('http://someurl', '_blank')`
946
+ * or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
947
+ *
948
+ * @platform android
949
+ */
950
+ onOpenWindow?: (event: WebViewOpenWindowEvent) => void;
951
+
952
+ /**
953
+ * https://developer.android.com/reference/android/webkit/WebSettings.html#setCacheMode(int)
954
+ * Set the cacheMode. Possible values are:
955
+ *
956
+ * - `'LOAD_DEFAULT'` (default)
957
+ * - `'LOAD_CACHE_ELSE_NETWORK'`
958
+ * - `'LOAD_NO_CACHE'`
959
+ * - `'LOAD_CACHE_ONLY'`
960
+ *
961
+ * @platform android
962
+ */
963
+ cacheMode?: CacheMode;
964
+
965
+ /**
966
+ * https://developer.android.com/reference/android/view/View#setOverScrollMode(int)
967
+ * Sets the overScrollMode. Possible values are:
968
+ *
969
+ * - `'always'` (default)
970
+ * - `'content'`
971
+ * - `'never'`
972
+ *
973
+ * @platform android
974
+ */
975
+ overScrollMode?: OverScrollModeType;
976
+
977
+ /**
978
+ * Boolean that controls whether the web content is scaled to fit
979
+ * the view and enables the user to change the scale. The default value
980
+ * is `true`.
981
+ */
982
+ scalesPageToFit?: boolean;
983
+
984
+ /**
985
+ * Sets whether Geolocation is enabled. The default is false.
986
+ * @platform android
987
+ */
988
+ geolocationEnabled?: boolean;
989
+
990
+ /**
991
+ * Boolean that sets whether JavaScript running in the context of a file
992
+ * scheme URL should be allowed to access content from other file scheme URLs.
993
+ * Including accessing content from other file scheme URLs
994
+ * @platform android
995
+ */
996
+ allowFileAccessFromFileURLs?: boolean;
997
+
998
+ /**
999
+ * Boolean that sets whether JavaScript running in the context of a file
1000
+ * scheme URL should be allowed to access content from any origin.
1001
+ * Including accessing content from other file scheme URLs
1002
+ * @platform android
1003
+ */
1004
+ allowUniversalAccessFromFileURLs?: boolean;
1005
+
1006
+ /**
1007
+ * Sets whether the webview allow access to file system.
1008
+ * @platform android
1009
+ */
1010
+ allowFileAccess?: boolean;
1011
+
1012
+ /**
1013
+ * Used on Android only, controls whether form autocomplete data should be saved
1014
+ * @platform android
1015
+ */
1016
+ saveFormDataDisabled?: boolean;
1017
+
1018
+ /**
1019
+ * Boolean value to set whether the WebView supports multiple windows. Used on Android only
1020
+ * The default value is `true`.
1021
+ * @platform android
1022
+ */
1023
+ setSupportMultipleWindows?: boolean;
1024
+
1025
+ /**
1026
+ * https://developer.android.com/reference/android/webkit/WebView#setLayerType(int,%20android.graphics.Paint)
1027
+ * Sets the layerType. Possible values are:
1028
+ *
1029
+ * - `'none'` (default)
1030
+ * - `'software'`
1031
+ * - `'hardware'`
1032
+ *
1033
+ * @platform android
1034
+ */
1035
+ androidLayerType?: AndroidLayerType;
1036
+
1037
+ /**
1038
+ * Boolean value to enable third party cookies in the `WebView`. Used on
1039
+ * Android Lollipop and above only as third party cookies are enabled by
1040
+ * default on Android Kitkat and below and on iOS. The default value is `true`.
1041
+ * @platform android
1042
+ */
1043
+ thirdPartyCookiesEnabled?: boolean;
1044
+
1045
+ /**
1046
+ * Boolean value to control whether DOM Storage is enabled. Used only in
1047
+ * Android.
1048
+ * @platform android
1049
+ */
1050
+ domStorageEnabled?: boolean;
1051
+
1052
+ /**
1053
+ * Sets the user-agent for the `WebView`.
1054
+ * @platform android
1055
+ */
1056
+ userAgent?: string;
1057
+
1058
+ /**
1059
+ * Sets number that controls text zoom of the page in percent.
1060
+ * @platform android
1061
+ */
1062
+ textZoom?: number;
1063
+
1064
+ /**
1065
+ * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
1066
+ *
1067
+ * Possible values for `mixedContentMode` are:
1068
+ *
1069
+ * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
1070
+ * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
1071
+ * - `'compatibility'` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
1072
+ * @platform android
1073
+ */
1074
+ mixedContentMode?: 'never' | 'always' | 'compatibility';
1075
+
1076
+ /**
1077
+ * Sets ability to open fullscreen videos on Android devices.
1078
+ */
1079
+ allowsFullscreenVideo?: boolean;
1080
+
1081
+ /**
1082
+ * Configuring Dark Theme
1083
+ *
1084
+ * *NOTE* : The force dark setting is not persistent. You must call the static method every time your app process is started.
1085
+ *
1086
+ * *NOTE* : The change from day<->night mode is a configuration change so by default the activity will be restarted
1087
+ * and pickup the new values to apply the theme.
1088
+ * Take care when overriding this default behavior to ensure this method is still called when changes are made.
1089
+ *
1090
+ * @platform android
1091
+ */
1092
+ forceDarkOn?: boolean;
1093
+
1094
+ /**
1095
+ * Boolean value to control whether pinch zoom is enabled. Used only in Android.
1096
+ * Default to true
1097
+ *
1098
+ * @platform android
1099
+ */
1100
+ setBuiltInZoomControls?: boolean;
1101
+
1102
+ /**
1103
+ * Boolean value to control whether built-in zooms controls are displayed. Used only in Android.
1104
+ * Default to false
1105
+ * Controls will always be hidden if setBuiltInZoomControls is set to `false`
1106
+ *
1107
+ * @platform android
1108
+ */
1109
+ setDisplayZoomControls?: boolean;
1110
+
1111
+ /**
1112
+ * Allows to scroll inside the webview when used inside a scrollview.
1113
+ * Behaviour already existing on iOS.
1114
+ * Default to false
1115
+ *
1116
+ * @platform android
1117
+ */
1118
+ nestedScrollEnabled?: boolean;
1119
+
1120
+ /**
1121
+ * Sets the minimum font size.
1122
+ * A non-negative integer between 1 and 72. Any number outside the specified range will be pinned.
1123
+ * Default is 8.
1124
+ * @platform android
1125
+ */
1126
+ minimumFontSize?: number;
1127
+
1128
+ /**
1129
+ * Sets the message to be shown in the toast when downloading via the webview.
1130
+ * Default is 'Downloading'.
1131
+ * @platform android
1132
+ */
1133
+ downloadingMessage?: string;
1134
+
1135
+ /**
1136
+ * Sets the message to be shown in the toast when webview is unable to download due to permissions issue.
1137
+ * Default is 'Cannot download files as permission was denied. Please provide permission to write to storage, in order to download files.'.
1138
+ * @platform android
1139
+ */
1140
+ lackPermissionToDownloadMessage?: string;
1141
+
1142
+ /**
1143
+ * Boolean value to control whether webview can play media protected by DRM.
1144
+ * Default is false.
1145
+ * @platform android
1146
+ */
1147
+ allowsProtectedMedia?: boolean;
1148
+ }
1149
+
1150
+ export interface WebViewSharedProps extends ViewProps {
1151
+ /**
1152
+ * Loads static html or a uri (with optional headers) in the WebView.
1153
+ */
1154
+ source?: WebViewSource;
1155
+
1156
+ /**
1157
+ * Boolean value to enable JavaScript in the `WebView`. Used on Android only
1158
+ * as JavaScript is enabled by default on iOS. The default value is `true`.
1159
+ * @platform android
1160
+ */
1161
+ javaScriptEnabled?: boolean;
1162
+
1163
+ /**
1164
+ * A Boolean value indicating whether JavaScript can open windows without user interaction.
1165
+ * The default value is `false`.
1166
+ */
1167
+ javaScriptCanOpenWindowsAutomatically?: boolean;
1168
+
1169
+ /**
1170
+ * Stylesheet object to set the style of the container view.
1171
+ */
1172
+ containerStyle?: StyleProp<ViewStyle>;
1173
+
1174
+ /**
1175
+ * Function that returns a view to show if there's an error.
1176
+ */
1177
+ renderError?: (
1178
+ errorDomain: string | undefined,
1179
+ errorCode: number,
1180
+ errorDesc: string
1181
+ ) => ReactElement; // view to show if there's an error
1182
+
1183
+ /**
1184
+ * Function that returns a loading indicator.
1185
+ */
1186
+ renderLoading?: () => ReactElement;
1187
+
1188
+ /**
1189
+ * Function that is invoked when the `WebView` scrolls.
1190
+ */
1191
+ onScroll?: ComponentProps<typeof NativeWebViewComponent>['onScroll'];
1192
+
1193
+ /**
1194
+ * Function that is invoked when the `WebView` has finished loading.
1195
+ */
1196
+ onLoad?: (event: WebViewNavigationEvent) => void;
1197
+
1198
+ /**
1199
+ * Function that is invoked when the `WebView` load succeeds or fails.
1200
+ */
1201
+ onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => void;
1202
+
1203
+ /**
1204
+ * Function that is invoked when the `WebView` starts loading.
1205
+ */
1206
+ onLoadStart?: (event: WebViewNavigationEvent) => void;
1207
+
1208
+ /**
1209
+ * Function that is invoked when the `WebView` load fails.
1210
+ */
1211
+ onError?: (event: WebViewErrorEvent) => void;
1212
+
1213
+ /**
1214
+ * Function that is invoked when the `WebView` receives an error status code.
1215
+ * Works on iOS and Android (minimum API level 23).
1216
+ */
1217
+ onHttpError?: (event: WebViewHttpErrorEvent) => void;
1218
+
1219
+ /**
1220
+ * Function that is invoked when the `WebView` loading starts or ends.
1221
+ */
1222
+ onNavigationStateChange?: (event: WebViewNavigation) => void;
1223
+
1224
+ /**
1225
+ * Function that is invoked when the webview calls `window.ReactNativeWebView.postMessage`.
1226
+ * Setting this property will inject this global into your webview.
1227
+ *
1228
+ * `window.ReactNativeWebView.postMessage` accepts one argument, `data`, which will be
1229
+ * available on the event object, `event.nativeEvent.data`. `data` must be a string.
1230
+ */
1231
+ onMessage?: (event: WebViewMessageEvent) => void;
1232
+
1233
+ /**
1234
+ * Function that is invoked when the `WebView` is loading.
1235
+ */
1236
+ onLoadProgress?: (event: WebViewProgressEvent) => void;
1237
+
1238
+ /**
1239
+ * Boolean value that forces the `WebView` to show the loading view
1240
+ * on the first load.
1241
+ */
1242
+ startInLoadingState?: boolean;
1243
+
1244
+ /**
1245
+ * Set this to provide JavaScript that will be injected into the web page
1246
+ * when the view loads.
1247
+ */
1248
+ injectedJavaScript?: string;
1249
+
1250
+ /**
1251
+ * Set this to provide JavaScript that will be injected into the web page
1252
+ * once the webview is initialized but before the view loads any content.
1253
+ */
1254
+ injectedJavaScriptBeforeContentLoaded?: string;
1255
+
1256
+ /**
1257
+ * If `true` (default; mandatory for Android), loads the `injectedJavaScript` only into the main frame.
1258
+ * If `false` (only supported on iOS and macOS), loads it into all frames (e.g. iframes).
1259
+ */
1260
+ injectedJavaScriptForMainFrameOnly?: boolean;
1261
+
1262
+ /**
1263
+ * If `true` (default; mandatory for Android), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame.
1264
+ * If `false` (only supported on iOS and macOS), loads it into all frames (e.g. iframes).
1265
+ */
1266
+ injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
1267
+
1268
+ /**
1269
+ * Boolean value that determines whether a horizontal scroll indicator is
1270
+ * shown in the `WebView`. The default value is `true`.
1271
+ */
1272
+ showsHorizontalScrollIndicator?: boolean;
1273
+
1274
+ /**
1275
+ * Boolean value that determines whether a vertical scroll indicator is
1276
+ * shown in the `WebView`. The default value is `true`.
1277
+ */
1278
+ showsVerticalScrollIndicator?: boolean;
1279
+
1280
+ /**
1281
+ * Boolean that determines whether HTML5 audio and video requires the user
1282
+ * to tap them before they start playing. The default value is `true`.
1283
+ */
1284
+ mediaPlaybackRequiresUserAction?: boolean;
1285
+
1286
+ /**
1287
+ * List of origin strings to allow being navigated to. The strings allow
1288
+ * wildcards and get matched against *just* the origin (not the full URL).
1289
+ * If the user taps to navigate to a new page but the new page is not in
1290
+ * this whitelist, we will open the URL in Safari.
1291
+ * The default whitelisted origins are "http://*" and "https://*".
1292
+ */
1293
+ readonly originWhitelist?: string[];
1294
+
1295
+ /**
1296
+ * Function that allows custom handling of any web view requests. Return
1297
+ * `true` from the function to continue loading the request and `false`
1298
+ * to stop loading. The `navigationType` is always `other` on android.
1299
+ */
1300
+ onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest;
1301
+
1302
+ /**
1303
+ * Override the native component used to render the WebView. Enables a custom native
1304
+ * WebView which uses the same JavaScript as the original WebView.
1305
+ */
1306
+ nativeConfig?: WebViewNativeConfig;
1307
+
1308
+ /**
1309
+ * Should caching be enabled. Default is true.
1310
+ */
1311
+ cacheEnabled?: boolean;
1312
+
1313
+ /**
1314
+ * Append to the existing user-agent. Overridden if `userAgent` is set.
1315
+ */
1316
+ applicationNameForUserAgent?: string;
1317
+
1318
+ /**
1319
+ * An object that specifies the credentials of a user to be used for basic authentication.
1320
+ */
1321
+ basicAuthCredential?: BasicAuthCredential;
1322
+
1323
+ /**
1324
+ * Inject a JavaScript object to be accessed as a JSON string via JavaScript in the WebView.
1325
+ */
1326
+ injectedJavaScriptObject?: object;
1327
+
1328
+ /**
1329
+ * Enables WebView remote debugging using Chrome (Android) or Safari (iOS).
1330
+ */
1331
+ webviewDebuggingEnabled?: boolean;
1332
+ }