Skip to content

Commit

Permalink
refactor(react-native-github): move ImagePickerIOS to internal (#35199)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #35199

**Changelog:**
[iOS][Removed] - Removed ImagePickerIOS module native sources
[JS][Removed] - Removed ImagePickerIOS module from react-native

Reviewed By: cortinico

Differential Revision: D40859520

fbshipit-source-id: a6a114a05574d46ea62600999bff95025ba7cdc8
  • Loading branch information
hoxyq authored and facebook-github-bot committed Nov 4, 2022
1 parent fc9954a commit d03a29c
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 386 deletions.
48 changes: 0 additions & 48 deletions Libraries/Image/ImagePickerIOS.d.ts

This file was deleted.

103 changes: 0 additions & 103 deletions Libraries/Image/ImagePickerIOS.js

This file was deleted.

39 changes: 0 additions & 39 deletions Libraries/Image/NativeImagePickerIOS.js

This file was deleted.

27 changes: 16 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
},
Expand Down Expand Up @@ -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',
);
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeImagePickerIOSCxxSpecJSI *>(&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<CallInvoker> 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<NativeExceptionsManagerCxxSpecJSI *>(&turboModule)->reportFatalException(rt, args[0].asString(rt), args[1].asObject(rt).asArray(rt), args[2].asNumber());
return jsi::Value::undefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,49 +505,6 @@ private:
Delegate delegate_;
};
class JSI_EXPORT NativeImagePickerIOSCxxSpecJSI : public TurboModule {
protected:
NativeImagePickerIOSCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
public:
virtual void openCameraDialog(jsi::Runtime &rt, jsi::Object config, jsi::Function successCallback, jsi::Function cancelCallback) = 0;
};
template <typename T>
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<CallInvoker> jsInvoker)
: TurboModule(\\"ImagePickerIOS\\", jsInvoker),
delegate_(static_cast<T*>(this), jsInvoker) {}
private:
class Delegate : public NativeImagePickerIOSCxxSpecJSI {
public:
Delegate(T *instance, std::shared_ptr<CallInvoker> 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<void>(
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<CallInvoker> jsInvoker);
Expand Down
Loading

0 comments on commit d03a29c

Please sign in to comment.