diff --git a/packages/eslint-plugin-react-native/utils.js b/packages/eslint-plugin-react-native/utils.js index 3c9650e06e59f5..66bb7f2ff26875 100644 --- a/packages/eslint-plugin-react-native/utils.js +++ b/packages/eslint-plugin-react-native/utils.js @@ -264,10 +264,6 @@ const publicAPIMapping = { default: 'BackHandler', types: ['BackPressEventName'], }, - 'Libraries/Components/Clipboard/Clipboard': { - default: 'Clipboard', - types: null, - }, 'Libraries/Utilities/DeviceInfo': { default: 'DeviceInfo', types: ['DeviceInfoConstants'], diff --git a/packages/react-native/Libraries/Components/Clipboard/Clipboard.d.ts b/packages/react-native/Libraries/Components/Clipboard/Clipboard.d.ts deleted file mode 100644 index 8bc5cb7623cfd5..00000000000000 --- a/packages/react-native/Libraries/Components/Clipboard/Clipboard.d.ts +++ /dev/null @@ -1,28 +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 - */ - -export interface ClipboardStatic { - getString(): Promise; - setString(content: string): void; -} - -/** - * Clipboard 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-clipboard/clipboard` instead of 'react-native'. - * @see https://github.com/react-native-clipboard/clipboard - * @deprecated - */ -export const Clipboard: ClipboardStatic; -/** - * Clipboard 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-clipboard/clipboard` instead of 'react-native'. - * @see https://github.com/react-native-clipboard/clipboard - * @deprecated - */ -export type Clipboard = ClipboardStatic; diff --git a/packages/react-native/Libraries/Components/Clipboard/Clipboard.js b/packages/react-native/Libraries/Components/Clipboard/Clipboard.js deleted file mode 100644 index 5b17cd17359b26..00000000000000 --- a/packages/react-native/Libraries/Components/Clipboard/Clipboard.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. - * - * @flow strict - * @format - */ - -import NativeClipboard from './NativeClipboard'; - -/** - * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android - */ -export default { - /** - * Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content - * ```javascript - * async _getContent() { - * var content = await Clipboard.getString(); - * } - * ``` - */ - getString(): Promise { - return NativeClipboard.getString(); - }, - /** - * Set content of string type. You can use following code to set clipboard content - * ```javascript - * _setContent() { - * Clipboard.setString('hello world'); - * } - * ``` - * @param {string} content the content to be stored in the clipboard. - */ - setString(content: string) { - NativeClipboard.setString(content); - }, -}; diff --git a/packages/react-native/Libraries/Components/Clipboard/NativeClipboard.js b/packages/react-native/Libraries/Components/Clipboard/NativeClipboard.js deleted file mode 100644 index 65ddd1a522abd2..00000000000000 --- a/packages/react-native/Libraries/Components/Clipboard/NativeClipboard.js +++ /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. - * - * @flow strict - * @format - */ - -export * from '../../../src/private/specs_DEPRECATED/modules/NativeClipboard'; -export {default} from '../../../src/private/specs_DEPRECATED/modules/NativeClipboard'; diff --git a/packages/react-native/React/Base/RCTBridge.mm b/packages/react-native/React/Base/RCTBridge.mm index b8452a3a22585e..a0121d6d16b345 100644 --- a/packages/react-native/React/Base/RCTBridge.mm +++ b/packages/react-native/React/Base/RCTBridge.mm @@ -65,7 +65,6 @@ @"RCTAlertManager", @"RCTAppearance", @"RCTAppState", - @"RCTClipboard", @"RCTDeviceInfo", @"RCTDevLoadingView", @"RCTDevMenu", diff --git a/packages/react-native/React/CoreModules/CoreModulesPlugins.h b/packages/react-native/React/CoreModules/CoreModulesPlugins.h index e62d4d157bb070..2aa01f5251c453 100644 --- a/packages/react-native/React/CoreModules/CoreModulesPlugins.h +++ b/packages/react-native/React/CoreModules/CoreModulesPlugins.h @@ -34,7 +34,6 @@ Class RCTActionSheetManagerCls(void) __attribute__((used)); Class RCTAlertManagerCls(void) __attribute__((used)); Class RCTAppStateCls(void) __attribute__((used)); Class RCTAppearanceCls(void) __attribute__((used)); -Class RCTClipboardCls(void) __attribute__((used)); Class RCTDevLoadingViewCls(void) __attribute__((used)); Class RCTDevMenuCls(void) __attribute__((used)); Class RCTDevSettingsCls(void) __attribute__((used)); diff --git a/packages/react-native/React/CoreModules/CoreModulesPlugins.mm b/packages/react-native/React/CoreModules/CoreModulesPlugins.mm index f0844ee8afdf4c..4917f9b896c170 100644 --- a/packages/react-native/React/CoreModules/CoreModulesPlugins.mm +++ b/packages/react-native/React/CoreModules/CoreModulesPlugins.mm @@ -40,10 +40,6 @@ Class RCTCoreModulesClassProvider(const char *name) return RCTAppearanceCls(); } - if (name == "Clipboard"sv) { - return RCTClipboardCls(); - } - if (name == "DevLoadingView"sv) { return RCTDevLoadingViewCls(); } diff --git a/packages/react-native/React/CoreModules/RCTClipboard.h b/packages/react-native/React/CoreModules/RCTClipboard.h deleted file mode 100644 index 8606b225ea37b3..00000000000000 --- a/packages/react-native/React/CoreModules/RCTClipboard.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 RCTClipboard : NSObject - -@end diff --git a/packages/react-native/React/CoreModules/RCTClipboard.mm b/packages/react-native/React/CoreModules/RCTClipboard.mm deleted file mode 100644 index 2dc098a4730273..00000000000000 --- a/packages/react-native/React/CoreModules/RCTClipboard.mm +++ /dev/null @@ -1,51 +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 "RCTClipboard.h" - -#import -#import - -#import "CoreModulesPlugins.h" - -using namespace facebook::react; - -@interface RCTClipboard () -@end - -@implementation RCTClipboard - -RCT_EXPORT_MODULE() - -- (dispatch_queue_t)methodQueue -{ - return dispatch_get_main_queue(); -} - -RCT_EXPORT_METHOD(setString : (NSString *)content) -{ - UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; - clipboard.string = (content ?: @""); -} - -RCT_EXPORT_METHOD(getString : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject) -{ - UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; - resolve((clipboard.string ?: @"")); -} - -- (std::shared_ptr)getTurboModule:(const ObjCTurboModule::InitParams &)params -{ - return std::make_shared(params); -} - -@end - -Class RCTClipboardCls(void) -{ - return RCTClipboard.class; -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.kt deleted file mode 100644 index c549acec9a7c1a..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.kt +++ /dev/null @@ -1,48 +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. - */ - -package com.facebook.react.modules.clipboard - -import android.content.ClipData -import android.content.ClipboardManager -import android.content.Context -import com.facebook.fbreact.specs.NativeClipboardSpec -import com.facebook.react.bridge.Promise -import com.facebook.react.bridge.ReactApplicationContext -import com.facebook.react.module.annotations.ReactModule - -/** A module that allows JS to get/set clipboard contents. */ -@ReactModule(name = NativeClipboardSpec.NAME) -internal class ClipboardModule(context: ReactApplicationContext) : NativeClipboardSpec(context) { - - private val clipboardService: ClipboardManager - get() = reactApplicationContext.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - - override fun getString(promise: Promise) { - try { - val clipboard = clipboardService - val clipData = clipboard.primaryClip - if (clipData != null && clipData.itemCount >= 1) { - val firstItem = clipData.getItemAt(0) - promise.resolve("${firstItem.text}") - } else { - promise.resolve("") - } - } catch (e: Exception) { - promise.reject(e) - } - } - - override fun setString(text: String?) { - val clipdata: ClipData = ClipData.newPlainText(null, text) - clipboardService.setPrimaryClip(clipdata) - } - - companion object { - const val NAME: String = NativeClipboardSpec.NAME - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt index 36684e8d8c3468..e2523892d11a48 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt @@ -27,7 +27,6 @@ import com.facebook.react.modules.appstate.AppStateModule import com.facebook.react.modules.blob.BlobModule import com.facebook.react.modules.blob.FileReaderModule import com.facebook.react.modules.camera.ImageStoreManager -import com.facebook.react.modules.clipboard.ClipboardModule import com.facebook.react.modules.devloading.DevLoadingModule import com.facebook.react.modules.devtoolsruntimesettings.ReactDevToolsRuntimeSettingsModule import com.facebook.react.modules.dialog.DialogModule @@ -76,7 +75,6 @@ import com.facebook.react.views.view.ReactViewManager BlobModule::class, DevLoadingModule::class, FileReaderModule::class, - ClipboardModule::class, DialogModule::class, FrescoModule::class, I18nManagerModule::class, @@ -109,7 +107,6 @@ constructor(private val config: MainPackageConfig? = null) : BlobModule.NAME -> BlobModule(reactContext) DevLoadingModule.NAME -> DevLoadingModule(reactContext) FileReaderModule.NAME -> FileReaderModule(reactContext) - ClipboardModule.NAME -> ClipboardModule(reactContext) DialogModule.NAME -> DialogModule(reactContext) FrescoModule.NAME -> FrescoModule(reactContext, true, config?.frescoConfig) I18nManagerModule.NAME -> I18nManagerModule(reactContext) @@ -247,7 +244,6 @@ constructor(private val config: MainPackageConfig? = null) : BlobModule::class.java, DevLoadingModule::class.java, FileReaderModule::class.java, - ClipboardModule::class.java, DialogModule::class.java, FrescoModule::class.java, I18nManagerModule::class.java, diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.kt deleted file mode 100644 index 360c0c406dc0eb..00000000000000 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.kt +++ /dev/null @@ -1,62 +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. - */ - -package com.facebook.react.modules.clipboard - -import android.content.ClipboardManager -import android.content.Context -import com.facebook.react.bridge.ReactTestHelper.createTestReactApplicationContext -import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags -import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests -import com.facebook.testutils.shadows.ShadowSoLoader -import org.assertj.core.api.Assertions.assertThat -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner -import org.robolectric.RuntimeEnvironment -import org.robolectric.annotation.Config - -@RunWith(RobolectricTestRunner::class) -@Config(shadows = [ShadowSoLoader::class]) -class ClipboardModuleTest { - private lateinit var clipboardModule: ClipboardModule - private lateinit var clipboardManager: ClipboardManager - - @Before - fun setUp() { - ReactNativeFeatureFlagsForTests.setUp() - clipboardModule = - ClipboardModule(createTestReactApplicationContext(RuntimeEnvironment.getApplication())) - clipboardManager = - RuntimeEnvironment.getApplication().getSystemService(Context.CLIPBOARD_SERVICE) - as ClipboardManager - } - - @After - fun tearDown() { - ReactNativeFeatureFlags.dangerouslyReset() - } - - @Suppress("DEPRECATION") - @Test - fun testSetString() { - clipboardModule.setString(TEST_CONTENT) - assertThat(clipboardManager.text == TEST_CONTENT).isTrue() - clipboardModule.setString(null) - assertThat(clipboardManager.hasText()).isFalse() - clipboardModule.setString("") - assertThat(clipboardManager.hasText()).isFalse() - clipboardModule.setString(" ") - assertThat(clipboardManager.hasText()).isTrue() - } - - companion object { - private const val TEST_CONTENT = "test" - } -} diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index 3dff962fc17956..690dbbf36c49d8 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<31fb0fdcce971ceac0e6cb26829860f2>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -165,10 +165,6 @@ declare const Button_default: ( ref?: React.Ref }, ) => React.ReactNode -declare const Clipboard: { - getString(): Promise - setString(content: string): void -} declare const codegenNativeCommands: typeof codegenNativeCommands_default declare const codegenNativeComponent: typeof codegenNativeComponent_default declare const compose: typeof composeStyles_default @@ -1828,7 +1824,6 @@ declare class CellRenderMask { equals(other: CellRenderMask): boolean numCells(): number } -declare type Clipboard = typeof Clipboard declare type CodeFrame = { readonly collapse?: boolean readonly content: string @@ -5960,7 +5955,6 @@ export { BoxShadowValue, // b679703f Button, // dd130b61 ButtonProps, // 3c081e75 - Clipboard, // 9b8c878e CodegenTypes, // 030a94b8 ColorSchemeName, // 31a4350e ColorValue, // 98989a8f diff --git a/packages/react-native/index.js b/packages/react-native/index.js index b205422effd77b..6fe2b778dbbe69 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -183,15 +183,6 @@ module.exports = { get BackHandler() { return require('./Libraries/Utilities/BackHandler').default; }, - get Clipboard() { - warnOnce( - 'clipboard-moved', - 'Clipboard 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-clipboard/clipboard' instead of 'react-native'. " + - 'See https://github.com/react-native-clipboard/clipboard', - ); - return require('./Libraries/Components/Clipboard/Clipboard').default; - }, get codegenNativeCommands() { return require('./Libraries/Utilities/codegenNativeCommands').default; }, diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index aebeabfdf01012..ddf51a0482d136 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -246,8 +246,6 @@ export {default as AppState} from './Libraries/AppState/AppState'; export type {BackPressEventName} from './Libraries/Utilities/BackHandler'; export {default as BackHandler} from './Libraries/Utilities/BackHandler'; -export {default as Clipboard} from './Libraries/Components/Clipboard/Clipboard'; - export {default as codegenNativeComponent} from './Libraries/Utilities/codegenNativeComponent'; export {default as codegenNativeCommands} from './Libraries/Utilities/codegenNativeCommands'; diff --git a/packages/react-native/jest/mocks/Clipboard.js b/packages/react-native/jest/mocks/Clipboard.js deleted file mode 100644 index 035dc076fd62a4..00000000000000 --- a/packages/react-native/jest/mocks/Clipboard.js +++ /dev/null @@ -1,16 +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. - * - * @flow strict - * @format - */ - -const Clipboard = { - getString: jest.fn(async () => '') as JestMockFn<[], Promise>, - setString: jest.fn() as JestMockFn<[string], void>, -}; - -export default Clipboard; diff --git a/packages/react-native/jest/setup.js b/packages/react-native/jest/setup.js index 580181701bda63..272162a1323aba 100644 --- a/packages/react-native/jest/setup.js +++ b/packages/react-native/jest/setup.js @@ -97,7 +97,6 @@ mock( 'm#../Libraries/Components/ActivityIndicator/ActivityIndicator', 'm#./mocks/ActivityIndicator', ); -mock('m#../Libraries/Components/Clipboard/Clipboard', 'm#./mocks/Clipboard'); mock( 'm#../Libraries/Components/RefreshControl/RefreshControl', // $FlowFixMe[incompatible-type] - `../Libraries/Components/RefreshControl/RefreshControl` should export a component type. diff --git a/packages/react-native/scripts/ios-prebuild/React-umbrella.h b/packages/react-native/scripts/ios-prebuild/React-umbrella.h index 45b365b92b9a58..741855f362e77a 100644 --- a/packages/react-native/scripts/ios-prebuild/React-umbrella.h +++ b/packages/react-native/scripts/ios-prebuild/React-umbrella.h @@ -65,7 +65,6 @@ #import "React/RCTBundleURLProvider.h" #import "React/RCTCallInvoker.h" #import "React/RCTCallInvokerModule.h" -#import "React/RCTClipboard.h" #import "React/RCTColorAnimatedNode.h" #import "React/RCTComponent.h" #import "React/RCTComponentData.h" diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.js deleted file mode 100644 index ef3c10f92ff37d..00000000000000 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.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. - * - * @flow strict - * @format - */ - -import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; - -import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; - -export interface Spec extends TurboModule { - +getConstants: () => {}; - +getString: () => Promise; - +setString: (content: string) => void; -} - -export default (TurboModuleRegistry.getEnforcing('Clipboard'): Spec); diff --git a/packages/react-native/types/index.d.ts b/packages/react-native/types/index.d.ts index f4bb82eabe4bd7..160f4973c9d139 100644 --- a/packages/react-native/types/index.d.ts +++ b/packages/react-native/types/index.d.ts @@ -79,7 +79,6 @@ export * from '../Libraries/AppState/AppState'; export * from '../Libraries/BatchedBridge/NativeModules'; export * from '../Libraries/Components/AccessibilityInfo/AccessibilityInfo'; export * from '../Libraries/Components/ActivityIndicator/ActivityIndicator'; -export * from '../Libraries/Components/Clipboard/Clipboard'; export * from '../Libraries/Components/DrawerAndroid/DrawerLayoutAndroid'; export * from '../Libraries/Components/Keyboard/Keyboard'; export * from '../Libraries/Components/Keyboard/KeyboardAvoidingView';