Thibault Malbranche 5 years ago
parent
commit
ec5aba9d2f
6 changed files with 2299 additions and 2232 deletions
  1. 23
    5
      .eslintrc.js
  2. 20
    21
      package.json
  3. 3
    8
      src/WebView.android.tsx
  4. 3
    8
      src/WebView.ios.tsx
  5. 16
    24
      src/WebViewTypes.ts
  6. 2234
    2166
      yarn.lock

+ 23
- 5
.eslintrc.js View File

20
     // Remove this rule because we only destructure props, but never state
20
     // Remove this rule because we only destructure props, but never state
21
     'react/destructuring-assignment': 'off',
21
     'react/destructuring-assignment': 'off',
22
     'react/prop-types': 'off',
22
     'react/prop-types': 'off',
23
+    'react/jsx-props-no-spreading': 'off',
24
+    'react/static-property-placement': 'off',
25
+    'react/state-in-constructor': 'off',
23
     '@typescript-eslint/adjacent-overload-signatures': 'error',
26
     '@typescript-eslint/adjacent-overload-signatures': 'error',
24
-    '@typescript-eslint/array-type': ['error', 'array'],
27
+    '@typescript-eslint/array-type': [
28
+      'error',
29
+      {
30
+        default: 'array',
31
+      },
32
+    ],
25
     '@typescript-eslint/generic-type-naming': ['error', '^[a-zA-Z]+$'],
33
     '@typescript-eslint/generic-type-naming': ['error', '^[a-zA-Z]+$'],
26
-    '@typescript-eslint/no-angle-bracket-type-assertion': 'error',
27
     '@typescript-eslint/no-array-constructor': 'error',
34
     '@typescript-eslint/no-array-constructor': 'error',
28
     '@typescript-eslint/no-empty-interface': 'error',
35
     '@typescript-eslint/no-empty-interface': 'error',
29
     '@typescript-eslint/no-explicit-any': 'error',
36
     '@typescript-eslint/no-explicit-any': 'error',
32
     '@typescript-eslint/no-misused-new': 'error',
39
     '@typescript-eslint/no-misused-new': 'error',
33
     '@typescript-eslint/no-namespace': 'error',
40
     '@typescript-eslint/no-namespace': 'error',
34
     '@typescript-eslint/no-non-null-assertion': 'error',
41
     '@typescript-eslint/no-non-null-assertion': 'error',
35
-    '@typescript-eslint/no-object-literal-type-assertion': 'error',
42
+    '@typescript-eslint/consistent-type-assertions': [
43
+      'error',
44
+      {
45
+        assertionStyle: 'as',
46
+      },
47
+    ],
36
     '@typescript-eslint/no-parameter-properties': 'error',
48
     '@typescript-eslint/no-parameter-properties': 'error',
37
     '@typescript-eslint/no-this-alias': 'error',
49
     '@typescript-eslint/no-this-alias': 'error',
38
-    '@typescript-eslint/no-triple-slash-reference': 'error',
50
+    '@typescript-eslint/triple-slash-reference': [
51
+      'error',
52
+      { path: 'never', types: 'never', lib: 'never' },
53
+    ],
39
     '@typescript-eslint/no-type-alias': [
54
     '@typescript-eslint/no-type-alias': [
40
       'error',
55
       'error',
41
       {
56
       {
48
       'error',
63
       'error',
49
       { ignoreRestSiblings: true },
64
       { ignoreRestSiblings: true },
50
     ],
65
     ],
51
-    '@typescript-eslint/prefer-interface': 'error',
66
+    '@typescript-eslint/consistent-type-definitions': [
67
+      'error',
68
+      'interface',
69
+    ],
52
     '@typescript-eslint/prefer-namespace-keyword': 'error',
70
     '@typescript-eslint/prefer-namespace-keyword': 'error',
53
     '@typescript-eslint/type-annotation-spacing': 'error',
71
     '@typescript-eslint/type-annotation-spacing': 'error',
54
   },
72
   },

+ 20
- 21
package.json View File

23
     "react-native": ">=0.60 <0.62"
23
     "react-native": ">=0.60 <0.62"
24
   },
24
   },
25
   "dependencies": {
25
   "dependencies": {
26
-    "escape-string-regexp": "1.0.5",
26
+    "escape-string-regexp": "2.0.0",
27
     "invariant": "2.2.4"
27
     "invariant": "2.2.4"
28
   },
28
   },
