Skip to content

Commit

Permalink
feat: add macro for hyphen/underscore imports
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsoftwaretyler committed Dec 15, 2024
1 parent 828bc0f commit 571e7fd
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 94 deletions.
96 changes: 96 additions & 0 deletions changes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
diff --git a/ios/RNIContextMenuButton/RNIContextMenuButton.mm b/ios/RNIContextMenuButton/RNIContextMenuButton.mm
index 3d91bae..0870791 100644
--- a/ios/RNIContextMenuButton/RNIContextMenuButton.mm
+++ b/ios/RNIContextMenuButton/RNIContextMenuButton.mm
@@ -23,8 +23,13 @@
#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuButtonComponentDescriptor.h"

+#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewState.h>
+#include <react-native-ios-utilities/RNIBaseViewProps.h>
+#endif

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
diff --git a/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h b/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h
index 0fe922b..7cf637e 100644
--- a/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h
+++ b/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h
@@ -11,7 +11,11 @@
#include "RNIContextMenuButtonShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"

+#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewState.h>
+#endif

#include <react/renderer/core/ConcreteComponentDescriptor.h>

diff --git a/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h b/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
index ac1b293..d9ffbb6 100644
--- a/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
+++ b/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
@@ -8,9 +8,15 @@
#if __cplusplus
#pragma once

+#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
+#include <react-native-ios-utilities/RNIBaseViewProps.h>
+#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
+#endif

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
diff --git a/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h b/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h
index 2e30bbb..5aa27cd 100644
--- a/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h
+++ b/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h
@@ -8,11 +8,17 @@
#if __cplusplus
#pragma once

+
#include "RNIContextMenuViewShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"

+#if __has_include(<react_native_ios_utilities/RNIBaseViewComponentDescriptor.h>)
#include <react_native_ios_utilities/RNIBaseViewComponentDescriptor.h>
#include <react_native_ios_utilities/RNIBaseViewState.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewComponentDescriptor.h>
+#include <react-native-ios-utilities/RNIBaseViewState.h>
+#endif

#include <react/renderer/core/ConcreteComponentDescriptor.h>

diff --git a/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h b/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
index a72e1fc..d0a0106 100644
--- a/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
+++ b/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
@@ -8,9 +8,15 @@
#if __cplusplus
#pragma once

+#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
+#include <react-native-ios-utilities/RNIBaseViewProps.h>
+#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
+#endif

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
8 changes: 3 additions & 5 deletions ios/RNIContextMenuButton/RNIContextMenuButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
// Created by Dominic Go on 8/24/24.
//

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#endif
#import "RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseView.h)

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
Expand Down
25 changes: 6 additions & 19 deletions ios/RNIContextMenuButton/RNIContextMenuButton.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,16 @@

#import "RNIContextMenuButton.h"
#import "../Swift.h"
#import "RNIHeaderUtils.h"

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#import <react_native_ios_utilities/RNIContentViewParentDelegate.h>
#import <react_native_ios_utilities/UIApplication+RNIHelpers.h>
#import <react_native_ios_utilities/RNIObjcUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#import <react-native-ios-utilities/RNIContentViewParentDelegate.h>
#import <react-native-ios-utilities/UIApplication+RNIHelpers.h>
#import <react-native-ios-utilities/RNIObjcUtils.h>
#endif
RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
RNI_INCLUDE_HEADER(RNIObjcUtils.h)

