Skip to content

Commit 5a7e97f

Browse files
authored
Merge pull request #6 from callstackincubator/feature/migrate-to-fabric-native-component
feature/migrate to fabric native component
2 parents 631509a + d0f84b3 commit 5a7e97f

20 files changed

Lines changed: 650 additions & 416 deletions

Brewfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# React Native Multi-Instance Development Environment
2+
# Install with: brew bundle
3+
4+
# Core development tools
5+
brew "clang-format"
6+
brew "ccache"
7+
8+
# Additional useful tools for React Native development
9+
brew "node"
10+
brew "watchman"
11+
brew "git"
12+
brew "git-lfs"
13+
14+
# Optional but helpful tools
15+
# brew "llvm" # Full LLVM toolchain (includes clang-format)
16+
# brew "cmake" # For building native modules
17+
# brew "ninja" # Fast build system
18+
# brew "pkg-config" # Package configuration tool

apps/recursive/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function App({depth = 1}: AppProps): React.JSX.Element {
102102
jsBundleSource="index"
103103
moduleName="App" // Recursively load App itself
104104
initialProperties={{depth: depth + 1}}
105+
onMessage={msg => console.log('message', msg)}
106+
onError={e => console.error('error', e)}
105107
/>
106108
</View>
107109
) : (

apps/side-by-side/ios/Podfile.lock

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,10 +1649,34 @@ PODS:
16491649
- ReactCommon/turbomodule/core
16501650
- SocketRocket
16511651
- React-MultInstance (0.0.1):
1652+
- boost
1653+
- DoubleConversion
1654+
- fast_float
1655+
- fmt
1656+
- glog
1657+
- hermes-engine
1658+
- RCT-Folly
1659+
- RCT-Folly/Fabric
1660+
- RCTRequired
1661+
- RCTTypeSafety
16521662
- React-Core
1653-
- React-RCTAppDelegate
1654-
- ReactAppDependencyProvider
1655-
- ReactCommon
1663+
- React-debug
1664+
- React-Fabric
1665+
- React-featureflags
1666+
- React-graphics
1667+
- React-hermes
1668+
- React-ImageManager
1669+
- React-jsi
1670+
- React-NativeModulesApple
1671+
- React-RCTFabric
1672+
- React-renderercss
1673+
- React-rendererdebug
1674+
- React-utils
1675+
- ReactCodegen
1676+
- ReactCommon/turbomodule/bridging
1677+
- ReactCommon/turbomodule/core
1678+
- SocketRocket
1679+
- Yoga
16561680
- React-NativeModulesApple (0.80.1):
16571681
- boost
16581682
- DoubleConversion
@@ -2553,7 +2577,7 @@ SPEC CHECKSUMS:
25532577
React-logger: 984ebd897afad067555d081deaf03f57c4315723
25542578
React-Mapbuffer: 0c045c844ce6d85cde53e85ab163294c6adad349
25552579
React-microtasksnativemodule: d9499269ad1f484ae71319bac1d9231447f2094e
2556-
React-MultInstance: 316d4720cde73e6462eced209c7916e2353135be
2580+
React-MultInstance: 84b1242d0fbc23770b2c534afc89ddc6235c13a6
25572581
React-NativeModulesApple: 983f3483ef0a3446b56d490f09d579fba2442e17
25582582
React-oscompat: 114036cd8f064558c9c1a0c04fc9ae5e1453706a
25592583
React-perflogger: e7287fee27c16e3c8bd4d470f2361572b63be16b

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"scripts": {
99
"ios": "bun run ios --filter=@apps/side-by-side",
1010
"android": "bun run android --filter=@apps/side-by-side",
11-
"lint": "eslint .",
11+
"lint": "eslint . && bun --filter=react-native-multinstance lint",
12+
"format": "eslint . --fix && bun --filter=react-native-multinstance format",
1213
"test": "jest"
1314
},
1415
"devDependencies": {
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Config from RN repo https://github.com/facebook/react-native/blob/main/.clang-format
2+
3+
---
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: AlwaysBreak
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlinesLeft: true
9+
AlignOperands: false
10+
AlignTrailingComments: false
11+
AllowAllParametersOfDeclarationOnNextLine: false
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: Empty
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: true
19+
AlwaysBreakTemplateDeclarations: true
20+
BinPackArguments: false
21+
BinPackParameters: false
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: false
27+
AfterNamespace: false
28+
AfterObjCDeclaration: false
29+
AfterStruct: false
30+
AfterUnion: false
31+
BeforeCatch: false
32+
BeforeElse: false
33+
IndentBraces: false
34+
BreakBeforeBinaryOperators: None
35+
BreakBeforeBraces: Attach
36+
BreakBeforeTernaryOperators: true
37+
BreakConstructorInitializersBeforeComma: false
38+
BreakAfterJavaFieldAnnotations: false
39+
BreakStringLiterals: false
40+
ColumnLimit: 80
41+
CommentPragmas: '^ IWYU pragma:'
42+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
43+
ConstructorInitializerIndentWidth: 4
44+
ContinuationIndentWidth: 4
45+
Cpp11BracedListStyle: true
46+
DerivePointerAlignment: false
47+
DisableFormat: false
48+
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
49+
IncludeCategories:
50+
- Regex: '^<.*\.h(pp)?>'
51+
Priority: 1
52+
- Regex: '^<.*'
53+
Priority: 2
54+
- Regex: '.*'
55+
Priority: 3
56+
IndentCaseLabels: true
57+
IndentWidth: 2
58+
IndentWrappedFunctionNames: false
59+
KeepEmptyLinesAtTheStartOfBlocks: false
60+
MacroBlockBegin: ''
61+
MacroBlockEnd: ''
62+
MaxEmptyLinesToKeep: 1
63+
NamespaceIndentation: None
64+
ObjCBlockIndentWidth: 2
65+
ObjCSpaceAfterProperty: true
66+
ObjCSpaceBeforeProtocolList: true
67+
PenaltyBreakBeforeFirstCallParameter: 1
68+
PenaltyBreakComment: 300
69+
PenaltyBreakFirstLessLess: 120
70+
PenaltyBreakString: 1000
71+
PenaltyExcessCharacter: 1000000
72+
PenaltyReturnTypeOnItsOwnLine: 200
73+
PointerAlignment: Left
74+
ReflowComments: true
75+
SortIncludes: true
76+
SpaceAfterCStyleCast: false
77+
SpaceBeforeAssignmentOperators: true
78+
SpaceBeforeParens: ControlStatements
79+
SpaceInEmptyParentheses: false
80+
SpacesBeforeTrailingComments: 1
81+
SpacesInAngles: false
82+
SpacesInContainerLiterals: true
83+
SpacesInCStyleCastParentheses: false
84+
SpacesInParentheses: false
85+
SpacesInSquareBrackets: false
86+
Standard: Cpp11
87+
TabWidth: 8
88+
UseTab: Never
89+
QualifierAlignment: Left
90+
---
91+
Language: ObjC
92+
ColumnLimit: 120
93+
BreakBeforeBraces: WebKit
94+
PointerAlignment: Right
95+
...

packages/react-native-multinstance/React-MultInstance.podspec

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ require "json"
22

33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44

5+
header_search_paths = [
6+
"\"$(PODS_TARGET_SRCROOT)/ReactCommon\"",
7+
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
8+
"\"$(PODS_ROOT)/Headers/Private/Yoga\"",
9+
"\"$(PODS_ROOT)/Headers/Public/ReactCodegen\"",
10+
]
11+
512
Pod::Spec.new do |s|
613
s.name = "React-MultInstance"
714
s.version = package["version"]
@@ -12,14 +19,10 @@ Pod::Spec.new do |s|
1219
s.platforms = { :ios => "12.4" }
1320
s.source = { :git => "https://github.com/callstackincubator/react-native-multinstance.git", :tag => "#{s.version}" }
1421
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
15-
s.dependency "React-Core"
16-
s.dependency "React-RCTAppDelegate"
17-
s.dependency "ReactAppDependencyProvider"
18-
s.dependency "ReactCommon"
19-
s.pod_target_xcconfig = {
20-
"DEFINES_MODULE" => "YES",
21-
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES",
22-
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
23-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
22+
install_modules_dependencies(s)
23+
s.pod_target_xcconfig = {
24+
"HEADER_SEARCH_PATHS" => header_search_paths,
25+
# "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
26+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
2427
}
2528
end

packages/react-native-multinstance/ios/SandboxReactNativeDelegate.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#import <React-RCTAppDelegate/RCTDefaultReactNativeFactoryDelegate.h>
1111
#import <React/RCTComponent.h>
12+
#import <react/renderer/components/RNMultInstanceSpec/EventEmitters.h>
1213

1314
NS_ASSUME_NONNULL_BEGIN
1415

@@ -19,8 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
1920
*/
2021
@interface SandboxReactNativeDelegate : RCTDefaultReactNativeFactoryDelegate
2122

22-
@property (nonatomic, copy, nullable) RCTDirectEventBlock onMessageHost;
23-
@property (nonatomic, copy, nullable) RCTDirectEventBlock onErrorHost;
23+
@property (nonatomic) std::shared_ptr<const facebook::react::SandboxReactNativeViewEventEmitter> eventEmitter;
24+
@property (nonatomic, assign) BOOL hasOnMessageHandler;
25+
@property (nonatomic, assign) BOOL hasOnErrorHandler;
2426

2527
/**
2628
* Sets the list of allowed TurboModules for this sandbox instance.
@@ -37,9 +39,9 @@ NS_ASSUME_NONNULL_BEGIN
3739

3840
/**
3941
* Posts a message to the JavaScript runtime.
40-
* @param message Dictionary containing the message data
42+
* @param message String containing the JSON.stringified message
4143
*/
42-
- (void)postMessage:(NSDictionary *)message;
44+
- (void)postMessage:(NSString *)message;
4345

4446
@end
4547

0 commit comments

Comments
 (0)