@samitouri / QOS-React-2 / commits / 181747a6cc

[RN] Move takeSnapshot to RN (#12574)

It only uses public APIs. I have a diff on the other side.

Sebastian Markbåge committed Apr 7, 2018 at 23:13 UTC 181747a6cc25f3020b8561f475eca4ad2824256b
4 files changed -69
packages/react-native-renderer/src/ReactFabric.js
-2
@@ -26,7 +26,6 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
26 import createReactNativeComponentClass from './createReactNativeComponentClass';
27 import {injectFindHostInstance} from './findNodeHandle';
28 import findNumericNodeHandle from './findNumericNodeHandle';
29 -import takeSnapshot from './takeSnapshot';
29
30 injectFindHostInstance(ReactFabricRenderer.findHostInstance);
31
@@ -85,7 +84,6 @@ const ReactFabric: ReactNativeType = {
84 ReactNativeComponentTree, // ScrollResponder
85 ReactNativePropRegistry, // flattenStyle, Stylesheet
86 createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
88 - takeSnapshot, // react-native-implementation
87 },
88 };
89
packages/react-native-renderer/src/ReactNativeRenderer.js
-2
@@ -30,7 +30,6 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
30 import createReactNativeComponentClass from './createReactNativeComponentClass';
31 import {injectFindHostInstance} from './findNodeHandle';
32 import findNumericNodeHandle from './findNumericNodeHandle';
33 -import takeSnapshot from './takeSnapshot';
33
34 injectFindHostInstance(ReactNativeFiberRenderer.findHostInstance);
35
@@ -104,7 +103,6 @@ const ReactNativeRenderer: ReactNativeType = {
103 ReactNativeComponentTree, // ScrollResponder
104 ReactNativePropRegistry, // flattenStyle, Stylesheet
105 createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
107 - takeSnapshot, // react-native-implementation
106 computeComponentStackForErrorReporting,
107 },
108 };
packages/react-native-renderer/src/takeSnapshot.js deleted
-48
@@ -1,48 +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 - * @flow
8 - */
9 -
10 -// Module provided by RN:
11 -import UIManager from 'UIManager';
12 -
13 -import findNumericNodeHandle from './findNumericNodeHandle';
14 -
15 -/**
16 - * Capture an image of the screen, window or an individual view. The image
17 - * will be stored in a temporary file that will only exist for as long as the
18 - * app is running.
19 - *
20 - * The `view` argument can be the literal string `window` if you want to
21 - * capture the entire window, or it can be a reference to a specific
22 - * React Native component.
23 - *
24 - * The `options` argument may include:
25 - * - width/height (number) - the width and height of the image to capture.
26 - * - format (string) - either 'png' or 'jpeg'. Defaults to 'png'.
27 - * - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default).
28 - *
29 - * Returns a Promise.
30 - * @platform ios
31 - */
32 -export default function takeSnapshot(
33 - view?: 'window' | React$Element<any> | number,
34 - options?: {
35 - width?: number,
36 - height?: number,
37 - format?: 'png' | 'jpeg',
38 - quality?: number,
39 - },
40 -): Promise<any> {
41 - if (typeof view !== 'number' && view !== 'window') {
42 - view = findNumericNodeHandle(view) || 'window';
43 - }
44 -
45 - // Call the hidden '__takeSnapshot' method; the main one throws an error to
46 - // prevent accidental backwards-incompatible usage.
47 - return UIManager.__takeSnapshot(view, options);
48 -}
scripts/rollup/shims/react-native/takeSnapshot.js deleted
-17
@@ -1,17 +0,0 @@
1 -/**
2 - * Copyright (c) 2013-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 - * @providesModule takeSnapshot
8 - */
9 -
10 -'use strict';
11 -
12 -const {
13 - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
14 -} = require('ReactNative');
15 -
16 -module.exports =
17 - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.takeSnapshot;