#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuButtonComponentDescriptor.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#else
#include <react-native-ios-utilities/RNIBaseViewState.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#endif
RNI_INCLUDE_HEADER(RNIBaseViewState.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

#include "RNIContextMenuButtonShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"
#include "RNIHeaderUtils.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#else
#include <react-native-ios-utilities/RNIBaseViewState.h>
#endif
RNI_INCLUDE_HEADER(RNIBaseViewState.h)

#include <react/renderer/core/ConcreteComponentDescriptor.h>

Expand Down
16 changes: 6 additions & 10 deletions ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
#if __cplusplus
#pragma once

#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
#else
#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
#endif
#include "RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewShadowNode.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
RNI_INCLUDE_HEADER(RNIBaseViewEventEmitter.h)

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
Expand All @@ -34,7 +30,7 @@ class JSI_EXPORT RNIContextMenuButtonShadowNode final :

public:
using RNIBaseViewShadowNode::RNIBaseViewShadowNode;

static RNIBaseViewState initialStateData(
const Props::Shared&r , // props
const ShadowNodeFamily::Shared&, // family
Expand Down
8 changes: 3 additions & 5 deletions ios/RNIContextMenuButton/RNIContextMenuButtonViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#import "RNIContextMenuButton.h"
#import <objc/runtime.h>

#if __has_include(<react_native_ios_utilities/RNIBaseViewUtils.h>)
#import <react_native_ios_utilities/RNIBaseViewUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseViewUtils.h>
#endif
#import "RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)

#import "RCTBridge.h"
#import <React/RCTViewManager.h>
Expand Down
8 changes: 3 additions & 5 deletions ios/RNIContextMenuView/RNIContextMenuView.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
// Created by Dominic Go on 8/24/24.
//

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#endif
#import "RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseView.h)

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
Expand Down
30 changes: 14 additions & 16 deletions ios/RNIContextMenuView/RNIContextMenuView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,27 @@

#import "RNIContextMenuView.h"
#import "../Swift.h"
#import "RNIHeaderUtils.h"

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#import <react_native_ios_utilities/RNIContentViewParentDelegate.h>
#import <react_native_ios_utilities/UIApplication+RNIHelpers.h>
#import <react_native_ios_utilities/RNIObjcUtils.h>
RNI_INCLUDE_HEADER(RNIBaseView.h)
RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
RNI_INCLUDE_HEADER(RNIObjcUtils.h)

#if RCT_NEW_ARCH_ENABLED
RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#import <react-native-ios-utilities/RNIContentViewParentDelegate.h>
#import <react-native-ios-utilities/UIApplication+RNIHelpers.h>
#import <react-native-ios-utilities/RNIObjcUtils.h>
RNI_INCLUDE_HEADER(RNIBaseView.h)
RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
RNI_INCLUDE_HEADER(RNIObjcUtils.h)
#endif

#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuViewComponentDescriptor.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#else
#include <react-native-ios-utilities/RNIBaseViewState.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#endif
RNI_INCLUDE_HEADER(RNIBaseViewState.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RNIContextMenuViewComponentDescriptor final : public RNIBaseViewComponentD
RNIContextMenuViewShadowNode,
RNIContextMenuViewComponentName
> {

public:
using RNIBaseViewComponentDescriptor::RNIBaseViewComponentDescriptor;
};
Expand Down
7 changes: 2 additions & 5 deletions ios/RNIContextMenuView/RNIContextMenuViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@

#import "RNIContextMenuView.h"
#import <objc/runtime.h>
#import "RNIHeaderUtils.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewUtils.h>)
#import <react_native_ios_utilities/RNIBaseViewUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseViewUtils.h>
#endif
RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)

#import "RCTBridge.h"
#import <React/RCTViewManager.h>
Expand Down
16 changes: 6 additions & 10 deletions ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
#if __cplusplus
#pragma once

#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
#else
#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
#endif
#include "RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewShadowNode.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
RNI_INCLUDE_HEADER(RNIBaseViewEventEmitter.h)

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
Expand All @@ -34,7 +30,7 @@ class JSI_EXPORT RNIContextMenuViewShadowNode final :

public:
using RNIBaseViewShadowNode::RNIBaseViewShadowNode;

static RNIBaseViewState initialStateData(
const Props::Shared&r , // props
const ShadowNodeFamily::Shared&, // family
Expand Down
8 changes: 8 additions & 0 deletions ios/RNIHeaderUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#define RNI_INCLUDE_HEADER(header) \
#if __has_include(<react_native_ios_utilities/header>) \
#include <react_native_ios_utilities/header> \
#else \
#include <react-native-ios-utilities/header> \
#endif
15 changes: 2 additions & 13 deletions ios/Swift.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,9 @@
//
// Created by Dominic Go on 8/24/24.
//
#import "RNIHeaderUtils.h"

// When `use_frameworks!` is used, the generated Swift header is inside
// the module.
// Otherwise, it's available only locally with double-quoted imports.
#if __has_include(<react_native_ios_context_menu/react_native_ios_context_menu-Swift.h>)
#import <react_native_ios_context_menu/react_native_ios_context_menu-Swift.h>

#elif __has_include(<react-native-ios-context-menu/react_native_ios_context_menu-Swift.h>)
#import <react-native-ios-context-menu/react_native_ios_context_menu-Swift.h>

#else
#import "react_native_ios_context_menu-Swift.h"
#endif

RNI_INCLUDE_HEADER(react_native_ios_context_menu-Swift.h)

// #import <react-native-ios-utilities/react-native-ios-utilities-Swift.h>
// #import "<react_native_ios_utilities/react_native_ios_utilities-Swift.h>"
Expand Down

0 comments on commit 571e7fd

Please sign in to comment.