Browse Source

fix(deps): updated dependancies and types (#847)

* wip

* Update WebViewShared.tsx

* Update config.yml
Thibault Malbranche 5 years ago
parent
commit
85b921ce64
No account linked to committer's email address
8 changed files with 2304 additions and 2237 deletions
  1. 1
    1
      .circleci/config.yml
  2. 23
    5
      .eslintrc.js
  3. 20
    21
      package.json
  4. 3
    8
      src/WebView.android.tsx
  5. 3
    8
      src/WebView.ios.tsx
  6. 4
    4
      src/WebViewShared.tsx
  7. 16
    24
      src/WebViewTypes.ts
  8. 2234
    2166
      yarn.lock

+ 1
- 1
.circleci/config.yml View File

1
 defaults: &defaults
1
 defaults: &defaults
2
   working_directory: ~/code
2
   working_directory: ~/code
3
   docker:
3
   docker:
4
-    - image: circleci/node:10.6.0-browsers
4
+    - image: circleci/node:12.9.1-browsers
5
 
5
 
6
 version: 2
6
 version: 2
7
 jobs:
7
 jobs:

+ 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

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

+ 4
- 4
src/WebViewShared.tsx View File

18
   `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
18
   `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
19
 
19
 
20
 const passesWhitelist = (
20
 const passesWhitelist = (
21
-  compiledWhitelist: ReadonlyArray<string>,
21
+  compiledWhitelist: readonly string[],
22
   url: string,
22
   url: string,
23
 ) => {
23
 ) => {
24
   const origin = extractOrigin(url);
24
   const origin = extractOrigin(url);
26
 };
26
 };
27
 
27
 
28
 const compileWhitelist = (
28
 const compileWhitelist = (
29
-  originWhitelist: ReadonlyArray<string>,
30
-): ReadonlyArray<string> =>
29
+  originWhitelist: readonly string[],
30
+): readonly string[] =>
31
   ['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
31
   ['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
32
 
32
 
33
 const createOnShouldStartLoadWithRequest = (
33
 const createOnShouldStartLoadWithRequest = (
36
     url: string,
36
     url: string,
37
     lockIdentifier: number,
37
     lockIdentifier: number,
38
   ) => void,
38
   ) => void,
39
-  originWhitelist: ReadonlyArray<string>,
39
+  originWhitelist: readonly string[],
40
   onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest,
40
   onShouldStartLoadWithRequest?: OnShouldStartLoadWithRequest,
41
 ) => {
41
 ) => {
42
   return ({ nativeEvent }: WebViewNavigationEvent) => {
42
   return ({ nativeEvent }: WebViewNavigationEvent) => {

+ 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