react-native-webview.git

WebViewTypes.ts 21KB

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