diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 43554ac673..5c1a61c9c8 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2252,7 +2252,7 @@ SPEC CHECKSUMS: RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8 RNVectorIcons: 07792a9538e8577c1263fcad187712e90d65d8fb SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d - VisionCamera: fbe4f8de9a7243d5986d12a447b16d5528eb9a90 + VisionCamera: fa7ea32339d6c29bb43774e38d2d00a75075b37b Yoga: aa3df615739504eebb91925fc9c58b4922ea9a08 PODFILE CHECKSUM: f0198d9eea1d44be2bb929d80d6bfc9ddeae8414 diff --git a/package/VisionCamera.podspec b/package/VisionCamera.podspec index a2f5da0c90..a27e4e36f4 100644 --- a/package/VisionCamera.podspec +++ b/package/VisionCamera.podspec @@ -83,7 +83,7 @@ Pod::Spec.new do |s| # VisionCamera React-specific Swift codebase react.source_files = [ "ios/React/**/*.swift", - "ios/React/**/*.{h,m,mm}", + "ios/React/**/*.{h,m,mm,cpp}", ] react.public_header_files = [ "ios/React/CameraBridge.h" @@ -121,21 +121,4 @@ Pod::Spec.new do |s| fp.dependency "react-native-worklets-core" end end - - if $new_arch_enabled - # There is a bug in codegen where it generates broken code, this is a workaround - # https://github.com/facebook/react-native/issues/47113 - UI.puts "[VisionCamera] RCT_NEW_ARCH_ENABLED is enabled, adding workaround for EventEmitters" - root_dir = Pod::Config.instance.installation_root - target_file = Dir.glob("#{root_dir}/**/RNVisionCameraSpec/EventEmitters.cpp").first - - if target_file - content = File.read(target_file) - new_content = content.gsub("codesValue,frame.", "codesValue.frame.") - File.write(target_file, new_content) - UI.puts "[VisionCamera] Modified file: #{target_file}" - else - UI.puts "[VisionCamera] Warning: EventEmitters.cpp not found in any RNVisionCameraSpec directory" - end - end end diff --git a/package/ios/React/Fabric/CameraViewNativeComponent.mm b/package/ios/React/Fabric/CameraViewNativeComponent.mm index 6242aa4304..f85d609885 100644 --- a/package/ios/React/Fabric/CameraViewNativeComponent.mm +++ b/package/ios/React/Fabric/CameraViewNativeComponent.mm @@ -7,11 +7,12 @@ #import "CameraViewNativeComponent.h" -#include -#include +#include "ComponentDescriptors.h" +#include "RCTComponentViewHelpers.h" #import "RCTFabricComponentsPlugins.h" #import +#import #import #if __has_include() @@ -33,6 +34,12 @@ + (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider(); } +// Load the component manually into the global fabric view registry. +// TODO: Remove once https://github.com/facebook/react-native/issues/47113 is fixed and we can rely fully on codegen ++ (void)load { + [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[CameraViewNativeComponent class]]; +} + - (void)initCamera { static const auto defaultProps = std::make_shared(); _props = defaultProps; diff --git a/package/ios/React/Fabric/ComponentDescriptors.cpp b/package/ios/React/Fabric/ComponentDescriptors.cpp new file mode 100644 index 0000000000..84f40b30e2 --- /dev/null +++ b/package/ios/React/Fabric/ComponentDescriptors.cpp @@ -0,0 +1,22 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorCpp.js + */ + +#include "ComponentDescriptors.h" +#include +#include + +namespace facebook::react { + +void RNVisionCameraSpec_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry) { +registry->add(concreteComponentDescriptorProvider()); +} + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/ComponentDescriptors.h b/package/ios/React/Fabric/ComponentDescriptors.h new file mode 100644 index 0000000000..eefaedab27 --- /dev/null +++ b/package/ios/React/Fabric/ComponentDescriptors.h @@ -0,0 +1,24 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include "ShadowNodes.h" +#include +#include + +namespace facebook::react { + +using CameraViewComponentDescriptor = ConcreteComponentDescriptor; + +void RNVisionCameraSpec_registerComponentDescriptorsFromCodegen( + std::shared_ptr registry); + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/EventEmitters.cpp b/package/ios/React/Fabric/EventEmitters.cpp new file mode 100644 index 0000000000..0f468a5788 --- /dev/null +++ b/package/ios/React/Fabric/EventEmitters.cpp @@ -0,0 +1,168 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include "EventEmitters.h" + + +namespace facebook::react { + +void CameraViewEventEmitter::onViewReady(OnViewReady $event) const { + dispatchEvent("viewReady", [](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + return $payload; + }); +} + + +void CameraViewEventEmitter::onAverageFpsChanged(OnAverageFpsChanged $event) const { + dispatchEvent("averageFpsChanged", [$event=std::move($event)](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + $payload.setProperty(runtime, "averageFps", $event.averageFps); + return $payload; + }); +} + + +void CameraViewEventEmitter::onInitialized(OnInitialized $event) const { + dispatchEvent("initialized", [](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + return $payload; + }); +} + + +void CameraViewEventEmitter::onError(OnError $event) const { + dispatchEvent("error", [$event=std::move($event)](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + $payload.setProperty(runtime, "code", $event.code); +$payload.setProperty(runtime, "message", $event.message); +{ + auto cause = jsi::Object(runtime); + cause.setProperty(runtime, "code", $event.cause.code); + cause.setProperty(runtime, "domain", $event.cause.domain); + cause.setProperty(runtime, "message", $event.cause.message); + cause.setProperty(runtime, "details", $event.cause.details); + cause.setProperty(runtime, "stacktrace", $event.cause.stacktrace); + $payload.setProperty(runtime, "cause", cause); +} + return $payload; + }); +} + + +void CameraViewEventEmitter::onCodeScanned(OnCodeScanned $event) const { + dispatchEvent("codeScanned", [$event=std::move($event)](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + auto codes = jsi::Array(runtime, $event.codes.size()); + size_t codesIndex = 0; + for (auto codesValue : $event.codes) { + auto codesObject = jsi::Object(runtime); + codesObject.setProperty(runtime, "type", codesValue.type); +codesObject.setProperty(runtime, "value", codesValue.value); +{ + auto frame = jsi::Object(runtime); + frame.setProperty(runtime, "x", codesValue.frame.x); + frame.setProperty(runtime, "y", codesValue.frame.y); + frame.setProperty(runtime, "width", codesValue.frame.width); + frame.setProperty(runtime, "height", codesValue.frame.height); + codesObject.setProperty(runtime, "frame", frame); +} + + auto corners = jsi::Array(runtime, codesValue.corners.size()); + size_t cornersIndex = 0; + for (auto cornersValue : codesValue.corners) { + auto cornersObject = jsi::Object(runtime); + cornersObject.setProperty(runtime, "x", cornersValue.x); +cornersObject.setProperty(runtime, "y", cornersValue.y); + corners.setValueAtIndex(runtime, cornersIndex++, cornersObject); + } + codesObject.setProperty(runtime, "corners", corners); + + codes.setValueAtIndex(runtime, codesIndex++, codesObject); + } + $payload.setProperty(runtime, "codes", codes); + +{ + auto frame = jsi::Object(runtime); + frame.setProperty(runtime, "width", $event.frame.width); + frame.setProperty(runtime, "height", $event.frame.height); + $payload.setProperty(runtime, "frame", frame); +} + return $payload; + }); +} + + +void CameraViewEventEmitter::onStarted(OnStarted $event) const { + dispatchEvent("started", [](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + return $payload; + }); +} + + +void CameraViewEventEmitter::onStopped(OnStopped $event) const { + dispatchEvent("stopped", [](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + return $payload; + }); +} + + +void CameraViewEventEmitter::onPreviewStarted(OnPreviewStarted $event) const { + dispatchEvent("previewStarted", [](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + return $payload; + }); +} + + +void CameraViewEventEmitter::onPreviewStopped(OnPreviewStopped $event) const { + dispatchEvent("previewStopped", [](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + + return $payload; + }); +} + + +void CameraViewEventEmitter::onShutter(OnShutter $event) const { + dispatchEvent("shutter", [$event=std::move($event)](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + $payload.setProperty(runtime, "type", $event.type); + return $payload; + }); +} + + +void CameraViewEventEmitter::onOutputOrientationChanged(OnOutputOrientationChanged $event) const { + dispatchEvent("outputOrientationChanged", [$event=std::move($event)](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + $payload.setProperty(runtime, "outputOrientation", toString($event.outputOrientation)); + return $payload; + }); +} + + +void CameraViewEventEmitter::onPreviewOrientationChanged(OnPreviewOrientationChanged $event) const { + dispatchEvent("previewOrientationChanged", [$event=std::move($event)](jsi::Runtime &runtime) { + auto $payload = jsi::Object(runtime); + $payload.setProperty(runtime, "previewOrientation", toString($event.previewOrientation)); + return $payload; + }); +} + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/EventEmitters.h b/package/ios/React/Fabric/EventEmitters.h new file mode 100644 index 0000000000..f43617201b --- /dev/null +++ b/package/ios/React/Fabric/EventEmitters.h @@ -0,0 +1,158 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include + + +namespace facebook::react { +class CameraViewEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + struct OnViewReady { + + }; + + struct OnAverageFpsChanged { + double averageFps; + }; + + struct OnInitialized { + + }; + + struct OnErrorCause { + int code; + std::string domain; + std::string message; + std::string details; + std::string stacktrace; + }; + + struct OnError { + std::string code; + std::string message; + OnErrorCause cause; + }; + + struct OnCodeScannedCodesFrame { + double x; + double y; + double width; + double height; + }; + + struct OnCodeScannedCodesCorners { + double x; + double y; + }; + + struct OnCodeScannedCodes { + std::string type; + std::string value; + OnCodeScannedCodesFrame frame; + std::vector corners; + }; + + struct OnCodeScannedFrame { + int width; + int height; + }; + + struct OnCodeScanned { + std::vector codes; + OnCodeScannedFrame frame; + }; + + struct OnStarted { + + }; + + struct OnStopped { + + }; + + struct OnPreviewStarted { + + }; + + struct OnPreviewStopped { + + }; + + struct OnShutter { + std::string type; + }; + + enum class OnOutputOrientationChangedOutputOrientation { + Portrait, + PortraitUpsideDown, + LandscapeLeft, + LandscapeRight + }; + + static char const *toString(const OnOutputOrientationChangedOutputOrientation value) { + switch (value) { + case OnOutputOrientationChangedOutputOrientation::Portrait: return "portrait"; + case OnOutputOrientationChangedOutputOrientation::PortraitUpsideDown: return "portrait-upside-down"; + case OnOutputOrientationChangedOutputOrientation::LandscapeLeft: return "landscape-left"; + case OnOutputOrientationChangedOutputOrientation::LandscapeRight: return "landscape-right"; + } + } + + struct OnOutputOrientationChanged { + OnOutputOrientationChangedOutputOrientation outputOrientation; + }; + + enum class OnPreviewOrientationChangedPreviewOrientation { + Portrait, + PortraitUpsideDown, + LandscapeLeft, + LandscapeRight + }; + + static char const *toString(const OnPreviewOrientationChangedPreviewOrientation value) { + switch (value) { + case OnPreviewOrientationChangedPreviewOrientation::Portrait: return "portrait"; + case OnPreviewOrientationChangedPreviewOrientation::PortraitUpsideDown: return "portrait-upside-down"; + case OnPreviewOrientationChangedPreviewOrientation::LandscapeLeft: return "landscape-left"; + case OnPreviewOrientationChangedPreviewOrientation::LandscapeRight: return "landscape-right"; + } + } + + struct OnPreviewOrientationChanged { + OnPreviewOrientationChangedPreviewOrientation previewOrientation; + }; + void onViewReady(OnViewReady value) const; + + void onAverageFpsChanged(OnAverageFpsChanged value) const; + + void onInitialized(OnInitialized value) const; + + void onError(OnError value) const; + + void onCodeScanned(OnCodeScanned value) const; + + void onStarted(OnStarted value) const; + + void onStopped(OnStopped value) const; + + void onPreviewStarted(OnPreviewStarted value) const; + + void onPreviewStopped(OnPreviewStopped value) const; + + void onShutter(OnShutter value) const; + + void onOutputOrientationChanged(OnOutputOrientationChanged value) const; + + void onPreviewOrientationChanged(OnPreviewOrientationChanged value) const; +}; +} // namespace facebook::react diff --git a/package/ios/React/Fabric/Props.cpp b/package/ios/React/Fabric/Props.cpp new file mode 100644 index 0000000000..4f763f06c3 --- /dev/null +++ b/package/ios/React/Fabric/Props.cpp @@ -0,0 +1,53 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include "Props.h" +#include +#include + +namespace facebook::react { + +CameraViewProps::CameraViewProps( + const PropsParserContext &context, + const CameraViewProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), + + isActive(convertRawProp(context, rawProps, "isActive", sourceProps.isActive, {false})), + preview(convertRawProp(context, rawProps, "preview", sourceProps.preview, {false})), + photo(convertRawProp(context, rawProps, "photo", sourceProps.photo, {false})), + video(convertRawProp(context, rawProps, "video", sourceProps.video, {false})), + audio(convertRawProp(context, rawProps, "audio", sourceProps.audio, {false})), + pixelFormat(convertRawProp(context, rawProps, "pixelFormat", sourceProps.pixelFormat, {CameraViewPixelFormat::Yuv})), + enableLocation(convertRawProp(context, rawProps, "enableLocation", sourceProps.enableLocation, {false})), + torch(convertRawProp(context, rawProps, "torch", sourceProps.torch, {CameraViewTorch::Off})), + zoom(convertRawProp(context, rawProps, "zoom", sourceProps.zoom, {0.0})), + enableZoomGesture(convertRawProp(context, rawProps, "enableZoomGesture", sourceProps.enableZoomGesture, {false})), + exposure(convertRawProp(context, rawProps, "exposure", sourceProps.exposure, {0.0})), + format(convertRawProp(context, rawProps, "format", sourceProps.format, {})), + resizeMode(convertRawProp(context, rawProps, "resizeMode", sourceProps.resizeMode, {CameraViewResizeMode::Cover})), + androidPreviewViewType(convertRawProp(context, rawProps, "androidPreviewViewType", sourceProps.androidPreviewViewType, {CameraViewAndroidPreviewViewType::SurfaceView})), + videoHdr(convertRawProp(context, rawProps, "videoHdr", sourceProps.videoHdr, {false})), + photoHdr(convertRawProp(context, rawProps, "photoHdr", sourceProps.photoHdr, {false})), + photoQualityBalance(convertRawProp(context, rawProps, "photoQualityBalance", sourceProps.photoQualityBalance, {CameraViewPhotoQualityBalance::Balanced})), + enableBufferCompression(convertRawProp(context, rawProps, "enableBufferCompression", sourceProps.enableBufferCompression, {false})), + lowLightBoost(convertRawProp(context, rawProps, "lowLightBoost", sourceProps.lowLightBoost, {false})), + videoStabilizationMode(convertRawProp(context, rawProps, "videoStabilizationMode", sourceProps.videoStabilizationMode, {CameraViewVideoStabilizationMode::Off})), + enableDepthData(convertRawProp(context, rawProps, "enableDepthData", sourceProps.enableDepthData, {false})), + enablePortraitEffectsMatteDelivery(convertRawProp(context, rawProps, "enablePortraitEffectsMatteDelivery", sourceProps.enablePortraitEffectsMatteDelivery, {false})), + outputOrientation(convertRawProp(context, rawProps, "outputOrientation", sourceProps.outputOrientation, {CameraViewOutputOrientation::Device})), + isMirrored(convertRawProp(context, rawProps, "isMirrored", sourceProps.isMirrored, {false})), + cameraId(convertRawProp(context, rawProps, "cameraId", sourceProps.cameraId, {})), + enableFrameProcessor(convertRawProp(context, rawProps, "enableFrameProcessor", sourceProps.enableFrameProcessor, {false})), + codeScannerOptions(convertRawProp(context, rawProps, "codeScannerOptions", sourceProps.codeScannerOptions, {})), + minFps(convertRawProp(context, rawProps, "minFps", sourceProps.minFps, {0.0})), + maxFps(convertRawProp(context, rawProps, "maxFps", sourceProps.maxFps, {0.0})) + {} + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/Props.h b/package/ios/React/Fabric/Props.h new file mode 100644 index 0000000000..bd7deb58c2 --- /dev/null +++ b/package/ios/React/Fabric/Props.h @@ -0,0 +1,305 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include +#include + +namespace facebook::react { + +enum class CameraViewPixelFormat { Yuv, Rgb }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewPixelFormat &result) { + auto string = (std::string)value; + if (string == "yuv") { result = CameraViewPixelFormat::Yuv; return; } + if (string == "rgb") { result = CameraViewPixelFormat::Rgb; return; } + abort(); +} + +static inline std::string toString(const CameraViewPixelFormat &value) { + switch (value) { + case CameraViewPixelFormat::Yuv: return "yuv"; + case CameraViewPixelFormat::Rgb: return "rgb"; + } +} +enum class CameraViewTorch { Off, On }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewTorch &result) { + auto string = (std::string)value; + if (string == "off") { result = CameraViewTorch::Off; return; } + if (string == "on") { result = CameraViewTorch::On; return; } + abort(); +} + +static inline std::string toString(const CameraViewTorch &value) { + switch (value) { + case CameraViewTorch::Off: return "off"; + case CameraViewTorch::On: return "on"; + } +} +enum class CameraViewResizeMode { Cover, Contain }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewResizeMode &result) { + auto string = (std::string)value; + if (string == "cover") { result = CameraViewResizeMode::Cover; return; } + if (string == "contain") { result = CameraViewResizeMode::Contain; return; } + abort(); +} + +static inline std::string toString(const CameraViewResizeMode &value) { + switch (value) { + case CameraViewResizeMode::Cover: return "cover"; + case CameraViewResizeMode::Contain: return "contain"; + } +} +enum class CameraViewAndroidPreviewViewType { SurfaceView, TextureView }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewAndroidPreviewViewType &result) { + auto string = (std::string)value; + if (string == "surface-view") { result = CameraViewAndroidPreviewViewType::SurfaceView; return; } + if (string == "texture-view") { result = CameraViewAndroidPreviewViewType::TextureView; return; } + abort(); +} + +static inline std::string toString(const CameraViewAndroidPreviewViewType &value) { + switch (value) { + case CameraViewAndroidPreviewViewType::SurfaceView: return "surface-view"; + case CameraViewAndroidPreviewViewType::TextureView: return "texture-view"; + } +} +enum class CameraViewPhotoQualityBalance { Speed, Balanced, Quality }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewPhotoQualityBalance &result) { + auto string = (std::string)value; + if (string == "speed") { result = CameraViewPhotoQualityBalance::Speed; return; } + if (string == "balanced") { result = CameraViewPhotoQualityBalance::Balanced; return; } + if (string == "quality") { result = CameraViewPhotoQualityBalance::Quality; return; } + abort(); +} + +static inline std::string toString(const CameraViewPhotoQualityBalance &value) { + switch (value) { + case CameraViewPhotoQualityBalance::Speed: return "speed"; + case CameraViewPhotoQualityBalance::Balanced: return "balanced"; + case CameraViewPhotoQualityBalance::Quality: return "quality"; + } +} +enum class CameraViewVideoStabilizationMode { Off, Standard, Cinematic, CinematicExtended, Auto }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewVideoStabilizationMode &result) { + auto string = (std::string)value; + if (string == "off") { result = CameraViewVideoStabilizationMode::Off; return; } + if (string == "standard") { result = CameraViewVideoStabilizationMode::Standard; return; } + if (string == "cinematic") { result = CameraViewVideoStabilizationMode::Cinematic; return; } + if (string == "cinematic-extended") { result = CameraViewVideoStabilizationMode::CinematicExtended; return; } + if (string == "auto") { result = CameraViewVideoStabilizationMode::Auto; return; } + abort(); +} + +static inline std::string toString(const CameraViewVideoStabilizationMode &value) { + switch (value) { + case CameraViewVideoStabilizationMode::Off: return "off"; + case CameraViewVideoStabilizationMode::Standard: return "standard"; + case CameraViewVideoStabilizationMode::Cinematic: return "cinematic"; + case CameraViewVideoStabilizationMode::CinematicExtended: return "cinematic-extended"; + case CameraViewVideoStabilizationMode::Auto: return "auto"; + } +} +enum class CameraViewOutputOrientation { Device, Preview }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewOutputOrientation &result) { + auto string = (std::string)value; + if (string == "device") { result = CameraViewOutputOrientation::Device; return; } + if (string == "preview") { result = CameraViewOutputOrientation::Preview; return; } + abort(); +} + +static inline std::string toString(const CameraViewOutputOrientation &value) { + switch (value) { + case CameraViewOutputOrientation::Device: return "device"; + case CameraViewOutputOrientation::Preview: return "preview"; + } +} +struct CameraViewFormatStruct { + double photoHeight{0.0}; + double photoWidth{0.0}; + double videoHeight{0.0}; + double videoWidth{0.0}; + double maxISO{0.0}; + double minISO{0.0}; + double fieldOfView{0.0}; + bool supportsVideoHdr{false}; + bool supportsPhotoHdr{false}; + bool supportsDepthCapture{false}; + double minFps{0.0}; + double maxFps{0.0}; + std::string autoFocusSystem{}; + std::vector videoStabilizationModes{}; +}; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewFormatStruct &result) { + auto map = (std::unordered_map)value; + + auto tmp_photoHeight = map.find("photoHeight"); + if (tmp_photoHeight != map.end()) { + fromRawValue(context, tmp_photoHeight->second, result.photoHeight); + } + auto tmp_photoWidth = map.find("photoWidth"); + if (tmp_photoWidth != map.end()) { + fromRawValue(context, tmp_photoWidth->second, result.photoWidth); + } + auto tmp_videoHeight = map.find("videoHeight"); + if (tmp_videoHeight != map.end()) { + fromRawValue(context, tmp_videoHeight->second, result.videoHeight); + } + auto tmp_videoWidth = map.find("videoWidth"); + if (tmp_videoWidth != map.end()) { + fromRawValue(context, tmp_videoWidth->second, result.videoWidth); + } + auto tmp_maxISO = map.find("maxISO"); + if (tmp_maxISO != map.end()) { + fromRawValue(context, tmp_maxISO->second, result.maxISO); + } + auto tmp_minISO = map.find("minISO"); + if (tmp_minISO != map.end()) { + fromRawValue(context, tmp_minISO->second, result.minISO); + } + auto tmp_fieldOfView = map.find("fieldOfView"); + if (tmp_fieldOfView != map.end()) { + fromRawValue(context, tmp_fieldOfView->second, result.fieldOfView); + } + auto tmp_supportsVideoHdr = map.find("supportsVideoHdr"); + if (tmp_supportsVideoHdr != map.end()) { + fromRawValue(context, tmp_supportsVideoHdr->second, result.supportsVideoHdr); + } + auto tmp_supportsPhotoHdr = map.find("supportsPhotoHdr"); + if (tmp_supportsPhotoHdr != map.end()) { + fromRawValue(context, tmp_supportsPhotoHdr->second, result.supportsPhotoHdr); + } + auto tmp_supportsDepthCapture = map.find("supportsDepthCapture"); + if (tmp_supportsDepthCapture != map.end()) { + fromRawValue(context, tmp_supportsDepthCapture->second, result.supportsDepthCapture); + } + auto tmp_minFps = map.find("minFps"); + if (tmp_minFps != map.end()) { + fromRawValue(context, tmp_minFps->second, result.minFps); + } + auto tmp_maxFps = map.find("maxFps"); + if (tmp_maxFps != map.end()) { + fromRawValue(context, tmp_maxFps->second, result.maxFps); + } + auto tmp_autoFocusSystem = map.find("autoFocusSystem"); + if (tmp_autoFocusSystem != map.end()) { + fromRawValue(context, tmp_autoFocusSystem->second, result.autoFocusSystem); + } + auto tmp_videoStabilizationModes = map.find("videoStabilizationModes"); + if (tmp_videoStabilizationModes != map.end()) { + fromRawValue(context, tmp_videoStabilizationModes->second, result.videoStabilizationModes); + } +} + +static inline std::string toString(const CameraViewFormatStruct &value) { + return "[Object CameraViewFormatStruct]"; +} + +struct CameraViewCodeScannerOptionsRegionOfInterestStruct { + double x{0.0}; + double y{0.0}; + double width{0.0}; + double height{0.0}; +}; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewCodeScannerOptionsRegionOfInterestStruct &result) { + auto map = (std::unordered_map)value; + + auto tmp_x = map.find("x"); + if (tmp_x != map.end()) { + fromRawValue(context, tmp_x->second, result.x); + } + auto tmp_y = map.find("y"); + if (tmp_y != map.end()) { + fromRawValue(context, tmp_y->second, result.y); + } + auto tmp_width = map.find("width"); + if (tmp_width != map.end()) { + fromRawValue(context, tmp_width->second, result.width); + } + auto tmp_height = map.find("height"); + if (tmp_height != map.end()) { + fromRawValue(context, tmp_height->second, result.height); + } +} + +static inline std::string toString(const CameraViewCodeScannerOptionsRegionOfInterestStruct &value) { + return "[Object CameraViewCodeScannerOptionsRegionOfInterestStruct]"; +} + +struct CameraViewCodeScannerOptionsStruct { + std::vector codeTypes{}; + CameraViewCodeScannerOptionsRegionOfInterestStruct regionOfInterest{}; +}; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, CameraViewCodeScannerOptionsStruct &result) { + auto map = (std::unordered_map)value; + + auto tmp_codeTypes = map.find("codeTypes"); + if (tmp_codeTypes != map.end()) { + fromRawValue(context, tmp_codeTypes->second, result.codeTypes); + } + auto tmp_regionOfInterest = map.find("regionOfInterest"); + if (tmp_regionOfInterest != map.end()) { + fromRawValue(context, tmp_regionOfInterest->second, result.regionOfInterest); + } +} + +static inline std::string toString(const CameraViewCodeScannerOptionsStruct &value) { + return "[Object CameraViewCodeScannerOptionsStruct]"; +} +class CameraViewProps final : public ViewProps { + public: + CameraViewProps() = default; + CameraViewProps(const PropsParserContext& context, const CameraViewProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + bool isActive{false}; + bool preview{false}; + bool photo{false}; + bool video{false}; + bool audio{false}; + CameraViewPixelFormat pixelFormat{CameraViewPixelFormat::Yuv}; + bool enableLocation{false}; + CameraViewTorch torch{CameraViewTorch::Off}; + double zoom{0.0}; + bool enableZoomGesture{false}; + double exposure{0.0}; + CameraViewFormatStruct format{}; + CameraViewResizeMode resizeMode{CameraViewResizeMode::Cover}; + CameraViewAndroidPreviewViewType androidPreviewViewType{CameraViewAndroidPreviewViewType::SurfaceView}; + bool videoHdr{false}; + bool photoHdr{false}; + CameraViewPhotoQualityBalance photoQualityBalance{CameraViewPhotoQualityBalance::Balanced}; + bool enableBufferCompression{false}; + bool lowLightBoost{false}; + CameraViewVideoStabilizationMode videoStabilizationMode{CameraViewVideoStabilizationMode::Off}; + bool enableDepthData{false}; + bool enablePortraitEffectsMatteDelivery{false}; + CameraViewOutputOrientation outputOrientation{CameraViewOutputOrientation::Device}; + bool isMirrored{false}; + std::string cameraId{}; + bool enableFrameProcessor{false}; + CameraViewCodeScannerOptionsStruct codeScannerOptions{}; + double minFps{0.0}; + double maxFps{0.0}; +}; + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/RCTComponentViewHelpers.h b/package/ios/React/Fabric/RCTComponentViewHelpers.h new file mode 100644 index 0000000000..837def5aa6 --- /dev/null +++ b/package/ios/React/Fabric/RCTComponentViewHelpers.h @@ -0,0 +1,20 @@ +/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTCameraViewViewProtocol + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/package/ios/React/Fabric/ShadowNodes.cpp b/package/ios/React/Fabric/ShadowNodes.cpp new file mode 100644 index 0000000000..3b4957a0dc --- /dev/null +++ b/package/ios/React/Fabric/ShadowNodes.cpp @@ -0,0 +1,17 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include "ShadowNodes.h" + +namespace facebook::react { + +extern const char CameraViewComponentName[] = "CameraView"; + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/ShadowNodes.h b/package/ios/React/Fabric/ShadowNodes.h new file mode 100644 index 0000000000..ffe74ed7cb --- /dev/null +++ b/package/ios/React/Fabric/ShadowNodes.h @@ -0,0 +1,32 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include "EventEmitters.h" +#include "Props.h" +#include "States.h" +#include +#include + +namespace facebook::react { + +JSI_EXPORT extern const char CameraViewComponentName[]; + +/* + * `ShadowNode` for component. + */ +using CameraViewShadowNode = ConcreteViewShadowNode< + CameraViewComponentName, + CameraViewProps, + CameraViewEventEmitter, + CameraViewState>; + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/States.cpp b/package/ios/React/Fabric/States.cpp new file mode 100644 index 0000000000..1dbb184cbd --- /dev/null +++ b/package/ios/React/Fabric/States.cpp @@ -0,0 +1,16 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include "States.h" + +namespace facebook::react { + + + +} // namespace facebook::react diff --git a/package/ios/React/Fabric/States.h b/package/ios/React/Fabric/States.h new file mode 100644 index 0000000000..b6b61cec6c --- /dev/null +++ b/package/ios/React/Fabric/States.h @@ -0,0 +1,29 @@ +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#ifdef ANDROID +#include +#endif + +namespace facebook::react { + +class CameraViewState { +public: + CameraViewState() = default; + +#ifdef ANDROID + CameraViewState(CameraViewState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; +#endif +}; + +} // namespace facebook::react \ No newline at end of file diff --git a/package/package.json b/package/package.json index 99ab9605f6..9cfb4c78f4 100644 --- a/package/package.json +++ b/package/package.json @@ -177,13 +177,5 @@ } ] ] - }, - "codegenConfig": { - "name": "RNVisionCameraSpec", - "type": "all", - "jsSrcsDir": "./src", - "android": { - "javaPackageName": "com.mrousavy.camera" - } } }