Ei kuvausta

WebViewTypes.ts 21KB

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