29
   "devDependencies": {
29
   "devDependencies": {
30
-    "@babel/core": "7.3.4",
31
-    "@semantic-release/git": "7.0.5",
32
-    "@types/escape-string-regexp": "1.0.0",
33
-    "@types/invariant": "^2.2.29",
34
-    "@types/jest": "24.0.11",
30
+    "@babel/core": "7.5.5",
31
+    "@semantic-release/git": "7.0.16",
32
+    "@types/invariant": "^2.2.30",
33
+    "@types/jest": "24.0.18",
35
     "@types/react": "16.8.8",
34
     "@types/react": "16.8.8",
36
-    "@types/react-native": "0.57.40",
37
-    "@typescript-eslint/eslint-plugin": "1.4.2",
38
-    "@typescript-eslint/parser": "1.4.2",
39
-    "babel-eslint": "10.0.1",
40
-    "babel-jest": "^24.0.0",
41
-    "eslint": "5.15.1",
42
-    "eslint-config-airbnb": "17.1.0",
43
-    "eslint-config-prettier": "4.1.0",
44
-    "eslint-plugin-import": "2.16.0",
45
-    "eslint-plugin-jsx-a11y": "6.2.1",
46
-    "eslint-plugin-react": "7.12.4",
47
-    "eslint-plugin-react-native": "3.6.0",
48
-    "jest": "24.5.0",
35
+    "@types/react-native": "0.60.11",
36
+    "@typescript-eslint/eslint-plugin": "2.1.0",
37
+    "@typescript-eslint/parser": "2.1.0",
38
+    "babel-eslint": "10.0.3",
39
+    "babel-jest": "^24.9.0",
40
+    "eslint": "6.3.0",
41
+    "eslint-config-airbnb": "18.0.1",
42
+    "eslint-config-prettier": "6.2.0",
43
+    "eslint-plugin-import": "2.18.2",
44
+    "eslint-plugin-jsx-a11y": "6.2.3",
45
+    "eslint-plugin-react": "7.14.3",
46
+    "eslint-plugin-react-native": "3.7.0",
47
+    "jest": "24.9.0",
49
     "metro-react-native-babel-preset": "0.53.1",
48
     "metro-react-native-babel-preset": "0.53.1",
50
     "react": "16.8.3",
49
     "react": "16.8.3",
51
     "react-native": "0.60.5",
50
     "react-native": "0.60.5",
52
-    "semantic-release": "15.10.3",
53
-    "typescript": "3.3.3333"
51
+    "semantic-release": "15.13.24",
52
+    "typescript": "3.6.2"
54
   },
53
   },
55
   "repository": {
54
   "repository": {
56
     "type": "git",
55
     "type": "git",

+ 3
- 8
src/WebView.android.tsx View File

26
   AndroidWebViewProps,
26
   AndroidWebViewProps,
27
   NativeWebViewAndroid,
27
   NativeWebViewAndroid,
28
   State,
28
   State,
29
-  CustomUIManager,
29
+  RNCWebViewUIManager,
30
 } from './WebViewTypes';
30
 } from './WebViewTypes';
31
 
31
 
32
 import styles from './WebView.styles';
32
 import styles from './WebView.styles';
33
 
33
 
34
-const UIManager = NotTypedUIManager as CustomUIManager;
34
+const UIManager = NotTypedUIManager as RNCWebViewUIManager;
35
 
35
 
36
 const RNCWebView = requireNativeComponent(
36
 const RNCWebView = requireNativeComponent(
37
   'RNCWebView',
37
   'RNCWebView',
73
     UIManager.dispatchViewManagerCommand(
73
     UIManager.dispatchViewManagerCommand(
74
       this.getWebViewHandle(),
74
       this.getWebViewHandle(),
75
       this.getCommands().goForward,
75
       this.getCommands().goForward,
76
-      null,
77
     );
76
     );
78
   };
77
   };
79
 
78
 
81
     UIManager.dispatchViewManagerCommand(
80
     UIManager.dispatchViewManagerCommand(
82
       this.getWebViewHandle(),
81
       this.getWebViewHandle(),
83
       this.getCommands().goBack,
82
       this.getCommands().goBack,
84
-      null,
85
     );
83
     );
86
   };
84
   };
87
 
85
 
