Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove REACT_NATIVE_VERSION checks #506

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@ export function createHybridObjectIntializer(): SourceFile[] {
const autolinkingClassName = `${NitroConfig.getAndroidCxxLibName()}OnLoad`

const jniRegistrations = getJNINativeRegistrations()
.map((r) => {
const code = `${r.namespace}::${r.className}::registerNatives();`
if (r.ifGuard != null) {
return `
#if ${r.ifGuard}
${code}
#endif`.trim()
} else {
return code
}
})
.map((r) => `${r.namespace}::${r.className}::registerNatives();`)
.filter(isNotDuplicate)

const autolinkedHybridObjects = NitroConfig.getAutolinkedHybridObjects()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export interface JNINativeRegistration {
namespace: string
className: string
import: SourceImport
ifGuard?: string
}

const jniNativeRegistrations: JNINativeRegistration[] = []
Expand Down
13 changes: 2 additions & 11 deletions packages/nitrogen/src/views/CppHybridViewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ ${createFileMetadataString(`${component}.hpp`)}

#pragma once

#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
Expand Down Expand Up @@ -158,10 +156,6 @@ namespace ${namespace} {
/* The actual view for "${spec.name}" needs to be implemented in platform-specific code. */

} // namespace ${namespace}

#else
#warning "View Component '${HybridT}' will be unavailable in React Native, because it requires React Native 78 or higher."
#endif
`.trim()

// .cpp code
Expand Down Expand Up @@ -193,12 +187,11 @@ ${name}([&]() -> CachedProp<${type}> {
${createFileMetadataString(`${component}.cpp`)}

#include "${component}.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include <string>
#include <exception>
#include <utility>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/JSIConverter.hpp>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/core/ShadowNode.h>
Expand Down Expand Up @@ -241,8 +234,6 @@ namespace ${namespace} {
}

} // namespace ${namespace}

#endif
`.trim()

const files: SourceFile[] = [
Expand Down
13 changes: 2 additions & 11 deletions packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ ${createFileMetadataString(`J${stateUpdaterName}.hpp`)}

#pragma once

#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include <fbjni/fbjni.h>
#include <NitroModules/NitroDefines.hpp>
#include <react/fabric/StateWrapperImpl.h>
#include "${JHybridTSpec}.hpp"

Expand All @@ -138,8 +136,6 @@ public:
};

} // namespace ${cxxNamespace}

#endif
`.trim()

const propsUpdaterCalls = spec.properties.map((p) => {
Expand All @@ -154,10 +150,8 @@ if (props.${name}.isDirty) {
${createFileMetadataString(`J${stateUpdaterName}.cpp`)}

#include "J${stateUpdaterName}.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include "views/${component}.hpp"
#include <NitroModules/NitroDefines.hpp>

namespace ${cxxNamespace} {

Expand All @@ -182,8 +176,6 @@ void J${stateUpdaterName}::updateViewProps(jni::alias_ref<jni::JClass>,
}

} // namespace ${cxxNamespace}

#endif
`.trim()

addJNINativeRegistration({
Expand All @@ -194,7 +186,6 @@ void J${stateUpdaterName}::updateViewProps(jni::alias_ref<jni::JClass>,
space: 'user',
language: 'c++',
},
ifGuard: `REACT_NATIVE_VERSION_MINOR >= 78`,
})

return [
Expand Down
5 changes: 1 addition & 4 deletions packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ if (newViewProps.${name}.isDirty) {
${createFileMetadataString(`${component}.mm`)}

#import "${component}.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#import <memory>
#import <NitroModules/NitroDefines.hpp>
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
#import <React/RCTViewComponentView.h>
#import <React/RCTComponentViewFactory.h>
Expand Down Expand Up @@ -123,8 +122,6 @@ using namespace ${namespace}::views;
}

@end

#endif
`

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ int initialize(JavaVM* vm) {
margelo::nitro::image::JHybridBaseSpec::registerNatives();
margelo::nitro::image::JHybridChildSpec::registerNatives();
margelo::nitro::image::JHybridTestViewSpec::registerNatives();
#if REACT_NATIVE_VERSION_MINOR >= 78
margelo::nitro::image::views::JHybridTestViewStateUpdater::registerNatives();
#endif

// Register Nitro Hybrid Objects
HybridObjectRegistry::registerHybridObjectConstructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
///

#include "JHybridTestViewStateUpdater.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include "views/HybridTestViewComponent.hpp"
#include <NitroModules/NitroDefines.hpp>

namespace margelo::nitro::image::views {

Expand Down Expand Up @@ -39,5 +37,3 @@ void JHybridTestViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>,
}

} // namespace margelo::nitro::image::views

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

#pragma once

#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include <fbjni/fbjni.h>
#include <NitroModules/NitroDefines.hpp>
#include <react/fabric/StateWrapperImpl.h>
#include "JHybridTestViewSpec.hpp"

Expand All @@ -36,5 +34,3 @@ class JHybridTestViewStateUpdater: jni::HybridClass<JHybridTestViewStateUpdater>
};

} // namespace margelo::nitro::image::views

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
///

#import "HybridTestViewComponent.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#import <memory>
#import <NitroModules/NitroDefines.hpp>
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
#import <React/RCTViewComponentView.h>
#import <React/RCTComponentViewFactory.h>
Expand Down Expand Up @@ -89,5 +88,3 @@ - (void) updateProps:(const react::Props::Shared&)props
}

@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
///

#include "HybridTestViewComponent.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include <string>
#include <exception>
#include <utility>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/JSIConverter.hpp>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/core/ShadowNode.h>
Expand Down Expand Up @@ -77,5 +76,3 @@ namespace margelo::nitro::image::views {
}

} // namespace margelo::nitro::image::views

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

#pragma once

#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78

#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
Expand Down Expand Up @@ -96,7 +94,3 @@ namespace margelo::nitro::image::views {
/* The actual view for "TestView" needs to be implemented in platform-specific code. */

} // namespace margelo::nitro::image::views

#else
#warning "View Component 'HybridTestView' will be unavailable in React Native, because it requires React Native 78 or higher."
#endif
10 changes: 0 additions & 10 deletions packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,4 @@
#define SWIFT_NONCOPYABLE
#endif

// React Native Support
#if __has_include(<cxxreact/ReactNativeVersion.h>)
#include <cxxreact/ReactNativeVersion.h>
#endif
#ifndef REACT_NATIVE_VERSION_MINOR
#define REACT_NATIVE_VERSION_MAJOR 0
#define REACT_NATIVE_VERSION_MINOR 0
#define REACT_NATIVE_VERSION_PATCH 0
#endif

#endif /* NitroDefines_h */
Loading