mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Register RCTBridge with modern CDP backend (#42394)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42394 Changelog: [Internal][iOS] - Enable stub modern CDP backend in Bridge behind a feature flag Minimally integrates the stub native CDP backend implementation (D50936932) into iOS Bridge. This integration registers itself as a "Modern" target (D50967794, D50967795) to instruct `inspector-proxy` to disable its CDP hacks related to source map fetching, reloads, etc. This gives us a mostly-clean slate on which to develop and test native CDP functionality. Reviewed By: huntie Differential Revision: D50951138 fbshipit-source-id: 8c5ad9207e73265595884380c91e38f8d0ead84d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8a4c85316d
commit
9003d08839
@@ -95,6 +95,8 @@ Pod::Spec.new do |s|
|
||||
end
|
||||
ss.exclude_files = exclude_files
|
||||
ss.private_header_files = "React/Cxx*/*.h"
|
||||
|
||||
ss.dependency "React-jsinspector", version
|
||||
end
|
||||
|
||||
s.subspec "DevSupport" do |ss|
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#if RCT_ENABLE_INSPECTOR
|
||||
#import "RCTInspectorDevServerHelper.h"
|
||||
#endif
|
||||
#import <jsinspector-modern/InspectorFlags.h>
|
||||
#import <jsinspector-modern/InspectorInterfaces.h>
|
||||
#import <jsinspector-modern/ReactCdp.h>
|
||||
#import <optional>
|
||||
#import "RCTDevLoadingViewProtocol.h"
|
||||
#import "RCTJSThread.h"
|
||||
#import "RCTLog.h"
|
||||
@@ -189,6 +193,9 @@ void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled)
|
||||
|
||||
@implementation RCTBridge {
|
||||
NSURL *_delegateBundleURL;
|
||||
|
||||
std::unique_ptr<facebook::react::jsinspector_modern::PageTarget> _inspectorTarget;
|
||||
std::optional<int> _inspectorPageId;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
@@ -252,6 +259,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
* RCTAssertMainQueue();
|
||||
*/
|
||||
[self invalidate];
|
||||
if (_inspectorPageId.has_value()) {
|
||||
facebook::react::jsinspector_modern::getInspectorInstance().removePage(*_inspectorPageId);
|
||||
_inspectorPageId.reset();
|
||||
_inspectorTarget.reset();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setRCTTurboModuleRegistry:(id<RCTTurboModuleRegistry>)turboModuleRegistry
|
||||
@@ -377,6 +389,29 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
[_performanceLogger markStartForTag:RCTPLBridgeStartup];
|
||||
[_performanceLogger markStartForTag:RCTPLTTI];
|
||||
|
||||
auto &inspectorFlags = facebook::react::jsinspector_modern::InspectorFlags::getInstance();
|
||||
if (inspectorFlags.getEnableModernCDPRegistry() && !_inspectorPageId.has_value()) {
|
||||
_inspectorTarget = std::make_unique<facebook::react::jsinspector_modern::PageTarget>();
|
||||
__weak RCTBridge *weakSelf = self;
|
||||
_inspectorPageId = facebook::react::jsinspector_modern::getInspectorInstance().addPage(
|
||||
"React Native Bridge (Experimental)",
|
||||
/* vm */ "",
|
||||
[weakSelf](std::unique_ptr<facebook::react::jsinspector_modern::IRemoteConnection> remote)
|
||||
-> std::unique_ptr<facebook::react::jsinspector_modern::ILocalConnection> {
|
||||
RCTBridge *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
// This can happen if we're about to be dealloc'd. Reject the connection.
|
||||
return nullptr;
|
||||
}
|
||||
return strongSelf->_inspectorTarget->connect(
|
||||
std::move(remote),
|
||||
{
|
||||
.integrationName = "iOS Bridge (RCTBridge)",
|
||||
});
|
||||
},
|
||||
facebook::react::jsinspector_modern::InspectorPageType::Modern);
|
||||
}
|
||||
|
||||
Class bridgeClass = self.bridgeClass;
|
||||
|
||||
// Only update bundleURL from delegate if delegate bundleURL has changed
|
||||
|
||||
Reference in New Issue
Block a user