Thibault Malbranche il y a 6 ans
Parent
révision
e203e6571d

+ 1
- 0
.eslintignore Voir le fichier

@@ -0,0 +1 @@
1
+types/index.d.ts

+ 2
- 1
tsconfig.json Voir le fichier

@@ -6,13 +6,14 @@
6 6
     "esModuleInterop": true,
7 7
     "jsx": "react-native",
8 8
     "lib": ["es6"],
9
-    "module": "esnext",
9
+    "module": "AMD",
10 10
     "moduleResolution": "node",
11 11
     "noFallthroughCasesInSwitch": true,
12 12
     "noImplicitReturns": true,
13 13
     "noUnusedLocals": true,
14 14
     "noUnusedParameters": true,
15 15
     "outDir": "./types/",
16
+    "outFile": "./types/index.ts",
16 17
     "pretty": true,
17 18
     "skipLibCheck": true,
18 19
     "strict": true

+ 0
- 54
types/WebView.android.d.ts Voir le fichier

@@ -1,54 +0,0 @@
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 type State = {
10
-    viewState: WebViewState;
11
-    lastErrorEvent: WebViewError | null;
12
-};
13
-/**
14
- * Renders a native WebView.
15
- */
16
-export default class WebView extends React.Component<WebViewSharedProps, State> {
17
-    static defaultProps: {
18
-        overScrollMode: string;
19
-        javaScriptEnabled: boolean;
20
-        thirdPartyCookiesEnabled: boolean;
21
-        scalesPageToFit: boolean;
22
-        allowFileAccess: boolean;
23
-        saveFormDataDisabled: boolean;
24
-        originWhitelist: string[];
25
-    };
26
-    static isFileUploadSupported: () => Promise<boolean>;
27
-    state: State;
28
-    webViewRef: React.RefObject<React.ComponentClass<{}, any>>;
29
-    goForward: () => void;
30
-    goBack: () => void;
31
-    reload: () => void;
32
-    stopLoading: () => void;
33
-    postMessage: (data: string) => void;
34
-    /**
35
-     * Injects a javascript string into the referenced WebView. Deliberately does not
36
-     * return a response because using eval() to return a response breaks this method
37
-     * on pages with a Content Security Policy that disallows eval(). If you need that
38
-     * functionality, look into postMessage/onMessage.
39
-     */
40
-    injectJavaScript: (data: string) => void;
41
-    /**
42
-     * We return an event with a bunch of fields including:
43
-     *  url, title, loading, canGoBack, canGoForward
44
-     */
45
-    updateNavigationState: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
46
-    getWebViewHandle: () => number | null;
47
-    onLoadingStart: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
48
-    onLoadingError: (event: NativeSyntheticEvent<WebViewError>) => void;
49
-    onLoadingFinish: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
50
-    onMessage: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewMessage>) => void;
51
-    onLoadingProgress: (event: NativeSyntheticEvent<WebViewProgressEvent>) => void;
52
-    render(): React.ReactNode;
53
-}
54
-export {};

+ 0
- 114
types/WebView.ios.d.ts Voir le fichier

@@ -1,114 +0,0 @@
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 {};

+ 0
- 6
types/WebViewShared.d.ts Voir le fichier

@@ -1,6 +0,0 @@
1
-declare const WebViewShared: {
2
-    defaultOriginWhitelist: string[];
3
-    extractOrigin: (url: string) => string;
4
-    originWhitelistToRegex: (originWhitelist: string) => string;
5
-};
6
-export default WebViewShared;

+ 546
- 5
types/index.d.ts Voir le fichier

