-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Bridgeless files to OSS folders (#37066)
Summary: Pull Request resolved: #37066 Move Bridgeless ObjC files from > fbobjc/Apps/Wilde/Internal/venice to > xplat/js/react-native-github/packages/react-native/ReactCommon/react/bridgeless/platform/ios Changelog: [iOS][Changed] - Move Bridgeless files to OSS folders Reviewed By: fkgozali Differential Revision: D45120773 fbshipit-source-id: 2aa03238ae5c33dc8a3bf8004c51e9b6e0ca14b6
- Loading branch information
1 parent
33ebb5d
commit 0dcf81b
Showing
12 changed files
with
1,305 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/ObjCTimerRegistry.h
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,33 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import <PikaOptimizationsMacros/PikaOptimizationsMacros.h> | ||
#import <React/RCTTiming.h> | ||
#import <react/bridgeless/PlatformTimerRegistry.h> | ||
#import <react/bridgeless/TimerManager.h> | ||
|
||
@interface RCTJSTimerExecutor : NSObject <RCTTimingDelegate> | ||
|
||
- (void)setTimerManager:(std::weak_ptr<facebook::react::TimerManager>)timerManager FB_OBJC_DIRECT; | ||
|
||
@end | ||
|
||
class ObjCTimerRegistry : public facebook::react::PlatformTimerRegistry { | ||
public: | ||
ObjCTimerRegistry(); | ||
void createTimer(uint32_t timerID, double delayMS) override; | ||
void deleteTimer(uint32_t timerID) override; | ||
void createRecurringTimer(uint32_t timerID, double delayMS) override; | ||
void setTimerManager(std::weak_ptr<facebook::react::TimerManager> timerManager); | ||
RCTTiming *_Null_unspecified timing; | ||
|
||
private: | ||
RCTJSTimerExecutor *_Null_unspecified jsTimerExecutor_; | ||
double toSeconds(double ms); | ||
}; |
73 changes: 73 additions & 0 deletions
73
packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/ObjCTimerRegistry.mm
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,73 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "ObjCTimerRegistry.h" | ||
|
||
@implementation RCTJSTimerExecutor { | ||
std::weak_ptr<facebook::react::TimerManager> _timerManager; | ||
} | ||
|
||
- (void)setTimerManager:(std::weak_ptr<facebook::react::TimerManager>)timerManager | ||
{ | ||
_timerManager = timerManager; | ||
} | ||
|
||
- (void)callTimers:(NSArray<NSNumber *> *)timers | ||
{ | ||
if (auto timerManager = _timerManager.lock()) { | ||
for (NSNumber *timer in timers) { | ||
timerManager->callTimer([timer unsignedIntValue]); | ||
} | ||
} | ||
} | ||
|
||
- (void)immediatelyCallTimer:(nonnull NSNumber *)callbackID | ||
{ | ||
if (auto timerManager = _timerManager.lock()) { | ||
timerManager->callTimer([callbackID unsignedIntValue]); | ||
} | ||
} | ||
|
||
- (void)callIdleCallbacks:(nonnull NSNumber *)absoluteFrameStartMS | ||
{ | ||
// TODO(T53992765)(petetheheat) - Implement this | ||
} | ||
|
||
@end | ||
|
||
ObjCTimerRegistry::ObjCTimerRegistry() | ||
{ | ||
jsTimerExecutor_ = [RCTJSTimerExecutor new]; | ||
timing = [[RCTTiming alloc] initWithDelegate:jsTimerExecutor_]; | ||
} | ||
|
||
void ObjCTimerRegistry::createTimer(uint32_t timerID, double delayMS) | ||
{ | ||
[timing createTimerForNextFrame:@(timerID) duration:toSeconds(delayMS) jsSchedulingTime:nil repeats:NO]; | ||
} | ||
|
||
void ObjCTimerRegistry::deleteTimer(uint32_t timerID) | ||
{ | ||
[timing deleteTimer:(double)timerID]; | ||
} | ||
|
||
void ObjCTimerRegistry::createRecurringTimer(uint32_t timerID, double delayMS) | ||
{ | ||
[timing createTimerForNextFrame:@(timerID) duration:toSeconds(delayMS) jsSchedulingTime:nil repeats:YES]; | ||
} | ||
|
||
void ObjCTimerRegistry::setTimerManager(std::weak_ptr<facebook::react::TimerManager> timerManager) | ||
{ | ||
[jsTimerExecutor_ setTimerManager:timerManager]; | ||
} | ||
|
||
// ObjC timing native module expects a NSTimeInterval which is always specified in seconds. JS expresses timer delay | ||
// in ms. Perform a simple conversion here. | ||
double ObjCTimerRegistry::toSeconds(double ms) | ||
{ | ||
return ms / 1000.0; | ||
} |
83 changes: 83 additions & 0 deletions
83
packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHost.h
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,83 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import <PikaOptimizationsMacros/PikaOptimizationsMacros.h> | ||
#import <React/RCTDefines.h> | ||
#import <react/bridgeless/JSEngineInstance.h> | ||
#import <react/bridgeless/ReactInstance.h> | ||
#import <react/renderer/core/ReactPrimitives.h> | ||
|
||
#import "RCTInstance.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class RCTFabricSurface; | ||
@class RCTJSThreadManager; | ||
@class RCTModuleRegistry; | ||
@class RCTPerformanceLogger; | ||
@protocol RCTInstanceDelegate; | ||
FB_RUNTIME_PROTOCOL | ||
@protocol RCTTurboModuleManagerDelegate; | ||
|
||
/** | ||
* This notification fires just before RCTHost releases it's RCTInstance reference. | ||
*/ | ||
RCT_EXTERN NSString *const RCTHostWillReloadNotification; | ||
|
||
/** | ||
* This notification fires just after RCTHost releases it's RCTInstance reference. | ||
*/ | ||
RCT_EXTERN NSString *const RCTHostDidReloadNotification; | ||
|
||
@protocol RCTHostDelegate <NSObject> | ||
|
||
- (std::shared_ptr<facebook::react::JSEngineInstance>)getJSEngine; | ||
- (NSURL *)getBundleURL; | ||
|
||
@end | ||
|
||
/** | ||
* RCTHost is an object which is responsible for managing the lifecycle of a single RCTInstance. | ||
* RCTHost is long lived, while an instance may be deallocated and re-initialized. Some examples of when this happens: | ||
* CMD+R reload in DEV or a JS crash. The host should be the single owner of an RCTInstance. | ||
*/ | ||
@interface RCTHost : NSObject <ReactInstanceForwarding> | ||
|
||
- (instancetype)initWithHostDelegate:(id<RCTHostDelegate>)hostDelegate | ||
instanceDelegate:(id<RCTInstanceDelegate>)instanceDelegate | ||
turboModuleManagerDelegate:(id<RCTTurboModuleManagerDelegate>)turboModuleManagerDelegate | ||
bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc | ||
jsErrorHandlingFunc:(facebook::react::JsErrorHandler::JsErrorHandlingFunc)jsErrorHandlingFunc | ||
NS_DESIGNATED_INITIALIZER FB_OBJC_DIRECT; | ||
|
||
/** | ||
* This function initializes an RCTInstance if one does not yet exist. This function is currently only called on the | ||
* main thread, but it should be threadsafe. | ||
* TODO T74233481 - Verify if this function is threadsafe. | ||
*/ | ||
- (void)preload; | ||
|
||
- (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName | ||
mode:(facebook::react::DisplayMode)displayMode | ||
initialProperties:(NSDictionary *)properties FB_OBJC_DIRECT; | ||
|
||
- (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName | ||
initialProperties:(NSDictionary *)properties FB_OBJC_DIRECT; | ||
|
||
- (RCTJSThreadManager *)getJSThreadManager FB_OBJC_DIRECT; | ||
|
||
- (RCTModuleRegistry *)getModuleRegistry FB_OBJC_DIRECT; | ||
|
||
- (RCTPerformanceLogger *)getPerformanceLogger FB_OBJC_DIRECT; | ||
|
||
- (RCTSurfacePresenter *)getSurfacePresenter FB_OBJC_DIRECT; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.