diff --git a/Libraries/Image/ImagePickerIOS.d.ts b/Libraries/Image/ImagePickerIOS.d.ts deleted file mode 100644 index 7dbd447581bb0b..00000000000000 --- a/Libraries/Image/ImagePickerIOS.d.ts +++ /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. - * - * @format - */ - -export interface OpenCameraDialogOptions { - /** Defaults to false */ - videoMode?: boolean | undefined; -} - -export interface OpenSelectDialogOptions { - /** Defaults to true */ - showImages?: boolean | undefined; - /** Defaults to false */ - showVideos?: boolean | undefined; -} - -/** [imageURL|tempImageTag, height, width] */ -export type ImagePickerResult = [string, number, number]; - -export interface ImagePickerIOSStatic { - canRecordVideos(callback: (value: boolean) => void): void; - canUseCamera(callback: (value: boolean) => void): void; - openCameraDialog( - config: OpenCameraDialogOptions, - successCallback: (args: ImagePickerResult) => void, - cancelCallback: (args: any[]) => void, - ): void; - openSelectDialog( - config: OpenSelectDialogOptions, - successCallback: (args: ImagePickerResult) => void, - cancelCallback: (args: any[]) => void, - ): void; -} - -/** - * ImagePickerIOS has been extracted from react-native core and will be removed in a future release. - * Please upgrade to use either `@react-native-community/react-native-image-picker` or 'expo-image-picker'. - * If you cannot upgrade to a different library, please install the deprecated `@react-native-community/image-picker-ios` package. - * @see https://github.com/react-native-community/react-native-image-picker-ios - * @deprecated - */ -export const ImagePickerIOS: ImagePickerIOSStatic; -export type ImagePickerIOS = ImagePickerIOSStatic; diff --git a/Libraries/Image/ImagePickerIOS.js b/Libraries/Image/ImagePickerIOS.js deleted file mode 100644 index e94cd646e9a1f0..00000000000000 --- a/Libraries/Image/ImagePickerIOS.js +++ /dev/null @@ -1,103 +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 NativeImagePickerIOS from './NativeImagePickerIOS'; -import invariant from 'invariant'; - -const ImagePickerIOS = { - canRecordVideos: function (callback: (result: boolean) => void): void { - invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); - return NativeImagePickerIOS.canRecordVideos(callback); - }, - canUseCamera: function (callback: (result: boolean) => void): void { - invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); - return NativeImagePickerIOS.canUseCamera(callback); - }, - openCameraDialog: function ( - config: $ReadOnly<{| - unmirrorFrontFacingCamera?: boolean, - videoMode?: boolean, - |}>, - successCallback: (imageURL: string, height: number, width: number) => void, - cancelCallback: () => void, - ): void { - invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); - - var newConfig = { - videoMode: true, - unmirrorFrontFacingCamera: false, - }; - - if (config.videoMode != null) { - newConfig.videoMode = config.videoMode; - } - - if (config.unmirrorFrontFacingCamera != null) { - newConfig.unmirrorFrontFacingCamera = config.unmirrorFrontFacingCamera; - } - - return NativeImagePickerIOS.openCameraDialog( - newConfig, - successCallback, - cancelCallback, - ); - }, - openSelectDialog: function ( - config: $ReadOnly<{| - showImages?: boolean, - showVideos?: boolean, - |}>, - successCallback: (imageURL: string, height: number, width: number) => void, - cancelCallback: () => void, - ): void { - invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); - - var newConfig = { - showImages: true, - showVideos: false, - }; - - if (config.showImages != null) { - newConfig.showImages = config.showImages; - } - - if (config.showVideos != null) { - newConfig.showVideos = config.showVideos; - } - - return NativeImagePickerIOS.openSelectDialog( - newConfig, - successCallback, - cancelCallback, - ); - }, - /** - * In iOS 13, the video URLs returned by the Image Picker are invalidated when - * the picker is dismissed, unless reference to it is held. This API allows - * the application to signal when it's finished with the video so that the - * reference can be cleaned up. - * It is safe to call this method for urlsthat aren't video URLs; - * it will be a no-op. - */ - removePendingVideo: function (url: string): void { - invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); - NativeImagePickerIOS.removePendingVideo(url); - }, - /** - * WARNING: In most cases, removePendingVideo should be used instead because - * clearAllPendingVideos could clear out pending videos made by other callers. - */ - clearAllPendingVideos: function (): void { - invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); - NativeImagePickerIOS.clearAllPendingVideos(); - }, -}; - -module.exports = ImagePickerIOS; diff --git a/Libraries/Image/NativeImagePickerIOS.js b/Libraries/Image/NativeImagePickerIOS.js deleted file mode 100644 index 47f06fa1d36066..00000000000000 --- a/Libraries/Image/NativeImagePickerIOS.js +++ /dev/null @@ -1,39 +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 '../TurboModule/RCTExport'; - -import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; - -export interface Spec extends TurboModule { - +getConstants: () => {||}; - +canRecordVideos: (callback: (result: boolean) => void) => void; - +canUseCamera: (callback: (result: boolean) => void) => void; - +openCameraDialog: ( - config: {| - unmirrorFrontFacingCamera: boolean, - videoMode: boolean, - |}, - successCallback: (imageURL: string, height: number, width: number) => void, - cancelCallback: () => void, - ) => void; - +openSelectDialog: ( - config: {| - showImages: boolean, - showVideos: boolean, - |}, - successCallback: (imageURL: string, height: number, width: number) => void, - cancelCallback: () => void, - ) => void; - +clearAllPendingVideos: () => void; - +removePendingVideo: (url: string) => void; -} - -export default (TurboModuleRegistry.get('ImagePickerIOS'): ?Spec); diff --git a/index.js b/index.js index d33faf0bd9636d..f556fa31fa1d42 100644 --- a/index.js +++ b/index.js @@ -59,7 +59,6 @@ import typeof Dimensions from './Libraries/Utilities/Dimensions'; import typeof Easing from './Libraries/Animated/Easing'; import typeof ReactNative from './Libraries/Renderer/shims/ReactNative'; import typeof I18nManager from './Libraries/ReactNative/I18nManager'; -import typeof ImagePickerIOS from './Libraries/Image/ImagePickerIOS'; import typeof InteractionManager from './Libraries/Interaction/InteractionManager'; import typeof Keyboard from './Libraries/Components/Keyboard/Keyboard'; import typeof LayoutAnimation from './Libraries/LayoutAnimation/LayoutAnimation'; @@ -281,16 +280,6 @@ module.exports = { get I18nManager(): I18nManager { return require('./Libraries/ReactNative/I18nManager'); }, - get ImagePickerIOS(): ImagePickerIOS { - warnOnce( - 'imagePickerIOS-moved', - 'ImagePickerIOS has been extracted from react-native core and will be removed in a future release. ' + - "Please upgrade to use either '@react-native-community/react-native-image-picker' or 'expo-image-picker'. " + - "If you cannot upgrade to a different library, please install the deprecated '@react-native-community/image-picker-ios' package. " + - 'See https://github.com/rnc-archive/react-native-image-picker-ios', - ); - return require('./Libraries/Image/ImagePickerIOS'); - }, get InteractionManager(): InteractionManager { return require('./Libraries/Interaction/InteractionManager'); }, @@ -765,4 +754,20 @@ if (__DEV__) { ); }, }); + /* $FlowFixMe[prop-missing] This is intentional: Flow will error when + * attempting to access ImagePickerIOS. */ + /* $FlowFixMe[invalid-export] This is intentional: Flow will error when + * attempting to access ImagePickerIOS. */ + Object.defineProperty(module.exports, 'ImagePickerIOS', { + configurable: true, + get() { + invariant( + false, + 'ImagePickerIOS has been removed from React Native. ' + + "Please upgrade to use either '@react-native-community/react-native-image-picker' or 'expo-image-picker'. " + + "If you cannot upgrade to a different library, please install the deprecated '@react-native-community/image-picker-ios' package. " + + 'See https://github.com/rnc-archive/react-native-image-picker-ios', + ); + }, + }); } diff --git a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js index f3b88e526ba1df..b2b7e0cdfa9ae5 100644 --- a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js @@ -1224,73 +1224,6 @@ const REAL_MODULE_EXAMPLE: SchemaType = { }, moduleNames: ['CameraRollManager'], }, - NativeImagePickerIOS: { - type: 'NativeModule', - aliases: {}, - spec: { - properties: [ - { - name: 'openCameraDialog', - optional: false, - typeAnnotation: { - type: 'FunctionTypeAnnotation', - returnTypeAnnotation: { - type: 'VoidTypeAnnotation', - }, - params: [ - { - optional: false, - name: 'config', - typeAnnotation: { - type: 'ObjectTypeAnnotation', - properties: [ - { - optional: false, - name: 'unmirrorFrontFacingCamera', - typeAnnotation: { - type: 'BooleanTypeAnnotation', - }, - }, - { - optional: false, - name: 'videoMode', - typeAnnotation: { - type: 'BooleanTypeAnnotation', - }, - }, - ], - }, - }, - { - name: 'successCallback', - optional: false, - typeAnnotation: { - type: 'FunctionTypeAnnotation', - params: [], - returnTypeAnnotation: { - type: 'VoidTypeAnnotation', - }, - }, - }, - { - name: 'cancelCallback', - optional: false, - typeAnnotation: { - type: 'FunctionTypeAnnotation', - params: [], - returnTypeAnnotation: { - type: 'VoidTypeAnnotation', - }, - }, - }, - ], - }, - }, - ], - }, - moduleNames: ['ImagePickerIOS'], - excludedPlatforms: ['android'], - }, NativeExceptionsManager: { type: 'NativeModule', aliases: { diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap index 01d83b6869d405..4a22ab252d743b 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap @@ -240,15 +240,6 @@ NativeCameraRollManagerCxxSpecJSI::NativeCameraRollManagerCxxSpecJSI(std::shared methodMap_[\\"saveToCameraRoll\\"] = MethodMetadata {2, __hostFunction_NativeCameraRollManagerCxxSpecJSI_saveToCameraRoll}; methodMap_[\\"deletePhotos\\"] = MethodMetadata {1, __hostFunction_NativeCameraRollManagerCxxSpecJSI_deletePhotos}; } -static jsi::Value __hostFunction_NativeImagePickerIOSCxxSpecJSI_openCameraDialog(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->openCameraDialog(rt, args[0].asObject(rt), args[1].asObject(rt).asFunction(rt), args[2].asObject(rt).asFunction(rt)); - return jsi::Value::undefined(); -} - -NativeImagePickerIOSCxxSpecJSI::NativeImagePickerIOSCxxSpecJSI(std::shared_ptr jsInvoker) - : TurboModule(\\"ImagePickerIOS\\", jsInvoker) { - methodMap_[\\"openCameraDialog\\"] = MethodMetadata {3, __hostFunction_NativeImagePickerIOSCxxSpecJSI_openCameraDialog}; -} static jsi::Value __hostFunction_NativeExceptionsManagerCxxSpecJSI_reportFatalException(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { static_cast(&turboModule)->reportFatalException(rt, args[0].asString(rt), args[1].asObject(rt).asArray(rt), args[2].asNumber()); return jsi::Value::undefined(); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap index f8349c6811bf25..2e7955758b4d4e 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap @@ -505,49 +505,6 @@ private: Delegate delegate_; }; -class JSI_EXPORT NativeImagePickerIOSCxxSpecJSI : public TurboModule { -protected: - NativeImagePickerIOSCxxSpecJSI(std::shared_ptr jsInvoker); - -public: - virtual void openCameraDialog(jsi::Runtime &rt, jsi::Object config, jsi::Function successCallback, jsi::Function cancelCallback) = 0; - -}; - -template -class JSI_EXPORT NativeImagePickerIOSCxxSpec : public TurboModule { -public: - jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { - return delegate_.get(rt, propName); - } - -protected: - NativeImagePickerIOSCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(\\"ImagePickerIOS\\", jsInvoker), - delegate_(static_cast(this), jsInvoker) {} - -private: - class Delegate : public NativeImagePickerIOSCxxSpecJSI { - public: - Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeImagePickerIOSCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} - - void openCameraDialog(jsi::Runtime &rt, jsi::Object config, jsi::Function successCallback, jsi::Function cancelCallback) override { - static_assert( - bridging::getParameterCount(&T::openCameraDialog) == 4, - \\"Expected openCameraDialog(...) to have 4 parameters\\"); - - return bridging::callFromJs( - rt, &T::openCameraDialog, jsInvoker_, instance_, std::move(config), std::move(successCallback), std::move(cancelCallback)); - } - - private: - T *instance_; - }; - - Delegate delegate_; -}; - class JSI_EXPORT NativeExceptionsManagerCxxSpecJSI : public TurboModule { protected: NativeExceptionsManagerCxxSpecJSI(std::shared_ptr jsInvoker); diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap index 6c6afb74db32ca..4e923454c77659 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap @@ -711,40 +711,6 @@ namespace facebook { }; } // namespace react } // namespace facebook -namespace JS { - namespace NativeImagePickerIOS { - struct SpecOpenCameraDialogConfig { - bool unmirrorFrontFacingCamera() const; - bool videoMode() const; - - SpecOpenCameraDialogConfig(NSDictionary *const v) : _v(v) {} - private: - NSDictionary *_v; - }; - } -} - -@interface RCTCxxConvert (NativeImagePickerIOS_SpecOpenCameraDialogConfig) -+ (RCTManagedPointer *)JS_NativeImagePickerIOS_SpecOpenCameraDialogConfig:(id)json; -@end -@protocol NativeImagePickerIOSSpec - -- (void)openCameraDialog:(JS::NativeImagePickerIOS::SpecOpenCameraDialogConfig &)config - successCallback:(RCTResponseSenderBlock)successCallback - cancelCallback:(RCTResponseSenderBlock)cancelCallback; - -@end -namespace facebook { - namespace react { - /** - * ObjC++ class for module 'NativeImagePickerIOS' - */ - class JSI_EXPORT NativeImagePickerIOSSpecJSI : public ObjCTurboModule { - public: - NativeImagePickerIOSSpecJSI(const ObjCTurboModule::InitParams ¶ms); - }; - } // namespace react -} // namespace facebook inline double JS::NativeCameraRollManager::GetPhotosParams::first() const { id const p = _v[@\\"first\\"]; @@ -845,16 +811,6 @@ inline id _Nullable JS::NativeExceptionsManager::ExceptionData::extraD id const p = _v[@\\"extraData\\"]; return p; } -inline bool JS::NativeImagePickerIOS::SpecOpenCameraDialogConfig::unmirrorFrontFacingCamera() const -{ - id const p = _v[@\\"unmirrorFrontFacingCamera\\"]; - return RCTBridgingToBool(p); -} -inline bool JS::NativeImagePickerIOS::SpecOpenCameraDialogConfig::videoMode() const -{ - id const p = _v[@\\"videoMode\\"]; - return RCTBridgingToBool(p); -} ", } `; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap index 7630f24132a3d3..867858ae3252a7 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap @@ -367,27 +367,6 @@ namespace facebook { } } // namespace react } // namespace facebook -@implementation RCTCxxConvert (NativeImagePickerIOS_SpecOpenCameraDialogConfig) -+ (RCTManagedPointer *)JS_NativeImagePickerIOS_SpecOpenCameraDialogConfig:(id)json -{ - return facebook::react::managedPointer(json); -} -@end -namespace facebook { - namespace react { - - static facebook::jsi::Value __hostFunction_NativeImagePickerIOSSpecJSI_openCameraDialog(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, \\"openCameraDialog\\", @selector(openCameraDialog:successCallback:cancelCallback:), args, count); - } - - NativeImagePickerIOSSpecJSI::NativeImagePickerIOSSpecJSI(const ObjCTurboModule::InitParams ¶ms) - : ObjCTurboModule(params) { - - methodMap_[\\"openCameraDialog\\"] = MethodMetadata {3, __hostFunction_NativeImagePickerIOSSpecJSI_openCameraDialog}; - setMethodArgConversionSelector(@\\"openCameraDialog\\", 0, @\\"JS_NativeImagePickerIOS_SpecOpenCameraDialogConfig:\\"); - } - } // namespace react -} // namespace facebook ", } `; diff --git a/types/index.d.ts b/types/index.d.ts index 542f22e59199a8..c29ececdc92b12 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -110,7 +110,6 @@ export * from '../Libraries/EventEmitter/NativeEventEmitter'; export * from '../Libraries/EventEmitter/RCTDeviceEventEmitter'; export * from '../Libraries/EventEmitter/RCTNativeAppEventEmitter'; export * from '../Libraries/Image/Image'; -export * from '../Libraries/Image/ImagePickerIOS'; export * from '../Libraries/Image/ImageResizeMode'; export * from '../Libraries/Image/ImageSource'; export * from '../Libraries/Interaction/InteractionManager';