92
     UIManager.dispatchViewManagerCommand(
90
     UIManager.dispatchViewManagerCommand(
93
       this.getWebViewHandle(),
91
       this.getWebViewHandle(),
94
       this.getCommands().reload,
92
       this.getCommands().reload,
95
-      null,
96
     );
93
     );
97
   };
94
   };
98
 
95
 
100
     UIManager.dispatchViewManagerCommand(
97
     UIManager.dispatchViewManagerCommand(
101
       this.getWebViewHandle(),
98
       this.getWebViewHandle(),
102
       this.getCommands().stopLoading,
99
       this.getCommands().stopLoading,
103
-      null,
104
     );
100
     );
105
   };
101
   };
106
 
102
 
108
     UIManager.dispatchViewManagerCommand(
104
     UIManager.dispatchViewManagerCommand(
109
       this.getWebViewHandle(),
105
       this.getWebViewHandle(),
110
       this.getCommands().requestFocus,
106
       this.getCommands().requestFocus,
111
-      null,
112
     );
107
     );
113
   };
108
   };
114
 
109
 
268
     const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
263
     const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
269
       this.onShouldStartLoadWithRequestCallback,
264
       this.onShouldStartLoadWithRequestCallback,
270
       // casting cause it's in the default props
265
       // casting cause it's in the default props
271
-      originWhitelist as ReadonlyArray<string>,
266
+      originWhitelist as readonly string[],
272
       onShouldStartLoadWithRequestProp,
267
       onShouldStartLoadWithRequestProp,
273
     );
268
     );
274
 
269
 

+ 3
- 8
src/WebView.ios.tsx View File

26
   NativeWebViewIOS,
26
   NativeWebViewIOS,
27
   ViewManager,
27
   ViewManager,
28
   State,
28
   State,
29
-  CustomUIManager,
29
+  RNCWebViewUIManager,
30
 } from './WebViewTypes';
30
 } from './WebViewTypes';
31
 
31
 
32
 import styles from './WebView.styles';
32
 import styles from './WebView.styles';
33
 
33
 
34
-const UIManager = NotTypedUIManager as CustomUIManager;
34
+const UIManager = NotTypedUIManager as RNCWebViewUIManager;
35
 
35
 
36
 const { resolveAssetSource } = Image;
36
 const { resolveAssetSource } = Image;
37
 const processDecelerationRate = (
37
 const processDecelerationRate = (
82
     UIManager.dispatchViewManagerCommand(
82
     UIManager.dispatchViewManagerCommand(
83
       this.getWebViewHandle(),
83
       this.getWebViewHandle(),
84
       this.getCommands().goForward,
84
       this.getCommands().goForward,
85
-      null,
86
     );
85
     );
87
   };
86
   };
88
 
87
 
93
     UIManager.dispatchViewManagerCommand(
92
     UIManager.dispatchViewManagerCommand(
94
       this.getWebViewHandle(),
93
       this.getWebViewHandle(),
95
       this.getCommands().goBack,
94
       this.getCommands().goBack,
96
-      null,
97
     );
95
     );
98
   };
96
   };
99
 
97
 
105
     UIManager.dispatchViewManagerCommand(
103
     UIManager.dispatchViewManagerCommand(
106
       this.getWebViewHandle(),
104
       this.getWebViewHandle(),
107
       this.getCommands().reload,
105
       this.getCommands().reload,
108
-      null,
109
     );
106
     );
110
   };
107
   };
111
 
108
 
116
     UIManager.dispatchViewManagerCommand(
113
     UIManager.dispatchViewManagerCommand(
117
       this.getWebViewHandle(),
114
       this.getWebViewHandle(),
118
       this.getCommands().stopLoading,
115
       this.getCommands().stopLoading,
119
-      null,
120
     );
116
     );
121
   };
117
   };
122
 
118
 
127
     UIManager.dispatchViewManagerCommand(
123
     UIManager.dispatchViewManagerCommand(
128
       this.getWebViewHandle(),
124
       this.getWebViewHandle(),
129
       this.getCommands().requestFocus,
125
       this.getCommands().requestFocus,
130
-      null,
131
     );
126
     );
132
   };
127
   };
133
 
128
 
301
     const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
296
     const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
302
       this.onShouldStartLoadWithRequestCallback,
297
       this.onShouldStartLoadWithRequestCallback,
303
       // casting cause it's in the default props
298
       // casting cause it's in the default props
304
-      originWhitelist as ReadonlyArray<string>,
299
+      originWhitelist as readonly string[],
305
       onShouldStartLoadWithRequestProp,
