From a67360b0f3aec0e679be32715b02467429002c31 Mon Sep 17 00:00:00 2001 From: Michael Sokolnicki Date: Fri, 22 Jul 2022 17:07:26 -0700 Subject: [PATCH] Remove MaskedViewIOS from react-native-github Summary: Remove MaskedViewIOS from react-native-github, update deprecation warnings, rebuild CocoaPods. Changelog: [General][Removed] - Remove MaskedViewIOS Reviewed By: lunaleaps Differential Revision: D37860775 fbshipit-source-id: 963b4b9891eecf5610cfad1e93ac8bf83f29f521 --- .../MaskedView/MaskedViewIOS.android.js | 13 --- .../MaskedView/MaskedViewIOS.ios.js | 93 ------------------- .../RCTMaskedViewNativeComponent.js | 21 ----- .../__tests__/MaskedViewIOS-test.js | 40 -------- .../__snapshots__/MaskedViewIOS-test.js.snap | 77 --------------- React/Views/RCTMaskedView.h | 14 --- React/Views/RCTMaskedView.m | 34 ------- React/Views/RCTMaskedViewManager.h | 12 --- React/Views/RCTMaskedViewManager.m | 26 ------ index.js | 25 +++-- packages/rn-tester/Podfile.lock | 2 +- 11 files changed, 16 insertions(+), 341 deletions(-) delete mode 100644 Libraries/Components/MaskedView/MaskedViewIOS.android.js delete mode 100644 Libraries/Components/MaskedView/MaskedViewIOS.ios.js delete mode 100644 Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js delete mode 100644 Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js delete mode 100644 Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap delete mode 100644 React/Views/RCTMaskedView.h delete mode 100644 React/Views/RCTMaskedView.m delete mode 100644 React/Views/RCTMaskedViewManager.h delete mode 100644 React/Views/RCTMaskedViewManager.m diff --git a/Libraries/Components/MaskedView/MaskedViewIOS.android.js b/Libraries/Components/MaskedView/MaskedViewIOS.android.js deleted file mode 100644 index d9faa8e64e6bb4..00000000000000 --- a/Libraries/Components/MaskedView/MaskedViewIOS.android.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -'use strict'; - -module.exports = require('../UnimplementedViews/UnimplementedView'); diff --git a/Libraries/Components/MaskedView/MaskedViewIOS.ios.js b/Libraries/Components/MaskedView/MaskedViewIOS.ios.js deleted file mode 100644 index 9ae245ab6f3547..00000000000000 --- a/Libraries/Components/MaskedView/MaskedViewIOS.ios.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -import * as React from 'react'; -import StyleSheet from '../../StyleSheet/StyleSheet'; -import View from '../View/View'; - -import type {ViewProps} from '../View/ViewPropTypes'; -import RCTMaskedViewNativeComponent from './RCTMaskedViewNativeComponent'; - -type Props = $ReadOnly<{| - ...ViewProps, - - children: React.Node, - /** - * Should be a React element to be rendered and applied as the - * mask for the child element. - */ - maskElement: React.Element, -|}>; - -/** - * Renders the child view with a mask specified in the `maskElement` prop. - * - * ``` - * import React from 'react'; - * import { MaskedViewIOS, Text, View } from 'react-native'; - * - * class MyMaskedView extends React.Component { - * render() { - * return ( - * - * - * Basic Mask - * - * - * } - * > - * - * - * ); - * } - * } - * ``` - * - * The above example will render a view with a blue background that fills its - * parent, and then mask that view with text that says "Basic Mask". - * - * The alpha channel of the view rendered by the `maskElement` prop determines how - * much of the view's content and background shows through. Fully or partially - * opaque pixels allow the underlying content to show through but fully - * transparent pixels block that content. - * - */ -class MaskedViewIOS extends React.Component { - _hasWarnedInvalidRenderMask = false; - - render(): React.Node { - const {maskElement, children, ...otherViewProps} = this.props; - - if (!React.isValidElement(maskElement)) { - if (!this._hasWarnedInvalidRenderMask) { - console.warn( - 'MaskedView: Invalid `maskElement` prop was passed to MaskedView. ' + - 'Expected a React Element. No mask will render.', - ); - this._hasWarnedInvalidRenderMask = true; - } - return {children}; - } - - return ( - - - {maskElement} - - {children} - - ); - } -} - -module.exports = MaskedViewIOS; diff --git a/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js b/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js deleted file mode 100644 index 73448de16c112c..00000000000000 --- a/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -import type {ViewProps} from '../View/ViewPropTypes'; -import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; - -type NativeProps = $ReadOnly<{| - ...ViewProps, -|}>; - -export default (codegenNativeComponent( - 'RCTMaskedView', -): HostComponent); diff --git a/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js b/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js deleted file mode 100644 index 0abfd11da6540a..00000000000000 --- a/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @emails oncall+react_native - * @flow strict-local - */ - -'use strict'; - -const React = require('react'); -const Text = require('../../../Text/Text'); -const View = require('../../View/View'); -const MaskedViewIOS = require('../MaskedViewIOS'); - -const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools'); - -describe('', () => { - it('should render as expected', () => { - ReactNativeTestTools.expectRendersMatchingSnapshot( - 'MaskedViewIOS', - () => ( - - Basic Mask - - }> - - - ), - () => { - jest.dontMock('../MaskedViewIOS'); - }, - ); - }); -}); diff --git a/Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap b/Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap deleted file mode 100644 index 65d8046eb1a11c..00000000000000 --- a/Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap +++ /dev/null @@ -1,77 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` should render as expected: should deep render when mocked (please verify output manually) 1`] = ` - - - - - Basic Mask - - - - - -`; - -exports[` should render as expected: should deep render when not mocked (please verify output manually) 1`] = ` - - - - - Basic Mask - - - - - -`; - -exports[` should render as expected: should shallow render as when mocked 1`] = ` - - - Basic Mask - - - } -> - - -`; - -exports[` should render as expected: should shallow render as when not mocked 1`] = ` - - - Basic Mask - - - } -> - - -`; diff --git a/React/Views/RCTMaskedView.h b/React/Views/RCTMaskedView.h deleted file mode 100644 index cab90b6cdca3d8..00000000000000 --- a/React/Views/RCTMaskedView.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import - -@interface RCTMaskedView : RCTView - -@end diff --git a/React/Views/RCTMaskedView.m b/React/Views/RCTMaskedView.m deleted file mode 100644 index bf9bd88edf84ff..00000000000000 --- a/React/Views/RCTMaskedView.m +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "RCTMaskedView.h" - -#import - -@implementation RCTMaskedView - -- (void)didUpdateReactSubviews -{ - // RCTMaskedView expects that the first subview rendered is the mask. - UIView *maskView = [self.reactSubviews firstObject]; - self.maskView = maskView; - - // Add the other subviews to the view hierarchy - for (NSUInteger i = 1; i < self.reactSubviews.count; i++) { - UIView *subview = [self.reactSubviews objectAtIndex:i]; - [self addSubview:subview]; - } -} - -- (void)displayLayer:(__unused CALayer *)layer -{ - // RCTView uses displayLayer to do border rendering. - // We don't need to do that in RCTMaskedView, so we - // stub this method and override the default implementation. -} - -@end diff --git a/React/Views/RCTMaskedViewManager.h b/React/Views/RCTMaskedViewManager.h deleted file mode 100644 index 6aaf61fa281d3a..00000000000000 --- a/React/Views/RCTMaskedViewManager.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -@interface RCTMaskedViewManager : RCTViewManager - -@end diff --git a/React/Views/RCTMaskedViewManager.m b/React/Views/RCTMaskedViewManager.m deleted file mode 100644 index 808f2e805fed34..00000000000000 --- a/React/Views/RCTMaskedViewManager.m +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "RCTMaskedViewManager.h" - -#import "RCTMaskedView.h" -#import "RCTUIManager.h" - -@implementation RCTMaskedViewManager - -RCT_EXPORT_MODULE() - -- (UIView *)view -{ - RCTNewArchitectureValidationPlaceholder( - RCTNotAllowedInFabricWithoutLegacy, - self, - @"This native component is still using the legacy interop layer -- please migrate it to use a Fabric specific implementation."); - return [RCTMaskedView new]; -} - -@end diff --git a/index.js b/index.js index d59ba3454e9cab..434289fff4cb98 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,6 @@ import typeof Image from './Libraries/Image/Image'; import typeof ImageBackground from './Libraries/Image/ImageBackground'; import typeof InputAccessoryView from './Libraries/Components/TextInput/InputAccessoryView'; import typeof KeyboardAvoidingView from './Libraries/Components/Keyboard/KeyboardAvoidingView'; -import typeof MaskedViewIOS from './Libraries/Components/MaskedView/MaskedViewIOS'; import typeof Modal from './Libraries/Modal/Modal'; import typeof Pressable from './Libraries/Components/Pressable/Pressable'; import typeof ProgressBarAndroid from './Libraries/Components/ProgressBarAndroid/ProgressBarAndroid'; @@ -145,15 +144,6 @@ module.exports = { return require('./Libraries/Components/Keyboard/KeyboardAvoidingView') .default; }, - get MaskedViewIOS(): MaskedViewIOS { - warnOnce( - 'maskedviewios-moved', - 'MaskedViewIOS has been extracted from react-native core and will be removed in a future release. ' + - "It can now be installed and imported from '@react-native-masked-view/masked-view' instead of 'react-native'. " + - 'See https://github.com/react-native-masked-view/masked-view', - ); - return require('./Libraries/Components/MaskedView/MaskedViewIOS'); - }, get Modal(): Modal { return require('./Libraries/Modal/Modal'); }, @@ -736,4 +726,19 @@ if (__DEV__) { ); }, }); + /* $FlowFixMe[prop-missing] This is intentional: Flow will error when + * attempting to access MaskedViewIOS. */ + /* $FlowFixMe[invalid-export] This is intentional: Flow will error when + * attempting to access MaskedViewIOS. */ + Object.defineProperty(module.exports, 'MaskedViewIOS', { + configurable: true, + get() { + invariant( + false, + 'MaskedViewIOS has been removed from React Native. ' + + "It can now be installed and imported from '@react-native-community/react-native-masked-view' instead of 'react-native'. " + + 'See https://github.com/react-native-masked-view/masked-view', + ); + }, + }); } diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 96fed7c9a97f6a..3c6574fec14de9 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -934,7 +934,7 @@ SPEC CHECKSUMS: React-RCTTest: 06c388632dc7b30df17af01c8f9e89e641b4d31c React-RCTText: a861fbf2835299d3cc4189697cddd8bd8602afb9 React-RCTVibration: 0386f50996a153b3f39cecbe7d139763ac9a9fdf - React-rncore: 6daa27c74047a9e13ce3412b99660274a5780603 + React-rncore: 2a6ad37560e94cf7ff32e3f2ae1e708491b4c1f3 React-runtimeexecutor: 97dca9247f4d3cfe0733384b189c6930fbd402b7 ReactCommon: 6cef8ed13ee2a9d7d4cf9660dbe6dd2ea6ba7104 ScreenshotManager: 71d047abd38a77310985b87f8136b620c5c61e88