From 9961f1f90eca2f1a752705277fb5554f2de78425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Sat, 7 Apr 2018 23:13:34 -0700 Subject: [PATCH] [RN] Move takeSnapshot to RN (#12574) It only uses public APIs. I have a diff on the other side. --- .../react-native-renderer/src/ReactFabric.js | 2 - .../src/ReactNativeRenderer.js | 2 - .../react-native-renderer/src/takeSnapshot.js | 48 ------------------- .../rollup/shims/react-native/takeSnapshot.js | 17 ------- 4 files changed, 69 deletions(-) delete mode 100644 packages/react-native-renderer/src/takeSnapshot.js delete mode 100644 scripts/rollup/shims/react-native/takeSnapshot.js diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 3e8608015ea1f..ebaeae8214e43 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -26,7 +26,6 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; import createReactNativeComponentClass from './createReactNativeComponentClass'; import {injectFindHostInstance} from './findNodeHandle'; import findNumericNodeHandle from './findNumericNodeHandle'; -import takeSnapshot from './takeSnapshot'; injectFindHostInstance(ReactFabricRenderer.findHostInstance); @@ -85,7 +84,6 @@ const ReactFabric: ReactNativeType = { ReactNativeComponentTree, // ScrollResponder ReactNativePropRegistry, // flattenStyle, Stylesheet createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART - takeSnapshot, // react-native-implementation }, }; diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index 6701a8f68937a..c4bec308e214b 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -30,7 +30,6 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; import createReactNativeComponentClass from './createReactNativeComponentClass'; import {injectFindHostInstance} from './findNodeHandle'; import findNumericNodeHandle from './findNumericNodeHandle'; -import takeSnapshot from './takeSnapshot'; injectFindHostInstance(ReactNativeFiberRenderer.findHostInstance); @@ -104,7 +103,6 @@ const ReactNativeRenderer: ReactNativeType = { ReactNativeComponentTree, // ScrollResponder ReactNativePropRegistry, // flattenStyle, Stylesheet createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART - takeSnapshot, // react-native-implementation computeComponentStackForErrorReporting, }, }; diff --git a/packages/react-native-renderer/src/takeSnapshot.js b/packages/react-native-renderer/src/takeSnapshot.js deleted file mode 100644 index 61766ed78d3bf..0000000000000 --- a/packages/react-native-renderer/src/takeSnapshot.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -// Module provided by RN: -import UIManager from 'UIManager'; - -import findNumericNodeHandle from './findNumericNodeHandle'; - -/** - * Capture an image of the screen, window or an individual view. The image - * will be stored in a temporary file that will only exist for as long as the - * app is running. - * - * The `view` argument can be the literal string `window` if you want to - * capture the entire window, or it can be a reference to a specific - * React Native component. - * - * The `options` argument may include: - * - width/height (number) - the width and height of the image to capture. - * - format (string) - either 'png' or 'jpeg'. Defaults to 'png'. - * - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default). - * - * Returns a Promise. - * @platform ios - */ -export default function takeSnapshot( - view?: 'window' | React$Element | number, - options?: { - width?: number, - height?: number, - format?: 'png' | 'jpeg', - quality?: number, - }, -): Promise { - if (typeof view !== 'number' && view !== 'window') { - view = findNumericNodeHandle(view) || 'window'; - } - - // Call the hidden '__takeSnapshot' method; the main one throws an error to - // prevent accidental backwards-incompatible usage. - return UIManager.__takeSnapshot(view, options); -} diff --git a/scripts/rollup/shims/react-native/takeSnapshot.js b/scripts/rollup/shims/react-native/takeSnapshot.js deleted file mode 100644 index 00abd891769c7..0000000000000 --- a/scripts/rollup/shims/react-native/takeSnapshot.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule takeSnapshot - */ - -'use strict'; - -const { - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, -} = require('ReactNative'); - -module.exports = - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.takeSnapshot;