Kaynağa Gözat

Fixes flow

closes #275
Gaëtan Renaudeau 4 yıl önce
ebeveyn
işleme
323b613ef2
No account linked to committer's email address
6 değiştirilmiş dosya ile 5536 ekleme ve 542 silme
  1. 5
    40
      .flowconfig
  2. 19
    19
      example/package.json
  3. 813
    463
      example/yarn.lock
  4. 5
    0
      package.json
  5. 18
    20
      src/index.js
  6. 4676
    0
      yarn.lock

+ 5
- 40
.flowconfig Dosyayı Görüntüle

@@ -1,49 +1,14 @@
1 1
 [ignore]
2
-
3
-# We fork some components by platform.
4
-.*/*[.]android.js
5
-
6
-# Ignore templates with `@flow` in header
7
-.*/local-cli/generator.*
8
-
9
-# Ignore malformed json
10
-.*/node_modules/y18n/test/.*\.json
11
-
12
-# Ignore unexpected extra @providesModule
13
-.*/node_modules/commoner/test/source/widget/share.js
14
-
15
-# Ignore duplicate module providers
16
-# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
17
-.*/Libraries/react-native/React.js
18
-.*/Libraries/react-native/ReactNative.js
19
-.*/node_modules/jest-runtime/build/__tests__/.*
2
+<PROJECT_ROOT>/example/
20 3
 
21 4
 [include]
22 5
 
23 6
 [libs]
24
-node_modules/react-native/Libraries/react-native/react-native-interface.js
25 7
 node_modules/react-native/flow
26
-flow/
27
-
28
-[options]
29
-module.system=haste
30
-
31
-esproposal.class_static_fields=enable
32
-esproposal.class_instance_fields=enable
33
-
34
-experimental.strict_type_args=true
35
-
36
-munge_underscores=true
37
-
38
-module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
39
-module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
8
+node_modules/react-native/Libraries/react-native/react-native-interface.js
40 9
 
41
-suppress_type=$FlowIssue
42
-suppress_type=$FlowFixMe
43
-suppress_type=$FixMe
10
+[lints]
44 11
 
45
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
46
-suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
47
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
12
+[options]
48 13
 
49
-unsafe.enable_getters_and_setters=true
14
+[strict]

+ 19
- 19
example/package.json Dosyayı Görüntüle

@@ -7,32 +7,32 @@
7 7
     "lint": "eslint ."
8 8
   },
9 9
   "dependencies": {
10
-    "@react-native-community/art": "^1.0.1",
11
-    "@react-native-community/slider": "^2.0.0",
10
+    "@react-native-community/art": "^1.1.2",
11
+    "@react-native-community/slider": "^2.0.8",
12 12
     "gl-react": "2",
13 13
     "gl-react-native": "2",
14 14
     "lodash": "^4.17.15",
15
-    "react": "16.8.6",
16
-    "react-native": "0.60.4",
17
-    "react-native-canvas": "^0.1.33",
18
-    "react-native-fs": "^2.14.1",
19
-    "react-native-gesture-handler": "^1.3.0",
20
-    "react-native-maps": "^0.25.0",
21
-    "react-native-reanimated": "^1.2.0",
22
-    "react-native-svg": "^9.6.2",
15
+    "react": "16.12.0",
16
+    "react-native": "0.61.5",
17
+    "react-native-canvas": "^0.1.36",
18
+    "react-native-fs": "^2.16.2",
19
+    "react-native-gesture-handler": "^1.5.3",
20
+    "react-native-maps": "^0.26.1",
21
+    "react-native-reanimated": "^1.7.0",
22
+    "react-native-svg": "^11.0.1",
23 23
     "react-native-svg-uri": "^1.2.3",
24
-    "react-native-video": "^5.0.0",
24
+    "react-native-video": "^5.0.2",
25 25
     "react-native-view-shot": "^3.0.2",
26
-    "react-native-webview": "^6.9.0",
27
-    "react-navigation": "^3.11.1"
26
+    "react-native-webview": "^8.0.3",
27
+    "react-navigation": "^4.0.10"
28 28
   },
29 29
   "devDependencies": {
30
-    "@babel/core": "^7.5.5",
31
-    "@babel/runtime": "^7.5.5",
32
-    "@react-native-community/eslint-config": "^0.0.5",
33
-    "eslint": "^6.1.0",
30
+    "@babel/core": "^7.8.3",
31
+    "@babel/runtime": "^7.8.3",
32
+    "@react-native-community/eslint-config": "^0.0.6",
33
+    "eslint": "^6.8.0",
34 34
     "flow-bin": "0.98.0",
35
-    "metro-react-native-babel-preset": "^0.55.0",
36
-    "react-test-renderer": "16.8.6"
35
+    "metro-react-native-babel-preset": "^0.56.4",
36
+    "react-test-renderer": "16.12.0"
37 37
   }
