-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass whole RuntimeTargetDelegate from RN instead of aggregating its m…
…ethods (#43346) Summary: Pull Request resolved: #43346 Changelog: [Internal] (Continuing the theme of reducing integration boilerplate from D54537844.) This diff changes both `JSExecutor` (Bridge) and `JSRuntime` (Bridgeless) to no longer implement `RuntimeTargetDelegate`. Instead, each of them exposes a `getRuntimeTargetDelegate()` method that returns a stable reference to a target delegate that it *owns*. To facilitate this, we create a new `FallbackRuntimeTargetDelegate` for use in non-Hermes cases. This replaces *almost* all direct uses of `FallbackRuntimeAgentDelegate` outside of `jsinspector`. I'll follow up in a separate diff to deal with the last case and make the fallback agent delegate fully private. As a result, changing the `RuntimeTargetDelegate` interface (which we'll need to do for console support) becomes much easier: we only have unit test mocks + two concrete `RuntimeTargetDelegate` implementations (one fallback, one Hermes) to update for each API change. Reviewed By: huntie Differential Revision: D54585658 fbshipit-source-id: 08b61c74008ddc36c2b134a40755ef8e43ab21ed
- Loading branch information
Showing
18 changed files
with
148 additions
and
136 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
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
29 changes: 29 additions & 0 deletions
29
packages/react-native/ReactCommon/jsinspector-modern/FallbackRuntimeTargetDelegate.cpp
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,29 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "FallbackRuntimeTargetDelegate.h" | ||
#include "FallbackRuntimeAgentDelegate.h" | ||
|
||
namespace facebook::react::jsinspector_modern { | ||
|
||
FallbackRuntimeTargetDelegate::FallbackRuntimeTargetDelegate( | ||
std::string engineDescription) | ||
: engineDescription_{std::move(engineDescription)} {} | ||
|
||
std::unique_ptr<RuntimeAgentDelegate> | ||
FallbackRuntimeTargetDelegate::createAgentDelegate( | ||
FrontendChannel channel, | ||
SessionState& sessionState, | ||
std::unique_ptr<RuntimeAgentDelegate::ExportedState> | ||
/*previouslyExportedState*/, | ||
const ExecutionContextDescription& /*executionContextDescription*/, | ||
RuntimeExecutor /*runtimeExecutor*/) { | ||
return std::make_unique<jsinspector_modern::FallbackRuntimeAgentDelegate>( | ||
std::move(channel), sessionState, engineDescription_); | ||
} | ||
|
||
} // namespace facebook::react::jsinspector_modern |
38 changes: 38 additions & 0 deletions
38
packages/react-native/ReactCommon/jsinspector-modern/FallbackRuntimeTargetDelegate.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,38 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "InspectorInterfaces.h" | ||
#include "RuntimeTarget.h" | ||
#include "SessionState.h" | ||
|
||
#include <string> | ||
|
||
namespace facebook::react::jsinspector_modern { | ||
|
||
/** | ||
* A RuntimeTargetDelegate that stubs out debugging functionality for a | ||
* JavaScript runtime that does not natively support debugging. | ||
*/ | ||
class FallbackRuntimeTargetDelegate : public RuntimeTargetDelegate { | ||
public: | ||
explicit FallbackRuntimeTargetDelegate(std::string engineDescription); | ||
|
||
std::unique_ptr<RuntimeAgentDelegate> createAgentDelegate( | ||
FrontendChannel channel, | ||
SessionState& sessionState, | ||
std::unique_ptr<RuntimeAgentDelegate::ExportedState> | ||
previouslyExportedState, | ||
const ExecutionContextDescription& executionContextDescription, | ||
RuntimeExecutor runtimeExecutor) override; | ||
|
||
private: | ||
std::string engineDescription_; | ||
}; | ||
|
||
} // namespace facebook::react::jsinspector_modern |
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
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
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
Oops, something went wrong.