Thibault Malbranche 5 anos atrás
pai
commit
6ecd82007a
5 arquivos alterados com 931 adições e 1050 exclusões
  1. 1
    1
      .circleci/config.yml
  2. 8
    3
      jest.config.js
  3. 16
    17
      package.json
  4. 0
    515
      src/WebViewTypes.flow.js
  5. 906
    514
      yarn.lock

+ 1
- 1
.circleci/config.yml Ver arquivo

@@ -35,7 +35,7 @@ jobs:
35 35
 
36 36
       - run:
37 37
           name: Run Tests
38
-          command: yarn ci:test
38
+          command: yarn ci
39 39
 
40 40
   publish:
41 41
     <<: *defaults

+ 8
- 3
jest.config.js Ver arquivo

@@ -88,7 +88,7 @@ module.exports = {
88 88
   // notifyMode: "failure-change",
89 89
 
90 90
   // A preset that is used as a base for Jest's configuration
91
-  preset: "react-native",
91
+  preset: 'react-native',
92 92
 
93 93
   // Run tests from one or more projects
94 94
   // projects: null,
@@ -129,7 +129,7 @@ module.exports = {
129 129
   // snapshotSerializers: [],
130 130
 
131 131
   // The test environment that will be used for testing
132
-  testEnvironment: "node",
132
+  testEnvironment: 'node',
133 133
 
134 134
   // Options that will be passed to the testEnvironment
135 135
   // testEnvironmentOptions: {},
@@ -164,7 +164,12 @@ module.exports = {
164 164
   // timers: "real",
165 165
 
166 166
   // A map from regular expressions to paths to transformers
167
-  // transform: null,
167
+  transform: {
168
+    '^.+\\.ts(x)?$': 'ts-jest',
169
+    '^.+\\.js$': 'babel-jest',
170
+    '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$':
171
+      '<rootDir>/node_modules/react-native/jest/assetFileTransformer.js',
172
+  },
168 173
 
169 174
   // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
170 175
   // transformIgnorePatterns: [

+ 16
- 17
package.json Ver arquivo

@@ -11,35 +11,33 @@
11 11
   "version": "5.3.1",
12 12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13 13
   "scripts": {
14
-    "prepare": "yarn tsc",
15
-    "test:js": "yarn jest",
16
-    "test:ts": "yarn tsc --noEmit && yarn eslint ./src --ext .ts,.tsx",
14
+    "ci": "CI=true && yarn lint && yarn test",
17 15
     "ci:publish": "yarn semantic-release",
18
-    "ci:test": "yarn ci:test:ts && yarn ci:test:js",
19
-    "ci:test:js": "yarn test:js",
20
-    "ci:test:ts": "yarn test:ts",
21
-    "semantic-release": "semantic-release"
16
+    "lint": "yarn tsc --noEmit && yarn eslint ./src --ext .ts,.tsx",
17
+    "prepare": "yarn tsc",
18
+    "semantic-release": "semantic-release",
19
+    "test": "yarn jest"
22 20
   },
23 21
   "peerDependencies": {
24 22
     "react": "^16.0",
25
-    "react-native": ">=0.57 <0.59"
23
+    "react-native": ">=0.57 <0.60"
26 24
   },
27 25
   "dependencies": {
28 26
     "escape-string-regexp": "1.0.5",
29 27
     "invariant": "2.2.4"
30 28
   },
31 29
   "devDependencies": {
32
-    "@babel/core": "^7.2.2",
30
+    "@babel/core": "7.3.4",
33 31
     "@semantic-release/git": "7.0.5",
34
-    "@types/escape-string-regexp": "^1.0.0",
32
+    "@types/escape-string-regexp": "1.0.0",
35 33
     "@types/invariant": "^2.2.29",
36
-    "@types/react": "^16.6.3",
34
+    "@types/jest": "24.0.11",
35
+    "@types/react": "16.8.8",
37 36
     "@types/react-native": "0.57.40",
38 37
     "@typescript-eslint/eslint-plugin": "1.4.2",
39 38
     "@typescript-eslint/parser": "1.4.2",
40 39
     "babel-eslint": "10.0.1",
41 40
     "babel-jest": "^24.0.0",
42
-    "flow-bin": "^0.80.0",
43 41
     "eslint": "5.15.1",
44 42
     "eslint-config-airbnb": "17.1.0",
45 43
     "eslint-config-prettier": "4.1.0",
@@ -47,12 +45,13 @@
47 45
     "eslint-plugin-jsx-a11y": "6.2.1",
48 46
     "eslint-plugin-react": "7.12.4",
49 47
     "eslint-plugin-react-native": "3.6.0",
50
-    "jest": "^24.0.0",
51
-    "metro-react-native-babel-preset": "^0.51.1",
52
-    "react": "16.6.3",
53
-    "react-native": "^0.57.8",
48
+    "jest": "24.5.0",
49
+    "metro-react-native-babel-preset": "0.53.1",
50
+    "react": "16.8.3",
51
+    "react-native": "0.59.1",
54 52
     "semantic-release": "15.10.3",
55
-    "typescript": "^3.3.3333"
53
+    "ts-jest": "24.0.0",
54
+    "typescript": "3.3.3333"
56 55
   },
57 56
   "repository": {
58 57
     "type": "git",

+ 0
- 515
src/WebViewTypes.flow.js Ver arquivo

@@ -1,515 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @flow
9
- */
10
-
11
-'use strict';
12
-
13
-import type { Node, Element, ComponentType } from 'react';
14
-
15
-import type { SyntheticEvent } from 'CoreEventTypes';
16
-import type { EdgeInsetsProp } from 'EdgeInsetsPropType';
17
-import type { ViewStyleProp } from 'StyleSheet';
18
-import type { ViewProps } from 'ViewPropTypes';
19
-
20
-export type WebViewNativeEvent = $ReadOnly<{|
21
-  url: string,
22
-  loading: boolean,
23
-  title: string,
24
-  canGoBack: boolean,
25
-  canGoForward: boolean,
26
-  lockIdentifier: number,
27
-|}>;
28
-
29
-export type WebViewProgressEvent = $ReadOnly<{|
30
-  ...WebViewNativeEvent,
31
-  progress: number,
32
-|}>;
33
-
34
-export type WebViewNavigation = $ReadOnly<{|
35
-  ...WebViewNativeEvent,
36
-  navigationType:
37
-    | 'click'
38
-    | 'formsubmit'
39
-    | 'backforward'
40
-    | 'reload'
41
-    | 'formresubmit'
42
-    | 'other',
43
-|}>;
44
-
45
-export type WebViewMessage = $ReadOnly<{|
46
-  ...WebViewNativeEvent,
47
-  data: string,
48
-|}>;
49
-
50
-export type WebViewError = $ReadOnly<{|
51
-  ...WebViewNativeEvent,
52
-  /**
53
-   * `domain` is only used on iOS
54
-   */
55
-  domain: ?string,
56
-  code: number,
57
-  description: string,
58
-|}>;
59
-
60
-export type WebViewEvent = SyntheticEvent<WebViewNativeEvent>;
61
-
62
-export type WebViewNavigationEvent = SyntheticEvent<WebViewNavigation>;
63
-
64
-export type WebViewMessageEvent = SyntheticEvent<WebViewMessage>;
65
-
66
-export type WebViewErrorEvent = SyntheticEvent<WebViewError>;
67
-
68
-export type DataDetectorTypes =
69
-  | 'phoneNumber'
70
-  | 'link'
71
-  | 'address'
72
-  | 'calendarEvent'
73
-  | 'trackingNumber'
74
-  | 'flightNumber'
75
-  | 'lookupSuggestion'
76
-  | 'none'
77
-  | 'all';
78
-
79
-export type OverScrollModeType = 'always' | 'content' | 'never';
80
-
81
-export type WebViewSourceUri = $ReadOnly<{|
82
-  /**
83
-   * The URI to load in the `WebView`. Can be a local or remote file.
84
-   */
85
-  uri?: ?string,
86
-
87
-  /**
88
-   * The HTTP Method to use. Defaults to GET if not specified.
89
-   * NOTE: On Android, only GET and POST are supported.
90
-   */
91
-  method?: string,
92
-
93
-  /**
94
-   * Additional HTTP headers to send with the request.
95
-   * NOTE: On Android, this can only be used with GET requests.
96
-   */
97
-  headers?: Object,
98
-
99
-  /**
100
-   * The HTTP body to send with the request. This must be a valid
101
-   * UTF-8 string, and will be sent exactly as specified, with no
102
-   * additional encoding (e.g. URL-escaping or base64) applied.
103
-   * NOTE: On Android, this can only be used with POST requests.
104
-   */
105
-  body?: string,
106
-|}>;
107
-
108
-export type WebViewSourceHtml = $ReadOnly<{|
109
-  /**
110
-   * A static HTML page to display in the WebView.
111
-   */
112
-  html?: ?string,
113
-  /**
114
-   * The base URL to be used for any relative links in the HTML.
115
-   */
116
-  baseUrl?: ?string,
117
-|}>;
118
-
119
-export type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
120
-
121
-export type WebViewNativeConfig = $ReadOnly<{|
122
-  /**
123
-   * The native component used to render the WebView.
124
-   */
125
-  component?: ComponentType<WebViewSharedProps>,
126
-  /**
127
-   * Set props directly on the native component WebView. Enables custom props which the
128
-   * original WebView doesn't pass through.
129
-   */
130
-  props?: ?Object,
131
-  /**
132
-   * Set the ViewManager to use for communication with the native side.
133
-   * @platform ios
134
-   */
135
-  viewManager?: ?Object,
136
-|}>;
137
-
138
-export type OnShouldStartLoadWithRequest = (
139
-  event: WebViewNavigation,
140
-) => boolean;
141
-
142
-export type IOSWebViewProps = $ReadOnly<{|
143
-  /**
144
-   * If true, use WKWebView instead of UIWebView.
145
-   * @platform ios
146
-   */
147
-  useWebKit?: ?boolean,
148
-
149
-  /**
150
-   * Boolean value that determines whether the web view bounces
151
-   * when it reaches the edge of the content. The default value is `true`.
152
-   * @platform ios
153
-   */
154
-  bounces?: ?boolean,
155
-
156
-  /**
157
-   * A floating-point number that determines how quickly the scroll view
158
-   * decelerates after the user lifts their finger. You may also use the
159
-   * string shortcuts `"normal"` and `"fast"` which match the underlying iOS
160
-   * settings for `UIScrollViewDecelerationRateNormal` and
161
-   * `UIScrollViewDecelerationRateFast` respectively:
162
-   *
163
-   *   - normal: 0.998
164
-   *   - fast: 0.99 (the default for iOS web view)
165
-   * @platform ios
166
-   */
167
-  decelerationRate?: ?('fast' | 'normal' | number),
168
-
169
-  /**
170
-   * Boolean value that determines whether scrolling is enabled in the
171
-   * `WebView`. The default value is `true`.
172
-   * @platform ios
173
-   */
174
-  scrollEnabled?: ?boolean,
175
-
176
-  /**
177
-   * If the value of this property is true, the scroll view stops on multiples
178
-   * of the scroll view’s bounds when the user scrolls.
179
-   * The default value is false.
180
-   * @platform ios
181
-   */
182
-  pagingEnabled?: ?boolean,
183
-
184
-  /**
185
-   * The amount by which the web view content is inset from the edges of
186
-   * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
187
-   * @platform ios
188
-   */
189
-  contentInset?: ?EdgeInsetsProp,
190
-
191
-  /**
192
-   * Determines the types of data converted to clickable URLs in the web view's content.
193
-   * By default only phone numbers are detected.
194
-   *
195
-   * You can provide one type or an array of many types.
196
-   *
197
-   * Possible values for `dataDetectorTypes` are:
198
-   *
199
-   * - `'phoneNumber'`
200
-   * - `'link'`
201
-   * - `'address'`
202
-   * - `'calendarEvent'`
203
-   * - `'none'`
204
-   * - `'all'`
205
-   *
206
-   * With the new WebKit implementation, we have three new values:
207
-   * - `'trackingNumber'`,
208
-   * - `'flightNumber'`,
209
-   * - `'lookupSuggestion'`,
210
-   *
211
-   * @platform ios
212
-   */
213
-  dataDetectorTypes?: ?DataDetectorTypes | $ReadOnlyArray<DataDetectorTypes>,
214
-
215
-  /**
216
-   * Boolean that determines whether HTML5 videos play inline or use the
217
-   * native full-screen controller. The default value is `false`.
218
-   *
219
-   * **NOTE** : In order for video to play inline, not only does this
220
-   * property need to be set to `true`, but the video element in the HTML
221
-   * document must also include the `webkit-playsinline` attribute.
222
-   * @platform ios
223
-   */
224
-  allowsInlineMediaPlayback?: ?boolean,
225
-  /**
226
-   * Hide the accessory view when the keyboard is open. Default is false to be
227
-   * backward compatible.
228
-   */
229
-  hideKeyboardAccessoryView?: ?boolean,
230
-  /**
231
-   * A Boolean value indicating whether horizontal swipe gestures will trigger
232
-   * back-forward list navigations.
233
-   */
234
-  allowsBackForwardNavigationGestures?: ?boolean,
235
-  /**
236
-   * A Boolean value indicating whether WebKit WebView should be created using a shared
237
-   * process pool, enabling WebViews to share cookies and localStorage between each other.
238
-   * Default is true but can be set to false for backwards compatibility.
239
-   * @platform ios
240
-   */
241
-  useSharedProcessPool?: ?boolean,
242
-  /**
243
-   * The custom user agent string.
244
-   */
245
-  userAgent?: ?string,
246
-
247
-  /**
248
-   * A Boolean value that determines whether pressing on a link
249
-   * displays a preview of the destination for the link.
250
-   *
251
-   * This property is available on devices that support 3D Touch.
252
-   * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
253
-   * @platform ios
254
-   */
255
-  allowsLinkPreview?: ?boolean,
256
-
257
-  /**
258
-   * A Boolean value that determines whether scrolling is disabled in a particular direction.
259
-   * The default value is `true`.
260
-   * @platform ios
261
-   */
262
-  directionalLockEnabled?: ?boolean,
263
-|}>;
264
-
265
-export type AndroidWebViewProps = $ReadOnly<{|
266
-  onNavigationStateChange?: (event: WebViewNavigation) => mixed,
267
-  onContentSizeChange?: (event: WebViewEvent) => mixed,
268
-
269
-  /**
270
-   * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
271
-   * Sets the overScrollMode. Possible values are:
272
-   *
273
-   * - `'always'` (default)
274
-   * - `'content'`
275
-   * - `'never'`
276
-   *
277
-   * @platform android
278
-   */
279
-  overScrollMode?: ?OverScrollModeType,
280
-
281
-  /**
282
-   * Sets whether Geolocation is enabled. The default is false.
283
-   * @platform android
284
-   */
285
-  geolocationEnabled?: ?boolean,
286
-
287
-  /**
288
-   * Boolean that sets whether JavaScript running in the context of a file
289
-   * scheme URL should be allowed to access content from any origin.
290
-   * Including accessing content from other file scheme URLs
291
-   * @platform android
292
-   */
293
-  allowUniversalAccessFromFileURLs?: ?boolean,
294
-
295
-  /**
296
-   * Sets whether the webview allow access to file system.
297
-   * @platform android
298
-   */
299
-  allowFileAccess?: ?boolean,
300
-
301
-  /**
302
-   * Used on Android only, controls whether form autocomplete data should be saved
303
-   * @platform android
304
-   */
305
-  saveFormDataDisabled?: ?boolean,
306
-
307
-  /**
308
-   * Used on Android only, controls whether the given list of URL prefixes should
309
-   * make {@link com.facebook.react.views.webview.ReactWebViewClient} to launch a
310
-   * default activity intent for those URL instead of loading it within the webview.
311
-   * Use this to list URLs that WebView cannot handle, e.g. a PDF url.
312
-   * @platform android
313
-   */
314
-  urlPrefixesForDefaultIntent?: $ReadOnlyArray<string>,
315
-
316
-  /**
317
-   * Boolean value to enable JavaScript in the `WebView`. Used on Android only
318
-   * as JavaScript is enabled by default on iOS. The default value is `true`.
319
-   * @platform android
320
-   */
321
-  javaScriptEnabled?: ?boolean,
322
-
323
-  /**
324
-   * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
325
-   * as Hardware Acceleration is a feature only for Android. The default value is `false`.
326
-   * @platform android
327
-   */
328
-  androidHardwareAccelerationDisabled?: ?boolean,
329
-
330
-  /**
331
-   * Boolean value to enable third party cookies in the `WebView`. Used on
332
-   * Android Lollipop and above only as third party cookies are enabled by
333
-   * default on Android Kitkat and below and on iOS. The default value is `true`.
334
-   * @platform android
335
-   */
336
-  thirdPartyCookiesEnabled?: ?boolean,
337
-
338
-  /**
339
-   * Boolean value to control whether DOM Storage is enabled. Used only in
340
-   * Android.
341
-   * @platform android
342
-   */
343
-  domStorageEnabled?: ?boolean,
344
-
345
-  /**
346
-   * Sets the user-agent for the `WebView`.
347
-   * @platform android
348
-   */
349
-  userAgent?: ?string,
350
-
351
-  /**
352
-   * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
353
-   *
354
-   * Possible values for `mixedContentMode` are:
355
-   *
356
-   * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
357
-   * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
358
-   * - `'compatibility'` -  WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
359
-   * @platform android
360
-   */
361
-  mixedContentMode?: ?('never' | 'always' | 'compatibility'),
362
-|}>;
363
-
364
-export type WebViewSharedProps = $ReadOnly<{|
365
-  ...ViewProps,
366
-  ...IOSWebViewProps,
367
-  ...AndroidWebViewProps,
368
-  /**
369
-   * Deprecated. Use `source` instead.
370
-   */
371
-  url?: ?string,
372
-  /**
373
-   * Deprecated. Use `source` instead.
374
-   */
375
-  html?: ?string,
376
-
377
-  /**
378
-   * Loads static html or a uri (with optional headers) in the WebView.
379
-   */
380
-  source?: ?WebViewSource,
381
-
382
-  /**
383
-   * Does not store any data within the lifetime of the WebView.
384
-   */
385
-  incognito?: ?boolean,
386
-
387
-  /**
388
-   * Function that returns a view to show if there's an error.
389
-   */
390
-  renderError: (
391
-    errorDomain: ?string,
392
-    errorCode: number,
393
-    errorDesc: string,
394
-  ) => Element<any>, // view to show if there's an error
395
-
396
-  /**
397
-   * Function that returns a loading indicator.
398
-   */
399
-  renderLoading: () => Element<any>,
400
-
401
-  /**
402
-   * Function that is invoked when the `WebView` has finished loading.
403
-   */
404
-  onLoad: (event: WebViewNavigationEvent) => mixed,
405
-
406
-  /**
407
-   * Function that is invoked when the `WebView` load succeeds or fails.
408
-   */
409
-  onLoadEnd: (event: WebViewNavigationEvent | WebViewErrorEvent) => mixed,
410
-
411
-  /**
412
-   * Function that is invoked when the `WebView` starts loading.
413
-   */
414
-  onLoadStart: (event: WebViewNavigationEvent) => mixed,
415
-
416
-  /**
417
-   * Function that is invoked when the `WebView` load fails.
418
-   */
419
-  onError: (event: WebViewErrorEvent) => mixed,
420
-
421
-  /**
422
-   * Controls whether to adjust the content inset for web views that are
423
-   * placed behind a navigation bar, tab bar, or toolbar. The default value
424
-   * is `true`.
425
-   */
426
-  automaticallyAdjustContentInsets?: ?boolean,
427
-
428
-  /**
429
-   * Function that is invoked when the `WebView` loading starts or ends.
430
-   */
431
-  onNavigationStateChange?: (event: WebViewNavigation) => mixed,
432
-
433
-  /**
434
-   * Function that is invoked when the webview calls `window.ReactNativeWebView.postMessage`.
435
-   * Setting this property will inject this global into your webview.
436
-   *
437
-   * `window.ReactNativeWebView.postMessage` accepts one argument, `data`, which will be
438
-   * available on the event object, `event.nativeEvent.data`. `data` must be a string.
439
-   */
440
-  onMessage?: (event: WebViewMessageEvent) => mixed,
441
-
442
-  /**
443
-   * Function that is invoked when the `WebView` is loading.
444
-   */
445
-  onLoadProgress?: (event: WebViewProgressEvent) => mixed,
446
-
447
-  /**
448
-   * Boolean value that forces the `WebView` to show the loading view
449
-   * on the first load.
450
-   */
451
-  startInLoadingState?: ?boolean,
452
-
453
-  /**
454
-   * Set this to provide JavaScript that will be injected into the web page
455
-   * when the view loads.
456
-   */
457
-  injectedJavaScript?: ?string,
458
-
459
-  /**
460
-   * Boolean value that determines whether a horizontal scroll indicator is
461
-   * shown in the `WebView`. The default value is `true`.
462
-   */
463
-  showsHorizontalScrollIndicator?: ?boolean,
464
-
465
-  /**
466
-   * Boolean value that determines whether a vertical scroll indicator is
467
-   * shown in the `WebView`. The default value is `true`.
468
-   */
469
-  showsVerticalScrollIndicator?: ?boolean,
470
-
471
-  /**
472
-   * Boolean that controls whether the web content is scaled to fit
473
-   * the view and enables the user to change the scale. The default value
474
-   * is `true`.
475
-   *
476
-   * On iOS, when `useWebKit=true`, this prop will not work.
477
-   */
478
-  scalesPageToFit?: ?boolean,
479
-
480
-  /**
481
-   * Boolean that determines whether HTML5 audio and video requires the user
482
-   * to tap them before they start playing. The default value is `true`.
483
-   */
484
-  mediaPlaybackRequiresUserAction?: ?boolean,
485
-
486
-  /**
487
-   * List of origin strings to allow being navigated to. The strings allow
488
-   * wildcards and get matched against *just* the origin (not the full URL).
489
-   * If the user taps to navigate to a new page but the new page is not in
490
-   * this whitelist, we will open the URL in Safari.
491
-   * The default whitelisted origins are "http://*" and "https://*".
492
-   */
493
-  originWhitelist?: $ReadOnlyArray<string>,
494
-
495
-  /**
496
-   * Function that allows custom handling of any web view requests. Return
497
-   * `true` from the function to continue loading the request and `false`
498
-   * to stop loading. The `navigationType` is always `other` on android.
499
-   */
500
-  onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest,
501
-
502
-  /**
503
-   * Override the native component used to render the WebView. Enables a custom native
504
-   * WebView which uses the same JavaScript as the original WebView.
505
-   */
506
-  nativeConfig?: ?WebViewNativeConfig,
507
-
508
-  /**
509
-   * Should caching be enabled. Default is true.
510
-   */
511
-  cacheEnabled?: ?boolean,
512
-
513
-  style?: ViewStyleProp,
514
-  children: Node,
515
-|}>;

+ 906
- 514
yarn.lock
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo