diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index 0f9b243a3fe5..6130366ba5cb 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -37,8 +37,35 @@ ArrayPropsNativeComponentViewProps::ArrayPropsNativeComponentViewProps( sizes(convertRawProp(context, rawProps, \\"sizes\\", ArrayPropsNativeComponentViewSizesMaskWrapped{ .value = sourceProps.sizes }, {static_cast(ArrayPropsNativeComponentViewSizes::Small)}).value), object(convertRawProp(context, rawProps, \\"object\\", sourceProps.object, {})), arrayOfObjects(convertRawProp(context, rawProps, \\"arrayOfObjects\\", sourceProps.arrayOfObjects, {})), - arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) - {} + arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ArrayPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentViewProps(); + const ArrayPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + + + + + + + + + + + + return result; +} +#endif } // namespace facebook::react ", @@ -69,8 +96,30 @@ BooleanPropNativeComponentViewProps::BooleanPropNativeComponentViewProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})), - disabledNullable(convertRawProp(context, rawProps, \\"disabledNullable\\", sourceProps.disabledNullable, {})) - {} + disabledNullable(convertRawProp(context, rawProps, \\"disabledNullable\\", sourceProps.disabledNullable, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic BooleanPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = BooleanPropNativeComponentViewProps(); + const BooleanPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + + if (disabledNullable != oldProps->disabledNullable) { + result[\\"disabledNullable\\"] = disabledNullable; + } + return result; +} +#endif } // namespace facebook::react ", @@ -100,8 +149,26 @@ ColorPropNativeComponentViewProps::ColorPropNativeComponentViewProps( const ColorPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) - {} + tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ColorPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ColorPropNativeComponentViewProps(); + const ColorPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (tintColor != oldProps->tintColor) { + result[\\"tintColor\\"] = *tintColor; + } + return result; +} +#endif } // namespace facebook::react ", @@ -132,8 +199,23 @@ DimensionPropNativeComponentViewProps::DimensionPropNativeComponentViewProps( const DimensionPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) - {} + marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic DimensionPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = DimensionPropNativeComponentViewProps(); + const DimensionPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -163,8 +245,23 @@ EdgeInsetsPropNativeComponentViewProps::EdgeInsetsPropNativeComponentViewProps( const EdgeInsetsPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EdgeInsetsPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EdgeInsetsPropNativeComponentViewProps(); + const EdgeInsetsPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -195,8 +292,24 @@ EnumPropNativeComponentViewProps::EnumPropNativeComponentViewProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), alignment(convertRawProp(context, rawProps, \\"alignment\\", sourceProps.alignment, {EnumPropNativeComponentViewAlignment::Center})), - intervals(convertRawProp(context, rawProps, \\"intervals\\", sourceProps.intervals, {EnumPropNativeComponentViewIntervals::Intervals0})) - {} + intervals(convertRawProp(context, rawProps, \\"intervals\\", sourceProps.intervals, {EnumPropNativeComponentViewIntervals::Intervals0})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EnumPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EnumPropNativeComponentViewProps(); + const EnumPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + return result; +} +#endif } // namespace facebook::react ", @@ -226,8 +339,26 @@ EventNestedObjectPropsNativeComponentViewProps::EventNestedObjectPropsNativeComp const EventNestedObjectPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EventNestedObjectPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EventNestedObjectPropsNativeComponentViewProps(); + const EventNestedObjectPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -257,8 +388,26 @@ EventPropsNativeComponentViewProps::EventPropsNativeComponentViewProps( const EventPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EventPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EventPropsNativeComponentViewProps(); + const EventPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -294,8 +443,50 @@ FloatPropsNativeComponentViewProps::FloatPropsNativeComponentViewProps( blurRadius4(convertRawProp(context, rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), blurRadius5(convertRawProp(context, rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})), - blurRadiusNullable(convertRawProp(context, rawProps, \\"blurRadiusNullable\\", sourceProps.blurRadiusNullable, {})) - {} + blurRadiusNullable(convertRawProp(context, rawProps, \\"blurRadiusNullable\\", sourceProps.blurRadiusNullable, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic FloatPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = FloatPropsNativeComponentViewProps(); + const FloatPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if ((blurRadius != oldProps->blurRadius) && !(std::isnan(blurRadius) && std::isnan(oldProps->blurRadius))) { + result[\\"blurRadius\\"] = blurRadius; + } + + if ((blurRadius2 != oldProps->blurRadius2) && !(std::isnan(blurRadius2) && std::isnan(oldProps->blurRadius2))) { + result[\\"blurRadius2\\"] = blurRadius2; + } + + if ((blurRadius3 != oldProps->blurRadius3) && !(std::isnan(blurRadius3) && std::isnan(oldProps->blurRadius3))) { + result[\\"blurRadius3\\"] = blurRadius3; + } + + if ((blurRadius4 != oldProps->blurRadius4) && !(std::isnan(blurRadius4) && std::isnan(oldProps->blurRadius4))) { + result[\\"blurRadius4\\"] = blurRadius4; + } + + if ((blurRadius5 != oldProps->blurRadius5) && !(std::isnan(blurRadius5) && std::isnan(oldProps->blurRadius5))) { + result[\\"blurRadius5\\"] = blurRadius5; + } + + if ((blurRadius6 != oldProps->blurRadius6) && !(std::isnan(blurRadius6) && std::isnan(oldProps->blurRadius6))) { + result[\\"blurRadius6\\"] = blurRadius6; + } + + if ((blurRadiusNullable != oldProps->blurRadiusNullable) && !(std::isnan(blurRadiusNullable) && std::isnan(oldProps->blurRadiusNullable))) { + result[\\"blurRadiusNullable\\"] = blurRadiusNullable; + } + return result; +} +#endif } // namespace facebook::react ", @@ -326,8 +517,23 @@ ImagePropNativeComponentViewProps::ImagePropNativeComponentViewProps( const ImagePropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) - {} + thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ImagePropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ImagePropNativeComponentViewProps(); + const ImagePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -359,8 +565,34 @@ IntegerPropNativeComponentViewProps::IntegerPropNativeComponentViewProps( progress1(convertRawProp(context, rawProps, \\"progress1\\", sourceProps.progress1, {0})), progress2(convertRawProp(context, rawProps, \\"progress2\\", sourceProps.progress2, {-1})), - progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) - {} + progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic IntegerPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = IntegerPropNativeComponentViewProps(); + const IntegerPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (progress1 != oldProps->progress1) { + result[\\"progress1\\"] = progress1; + } + + if (progress2 != oldProps->progress2) { + result[\\"progress2\\"] = progress2; + } + + if (progress3 != oldProps->progress3) { + result[\\"progress3\\"] = progress3; + } + return result; +} +#endif } // namespace facebook::react ", @@ -390,8 +622,26 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps( const InterfaceOnlyNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) - {} + title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic InterfaceOnlyNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyNativeComponentViewProps(); + const InterfaceOnlyNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (title != oldProps->title) { + result[\\"title\\"] = title; + } + return result; +} +#endif } // namespace facebook::react ", @@ -422,8 +672,23 @@ MixedPropNativeComponentViewProps::MixedPropNativeComponentViewProps( const MixedPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) - {} + mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MixedPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MixedPropNativeComponentViewProps(); + const MixedPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -457,8 +722,32 @@ MultiNativePropNativeComponentViewProps::MultiNativePropNativeComponentViewProps thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})), color(convertRawProp(context, rawProps, \\"color\\", sourceProps.color, {})), thumbTintColor(convertRawProp(context, rawProps, \\"thumbTintColor\\", sourceProps.thumbTintColor, {})), - point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) - {} + point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiNativePropNativeComponentViewProps(); + const MultiNativePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + if (color != oldProps->color) { + result[\\"color\\"] = *color; + } + + if (thumbTintColor != oldProps->thumbTintColor) { + result[\\"thumbTintColor\\"] = *thumbTintColor; + } + + return result; +} +#endif } // namespace facebook::react ", @@ -488,8 +777,23 @@ NoPropsNoEventsNativeComponentViewProps::NoPropsNoEventsNativeComponentViewProps const NoPropsNoEventsNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic NoPropsNoEventsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = NoPropsNoEventsNativeComponentViewProps(); + const NoPropsNoEventsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -522,8 +826,25 @@ ObjectPropsNativeComponentProps::ObjectPropsNativeComponentProps( objectProp(convertRawProp(context, rawProps, \\"objectProp\\", sourceProps.objectProp, {})), objectArrayProp(convertRawProp(context, rawProps, \\"objectArrayProp\\", sourceProps.objectArrayProp, {})), - objectPrimitiveRequiredProp(convertRawProp(context, rawProps, \\"objectPrimitiveRequiredProp\\", sourceProps.objectPrimitiveRequiredProp, {})) - {} + objectPrimitiveRequiredProp(convertRawProp(context, rawProps, \\"objectPrimitiveRequiredProp\\", sourceProps.objectPrimitiveRequiredProp, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ObjectPropsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ObjectPropsNativeComponentProps(); + const ObjectPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + + return result; +} +#endif } // namespace facebook::react ", @@ -553,8 +874,23 @@ PointPropNativeComponentViewProps::PointPropNativeComponentViewProps( const PointPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) - {} + startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic PointPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = PointPropNativeComponentViewProps(); + const PointPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -585,8 +921,30 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), placeholder(convertRawProp(context, rawProps, \\"placeholder\\", sourceProps.placeholder, {\\"\\"})), - defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) - {} + defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic StringPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = StringPropNativeComponentViewProps(); + const StringPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (placeholder != oldProps->placeholder) { + result[\\"placeholder\\"] = placeholder; + } + + if (defaultValue != oldProps->defaultValue) { + result[\\"defaultValue\\"] = defaultValue; + } + return result; +} +#endif } // namespace facebook::react ", diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap index b7e2b088f316..5e564ac33979 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap @@ -163,6 +163,10 @@ class ArrayPropsNativeComponentViewProps final : public ViewProps { std::vector object{}; std::vector arrayOfObjects{}; std::vector arrayOfMixed{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -197,6 +201,10 @@ class BooleanPropNativeComponentViewProps final : public ViewProps { bool disabled{false}; bool disabledNullable{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -231,6 +239,10 @@ class ColorPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props SharedColor tintColor{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -265,6 +277,10 @@ class DimensionPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props YGValue marginBack{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -298,6 +314,10 @@ class EdgeInsetsPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -380,6 +400,10 @@ class EnumPropNativeComponentViewProps final : public ViewProps { EnumPropNativeComponentViewAlignment alignment{EnumPropNativeComponentViewAlignment::Center}; EnumPropNativeComponentViewIntervals intervals{EnumPropNativeComponentViewIntervals::Intervals0}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -413,6 +437,10 @@ class EventNestedObjectPropsNativeComponentViewProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -446,6 +474,10 @@ class EventPropsNativeComponentViewProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -485,6 +517,10 @@ class FloatPropsNativeComponentViewProps final : public ViewProps { Float blurRadius5{1.0}; Float blurRadius6{0.0}; Float blurRadiusNullable{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -519,6 +555,10 @@ class ImagePropNativeComponentViewProps final : public ViewProps { #pragma mark - Props ImageSource thumbImage{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -554,6 +594,10 @@ class IntegerPropNativeComponentViewProps final : public ViewProps { int progress1{0}; int progress2{-1}; int progress3{10}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -587,6 +631,10 @@ class InterfaceOnlyNativeComponentViewProps final : public ViewProps { #pragma mark - Props std::string title{\\"\\"}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -620,6 +668,10 @@ class MixedPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props folly::dynamic mixedProp{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -659,6 +711,10 @@ class MultiNativePropNativeComponentViewProps final : public ViewProps { SharedColor color{}; SharedColor thumbTintColor{}; Point point{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -692,6 +748,10 @@ class NoPropsNoEventsNativeComponentViewProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -855,6 +915,10 @@ class ObjectPropsNativeComponentProps final : public ViewProps { ObjectPropsNativeComponentObjectPropStruct objectProp{}; ObjectPropsNativeComponentObjectArrayPropStruct objectArrayProp{}; ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct objectPrimitiveRequiredProp{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -889,6 +953,10 @@ class PointPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props Point startPoint{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -923,6 +991,10 @@ class StringPropNativeComponentViewProps final : public ViewProps { std::string placeholder{\\"\\"}; std::string defaultValue{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index 5932fabefec8..87eda91a5b96 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -37,8 +37,35 @@ ArrayPropsNativeComponentViewProps::ArrayPropsNativeComponentViewProps( sizes(convertRawProp(context, rawProps, \\"sizes\\", ArrayPropsNativeComponentViewSizesMaskWrapped{ .value = sourceProps.sizes }, {static_cast(ArrayPropsNativeComponentViewSizes::Small)}).value), object(convertRawProp(context, rawProps, \\"object\\", sourceProps.object, {})), arrayOfObjects(convertRawProp(context, rawProps, \\"arrayOfObjects\\", sourceProps.arrayOfObjects, {})), - arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) - {} + arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ArrayPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentViewProps(); + const ArrayPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + + + + + + + + + + + + return result; +} +#endif } // namespace facebook::react ", @@ -69,8 +96,30 @@ BooleanPropNativeComponentViewProps::BooleanPropNativeComponentViewProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})), - disabledNullable(convertRawProp(context, rawProps, \\"disabledNullable\\", sourceProps.disabledNullable, {})) - {} + disabledNullable(convertRawProp(context, rawProps, \\"disabledNullable\\", sourceProps.disabledNullable, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic BooleanPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = BooleanPropNativeComponentViewProps(); + const BooleanPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + + if (disabledNullable != oldProps->disabledNullable) { + result[\\"disabledNullable\\"] = disabledNullable; + } + return result; +} +#endif } // namespace facebook::react ", @@ -100,8 +149,26 @@ ColorPropNativeComponentViewProps::ColorPropNativeComponentViewProps( const ColorPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) - {} + tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ColorPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ColorPropNativeComponentViewProps(); + const ColorPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (tintColor != oldProps->tintColor) { + result[\\"tintColor\\"] = *tintColor; + } + return result; +} +#endif } // namespace facebook::react ", @@ -132,8 +199,23 @@ DimensionPropNativeComponentViewProps::DimensionPropNativeComponentViewProps( const DimensionPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) - {} + marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic DimensionPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = DimensionPropNativeComponentViewProps(); + const DimensionPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -163,8 +245,23 @@ EdgeInsetsPropNativeComponentViewProps::EdgeInsetsPropNativeComponentViewProps( const EdgeInsetsPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EdgeInsetsPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EdgeInsetsPropNativeComponentViewProps(); + const EdgeInsetsPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -195,8 +292,24 @@ EnumPropNativeComponentViewProps::EnumPropNativeComponentViewProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), alignment(convertRawProp(context, rawProps, \\"alignment\\", sourceProps.alignment, {EnumPropNativeComponentViewAlignment::Center})), - intervals(convertRawProp(context, rawProps, \\"intervals\\", sourceProps.intervals, {EnumPropNativeComponentViewIntervals::Intervals0})) - {} + intervals(convertRawProp(context, rawProps, \\"intervals\\", sourceProps.intervals, {EnumPropNativeComponentViewIntervals::Intervals0})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EnumPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EnumPropNativeComponentViewProps(); + const EnumPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + return result; +} +#endif } // namespace facebook::react ", @@ -226,8 +339,26 @@ EventNestedObjectPropsNativeComponentViewProps::EventNestedObjectPropsNativeComp const EventNestedObjectPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EventNestedObjectPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EventNestedObjectPropsNativeComponentViewProps(); + const EventNestedObjectPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -257,8 +388,26 @@ EventPropsNativeComponentViewProps::EventPropsNativeComponentViewProps( const EventPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EventPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EventPropsNativeComponentViewProps(); + const EventPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -294,8 +443,50 @@ FloatPropsNativeComponentViewProps::FloatPropsNativeComponentViewProps( blurRadius4(convertRawProp(context, rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), blurRadius5(convertRawProp(context, rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})), - blurRadiusNullable(convertRawProp(context, rawProps, \\"blurRadiusNullable\\", sourceProps.blurRadiusNullable, {})) - {} + blurRadiusNullable(convertRawProp(context, rawProps, \\"blurRadiusNullable\\", sourceProps.blurRadiusNullable, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic FloatPropsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = FloatPropsNativeComponentViewProps(); + const FloatPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if ((blurRadius != oldProps->blurRadius) && !(std::isnan(blurRadius) && std::isnan(oldProps->blurRadius))) { + result[\\"blurRadius\\"] = blurRadius; + } + + if ((blurRadius2 != oldProps->blurRadius2) && !(std::isnan(blurRadius2) && std::isnan(oldProps->blurRadius2))) { + result[\\"blurRadius2\\"] = blurRadius2; + } + + if ((blurRadius3 != oldProps->blurRadius3) && !(std::isnan(blurRadius3) && std::isnan(oldProps->blurRadius3))) { + result[\\"blurRadius3\\"] = blurRadius3; + } + + if ((blurRadius4 != oldProps->blurRadius4) && !(std::isnan(blurRadius4) && std::isnan(oldProps->blurRadius4))) { + result[\\"blurRadius4\\"] = blurRadius4; + } + + if ((blurRadius5 != oldProps->blurRadius5) && !(std::isnan(blurRadius5) && std::isnan(oldProps->blurRadius5))) { + result[\\"blurRadius5\\"] = blurRadius5; + } + + if ((blurRadius6 != oldProps->blurRadius6) && !(std::isnan(blurRadius6) && std::isnan(oldProps->blurRadius6))) { + result[\\"blurRadius6\\"] = blurRadius6; + } + + if ((blurRadiusNullable != oldProps->blurRadiusNullable) && !(std::isnan(blurRadiusNullable) && std::isnan(oldProps->blurRadiusNullable))) { + result[\\"blurRadiusNullable\\"] = blurRadiusNullable; + } + return result; +} +#endif } // namespace facebook::react ", @@ -326,8 +517,23 @@ ImagePropNativeComponentViewProps::ImagePropNativeComponentViewProps( const ImagePropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) - {} + thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ImagePropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ImagePropNativeComponentViewProps(); + const ImagePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -359,8 +565,34 @@ IntegerPropNativeComponentViewProps::IntegerPropNativeComponentViewProps( progress1(convertRawProp(context, rawProps, \\"progress1\\", sourceProps.progress1, {0})), progress2(convertRawProp(context, rawProps, \\"progress2\\", sourceProps.progress2, {-1})), - progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) - {} + progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic IntegerPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = IntegerPropNativeComponentViewProps(); + const IntegerPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (progress1 != oldProps->progress1) { + result[\\"progress1\\"] = progress1; + } + + if (progress2 != oldProps->progress2) { + result[\\"progress2\\"] = progress2; + } + + if (progress3 != oldProps->progress3) { + result[\\"progress3\\"] = progress3; + } + return result; +} +#endif } // namespace facebook::react ", @@ -390,8 +622,26 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps( const InterfaceOnlyNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) - {} + title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic InterfaceOnlyNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyNativeComponentViewProps(); + const InterfaceOnlyNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (title != oldProps->title) { + result[\\"title\\"] = title; + } + return result; +} +#endif } // namespace facebook::react ", @@ -422,8 +672,23 @@ MixedPropNativeComponentViewProps::MixedPropNativeComponentViewProps( const MixedPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) - {} + mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MixedPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MixedPropNativeComponentViewProps(); + const MixedPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -457,8 +722,32 @@ MultiNativePropNativeComponentViewProps::MultiNativePropNativeComponentViewProps thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})), color(convertRawProp(context, rawProps, \\"color\\", sourceProps.color, {})), thumbTintColor(convertRawProp(context, rawProps, \\"thumbTintColor\\", sourceProps.thumbTintColor, {})), - point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) - {} + point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiNativePropNativeComponentViewProps(); + const MultiNativePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + if (color != oldProps->color) { + result[\\"color\\"] = *color; + } + + if (thumbTintColor != oldProps->thumbTintColor) { + result[\\"thumbTintColor\\"] = *thumbTintColor; + } + + return result; +} +#endif } // namespace facebook::react ", @@ -488,8 +777,23 @@ NoPropsNoEventsNativeComponentViewProps::NoPropsNoEventsNativeComponentViewProps const NoPropsNoEventsNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic NoPropsNoEventsNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = NoPropsNoEventsNativeComponentViewProps(); + const NoPropsNoEventsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -522,8 +826,25 @@ ObjectPropsNativeComponentProps::ObjectPropsNativeComponentProps( objectProp(convertRawProp(context, rawProps, \\"objectProp\\", sourceProps.objectProp, {})), objectArrayProp(convertRawProp(context, rawProps, \\"objectArrayProp\\", sourceProps.objectArrayProp, {})), - objectPrimitiveRequiredProp(convertRawProp(context, rawProps, \\"objectPrimitiveRequiredProp\\", sourceProps.objectPrimitiveRequiredProp, {})) - {} + objectPrimitiveRequiredProp(convertRawProp(context, rawProps, \\"objectPrimitiveRequiredProp\\", sourceProps.objectPrimitiveRequiredProp, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ObjectPropsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ObjectPropsNativeComponentProps(); + const ObjectPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + + return result; +} +#endif } // namespace facebook::react ", @@ -553,8 +874,23 @@ PointPropNativeComponentViewProps::PointPropNativeComponentViewProps( const PointPropNativeComponentViewProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) - {} + startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic PointPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = PointPropNativeComponentViewProps(); + const PointPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -585,8 +921,30 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), placeholder(convertRawProp(context, rawProps, \\"placeholder\\", sourceProps.placeholder, {\\"\\"})), - defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) - {} + defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic StringPropNativeComponentViewProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = StringPropNativeComponentViewProps(); + const StringPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (placeholder != oldProps->placeholder) { + result[\\"placeholder\\"] = placeholder; + } + + if (defaultValue != oldProps->defaultValue) { + result[\\"defaultValue\\"] = defaultValue; + } + return result; +} +#endif } // namespace facebook::react ", diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap index a3d703761c4b..0faad8050764 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap @@ -163,6 +163,10 @@ class ArrayPropsNativeComponentViewProps final : public ViewProps { std::vector object{}; std::vector arrayOfObjects{}; std::vector arrayOfMixed{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -197,6 +201,10 @@ class BooleanPropNativeComponentViewProps final : public ViewProps { bool disabled{false}; bool disabledNullable{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -231,6 +239,10 @@ class ColorPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props SharedColor tintColor{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -265,6 +277,10 @@ class DimensionPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props YGValue marginBack{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -298,6 +314,10 @@ class EdgeInsetsPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -380,6 +400,10 @@ class EnumPropNativeComponentViewProps final : public ViewProps { EnumPropNativeComponentViewAlignment alignment{EnumPropNativeComponentViewAlignment::Center}; EnumPropNativeComponentViewIntervals intervals{EnumPropNativeComponentViewIntervals::Intervals0}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -413,6 +437,10 @@ class EventNestedObjectPropsNativeComponentViewProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -446,6 +474,10 @@ class EventPropsNativeComponentViewProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -485,6 +517,10 @@ class FloatPropsNativeComponentViewProps final : public ViewProps { Float blurRadius5{1.0}; Float blurRadius6{0.0}; Float blurRadiusNullable{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -519,6 +555,10 @@ class ImagePropNativeComponentViewProps final : public ViewProps { #pragma mark - Props ImageSource thumbImage{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -554,6 +594,10 @@ class IntegerPropNativeComponentViewProps final : public ViewProps { int progress1{0}; int progress2{-1}; int progress3{10}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -587,6 +631,10 @@ class InterfaceOnlyNativeComponentViewProps final : public ViewProps { #pragma mark - Props std::string title{\\"\\"}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -620,6 +668,10 @@ class MixedPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props folly::dynamic mixedProp{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -659,6 +711,10 @@ class MultiNativePropNativeComponentViewProps final : public ViewProps { SharedColor color{}; SharedColor thumbTintColor{}; Point point{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -692,6 +748,10 @@ class NoPropsNoEventsNativeComponentViewProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -855,6 +915,10 @@ class ObjectPropsNativeComponentProps final : public ViewProps { ObjectPropsNativeComponentObjectPropStruct objectProp{}; ObjectPropsNativeComponentObjectArrayPropStruct objectArrayProp{}; ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct objectPrimitiveRequiredProp{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -889,6 +953,10 @@ class PointPropNativeComponentViewProps final : public ViewProps { #pragma mark - Props Point startPoint{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -923,6 +991,10 @@ class StringPropNativeComponentViewProps final : public ViewProps { std::string placeholder{\\"\\"}; std::string defaultValue{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js index 7012ab8f5516..cb96b96d66e2 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js @@ -55,10 +55,12 @@ const ComponentTemplate = ({ className, extendClasses, props, + diffProps, }: { className: string, extendClasses: string, props: string, + diffProps: string, }) => ` ${className}::${className}( @@ -66,10 +68,80 @@ ${className}::${className}( const ${className} &sourceProps, const RawProps &rawProps):${extendClasses} - ${props} - {} + ${props} {} + ${diffProps} + `.trim(); +function generatePropsDiffString( + className: string, + componentName: string, + component: ComponentShape, +) { + const diffProps = component.props + .map(prop => { + const typeAnnotation = prop.typeAnnotation; + switch (typeAnnotation.type) { + case 'StringTypeAnnotation': + case 'Int32TypeAnnotation': + case 'BooleanTypeAnnotation': + return ` + if (${prop.name} != oldProps->${prop.name}) { + result["${prop.name}"] = ${prop.name}; + }`; + case 'DoubleTypeAnnotation': + case 'FloatTypeAnnotation': + return ` + if ((${prop.name} != oldProps->${prop.name}) && !(std::isnan(${prop.name}) && std::isnan(oldProps->${prop.name}))) { + result["${prop.name}"] = ${prop.name}; + }`; + case 'ReservedPropTypeAnnotation': + switch (typeAnnotation.name) { + case 'ColorPrimitive': + return ` + if (${prop.name} != oldProps->${prop.name}) { + result["${prop.name}"] = *${prop.name}; + }`; + case 'ImageSourcePrimitive': + case 'ImageRequestPrimitive': + case 'PointPrimitive': + case 'EdgeInsetsPrimitive': + case 'DimensionPrimitive': + // TODO: Implement diffProps for complex types + return ''; + default: + (typeAnnotation.name: empty); + throw new Error('Received unknown ReservedPropTypeAnnotation'); + } + case 'ArrayTypeAnnotation': + case 'ObjectTypeAnnotation': + case 'StringEnumTypeAnnotation': + case 'Int32EnumTypeAnnotation': + case 'MixedTypeAnnotation': + default: + // TODO: Implement diffProps for complex types + return ''; + } + }) + .join('\n' + ' '); + + return ` +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ${className}::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ${className}(); + const ${className}* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + ${diffProps} + return result; +} +#endif`; +} function generatePropsString(componentName: string, component: ComponentShape) { return component.props .map(prop => { @@ -144,6 +216,11 @@ module.exports = { const propsString = generatePropsString(componentName, component); const extendString = getClassExtendString(component); + const diffPropsString = generatePropsDiffString( + newName, + componentName, + component, + ); const imports = getImports(component.props); // $FlowFixMe[method-unbinding] added when improving typing for this parameters @@ -153,6 +230,7 @@ module.exports = { className: newName, extendClasses: extendString, props: propsString, + diffProps: diffPropsString, }); return replacedTemplate; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index a623ebe2db4c..66a748452dd7 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -83,6 +83,10 @@ class ${className} final${extendClasses} { #pragma mark - Props ${props} + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; `.trim(); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index 82ae006837dd..58e74ab5386c 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -37,8 +37,35 @@ ArrayPropsNativeComponentProps::ArrayPropsNativeComponentProps( object(convertRawProp(context, rawProps, \\"object\\", sourceProps.object, {})), array(convertRawProp(context, rawProps, \\"array\\", sourceProps.array, {})), arrayOfArrayOfObject(convertRawProp(context, rawProps, \\"arrayOfArrayOfObject\\", sourceProps.arrayOfArrayOfObject, {})), - arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) - {} + arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ArrayPropsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentProps(); + const ArrayPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + + + + + + + + + + + + return result; +} +#endif } // namespace facebook::react ", @@ -68,8 +95,23 @@ ArrayPropsNativeComponentProps::ArrayPropsNativeComponentProps( const ArrayPropsNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - nativePrimitives(convertRawProp(context, rawProps, \\"nativePrimitives\\", sourceProps.nativePrimitives, {})) - {} + nativePrimitives(convertRawProp(context, rawProps, \\"nativePrimitives\\", sourceProps.nativePrimitives, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ArrayPropsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentProps(); + const ArrayPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -99,8 +141,26 @@ BooleanPropNativeComponentProps::BooleanPropNativeComponentProps( const BooleanPropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic BooleanPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = BooleanPropNativeComponentProps(); + const BooleanPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -130,8 +190,26 @@ ColorPropNativeComponentProps::ColorPropNativeComponentProps( const ColorPropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) - {} + tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ColorPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ColorPropNativeComponentProps(); + const ColorPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (tintColor != oldProps->tintColor) { + result[\\"tintColor\\"] = *tintColor; + } + return result; +} +#endif } // namespace facebook::react ", @@ -161,8 +239,23 @@ CommandNativeComponentProps::CommandNativeComponentProps( const CommandNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic CommandNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = CommandNativeComponentProps(); + const CommandNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -192,8 +285,26 @@ CommandNativeComponentProps::CommandNativeComponentProps( const CommandNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) - {} + accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic CommandNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = CommandNativeComponentProps(); + const CommandNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (accessibilityHint != oldProps->accessibilityHint) { + result[\\"accessibilityHint\\"] = accessibilityHint; + } + return result; +} +#endif } // namespace facebook::react ", @@ -224,8 +335,23 @@ DimensionPropNativeComponentProps::DimensionPropNativeComponentProps( const DimensionPropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) - {} + marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic DimensionPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = DimensionPropNativeComponentProps(); + const DimensionPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -260,8 +386,46 @@ DoublePropNativeComponentProps::DoublePropNativeComponentProps( blurRadius3(convertRawProp(context, rawProps, \\"blurRadius3\\", sourceProps.blurRadius3, {2.1})), blurRadius4(convertRawProp(context, rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), blurRadius5(convertRawProp(context, rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), - blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) - {} + blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic DoublePropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = DoublePropNativeComponentProps(); + const DoublePropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if ((blurRadius != oldProps->blurRadius) && !(std::isnan(blurRadius) && std::isnan(oldProps->blurRadius))) { + result[\\"blurRadius\\"] = blurRadius; + } + + if ((blurRadius2 != oldProps->blurRadius2) && !(std::isnan(blurRadius2) && std::isnan(oldProps->blurRadius2))) { + result[\\"blurRadius2\\"] = blurRadius2; + } + + if ((blurRadius3 != oldProps->blurRadius3) && !(std::isnan(blurRadius3) && std::isnan(oldProps->blurRadius3))) { + result[\\"blurRadius3\\"] = blurRadius3; + } + + if ((blurRadius4 != oldProps->blurRadius4) && !(std::isnan(blurRadius4) && std::isnan(oldProps->blurRadius4))) { + result[\\"blurRadius4\\"] = blurRadius4; + } + + if ((blurRadius5 != oldProps->blurRadius5) && !(std::isnan(blurRadius5) && std::isnan(oldProps->blurRadius5))) { + result[\\"blurRadius5\\"] = blurRadius5; + } + + if ((blurRadius6 != oldProps->blurRadius6) && !(std::isnan(blurRadius6) && std::isnan(oldProps->blurRadius6))) { + result[\\"blurRadius6\\"] = blurRadius6; + } + return result; +} +#endif } // namespace facebook::react ", @@ -291,8 +455,26 @@ EventsNestedObjectNativeComponentProps::EventsNestedObjectNativeComponentProps( const EventsNestedObjectNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EventsNestedObjectNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EventsNestedObjectNativeComponentProps(); + const EventsNestedObjectNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -322,8 +504,26 @@ EventsNativeComponentProps::EventsNativeComponentProps( const EventsNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic EventsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EventsNativeComponentProps(); + const EventsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -353,8 +553,23 @@ InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic InterfaceOnlyComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyComponentProps(); + const InterfaceOnlyComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -384,8 +599,23 @@ ExcludedAndroidComponentProps::ExcludedAndroidComponentProps( const ExcludedAndroidComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ExcludedAndroidComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ExcludedAndroidComponentProps(); + const ExcludedAndroidComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -415,8 +645,23 @@ ExcludedAndroidIosComponentProps::ExcludedAndroidIosComponentProps( const ExcludedAndroidIosComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ExcludedAndroidIosComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ExcludedAndroidIosComponentProps(); + const ExcludedAndroidIosComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -446,15 +691,48 @@ ExcludedIosComponentProps::ExcludedIosComponentProps( const ExcludedIosComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ExcludedIosComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ExcludedIosComponentProps(); + const ExcludedIosComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif MultiFileIncludedNativeComponentProps::MultiFileIncludedNativeComponentProps( const PropsParserContext &context, const MultiFileIncludedNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiFileIncludedNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiFileIncludedNativeComponentProps(); + const MultiFileIncludedNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -489,8 +767,46 @@ FloatPropNativeComponentProps::FloatPropNativeComponentProps( blurRadius3(convertRawProp(context, rawProps, \\"blurRadius3\\", sourceProps.blurRadius3, {2.1})), blurRadius4(convertRawProp(context, rawProps, \\"blurRadius4\\", sourceProps.blurRadius4, {0.0})), blurRadius5(convertRawProp(context, rawProps, \\"blurRadius5\\", sourceProps.blurRadius5, {1.0})), - blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) - {} + blurRadius6(convertRawProp(context, rawProps, \\"blurRadius6\\", sourceProps.blurRadius6, {0.0})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic FloatPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = FloatPropNativeComponentProps(); + const FloatPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if ((blurRadius != oldProps->blurRadius) && !(std::isnan(blurRadius) && std::isnan(oldProps->blurRadius))) { + result[\\"blurRadius\\"] = blurRadius; + } + + if ((blurRadius2 != oldProps->blurRadius2) && !(std::isnan(blurRadius2) && std::isnan(oldProps->blurRadius2))) { + result[\\"blurRadius2\\"] = blurRadius2; + } + + if ((blurRadius3 != oldProps->blurRadius3) && !(std::isnan(blurRadius3) && std::isnan(oldProps->blurRadius3))) { + result[\\"blurRadius3\\"] = blurRadius3; + } + + if ((blurRadius4 != oldProps->blurRadius4) && !(std::isnan(blurRadius4) && std::isnan(oldProps->blurRadius4))) { + result[\\"blurRadius4\\"] = blurRadius4; + } + + if ((blurRadius5 != oldProps->blurRadius5) && !(std::isnan(blurRadius5) && std::isnan(oldProps->blurRadius5))) { + result[\\"blurRadius5\\"] = blurRadius5; + } + + if ((blurRadius6 != oldProps->blurRadius6) && !(std::isnan(blurRadius6) && std::isnan(oldProps->blurRadius6))) { + result[\\"blurRadius6\\"] = blurRadius6; + } + return result; +} +#endif } // namespace facebook::react ", @@ -521,8 +837,23 @@ ImagePropNativeComponentProps::ImagePropNativeComponentProps( const ImagePropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) - {} + thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ImagePropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ImagePropNativeComponentProps(); + const ImagePropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -552,8 +883,23 @@ InsetsPropNativeComponentProps::InsetsPropNativeComponentProps( const InsetsPropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - contentInset(convertRawProp(context, rawProps, \\"contentInset\\", sourceProps.contentInset, {})) - {} + contentInset(convertRawProp(context, rawProps, \\"contentInset\\", sourceProps.contentInset, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic InsetsPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = InsetsPropNativeComponentProps(); + const InsetsPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -583,8 +929,23 @@ Int32EnumPropsNativeComponentProps::Int32EnumPropsNativeComponentProps( const Int32EnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - maxInterval(convertRawProp(context, rawProps, \\"maxInterval\\", sourceProps.maxInterval, {Int32EnumPropsNativeComponentMaxInterval::MaxInterval0})) - {} + maxInterval(convertRawProp(context, rawProps, \\"maxInterval\\", sourceProps.maxInterval, {Int32EnumPropsNativeComponentMaxInterval::MaxInterval0})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic Int32EnumPropsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = Int32EnumPropsNativeComponentProps(); + const Int32EnumPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -616,8 +977,34 @@ IntegerPropNativeComponentProps::IntegerPropNativeComponentProps( progress1(convertRawProp(context, rawProps, \\"progress1\\", sourceProps.progress1, {0})), progress2(convertRawProp(context, rawProps, \\"progress2\\", sourceProps.progress2, {-1})), - progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) - {} + progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic IntegerPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = IntegerPropNativeComponentProps(); + const IntegerPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (progress1 != oldProps->progress1) { + result[\\"progress1\\"] = progress1; + } + + if (progress2 != oldProps->progress2) { + result[\\"progress2\\"] = progress2; + } + + if (progress3 != oldProps->progress3) { + result[\\"progress3\\"] = progress3; + } + return result; +} +#endif } // namespace facebook::react ", @@ -647,8 +1034,26 @@ InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) - {} + accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic InterfaceOnlyComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyComponentProps(); + const InterfaceOnlyComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (accessibilityHint != oldProps->accessibilityHint) { + result[\\"accessibilityHint\\"] = accessibilityHint; + } + return result; +} +#endif } // namespace facebook::react ", @@ -679,8 +1084,23 @@ MixedPropNativeComponentProps::MixedPropNativeComponentProps( const MixedPropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) - {} + mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MixedPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MixedPropNativeComponentProps(); + const MixedPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -714,8 +1134,32 @@ ImageColorPropNativeComponentProps::ImageColorPropNativeComponentProps( thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})), color(convertRawProp(context, rawProps, \\"color\\", sourceProps.color, {})), thumbTintColor(convertRawProp(context, rawProps, \\"thumbTintColor\\", sourceProps.thumbTintColor, {})), - point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) - {} + point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ImageColorPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ImageColorPropNativeComponentProps(); + const ImageColorPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + + if (color != oldProps->color) { + result[\\"color\\"] = *color; + } + + if (thumbTintColor != oldProps->thumbTintColor) { + result[\\"thumbTintColor\\"] = *thumbTintColor; + } + + return result; +} +#endif } // namespace facebook::react ", @@ -745,8 +1189,23 @@ NoPropsNoEventsComponentProps::NoPropsNoEventsComponentProps( const NoPropsNoEventsComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + {} - {} +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic NoPropsNoEventsComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = NoPropsNoEventsComponentProps(); + const NoPropsNoEventsComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -777,8 +1236,23 @@ ObjectPropsProps::ObjectPropsProps( const ObjectPropsProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - objectProp(convertRawProp(context, rawProps, \\"objectProp\\", sourceProps.objectProp, {})) - {} + objectProp(convertRawProp(context, rawProps, \\"objectProp\\", sourceProps.objectProp, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic ObjectPropsProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = ObjectPropsProps(); + const ObjectPropsProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -808,8 +1282,23 @@ PointPropNativeComponentProps::PointPropNativeComponentProps( const PointPropNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) - {} + startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic PointPropNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = PointPropNativeComponentProps(); + const PointPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -839,8 +1328,23 @@ StringEnumPropsNativeComponentProps::StringEnumPropsNativeComponentProps( const StringEnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - alignment(convertRawProp(context, rawProps, \\"alignment\\", sourceProps.alignment, {StringEnumPropsNativeComponentAlignment::Center})) - {} + alignment(convertRawProp(context, rawProps, \\"alignment\\", sourceProps.alignment, {StringEnumPropsNativeComponentAlignment::Center})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic StringEnumPropsNativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = StringEnumPropsNativeComponentProps(); + const StringEnumPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + return result; +} +#endif } // namespace facebook::react ", @@ -871,8 +1375,30 @@ StringPropComponentProps::StringPropComponentProps( const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})), - accessibilityRole(convertRawProp(context, rawProps, \\"accessibilityRole\\", sourceProps.accessibilityRole, {})) - {} + accessibilityRole(convertRawProp(context, rawProps, \\"accessibilityRole\\", sourceProps.accessibilityRole, {})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic StringPropComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = StringPropComponentProps(); + const StringPropComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (accessibilityHint != oldProps->accessibilityHint) { + result[\\"accessibilityHint\\"] = accessibilityHint; + } + + if (accessibilityRole != oldProps->accessibilityRole) { + result[\\"accessibilityRole\\"] = accessibilityRole; + } + return result; +} +#endif } // namespace facebook::react ", @@ -902,15 +1428,51 @@ MultiFile1NativeComponentProps::MultiFile1NativeComponentProps( const MultiFile1NativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiFile1NativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiFile1NativeComponentProps(); + const MultiFile1NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif MultiFile2NativeComponentProps::MultiFile2NativeComponentProps( const PropsParserContext &context, const MultiFile2NativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiFile2NativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiFile2NativeComponentProps(); + const MultiFile2NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", @@ -940,15 +1502,51 @@ MultiComponent1NativeComponentProps::MultiComponent1NativeComponentProps( const MultiComponent1NativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiComponent1NativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiComponent1NativeComponentProps(); + const MultiComponent1NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif MultiComponent2NativeComponentProps::MultiComponent2NativeComponentProps( const PropsParserContext &context, const MultiComponent2NativeComponentProps &sourceProps, const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) - {} + disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true})) {} + +#ifdef RN_SERIALIZABLE_STATE +folly::dynamic MultiComponent2NativeComponentProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = MultiComponent2NativeComponentProps(); + const MultiComponent2NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + + if (disabled != oldProps->disabled) { + result[\\"disabled\\"] = disabled; + } + return result; +} +#endif } // namespace facebook::react ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index 36b3d1a1277f..bfc6dd458a50 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -215,6 +215,10 @@ class ArrayPropsNativeComponentProps final : public ViewProps { std::vector array{}; std::vector> arrayOfArrayOfObject{}; std::vector arrayOfMixed{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -290,6 +294,10 @@ class ArrayPropsNativeComponentProps final : public ViewProps { #pragma mark - Props std::vector nativePrimitives{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -323,6 +331,10 @@ class BooleanPropNativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -357,6 +369,10 @@ class ColorPropNativeComponentProps final : public ViewProps { #pragma mark - Props SharedColor tintColor{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -390,6 +406,10 @@ class CommandNativeComponentProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -423,6 +443,10 @@ class CommandNativeComponentProps final : public ViewProps { #pragma mark - Props std::string accessibilityHint{\\"\\"}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -457,6 +481,10 @@ class DimensionPropNativeComponentProps final : public ViewProps { #pragma mark - Props YGValue marginBack{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -495,6 +523,10 @@ class DoublePropNativeComponentProps final : public ViewProps { double blurRadius4{0.0}; double blurRadius5{1.0}; double blurRadius6{0.0}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -528,6 +560,10 @@ class EventsNestedObjectNativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -561,6 +597,10 @@ class EventsNativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -594,6 +634,10 @@ class InterfaceOnlyComponentProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -627,6 +671,10 @@ class ExcludedAndroidComponentProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -660,6 +708,10 @@ class ExcludedAndroidIosComponentProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -693,6 +745,10 @@ class ExcludedIosComponentProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; class MultiFileIncludedNativeComponentProps final : public ViewProps { @@ -703,6 +759,10 @@ class MultiFileIncludedNativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{true}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -741,6 +801,10 @@ class FloatPropNativeComponentProps final : public ViewProps { Float blurRadius4{0.0}; Float blurRadius5{1.0}; Float blurRadius6{0.0}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -775,6 +839,10 @@ class ImagePropNativeComponentProps final : public ViewProps { #pragma mark - Props ImageSource thumbImage{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -809,6 +877,10 @@ class InsetsPropNativeComponentProps final : public ViewProps { #pragma mark - Props EdgeInsets contentInset{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -869,6 +941,10 @@ class Int32EnumPropsNativeComponentProps final : public ViewProps { #pragma mark - Props Int32EnumPropsNativeComponentMaxInterval maxInterval{Int32EnumPropsNativeComponentMaxInterval::MaxInterval0}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -904,6 +980,10 @@ class IntegerPropNativeComponentProps final : public ViewProps { int progress1{0}; int progress2{-1}; int progress3{10}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -937,6 +1017,10 @@ class InterfaceOnlyComponentProps final : public ViewProps { #pragma mark - Props std::string accessibilityHint{\\"\\"}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -970,6 +1054,10 @@ class MixedPropNativeComponentProps final : public ViewProps { #pragma mark - Props folly::dynamic mixedProp{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1009,6 +1097,10 @@ class ImageColorPropNativeComponentProps final : public ViewProps { SharedColor color{}; SharedColor thumbTintColor{}; Point point{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1042,6 +1134,10 @@ class NoPropsNoEventsComponentProps final : public ViewProps { #pragma mark - Props + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1315,6 +1411,10 @@ class ObjectPropsProps final : public ViewProps { #pragma mark - Props ObjectPropsObjectPropStruct objectProp{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1349,6 +1449,10 @@ class PointPropNativeComponentProps final : public ViewProps { #pragma mark - Props Point startPoint{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1400,6 +1504,10 @@ class StringEnumPropsNativeComponentProps final : public ViewProps { #pragma mark - Props StringEnumPropsNativeComponentAlignment alignment{StringEnumPropsNativeComponentAlignment::Center}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1434,6 +1542,10 @@ class StringPropComponentProps final : public ViewProps { std::string accessibilityHint{\\"\\"}; std::string accessibilityRole{}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1467,6 +1579,10 @@ class MultiFile1NativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; class MultiFile2NativeComponentProps final : public ViewProps { @@ -1477,6 +1593,10 @@ class MultiFile2NativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{true}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react @@ -1510,6 +1630,10 @@ class MultiComponent1NativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{false}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; class MultiComponent2NativeComponentProps final : public ViewProps { @@ -1520,6 +1644,10 @@ class MultiComponent2NativeComponentProps final : public ViewProps { #pragma mark - Props bool disabled{true}; + + #ifdef RN_SERIALIZABLE_STATE + folly::dynamic getDiffProps(const Props* prevProps) const override; + #endif }; } // namespace facebook::react