@@ -1,5 +1,546 @@
1
-import WebViewIOS from './src/WebView.ios';
2
-import WebViewAndroid from './src/WebView.android';
3
-declare const WebView: typeof WebViewAndroid | typeof WebViewIOS;
4
-export { WebView };
5
-export default WebView;
1
+/// <reference types="react" />
2
+declare module "src/WebViewShared" {
3
+    const WebViewShared: {
4
+        defaultOriginWhitelist: string[];
5
+        extractOrigin: (url: string) => string;
6
+        originWhitelistToRegex: (originWhitelist: string) => string;
7
+    };
8
+    export default WebViewShared;
9
+}
10
+declare module "src/types/WebViewTypes" {
11
+    import { ComponentType, ReactElement, ReactNode } from 'react';
12
+    import { Insets, NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
13
+    module 'react-native' {
14
+        interface UIManagerStatic {
15
+            dispatchViewManagerCommand(node: any, callback: any, x: any): void;
16
+            RNCUIWebView: any;
17
+            RNCWKWebView: any;
18
+            RNCWebView: any;
19
+        }
20
+    }
21
+    export interface WebViewNativeEvent {
22
+        readonly url: string;
23
+        readonly loading: boolean;
24
+        readonly title: string;
25
+        readonly canGoBack: boolean;
26
+        readonly canGoForward: boolean;
27
+    }
28
+    export interface WebViewIOSLoadRequestEvent extends WebViewNativeEvent {
29
+        target: number;
30
+        lockIdentifier: number;
31
+        navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
32
+    }
33
+    export interface WebViewProgressEvent extends WebViewNativeEvent {
34
+        readonly progress: number;
35
+    }
36
+    export interface WebViewNavigation extends WebViewNativeEvent {
37
+        readonly navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
38
+    }
39
+    export interface WebViewMessage extends WebViewNativeEvent {
40
+        readonly data: string;
41
+    }
42
+    export interface WebViewError extends WebViewNativeEvent {
43
+        readonly domain?: string;
44
+        readonly code: number;
45
+        readonly description: string;
46
+    }
47
+    export type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
48
+    export type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
49
+    export type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
50
+    export type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
51
+    export type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'trackingNumber' | 'flightNumber' | 'lookupSuggestion' | 'none' | 'all';
52
+    export type OverScrollModeType = 'always' | 'content' | 'never';
53
+    export interface WebViewSourceUri {
54
+        /**
55
+         * The URI to load in the `WebView`. Can be a local or remote file.
56
+         */
57
+        uri?: string;
58
+        /**
59
+         * The HTTP Method to use. Defaults to GET if not specified.
60
+         * NOTE: On Android, only GET and POST are supported.
61
+         */
62
+        method?: string;
63
+        /**
64
+         * Additional HTTP headers to send with the request.
65
+         * NOTE: On Android, this can only be used with GET requests.
66
+         */
67
+        headers?: {
68
+            [key: string]: string;
69
+        };
70
+        /**
71
+         * The HTTP body to send with the request. This must be a valid
72
+         * UTF-8 string, and will be sent exactly as specified, with no
73
+         * additional encoding (e.g. URL-escaping or base64) applied.
74
+         * NOTE: On Android, this can only be used with POST requests.
75
+         */
76
+        body?: string;
77
+    }
78
+    export interface WebViewSourceHtml {
79
+        /**
80
+         * A static HTML page to display in the WebView.
81
+         */
82
+        html?: string;
83
+        /**
84
+         * The base URL to be used for any relative links in the HTML.
85
+         */
86
+        baseUrl?: string;
87
+    }
88
+    export type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
89
+    export interface WebViewNativeConfig {
90
+        component?: ComponentType<WebViewSharedProps>;
91
+        props?: any;
92
+        viewManager?: any;
93
+    }
94
+    export interface IOSWebViewProps {
95
+        /**
96
+         * If true, use WKWebView instead of UIWebView.
97
+         * @platform ios
98
+         */
99
+        useWebKit?: boolean;
100
+        /**
101
+         * Boolean value that determines whether the web view bounces
102
+         * when it reaches the edge of the content. The default value is `true`.
103
+         * @platform ios
104
+         */
105
+        bounces?: boolean;
106
+        /**
107
+         * A floating-point number that determines how quickly the scroll view
108
+         * decelerates after the user lifts their finger. You may also use the
109
+         * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
110
+         * settings for `UIScrollViewDecelerationRateNormal` and
111
+         * `UIScrollViewDecelerationRateFast` respectively:
112
+         *
113
+         *   - normal: 0.998
114
+         *   - fast: 0.99 (the default for iOS web view)
115
+         * @platform ios
116
+         */
117
+        decelerationRate?: 'fast' | 'normal' | number;
118
+        /**
119
+         * Boolean value that determines whether scrolling is enabled in the
120
+         * `WebView`. The default value is `true`.
121
+         * @platform ios
122
+         */
123
+        scrollEnabled?: boolean;
124
+        /**
125
+         * If the value of this property is true, the scroll view stops on multiples
126
+         * of the scroll view’s bounds when the user scrolls.
127
+         * The default value is false.
128
+         * @platform ios
129
+         */
130
+        pagingEnabled?: boolean;
131
+        /**
132
+         * The amount by which the web view content is inset from the edges of
133
+         * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
134
+         * @platform ios
135
+         */
136
+        contentInset?: Insets;
137
+        /**
138
+         * Determines the types of data converted to clickable URLs in the web view's content.
139
+         * By default only phone numbers are detected.
140
+         *
141
+         * You can provide one type or an array of many types.
142
+         *
143
+         * Possible values for `dataDetectorTypes` are:
144
+         *
145
+         * - `'phoneNumber'`
146
+         * - `'link'`
147
+         * - `'address'`
148
+         * - `'calendarEvent'`
149
+         * - `'none'`
150
+         * - `'all'`
151
+         *
152
+         * With the new WebKit implementation, we have three new values:
153
+         * - `'trackingNumber'`,
154
+         * - `'flightNumber'`,
155
+         * - `'lookupSuggestion'`,
156
+         *
157
+         * @platform ios
158
+         */
159
+        dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
160
+        /**
161
+         * Function that allows custom handling of any web view requests. Return
162
+         * `true` from the function to continue loading the request and `false`
163
+         * to stop loading.
164
+         * @platform ios
165
+         */
166
+        onShouldStartLoadWithRequest?: (event: WebViewIOSLoadRequestEvent) => any;
167
+        /**
168
+         * Boolean that determines whether HTML5 videos play inline or use the
169
+         * native full-screen controller. The default value is `false`.
170
+         *
171
+         * **NOTE** : In order for video to play inline, not only does this
172
+         * property need to be set to `true`, but the video element in the HTML
173
+         * document must also include the `webkit-playsinline` attribute.
174
+         * @platform ios
175
+         */
176
+        allowsInlineMediaPlayback?: boolean;
177
+        /**
178
+         * Hide the accessory view when the keyboard is open. Default is false to be
179
+         * backward compatible.
180
+         */
181
+        hideKeyboardAccessoryView?: boolean;
182
+        /**
183
+         * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
184
+         */
185
+        allowsBackForwardNavigationGestures?: boolean;
186
+        /**
187
+         * A Boolean value that determines whether pressing on a link
188
+         * displays a preview of the destination for the link.
189
+         *
190
+         * This property is available on devices that support 3D Touch.
191
+         * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
192
+         * @platform ios
193
+         */
194
+        allowsLinkPreview?: boolean;
195
+    }
196
+    export interface AndroidWebViewProps {
197
+        onNavigationStateChange?: (event: WebViewNavigation) => any;
198
+        onContentSizeChange?: (event: WebViewEvent) => any;
199
+        /**
200
+         * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
201
+         * Sets the overScrollMode. Possible values are:
202
+         *
203
+         * - `'always'` (default)
204
+         * - `'content'`
205
+         * - `'never'`
206
+         *
207
+         * @platform android
208
+         */
209
+        overScrollMode?: OverScrollModeType;
210
+        /**
211
+         * Sets whether Geolocation is enabled. The default is false.
212
+         * @platform android
213
+         */
214
+        geolocationEnabled?: boolean;
215
+        /**
216
+         * Boolean that sets whether JavaScript running in the context of a file
217
+         * scheme URL should be allowed to access content from any origin.
218
+         * Including accessing content from other file scheme URLs
219
+         * @platform android
220
+         */
221
+        allowUniversalAccessFromFileURLs?: boolean;
222
+        /**
223
+         * Sets whether the webview allow access to file system.
224
+         * @platform android
225
+         */
226
+        allowFileAccess?: boolean;
227
+        /**
228
+         * Used on Android only, controls whether form autocomplete data should be saved
229
+         * @platform android
230
+         */
231
+        saveFormDataDisabled?: boolean;
232
+        urlPrefixesForDefaultIntent?: string[];
233
+        /**
234
+         * Boolean value to enable JavaScript in the `WebView`. Used on Android only
235
+         * as JavaScript is enabled by default on iOS. The default value is `true`.
236
+         * @platform android
237
+         */
238
+        javaScriptEnabled?: boolean;
239
+        /**
240
+         * Boolean value to enable third party cookies in the `WebView`. Used on
241
+         * Android Lollipop and above only as third party cookies are enabled by
242
+         * default on Android Kitkat and below and on iOS. The default value is `true`.
243
+         * @platform android
244
+         */
245
+        thirdPartyCookiesEnabled?: boolean;
246
+        /**
247
+         * Boolean value to control whether DOM Storage is enabled. Used only in
248
+         * Android.
249
+         * @platform android
250
+         */
251
+        domStorageEnabled?: boolean;
252
+        /**
253
+         * Sets the user-agent for the `WebView`.
254
+         * @platform android
255
+         */
256
+        userAgent?: string;
257
+        /**
258
+         * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
259
+         *
260
+         * Possible values for `mixedContentMode` are:
261
+         *
262
+         * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
263
+         * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
264
+         * - `'compatibility'` -  WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
265
+         * @platform android
266
+         */
267
+        mixedContentMode?: 'never' | 'always' | 'compatibility';
268
+    }
269
+    export interface WebViewSharedProps extends ViewProps, IOSWebViewProps, AndroidWebViewProps {
270
+        /**
271
+         * @Deprecated. Use `source` instead.
272
+         */
273
+        url?: string;
274
+        /**
275
+         * @Deprecated. Use `source` instead.
276
+         */
277
+        html?: string;
278
+        /**
279
+         * Loads static html or a uri (with optional headers) in the WebView.
280
+         */
281
+        source?: WebViewSource;
282
+        /**
283
+         * Function that returns a view to show if there's an error.
284
+         */
285
+        renderError?: (errorDomain: string | undefined, errorCode: number, errorDesc: string) => ReactElement<any>;
286
+        /**
287
+         * Function that returns a loading indicator.
288
+         */
289
+        renderLoading?: () => ReactElement<any>;
290
+        /**
291
+         * Function that is invoked when the `WebView` has finished loading.
292
+         */
293
+        onLoad?: (event: WebViewNavigationEvent) => any;
294
+        /**
295
+         * Function that is invoked when the `WebView` load succeeds or fails.
296
+         */
297
+        onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => any;
298
+        /**
299
+         * Function that is invoked when the `WebView` starts loading.
300
+         */
301
+        onLoadStart?: (event: WebViewNavigationEvent) => any;
302
+        /**
303
+         * Function that is invoked when the `WebView` load fails.
304
+         */
305
+        onError?: (event: WebViewErrorEvent) => any;
306
+        /**
307
+         * Controls whether to adjust the content inset for web views that are
308
+         * placed behind a navigation bar, tab bar, or toolbar. The default value
309
+         * is `true`.
310
+         */
311
+        automaticallyAdjustContentInsets?: boolean;
312
+        /**
313
+         * Function that is invoked when the `WebView` loading starts or ends.
314
+         */
315
+        onNavigationStateChange?: (event: WebViewNavigation) => any;
316
+        /**
317
+         * A function that is invoked when the webview calls `window.postMessage`.
318
+         * Setting this property will inject a `postMessage` global into your
319
+         * webview, but will still call pre-existing values of `postMessage`.
320
+         *
321
+         * `window.postMessage` accepts one argument, `data`, which will be
322
+         * available on the event object, `event.nativeEvent.data`. `data`
323
+         * must be a string.
324
+         */
325
+        onMessage?: (event: WebViewMessageEvent) => any;
326
+        /**
327
+         * Function that is invoked when the `WebView` is loading.
328
+         */
329
+        onLoadProgress?: (event: NativeSyntheticEvent<WebViewProgressEvent>) => any;
330
+        /**
331
+         * Boolean value that forces the `WebView` to show the loading view
332
+         * on the first load.
333
+         */
334
+        startInLoadingState?: boolean;
335
+        /**
336
+         * Set this to provide JavaScript that will be injected into the web page
337
+         * when the view loads.
338
+         */
339
+        injectedJavaScript?: string;
340
+        /**
341
+         * Boolean that controls whether the web content is scaled to fit
342
+         * the view and enables the user to change the scale. The default value
343
+         * is `true`.
344
+         *
345
+         * On iOS, when `useWebKit=true`, this prop will not work.
346
+         */
347
+        scalesPageToFit?: boolean;
348
+        /**
349
+         * Boolean that determines whether HTML5 audio and video requires the user
350
+         * to tap them before they start playing. The default value is `true`.
351
+         */
352
+        mediaPlaybackRequiresUserAction?: boolean;
353
+        /**
354
+         * List of origin strings to allow being navigated to. The strings allow
355
+         * wildcards and get matched against *just* the origin (not the full URL).
356
+         * If the user taps to navigate to a new page but the new page is not in
357
+         * this whitelist, we will open the URL in Safari.
358
+         * The default whitelisted origins are "http://*" and "https://*".
359
+         */
360
+        originWhitelist?: string[];
361
+        /**
362
+         * Override the native component used to render the WebView. Enables a custom native
363
+         * WebView which uses the same JavaScript as the original WebView.
364
+         */
365
+        nativeConfig?: WebViewNativeConfig;
366
+        style?: StyleProp<ViewStyle>;
367
+        children?: ReactNode;
368
+    }
369
+}
370
+declare module "src/WebView.android" {
371
+    import React from 'react';
372
+    import { NativeSyntheticEvent } from 'react-native';
373
+    import { WebViewError, WebViewSharedProps, WebViewProgressEvent } from "src/types/WebViewTypes";
374
+    enum WebViewState {
375
+        IDLE = "IDLE",
376
+        LOADING = "LOADING",
377
+        ERROR = "ERROR"
378
+    }
379
+    type State = {
380
+        viewState: WebViewState;
381
+        lastErrorEvent: WebViewError | null;
382
+    };
383
+    /**
384
+     * Renders a native WebView.
385
+     */
386
+    export default class WebView extends React.Component<WebViewSharedProps, State> {
387
+        static defaultProps: {
388
+            overScrollMode: string;
389
+            javaScriptEnabled: boolean;
390
+            thirdPartyCookiesEnabled: boolean;
391
+            scalesPageToFit: boolean;
392
+            allowFileAccess: boolean;
393
+            saveFormDataDisabled: boolean;
394
+            originWhitelist: string[];
395
+        };
396
+        static isFileUploadSupported: () => Promise<boolean>;
397
+        state: State;
398
+        webViewRef: React.RefObject<React.ComponentClass<{}, any>>;
399
+        goForward: () => void;
400
+        goBack: () => void;
401
+        reload: () => void;
402
+        stopLoading: () => void;
403
+        postMessage: (data: string) => void;
404
+        /**
405
+         * Injects a javascript string into the referenced WebView. Deliberately does not
406
+         * return a response because using eval() to return a response breaks this method
407
+         * on pages with a Content Security Policy that disallows eval(). If you need that
408
+         * functionality, look into postMessage/onMessage.
409
+         */
410
+        injectJavaScript: (data: string) => void;
411
+        /**
412
+         * We return an event with a bunch of fields including:
413
+         *  url, title, loading, canGoBack, canGoForward
414
+         */
415
+        updateNavigationState: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewNavigation>) => void;
416
+        getWebViewHandle: () => number | null;
417
+        onLoadingStart: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewNavigation>) => void;
418
+        onLoadingError: (event: NativeSyntheticEvent<WebViewError>) => void;
419
+        onLoadingFinish: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewNavigation>) => void;
420
+        onMessage: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewMessage>) => void;
421
+        onLoadingProgress: (event: NativeSyntheticEvent<WebViewProgressEvent>) => void;
422
+        render(): React.ReactNode;
423
+    }
424
+}
425
+declare module "src/WebView.ios" {
426
+    import React from 'react';
427
+    import { NativeSyntheticEvent } from 'react-native';
428
+    import { WebViewError, WebViewSharedProps, WebViewProgressEvent } from "src/types/WebViewTypes";
429
+    enum WebViewState {
430
+        IDLE = "IDLE",
431
+        LOADING = "LOADING",
432
+        ERROR = "ERROR"
433
+    }
434
+    enum NavigationType {
435
+        click = "click",
436
+        formsubmit = "formsubmit",
437
+        backforward = "backforward",
438
+        reload = "reload",
439
+        formresubmit = "formresubmit",
440
+        other = "other"
441
+    }
442
+    type State = {
443
+        viewState: WebViewState;
444
+        lastErrorEvent: WebViewError | null;
445
+    };
446
+    /**
447
+     * `WebView` renders web content in a native view.
448
+     *
449
+     *```
450
+     * import React, { Component } from 'react';
451
+     * import { WebView } from 'react-native';
452
+     *
453
+     * class MyWeb extends Component {
454
+     *   render() {
455
+     *     return (
456
+     *       <WebView
457
+     *         source={{uri: 'https://github.com/facebook/react-native'}}
458
+     *         style={{marginTop: 20}}
459
+     *       />
460
+     *     );
461
+     *   }
462
+     * }
463
+     *```
464
+     *
465
+     * You can use this component to navigate back and forth in the web view's
466
+     * history and configure various properties for the web content.
467
+     */
468
+    export default class WebView extends React.Component<WebViewSharedProps, State> {
469
+        static JSNavigationScheme: string;
470
+        static NavigationType: typeof NavigationType;
471
+        static defaultProps: {
472
+            useWebKit: boolean;
473
+            originWhitelist: string[];
474
+        };
475
+        static isFileUploadSupported: () => Promise<boolean>;
476
+        state: State;
477
+        webViewRef: React.RefObject<React.ComponentClass<{}, any>>;
478
+        UNSAFE_componentWillMount(): void;
479
+        _getCommands(): {
480
+            goForward: () => void;
481
+            goBack: () => void;
482
+            reload: () => void;
483
+            stopLoading: () => void;
484
+            postMessage: () => void;
485
+            injectJavaScript: () => void;
486
+        };
487
+        /**
488
+         * Go forward one page in the web view's history.
489
+         */
490
+        goForward: () => void;
491
+        /**
492
+         * Go back one page in the web view's history.
493
+         */
494
+        goBack: () => void;
495
+        /**
496
+         * Reloads the current page.
497
+         */
498
+        reload: () => void;
499
+        /**
500
+         * Stop loading the current page.
501
+         */
502
+        stopLoading: () => void;
503
+        /**
504
+         * Posts a message to the web view, which will emit a `message` event.
505
+         * Accepts one argument, `data`, which must be a string.
506
+         *
507
+         * In your webview, you'll need to something like the following.
508
+         *
509
+         * ```js
510
+         * document.addEventListener('message', e => { document.title = e.data; });
511
+         * ```
512
+         */
513
+        postMessage: (data: string) => void;
514
+        /**
515
+         * Injects a javascript string into the referenced WebView. Deliberately does not
516
+         * return a response because using eval() to return a response breaks this method
517
+         * on pages with a Content Security Policy that disallows eval(). If you need that
518
+         * functionality, look into postMessage/onMessage.
519
+         */
520
+        injectJavaScript: (data: string) => void;
521
+        /**
522
+         * We return an event with a bunch of fields including:
523
+         *  url, title, loading, canGoBack, canGoForward
524
+         */
525
+        _updateNavigationState: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewNavigation>) => void;
526
+        /**
527
+         * Returns the native `WebView` node.
528
+         */
529
+        getWebViewHandle: () => number | null;
530
+        _onLoadingStart: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewNavigation>) => void;
531
+        _onLoadingError: (event: NativeSyntheticEvent<WebViewError>) => void;
532
+        _onLoadingFinish: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewNavigation>) => void;
533
+        _onMessage: (event: NativeSyntheticEvent<import("src/types/WebViewTypes").WebViewMessage>) => void;
534
+        _onLoadingProgress: (event: NativeSyntheticEvent<WebViewProgressEvent>) => void;
535
+        componentDidUpdate(prevProps: WebViewSharedProps): void;
536
+        _showRedboxOnPropChanges(prevProps: WebViewSharedProps, propName: 'allowsInlineMediaPlayback' | 'mediaPlaybackRequiresUserAction' | 'dataDetectorTypes'): void;
537
+        render(): React.ReactNode;
538
+    }
539
+}
540
+declare module "index" {
541
+    import WebViewIOS from "src/WebView.ios";
542
+    import WebViewAndroid from "src/WebView.android";
543
+    const WebView: typeof WebViewAndroid | typeof WebViewIOS;
544
+    export { WebView };
545
+    export default WebView;
546
+}