38 38
 }

+ 813
- 463
example/yarn.lock
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 5
- 0
package.json Dosyayı Görüntüle

@@ -22,5 +22,10 @@
22 22
   "peerDependencies": {
23 23
     "react": "*",
24 24
     "react-native": "*"
25
+  },
26
+  "devDependencies": {
27
+    "flow-bin": "^0.116.1",
28
+    "react": "^16.12.0",
29
+    "react-native": "^0.61.5"
25 30
   }
26 31
 }

+ 18
- 20
src/index.js Dosyayı Görüntüle

@@ -1,11 +1,11 @@
1
-//@flow
1
+// @flow
2 2
 import React, { Component } from "react";
3 3
 import { View, NativeModules, Platform, findNodeHandle } from "react-native";
4 4
 const { RNViewShot } = NativeModules;
5 5
 
6 6
 import type { Element, ElementRef, ElementType, Ref } from "react";
7
-import type { ViewStyleProp } from "StyleSheet";
8
-import type { LayoutEvent } from "CoreEventTypes";
7
+import type { ViewStyleProp } from "react-native/Libraries/StyleSheet/StyleSheet";
8
+import type { LayoutEvent } from "react-native/Libraries/Types/CoreEventTypes";
9 9
 
10 10
 const neverEndingPromise = new Promise(() => {});
11 11
 
@@ -41,11 +41,11 @@ const defaultOptions = {
41 41
 
42 42
 // validate and coerce options
43 43
 function validateOptions(
44
-  options: ?Object
44
+  input: ?$Shape<Options>
45 45
 ): { options: Options, errors: Array<string> } {
46
-  options = {
46
+  const options: Options = {
47 47
     ...defaultOptions,
48
-    ...options
48
+    ...input
49 49
   };
50 50
   const errors = [];
51 51
   if (
@@ -103,22 +103,23 @@ export function ensureModuleIsLoaded() {
103 103
 }
104 104
 
105 105
 export function captureRef<T: ElementType>(
106
-  view: number | ?View | Ref<T>,
106
+  input: number | ?View | Ref<T>,
107 107
   optionsObject?: Object
108 108
 ): Promise<string> {
109 109
   ensureModuleIsLoaded();
110
-  if (view && typeof view === "object" && "current" in view && view.current) {
111
-    // React.RefObject
112
-    view = view.current;
110
+  let view;
111
+  if (input && typeof input === "object" && "current" in input) {
112
+    // $FlowFixMe input is a ref
113
+    view = input.current;
113 114
     if (!view) {
114 115
       return Promise.reject(new Error("ref.current is null"));
115 116
     }
116 117
   }
117
-  if (typeof view !== "number") {
118
-    const node = findNodeHandle(view);
118
+  if (typeof input !== "number") {
119
+    const node = findNodeHandle(input);
119 120
     if (!node) {
120 121
       return Promise.reject(
121
-        new Error("findNodeHandle failed to resolve view=" + String(view))
122
+        new Error("findNodeHandle failed to resolve view=" + String(input))
122 123
       );
123 124
     }
124 125
     view = node;
@@ -130,7 +131,7 @@ export function captureRef<T: ElementType>(
130 131
         errors.map(e => `- ${e}`).join("\n")
131 132
     );
132 133
   }
133
-  return RNViewShot.captureRef(view, options);
134
+  return RNViewShot.captureRef(input, options);
134 135
 }
135 136
 
136 137
 export function releaseCapture(uri: string): void {
@@ -190,17 +191,14 @@ function checkCompatibleProps(props: Props) {
190 191
 export default class ViewShot extends Component<Props> {
191 192
   static captureRef = captureRef;
192 193
   static releaseCapture = releaseCapture;
193
-  constructor(props) {
194
-    super(props);
195
-    this.state = {};
196
-  }
194
+
197 195
   root: ?View;
198 196
 
199 197
   _raf: *;
200 198
   lastCapturedURI: ?string;
201 199
 
202 200
   resolveFirstLayout: (layout: Object) => void;
203
-  firstLayoutPromise = new Promise(resolve => {
201
+  firstLayoutPromise: Promise<Object> = new Promise(resolve => {
204 202
     this.resolveFirstLayout = resolve;
205 203
   });
206 204
 
@@ -272,7 +270,7 @@ export default class ViewShot extends Component<Props> {
272 270
     }
273 271
   }
274 272
 
275
-  componentDidUpdate(prevProps) {
273
+  componentDidUpdate(prevProps: Props) {
276 274
     if (this.props.captureMode !== undefined) {
277 275
       if (this.props.captureMode !== prevProps.captureMode) {
278 276
         this.syncCaptureLoop(this.props.captureMode);

+ 4676
- 0
yarn.lock
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle