-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// AppleFilamentProxy.mm | ||
// react-native-filament | ||
// | ||
// Created by Marc Rousavy on 20.02.24. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "AppleFilamentProxy.h" | ||
|
||
namespace margelo { | ||
|
||
AppleFilamentProxy::AppleFilamentProxy(jsi::Runtime* runtime, std::shared_ptr<react::CallInvoker> callInvoker): | ||
_runtime(runtime), _callInvoker(callInvoker) { } | ||
|
||
AppleFilamentProxy::~AppleFilamentProxy() { | ||
// TODO(hanno): cleanup here? | ||
} | ||
|
||
int AppleFilamentProxy::loadModel(const std::string &path) { | ||
// TODO(hanno): Implement model loading here | ||
return 13; | ||
} | ||
|
||
} // namespace margelo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// IOSFilamentInstaller.h | ||
// react-native-filament | ||
// | ||
// Created by Marc Rousavy on 20.02.24. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <React/RCTBridge.h> | ||
|
||
@interface FilamentInstaller : NSObject | ||
|
||
+ (BOOL)installToBridge:(RCTBridge*)bridge; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// FilamentInstaller.m | ||
// react-native-filament | ||
// | ||
// Created by Marc Rousavy on 20.02.24. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "FilamentInstaller.h" | ||
#import "AppleFilamentProxy.h" | ||
#import <ReactCommon/CallInvoker.h> | ||
|
||
#import <React/RCTBridge+Private.h> | ||
#import <React/RCTBridge.h> | ||
|
||
using namespace facebook; | ||
|
||
// This is defined in RCTCxxBridge.mm, and we are technically using a private API here. | ||
@interface RCTCxxBridge (CallInvoker) | ||
- (std::shared_ptr<react::CallInvoker>)jsCallInvoker; | ||
@end | ||
|
||
@implementation FilamentInstaller | ||
|
||
+ (BOOL)installToBridge:(RCTBridge *)bridge { | ||
RCTCxxBridge* cxxBridge = (RCTCxxBridge*)[RCTBridge currentBridge]; | ||
if (!cxxBridge.runtime) { | ||
return NO; | ||
} | ||
|
||
jsi::Runtime* runtime = (jsi::Runtime*)cxxBridge.runtime; | ||
if (!runtime) { | ||
return NO; | ||
} | ||
std::shared_ptr<react::CallInvoker> callInvoker = cxxBridge.jsCallInvoker; | ||
if (!callInvoker) { | ||
return NO; | ||
} | ||
|
||
// global.__filamentProxy | ||
auto filamentProxy = std::make_shared<margelo::AppleFilamentProxy>(runtime, callInvoker); | ||
runtime->global().setProperty(*runtime, "__filamentProxy", jsi::Object::createFromHostObject(*runtime, filamentProxy)); | ||
|
||
return YES; | ||
} | ||
|
||
@end |