+ 0
- 54
types/src/WebView.android.d.ts Voir le fichier

@@ -1,54 +0,0 @@
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 type State = {
10
-    viewState: WebViewState;
11
-    lastErrorEvent: WebViewError | null;
12
-};
13
-/**
14
- * Renders a native WebView.
15
- */
16
-export default class WebView extends React.Component<WebViewSharedProps, State> {
17
-    static defaultProps: {
18
-        overScrollMode: string;
19
-        javaScriptEnabled: boolean;
20
-        thirdPartyCookiesEnabled: boolean;
21
-        scalesPageToFit: boolean;
22
-        allowFileAccess: boolean;
23
-        saveFormDataDisabled: boolean;
24
-        originWhitelist: string[];
25
-    };
26
-    static isFileUploadSupported: () => Promise<boolean>;
27
-    state: State;
28
-    webViewRef: React.RefObject<React.ComponentClass<{}, any>>;
29
-    goForward: () => void;
30
-    goBack: () => void;
31
-    reload: () => void;
32
-    stopLoading: () => void;
33
-    postMessage: (data: string) => void;
34
-    /**
35
-     * Injects a javascript string into the referenced WebView. Deliberately does not
36
-     * return a response because using eval() to return a response breaks this method
37
-     * on pages with a Content Security Policy that disallows eval(). If you need that
38
-     * functionality, look into postMessage/onMessage.
39
-     */
40
-    injectJavaScript: (data: string) => void;
41
-    /**
42
-     * We return an event with a bunch of fields including:
43
-     *  url, title, loading, canGoBack, canGoForward
44
-     */
45
-    updateNavigationState: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
46
-    getWebViewHandle: () => number | null;
47
-    onLoadingStart: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
48
-    onLoadingError: (event: NativeSyntheticEvent<WebViewError>) => void;
49
-    onLoadingFinish: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewNavigation>) => void;
50
-    onMessage: (event: NativeSyntheticEvent<import("./types/WebViewTypes").WebViewMessage>) => void;
51
-    onLoadingProgress: (event: NativeSyntheticEvent<WebViewProgressEvent>) => void;
52
-    render(): React.ReactNode;
53
-}
54
-export {};

