react-native-webview.git

WebView.ios.d.ts 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React from 'react';
  2. import { NativeSyntheticEvent } from 'react-native';
  3. import { WebViewError, WebViewSharedProps, WebViewProgressEvent } from './types/WebViewTypes';
  4. declare enum WebViewState {
  5. IDLE = "IDLE",
  6. LOADING = "LOADING",
  7. ERROR = "ERROR"
  8. }
  9. declare enum NavigationType {
  10. click = "click",
  11. formsubmit = "formsubmit",
  12. backforward = "backforward",
  13. reload = "reload",
  14. formresubmit = "formresubmit",
  15. other = "other"
  16. }
  17. declare type State = {
  18. viewState: WebViewState;
  19. lastErrorEvent: WebViewError | null;
  20. };
  21. /**
  22. * `WebView` renders web content in a native view.
  23. *
  24. *```
  25. * import React, { Component } from 'react';
  26. * import { WebView } from 'react-native';
  27. *
  28. * class MyWeb extends Component {
  29. * render() {
  30. * return (
  31. * <WebView
  32. * source={{uri: 'https://github.com/facebook/react-native'}}
  33. * style={{marginTop: 20}}
  34. * />
  35. * );
  36. * }
  37. * }
  38. *```
  39. *
  40. * You can use this component to navigate back and forth in the web view's
  41. * history and configure various properties for the web content.
  42. */
  43. export default class WebView extends React.Component<WebViewSharedProps, State> {
  44. static JSNavigationScheme: string;
  45. static NavigationType: typeof NavigationType;
  46. static defaultProps: {
  47. useWebKit: boolean;
  48. originWhitelist: string[];
  49. };
  50. static isFileUploadSupported: () => Promise<boolean>;
  51. state: State;
  52. webViewRef: React.RefObject<React.ComponentClass<{}, any>>;
  53. UNSAFE_componentWillMount(): void;
  54. _getCommands(): {
  55. goForward: () => void;
  56. goBack: () => void;
  57. reload: () => void;
  58. stopLoading: () => void;
  59. postMessage: () => void;
  60. injectJavaScript: () => void;
  61. };
  62. /**
  63. * Go forward one page in the web view's history.
  64. */
  65. goForward: () => void;
  66. /**
  67. * Go back one page in the web view's history.
  68. */
  69. goBack: () => void;
  70. /**
  71. * Reloads the current page.
  72. */
  73. reload: () => void;
  74. /**
  75. * Stop loading the current page.
  76. */
  77. stopLoading: () => void;
  78. /**
  79. * Posts a message to the web view, which will emit a `message` event.
  80. * Accepts one argument, `data`, which must be a string.
  81. *
  82. * In your webview, you'll need to something like the following.
  83. *
  84. * ```js
  85. * document.addEventListener('message', e => { document.title = e.data; });
  86. * ```
  87. */
  88. postMessage: (data: string) => void;
  89. /**
  90. * Injects a javascript string into the referenced WebView. Deliberately does not
  91. * return a response because using eval() to return a response breaks this method
  92. * on pages with a Content Security Policy that disallows eval(). If you need that
  93. * functionality, look into postMessage/onMessage.
  94. */
  95. injectJavaScript: (data: string) => void;
  96. /**
  97. * We return an event with a bunch of fields including:
  98. * url, title, loading, canGoBack, canGoForward
  99. */
  100. _updateNavigationState: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
  101. /**
  102. * Returns the native `WebView` node.
  103. */
  104. getWebViewHandle: () => number | null;
  105. _onLoadingStart: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
  106. _onLoadingError: (event: NativeSyntheticEvent<WebViewError>) => void;
  107. _onLoadingFinish: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
  108. _onMessage: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewMessage>) => void;
  109. _onLoadingProgress: (event: NativeSyntheticEvent<WebViewProgressEvent>) => void;
  110. componentDidUpdate(prevProps: WebViewSharedProps): void;
  111. _showRedboxOnPropChanges(prevProps: WebViewSharedProps, propName: 'allowsInlineMediaPlayback' | 'mediaPlaybackRequiresUserAction' | 'dataDetectorTypes'): void;
  112. render(): React.ReactNode;
  113. }
  114. export {};