300
       onShouldStartLoadWithRequestProp,
306
     );
301
     );
307
 
302
 

+ 16
- 24
src/WebViewTypes.ts View File

1
-/* eslint-disable react/no-multi-comp */
1
+/* eslint-disable react/no-multi-comp, max-classes-per-file */
2
 
2
 
3
 import { ReactElement, Component } from 'react';
3
 import { ReactElement, Component } from 'react';
4
 import {
4
 import {
11
 } from 'react-native';
11
 } from 'react-native';
12
 
12
 
13
 export interface WebViewCommands {
13
 export interface WebViewCommands {
14
-  goForward: Function;
15
-  goBack: Function;
16
-  reload: Function;
17
-  stopLoading: Function;
18
-  postMessage: Function;
19
-  injectJavaScript: Function;
20
-  loadUrl: Function;
21
-  requestFocus: Function;
14
+  goForward: number;
15
+  goBack: number;
16
+  reload: number;
17
+  stopLoading: number;
18
+  postMessage: number;
19
+  injectJavaScript: number;
20
+  loadUrl: number;
21
+  requestFocus: number;
22
 }
22
 }
23
 
23
 
24
-export interface CustomUIManager extends UIManagerStatic {
24
+export interface RNCWebViewUIManager extends UIManagerStatic {
25
   getViewManagerConfig: (
25
   getViewManagerConfig: (
26
-    name: string,
26
+    name: 'RNCWebView',
27
   ) => {
27
   ) => {
28
     Commands: WebViewCommands;
28
     Commands: WebViewCommands;
29
   };
29
   };
30
-  dispatchViewManagerCommand: (
31
-    viewHandle: number,
32
-    command: Function,
33
-    params: object | null,
34
-  ) => void;
35
-  RNCWebView: {
36
-    Commands: WebViewCommands;
37
-  };
38
 }
30
 }
39
 
31
 
40
 type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
32
 type WebViewState = 'IDLE' | 'LOADING' | 'ERROR';
246
   saveFormDataDisabled?: boolean;
238
   saveFormDataDisabled?: boolean;
247
   textZoom?: number;
239
   textZoom?: number;
248
   thirdPartyCookiesEnabled?: boolean;
240
   thirdPartyCookiesEnabled?: boolean;
249
-  urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
241
+  urlPrefixesForDefaultIntent?: readonly string[];
250
 }
242
 }
251
 
243
 
252
 export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
244
 export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
262
     | 'scrollableAxes'
254
     | 'scrollableAxes'
263
     | 'never'
255
     | 'never'
264
     | 'always';
256
     | 'always';
265
-  dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
257
+  dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
266
   decelerationRate?: number;
258
   decelerationRate?: number;
267
   directionalLockEnabled?: boolean;
259
   directionalLockEnabled?: boolean;
268
   hideKeyboardAccessoryView?: boolean;
260
   hideKeyboardAccessoryView?: boolean;
360
    *
352
    *
361
    * @platform ios
353
    * @platform ios
362
    */
354
    */
363
-  dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
355
+  dataDetectorTypes?: DataDetectorTypes | readonly DataDetectorTypes[];
364
 
356
 
365
   /**
357
   /**
366
    * Boolean that determines whether HTML5 videos play inline or use the
358
    * Boolean that determines whether HTML5 videos play inline or use the
500
    * Use this to list URLs that WebView cannot handle, e.g. a PDF url.
492
    * Use this to list URLs that WebView cannot handle, e.g. a PDF url.
501
    * @platform android
493
    * @platform android
502
    */
494
    */
503
-  urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
495
+  urlPrefixesForDefaultIntent?: readonly string[];
504
 
496
 
505
   /**
497
   /**
506
    * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
498
    * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
662
    * this whitelist, we will open the URL in Safari.
654
    * this whitelist, we will open the URL in Safari.
663
    * The default whitelisted origins are "http://*" and "https://*".
655
    * The default whitelisted origins are "http://*" and "https://*".
664
    */
656
    */
665
-  originWhitelist?: ReadonlyArray<string>;
657
+  originWhitelist?: readonly string[];
666
 
658
 
667
   /**
659
   /**
668
    * Function that allows custom handling of any web view requests. Return
660
    * Function that allows custom handling of any web view requests. Return

+ 2234
- 2166
yarn.lock
File diff suppressed because it is too large
View File