+ 0
- 114
types/src/WebView.ios.d.ts Voir le fichier

@@ -1,114 +0,0 @@
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 {};

+ 0
- 6
types/src/WebViewShared.d.ts Voir le fichier

@@ -1,6 +0,0 @@
1
-declare const WebViewShared: {
2
-    defaultOriginWhitelist: string[];
3
-    extractOrigin: (url: string) => string;
4
-    originWhitelistToRegex: (originWhitelist: string) => string;
5
-};
6
-export default WebViewShared;

+ 0
- 358
types/src/types/WebViewTypes.d.ts Voir le fichier

@@ -1,358 +0,0 @@
1
-import { ComponentType, ReactElement, ReactNode } from 'react';
2
-import { Insets, NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
3
-declare module 'react-native' {
4
-    interface UIManagerStatic {
5
-        dispatchViewManagerCommand(node: any, callback: any, x: any): void;
6
-        RNCUIWebView: any;
7
-        RNCWKWebView: any;
8
-        RNCWebView: any;
9
-    }
10
-}
11
-export interface WebViewNativeEvent {
12
-    readonly url: string;
13
-    readonly loading: boolean;
14
-    readonly title: string;
15
-    readonly canGoBack: boolean;
16
-    readonly canGoForward: boolean;
17
-}
18
-export interface WebViewIOSLoadRequestEvent extends WebViewNativeEvent {
19
-    target: number;
20
-    lockIdentifier: number;
21
-    navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
22
-}
23
-export interface WebViewProgressEvent extends WebViewNativeEvent {
24
-    readonly progress: number;
25
-}
26
-export interface WebViewNavigation extends WebViewNativeEvent {
27
-    readonly navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
28
-}
29
-export interface WebViewMessage extends WebViewNativeEvent {
30
-    readonly data: string;
31
-}
32
-export interface WebViewError extends WebViewNativeEvent {
33
-    readonly domain?: string;
34
-    readonly code: number;
35
-    readonly description: string;
36
-}
37
-export declare type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
38
-export declare type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
39
-export declare type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
40
-export declare type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
41
-export declare type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'trackingNumber' | 'flightNumber' | 'lookupSuggestion' | 'none' | 'all';
42
-export declare type OverScrollModeType = 'always' | 'content' | 'never';
43
-export interface WebViewSourceUri {
44
-    /**
45
-     * The URI to load in the `WebView`. Can be a local or remote file.
46
-     */
47
-    uri?: string;
48
-    /**
49
-     * The HTTP Method to use. Defaults to GET if not specified.
50
-     * NOTE: On Android, only GET and POST are supported.
51
-     */
52
-    method?: string;
53
-    /**
54
-     * Additional HTTP headers to send with the request.
55
-     * NOTE: On Android, this can only be used with GET requests.
56
-     */
57
-    headers?: {
58
-        [key: string]: string;
59
-    };
60
-    /**
61
-     * The HTTP body to send with the request. This must be a valid
62
-     * UTF-8 string, and will be sent exactly as specified, with no
63
-     * additional encoding (e.g. URL-escaping or base64) applied.
64
-     * NOTE: On Android, this can only be used with POST requests.
65
-     */
66
-    body?: string;
67
-}
68
-export interface WebViewSourceHtml {
69
-    /**
70
-     * A static HTML page to display in the WebView.
71
-     */
72
-    html?: string;
73
-    /**
74
-     * The base URL to be used for any relative links in the HTML.
75
-     */
76
-    baseUrl?: string;
77
-}
78
-export declare type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
79
-export interface WebViewNativeConfig {
80
-    component?: ComponentType<WebViewSharedProps>;
81
-    props?: any;
82
-    viewManager?: any;
83
-}
84
-export interface IOSWebViewProps {
85
-    /**
86
-     * If true, use WKWebView instead of UIWebView.
87
-     * @platform ios
88
-     */
89
-    useWebKit?: boolean;
90
-    /**
91
-     * Boolean value that determines whether the web view bounces
92
-     * when it reaches the edge of the content. The default value is `true`.
93
-     * @platform ios
94
-     */
95
-    bounces?: boolean;
96
-    /**
97
-     * A floating-point number that determines how quickly the scroll view
98
-     * decelerates after the user lifts their finger. You may also use the
99
-     * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
100
-     * settings for `UIScrollViewDecelerationRateNormal` and
101
-     * `UIScrollViewDecelerationRateFast` respectively:
102
-     *
103
-     *   - normal: 0.998
104
-     *   - fast: 0.99 (the default for iOS web view)
105
-     * @platform ios
106
-     */
107
-    decelerationRate?: 'fast' | 'normal' | number;
108
-    /**
109
-     * Boolean value that determines whether scrolling is enabled in the
110
-     * `WebView`. The default value is `true`.
111
-     * @platform ios
112
-     */
113
-    scrollEnabled?: boolean;
114
-    /**
115
-     * If the value of this property is true, the scroll view stops on multiples
116
-     * of the scroll view’s bounds when the user scrolls.
117
-     * The default value is false.
118
-     * @platform ios
119
-     */
120
-    pagingEnabled?: boolean;
121
-    /**
122
-     * The amount by which the web view content is inset from the edges of
123
-     * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
124
-     * @platform ios
125
-     */
126
-    contentInset?: Insets;
127
-    /**
128
-     * Determines the types of data converted to clickable URLs in the web view's content.
129
-     * By default only phone numbers are detected.
130
-     *
131
-     * You can provide one type or an array of many types.
132
-     *
133
-     * Possible values for `dataDetectorTypes` are:
134
-     *
135
-     * - `'phoneNumber'`
136
-     * - `'link'`
137
-     * - `'address'`
138
-     * - `'calendarEvent'`
139
-     * - `'none'`
140
-     * - `'all'`
141
-     *
142
-     * With the new WebKit implementation, we have three new values:
143
-     * - `'trackingNumber'`,
144
-     * - `'flightNumber'`,
145
-     * - `'lookupSuggestion'`,
146
-     *
147
-     * @platform ios
148
-     */
149
-    dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
150
-    /**
151
-     * Function that allows custom handling of any web view requests. Return
152
-     * `true` from the function to continue loading the request and `false`
153
-     * to stop loading.
154
-     * @platform ios
155
-     */
156
-    onShouldStartLoadWithRequest?: (event: WebViewIOSLoadRequestEvent) => any;
157
-    /**
158
-     * Boolean that determines whether HTML5 videos play inline or use the
159
-     * native full-screen controller. The default value is `false`.
160
-     *
161
-     * **NOTE** : In order for video to play inline, not only does this
162
-     * property need to be set to `true`, but the video element in the HTML
163
-     * document must also include the `webkit-playsinline` attribute.
164
-     * @platform ios
165
-     */
166
-    allowsInlineMediaPlayback?: boolean;
167
-    /**
168
-     * Hide the accessory view when the keyboard is open. Default is false to be
169
-     * backward compatible.
170
-     */
171
-    hideKeyboardAccessoryView?: boolean;
172
-    /**
173
-     * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
174
-     */
175
-    allowsBackForwardNavigationGestures?: boolean;
176
-    /**
177
-     * A Boolean value that determines whether pressing on a link
178
-     * displays a preview of the destination for the link.
179
-     *
180
-     * This property is available on devices that support 3D Touch.
181
-     * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
182
-     * @platform ios
183
-     */
184
-    allowsLinkPreview?: boolean;
185
-}
186
-export interface AndroidWebViewProps {
187
-    onNavigationStateChange?: (event: WebViewNavigation) => any;
188
-    onContentSizeChange?: (event: WebViewEvent) => any;
189
-    /**
190
-     * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
191
-     * Sets the overScrollMode. Possible values are:
192
-     *
193
-     * - `'always'` (default)
194
-     * - `'content'`
195
-     * - `'never'`
196
-     *
197
-     * @platform android
198
-     */
199
-    overScrollMode?: OverScrollModeType;
200
-    /**
201
-     * Sets whether Geolocation is enabled. The default is false.
202
-     * @platform android
203
-     */
204
-    geolocationEnabled?: boolean;
205
-    /**
206
-     * Boolean that sets whether JavaScript running in the context of a file
207
-     * scheme URL should be allowed to access content from any origin.
208
-     * Including accessing content from other file scheme URLs
209
-     * @platform android
210
-     */
211
-    allowUniversalAccessFromFileURLs?: boolean;
212
-    /**
213
-     * Sets whether the webview allow access to file system.
214
-     * @platform android
215
-     */
216
-    allowFileAccess?: boolean;
217
-    /**
218
-     * Used on Android only, controls whether form autocomplete data should be saved
219
-     * @platform android
220
-     */
221
-    saveFormDataDisabled?: boolean;
222
-    urlPrefixesForDefaultIntent?: string[];
223
-    /**
224
-     * Boolean value to enable JavaScript in the `WebView`. Used on Android only
225
-     * as JavaScript is enabled by default on iOS. The default value is `true`.
226
-     * @platform android
227
-     */
228
-    javaScriptEnabled?: boolean;
229
-    /**
230
-     * Boolean value to enable third party cookies in the `WebView`. Used on
231
-     * Android Lollipop and above only as third party cookies are enabled by
232
-     * default on Android Kitkat and below and on iOS. The default value is `true`.
233
-     * @platform android
234
-     */
235
-    thirdPartyCookiesEnabled?: boolean;
236
-    /**
237
-     * Boolean value to control whether DOM Storage is enabled. Used only in
238
-     * Android.
239
-     * @platform android
240
-     */
241
-    domStorageEnabled?: boolean;
242
-    /**
243
-     * Sets the user-agent for the `WebView`.
244
-     * @platform android
245
-     */
246
-    userAgent?: string;
247
-    /**
248
-     * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
249
-     *
250
-     * Possible values for `mixedContentMode` are:
251
-     *
252
-     * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
253
-     * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
254
-     * - `'compatibility'` -  WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
255
-     * @platform android
256
-     */
257
-    mixedContentMode?: 'never' | 'always' | 'compatibility';
258
-}
259
-export interface WebViewSharedProps extends ViewProps, IOSWebViewProps, AndroidWebViewProps {
260
-    /**
261
-     * @Deprecated. Use `source` instead.
262
-     */
263
-    url?: string;
264
-    /**
265
-     * @Deprecated. Use `source` instead.
266
-     */
267
-    html?: string;
268
-    /**
269
-     * Loads static html or a uri (with optional headers) in the WebView.
270
-     */
271
-    source?: WebViewSource;
272
-    /**
273
-     * Function that returns a view to show if there's an error.
274
-     */
275
-    renderError?: (errorDomain: string | undefined, errorCode: number, errorDesc: string) => ReactElement<any>;
276
-    /**
277
-     * Function that returns a loading indicator.
278
-     */
279
-    renderLoading?: () => ReactElement<any>;
280
-    /**
281
-     * Function that is invoked when the `WebView` has finished loading.
282
-     */
283
-    onLoad?: (event: WebViewNavigationEvent) => any;
284
-    /**
285
-     * Function that is invoked when the `WebView` load succeeds or fails.
286
-     */
287
-    onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => any;
288
-    /**
289
-     * Function that is invoked when the `WebView` starts loading.
290
-     */
291
-    onLoadStart?: (event: WebViewNavigationEvent) => any;
292
-    /**
293
-     * Function that is invoked when the `WebView` load fails.
294
-     */
295
-    onError?: (event: WebViewErrorEvent) => any;
296
-    /**
297
-     * Controls whether to adjust the content inset for web views that are
298
-     * placed behind a navigation bar, tab bar, or toolbar. The default value
299
-     * is `true`.
300
-     */
301
-    automaticallyAdjustContentInsets?: boolean;
302
-    /**
303
-     * Function that is invoked when the `WebView` loading starts or ends.
304
-     */
305
-    onNavigationStateChange?: (event: WebViewNavigation) => any;
306
-    /**
307
-     * A function that is invoked when the webview calls `window.postMessage`.
308
-     * Setting this property will inject a `postMessage` global into your
309
-     * webview, but will still call pre-existing values of `postMessage`.
310
-     *
311
-     * `window.postMessage` accepts one argument, `data`, which will be
312
-     * available on the event object, `event.nativeEvent.data`. `data`
313
-     * must be a string.
314
-     */
315
-    onMessage?: (event: WebViewMessageEvent) => any;
316
-    /**
317
-     * Function that is invoked when the `WebView` is loading.
318
-     */
319
-    onLoadProgress?: (event: NativeSyntheticEvent<WebViewProgressEvent>) => any;
320
-    /**
321
-     * Boolean value that forces the `WebView` to show the loading view
322
-     * on the first load.
323
-     */
324
-    startInLoadingState?: boolean;
325
-    /**
326
-     * Set this to provide JavaScript that will be injected into the web page
327
-     * when the view loads.
328
-     */
329
-    injectedJavaScript?: string;
330
-    /**
331
-     * Boolean that controls whether the web content is scaled to fit
332
-     * the view and enables the user to change the scale. The default value
333
-     * is `true`.
334
-     *
335
-     * On iOS, when `useWebKit=true`, this prop will not work.
336
-     */
337
-    scalesPageToFit?: boolean;
338
-    /**
339
-     * Boolean that determines whether HTML5 audio and video requires the user
340
-     * to tap them before they start playing. The default value is `true`.
341
-     */
342
-    mediaPlaybackRequiresUserAction?: boolean;
343
-    /**
344
-     * List of origin strings to allow being navigated to. The strings allow
345
-     * wildcards and get matched against *just* the origin (not the full URL).
346
-     * If the user taps to navigate to a new page but the new page is not in
347
-     * this whitelist, we will open the URL in Safari.
348
-     * The default whitelisted origins are "http://*" and "https://*".
349
-     */
350
-    originWhitelist?: string[];
351
-    /**
352
-     * Override the native component used to render the WebView. Enables a custom native
353
-     * WebView which uses the same JavaScript as the original WebView.
354
-     */
355
-    nativeConfig?: WebViewNativeConfig;
356
-    style?: StyleProp<ViewStyle>;
357
-    children?: ReactNode;
358
-}

+ 0
- 358
types/types/WebViewTypes.d.ts Voir le fichier

@@ -1,358 +0,0 @@
1
-import { ComponentType, ReactElement, ReactNode } from 'react';
2
-import { Insets, NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
3
-declare module 'react-native' {
4
-    interface UIManagerStatic {
5
-        dispatchViewManagerCommand(node: any, callback: any, x: any): void;
6
-        RNCUIWebView: any;
7
-        RNCWKWebView: any;
8
-        RNCWebView: any;
9
-    }
10
-}
11
-export interface WebViewNativeEvent {
12
-    readonly url: string;
13
-    readonly loading: boolean;
14
-    readonly title: string;
15
-    readonly canGoBack: boolean;
16
-    readonly canGoForward: boolean;
17
-}
18
-export interface WebViewIOSLoadRequestEvent extends WebViewNativeEvent {
19
-    target: number;
20
-    lockIdentifier: number;
21
-    navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
22
-}
23
-export interface WebViewProgressEvent extends WebViewNativeEvent {
24
-    readonly progress: number;
25
-}
26
-export interface WebViewNavigation extends WebViewNativeEvent {
27
-    readonly navigationType: 'click' | 'formsubmit' | 'backforward' | 'reload' | 'formresubmit' | 'other';
28
-}
29
-export interface WebViewMessage extends WebViewNativeEvent {
30
-    readonly data: string;
31
-}
32
-export interface WebViewError extends WebViewNativeEvent {
33
-    readonly domain?: string;
34
-    readonly code: number;
35
-    readonly description: string;
36
-}
37
-export declare type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
38
-export declare type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
39
-export declare type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
40
-export declare type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
41
-export declare type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'trackingNumber' | 'flightNumber' | 'lookupSuggestion' | 'none' | 'all';
42
-export declare type OverScrollModeType = 'always' | 'content' | 'never';
43
-export interface WebViewSourceUri {
44
-    /**
45
-     * The URI to load in the `WebView`. Can be a local or remote file.
46
-     */
47
-    uri?: string;
48
-    /**
49
-     * The HTTP Method to use. Defaults to GET if not specified.
50
-     * NOTE: On Android, only GET and POST are supported.
51
-     */
52
-    method?: string;
53
-    /**
54
-     * Additional HTTP headers to send with the request.
55
-     * NOTE: On Android, this can only be used with GET requests.
56
-     */
57
-    headers?: {
58
-        [key: string]: string;
59
-    };
60
-    /**
61
-     * The HTTP body to send with the request. This must be a valid
62
-     * UTF-8 string, and will be sent exactly as specified, with no
63
-     * additional encoding (e.g. URL-escaping or base64) applied.
64
-     * NOTE: On Android, this can only be used with POST requests.
65
-     */
66
-    body?: string;
67
-}
68
-export interface WebViewSourceHtml {
69
-    /**
70
-     * A static HTML page to display in the WebView.
71
-     */
72
-    html?: string;
73
-    /**
74
-     * The base URL to be used for any relative links in the HTML.
75
-     */
76
-    baseUrl?: string;
77
-}
78
-export declare type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
79
-export interface WebViewNativeConfig {
80
-    component?: ComponentType<WebViewSharedProps>;
81
-    props?: any;
82
-    viewManager?: any;
83
-}
84
-export interface IOSWebViewProps {
85
-    /**
86
-     * If true, use WKWebView instead of UIWebView.
87
-     * @platform ios
88
-     */
89
-    useWebKit?: boolean;
90
-    /**
91
-     * Boolean value that determines whether the web view bounces
92
-     * when it reaches the edge of the content. The default value is `true`.
93
-     * @platform ios
94
-     */
95
-    bounces?: boolean;
96
-    /**
97
-     * A floating-point number that determines how quickly the scroll view
98
-     * decelerates after the user lifts their finger. You may also use the
99
-     * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
100
-     * settings for `UIScrollViewDecelerationRateNormal` and
101
-     * `UIScrollViewDecelerationRateFast` respectively:
102
-     *
103
-     *   - normal: 0.998
104
-     *   - fast: 0.99 (the default for iOS web view)
105
-     * @platform ios
106
-     */
107
-    decelerationRate?: 'fast' | 'normal' | number;
108
-    /**
109
-     * Boolean value that determines whether scrolling is enabled in the
110
-     * `WebView`. The default value is `true`.
111
-     * @platform ios
112
-     */
113
-    scrollEnabled?: boolean;
114
-    /**
115
-     * If the value of this property is true, the scroll view stops on multiples
116
-     * of the scroll view’s bounds when the user scrolls.
117
-     * The default value is false.
118
-     * @platform ios
119
-     */
120
-    pagingEnabled?: boolean;
121
-    /**
122
-     * The amount by which the web view content is inset from the edges of
123
-     * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
124
-     * @platform ios
125
-     */
126
-    contentInset?: Insets;
127
-    /**
128
-     * Determines the types of data converted to clickable URLs in the web view's content.
129
-     * By default only phone numbers are detected.
130
-     *
131
-     * You can provide one type or an array of many types.
132
-     *
133
-     * Possible values for `dataDetectorTypes` are:
134
-     *
135
-     * - `'phoneNumber'`
136
-     * - `'link'`
137
-     * - `'address'`
138
-     * - `'calendarEvent'`
139
-     * - `'none'`
140
-     * - `'all'`
141
-     *
142
-     * With the new WebKit implementation, we have three new values:
143
-     * - `'trackingNumber'`,
144
-     * - `'flightNumber'`,
145
-     * - `'lookupSuggestion'`,
146
-     *
147
-     * @platform ios
148
-     */
149
-    dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
150
-    /**
151
-     * Function that allows custom handling of any web view requests. Return
152
-     * `true` from the function to continue loading the request and `false`
153
-     * to stop loading.
154
-     * @platform ios
155
-     */
156
-    onShouldStartLoadWithRequest?: (event: WebViewIOSLoadRequestEvent) => any;
157
-    /**
158
-     * Boolean that determines whether HTML5 videos play inline or use the
159
-     * native full-screen controller. The default value is `false`.
160
-     *
161
-     * **NOTE** : In order for video to play inline, not only does this
162
-     * property need to be set to `true`, but the video element in the HTML
163
-     * document must also include the `webkit-playsinline` attribute.
164
-     * @platform ios
165
-     */
166
-    allowsInlineMediaPlayback?: boolean;
167
-    /**
168
-     * Hide the accessory view when the keyboard is open. Default is false to be
169
-     * backward compatible.
170
-     */
171
-    hideKeyboardAccessoryView?: boolean;
172
-    /**
173
-     * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
174
-     */
175
-    allowsBackForwardNavigationGestures?: boolean;
176
-    /**
177
-     * A Boolean value that determines whether pressing on a link
178
-     * displays a preview of the destination for the link.
179
-     *
180
-     * This property is available on devices that support 3D Touch.
181
-     * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
182
-     * @platform ios
183
-     */
184
-    allowsLinkPreview?: boolean;
185
-}
186
-export interface AndroidWebViewProps {
187
-    onNavigationStateChange?: (event: WebViewNavigation) => any;
188
-    onContentSizeChange?: (event: WebViewEvent) => any;
189
-    /**
190
-     * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
191
-     * Sets the overScrollMode. Possible values are:
192
-     *
193
-     * - `'always'` (default)
194
-     * - `'content'`
195
-     * - `'never'`
196
-     *
197
-     * @platform android
198
-     */
199
-    overScrollMode?: OverScrollModeType;
200
-    /**
201
-     * Sets whether Geolocation is enabled. The default is false.
202
-     * @platform android
203
-     */
204
-    geolocationEnabled?: boolean;
205
-    /**
206
-     * Boolean that sets whether JavaScript running in the context of a file
207
-     * scheme URL should be allowed to access content from any origin.
208
-     * Including accessing content from other file scheme URLs
209
-     * @platform android
210
-     */
211
-    allowUniversalAccessFromFileURLs?: boolean;
212
-    /**
213
-     * Sets whether the webview allow access to file system.
214
-     * @platform android
215
-     */
216
-    allowFileAccess?: boolean;
217
-    /**
218
-     * Used on Android only, controls whether form autocomplete data should be saved
219
-     * @platform android
220
-     */
221
-    saveFormDataDisabled?: boolean;
222
-    urlPrefixesForDefaultIntent?: string[];
223
-    /**
224
-     * Boolean value to enable JavaScript in the `WebView`. Used on Android only
225
-     * as JavaScript is enabled by default on iOS. The default value is `true`.
226
-     * @platform android
227
-     */
228
-    javaScriptEnabled?: boolean;
229
-    /**
230
-     * Boolean value to enable third party cookies in the `WebView`. Used on
231
-     * Android Lollipop and above only as third party cookies are enabled by
232
-     * default on Android Kitkat and below and on iOS. The default value is `true`.
233
-     * @platform android
234
-     */
235
-    thirdPartyCookiesEnabled?: boolean;
236
-    /**
237
-     * Boolean value to control whether DOM Storage is enabled. Used only in
238
-     * Android.
239
-     * @platform android
240
-     */
241
-    domStorageEnabled?: boolean;
242
-    /**
243
-     * Sets the user-agent for the `WebView`.
244
-     * @platform android
245
-     */
246
-    userAgent?: string;
247
-    /**
248
-     * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
249
-     *
250
-     * Possible values for `mixedContentMode` are:
251
-     *
252
-     * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
253
-     * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
254
-     * - `'compatibility'` -  WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
255
-     * @platform android
256
-     */
257
-    mixedContentMode?: 'never' | 'always' | 'compatibility';
258
-}
259
-export interface WebViewSharedProps extends ViewProps, IOSWebViewProps, AndroidWebViewProps {
260
-    /**
261
-     * @Deprecated. Use `source` instead.
262
-     */
263
-    url?: string;
264
-    /**
265
-     * @Deprecated. Use `source` instead.
266
-     */
267
-    html?: string;
268
-    /**
269
-     * Loads static html or a uri (with optional headers) in the WebView.
270
-     */
271
-    source?: WebViewSource;
272
-    /**
273
-     * Function that returns a view to show if there's an error.
274
-     */
275
-    renderError?: (errorDomain: string | undefined, errorCode: number, errorDesc: string) => ReactElement<any>;
276
-    /**
277
-     * Function that returns a loading indicator.
278
-     */
279
-    renderLoading?: () => ReactElement<any>;
280
-    /**
281
-     * Function that is invoked when the `WebView` has finished loading.
282
-     */
283
-    onLoad?: (event: WebViewNavigationEvent) => any;
284
-    /**
285
-     * Function that is invoked when the `WebView` load succeeds or fails.
286
-     */
287
-    onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => any;
288
-    /**
289
-     * Function that is invoked when the `WebView` starts loading.
290
-     */
291
-    onLoadStart?: (event: WebViewNavigationEvent) => any;
292
-    /**
293
-     * Function that is invoked when the `WebView` load fails.
294
-     */
295
-    onError?: (event: WebViewErrorEvent) => any;
296
-    /**
297
-     * Controls whether to adjust the content inset for web views that are
298
-     * placed behind a navigation bar, tab bar, or toolbar. The default value
299
-     * is `true`.
300
-     */
301
-    automaticallyAdjustContentInsets?: boolean;
302
-    /**
303
-     * Function that is invoked when the `WebView` loading starts or ends.
304
-     */
305
-    onNavigationStateChange?: (event: WebViewNavigation) => any;
306
-    /**
307
-     * A function that is invoked when the webview calls `window.postMessage`.
308
-     * Setting this property will inject a `postMessage` global into your
309
-     * webview, but will still call pre-existing values of `postMessage`.
310
-     *
311
-     * `window.postMessage` accepts one argument, `data`, which will be
312
-     * available on the event object, `event.nativeEvent.data`. `data`
313
-     * must be a string.
314
-     */
315
-    onMessage?: (event: WebViewMessageEvent) => any;
316
-    /**
317
-     * Function that is invoked when the `WebView` is loading.
318
-     */
319
-    onLoadProgress?: (event: NativeSyntheticEvent<WebViewProgressEvent>) => any;
320
-    /**
321
-     * Boolean value that forces the `WebView` to show the loading view
322
-     * on the first load.
323
-     */
324
-    startInLoadingState?: boolean;
325
-    /**
326
-     * Set this to provide JavaScript that will be injected into the web page
327
-     * when the view loads.
328
-     */
329
-    injectedJavaScript?: string;
330
-    /**
331
-     * Boolean that controls whether the web content is scaled to fit
332
-     * the view and enables the user to change the scale. The default value
333
-     * is `true`.
334
-     *
335
-     * On iOS, when `useWebKit=true`, this prop will not work.
336
-     */
337
-    scalesPageToFit?: boolean;
338
-    /**
339
-     * Boolean that determines whether HTML5 audio and video requires the user
340
-     * to tap them before they start playing. The default value is `true`.
341
-     */
342
-    mediaPlaybackRequiresUserAction?: boolean;
343
-    /**
344
-     * List of origin strings to allow being navigated to. The strings allow
345
-     * wildcards and get matched against *just* the origin (not the full URL).
346
-     * If the user taps to navigate to a new page but the new page is not in
347
-     * this whitelist, we will open the URL in Safari.
348
-     * The default whitelisted origins are "http://*" and "https://*".
349
-     */
350
-    originWhitelist?: string[];
351
-    /**
352
-     * Override the native component used to render the WebView. Enables a custom native
353
-     * WebView which uses the same JavaScript as the original WebView.
354
-     */
355
-    nativeConfig?: WebViewNativeConfig;
356
-    style?: StyleProp<ViewStyle>;
357
-    children?: ReactNode;
358
-}