react-native 0.74.0-nightly-20240220-e9351f0f8 → 0.74.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Lists/FlatList.js +0 -1
- package/React/Base/RCTBridge+Private.h +2 -2
- package/React/Base/RCTBridge.mm +7 -7
- package/React/Base/RCTVersion.m +1 -1
- package/React/CxxBridge/RCTCxxBridge.mm +3 -3
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +2 -2
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +0 -4
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessDevSupportManager.java +1 -1
- package/ReactCommon/cxxreact/Instance.cpp +1 -1
- package/ReactCommon/cxxreact/Instance.h +2 -2
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeAgentDelegate.cpp +2 -2
- package/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeAgentDelegate.h +1 -1
- package/ReactCommon/jsinspector-modern/CONCEPTS.md +2 -2
- package/ReactCommon/jsinspector-modern/InstanceAgent.h +1 -1
- package/ReactCommon/jsinspector-modern/InstanceTarget.cpp +1 -1
- package/ReactCommon/jsinspector-modern/{HostAgent.cpp → PageAgent.cpp} +9 -9
- package/ReactCommon/jsinspector-modern/{HostAgent.h → PageAgent.h} +13 -13
- package/ReactCommon/jsinspector-modern/{HostTarget.cpp → PageTarget.cpp} +34 -34
- package/ReactCommon/jsinspector-modern/{HostTarget.h → PageTarget.h} +52 -52
- package/ReactCommon/jsinspector-modern/ReactCdp.h +1 -1
- package/ReactCommon/jsinspector-modern/RuntimeAgent.cpp +1 -1
- package/ReactCommon/jsinspector-modern/RuntimeAgent.h +1 -1
- package/ReactCommon/jsinspector-modern/RuntimeTarget.h +4 -4
- package/ReactCommon/jsinspector-modern/tests/InspectorMocks.h +2 -2
- package/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp +5 -5
- package/ReactCommon/jsinspector-modern/tests/{HostTargetTest.cpp → PageTargetTest.cpp} +33 -33
- package/ReactCommon/react/runtime/ReactInstance.cpp +1 -1
- package/ReactCommon/react/runtime/ReactInstance.h +2 -2
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +6 -6
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h +1 -1
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +2 -2
- package/ReactCommon/react/test_utils/ios/Shims/ShimRCTInstance.mm +1 -1
- package/cli.js +13 -0
- package/package.json +11 -11
- package/sdks/.hermesversion +1 -0
- package/sdks/hermesc/osx-bin/hermes +0 -0
- package/sdks/hermesc/osx-bin/hermesc +0 -0
- package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
- package/template/package.json +5 -5
- package/template/android/gradle-wrapper.jar +0 -0
- package/template/android/gradle-wrapper.properties +0 -7
|
@@ -308,7 +308,6 @@ export type Props<ItemT> = {
|
|
|
308
308
|
* Also inherits [ScrollView Props](docs/scrollview.html#props), unless it is nested in another FlatList of same orientation.
|
|
309
309
|
*/
|
|
310
310
|
class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
311
|
-
props: Props<ItemT>;
|
|
312
311
|
/**
|
|
313
312
|
* Scrolls to the end of the content. May be janky without `getItemLayout` prop.
|
|
314
313
|
*/
|
|
@@ -74,11 +74,11 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
74
74
|
@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* The
|
|
77
|
+
* The page target for this bridge, if one has been created. Exposed for RCTCxxBridge only.
|
|
78
78
|
*/
|
|
79
79
|
@property (nonatomic, assign, readonly)
|
|
80
80
|
#ifdef __cplusplus
|
|
81
|
-
facebook::react::jsinspector_modern::
|
|
81
|
+
facebook::react::jsinspector_modern::PageTarget *
|
|
82
82
|
#else
|
|
83
83
|
// The inspector infrastructure cannot be used in C code.
|
|
84
84
|
void *
|
package/React/Base/RCTBridge.mm
CHANGED
|
@@ -188,9 +188,9 @@ void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled)
|
|
|
188
188
|
kDispatchAccessibilityManagerInitOntoMain = enabled;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
class
|
|
191
|
+
class RCTBridgePageTargetDelegate : public facebook::react::jsinspector_modern::PageTargetDelegate {
|
|
192
192
|
public:
|
|
193
|
-
|
|
193
|
+
RCTBridgePageTargetDelegate(RCTBridge *bridge) : bridge_(bridge) {}
|
|
194
194
|
|
|
195
195
|
void onReload(const PageReloadRequest &request) override
|
|
196
196
|
{
|
|
@@ -208,8 +208,8 @@ class RCTBridgeHostTargetDelegate : public facebook::react::jsinspector_modern::
|
|
|
208
208
|
@implementation RCTBridge {
|
|
209
209
|
NSURL *_delegateBundleURL;
|
|
210
210
|
|
|
211
|
-
std::unique_ptr<
|
|
212
|
-
std::shared_ptr<facebook::react::jsinspector_modern::
|
|
211
|
+
std::unique_ptr<RCTBridgePageTargetDelegate> _inspectorPageDelegate;
|
|
212
|
+
std::shared_ptr<facebook::react::jsinspector_modern::PageTarget> _inspectorTarget;
|
|
213
213
|
std::optional<int> _inspectorPageId;
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -259,7 +259,7 @@ static RCTBridge *RCTCurrentBridgeInstance = nil;
|
|
|
259
259
|
_bundleURL = bundleURL;
|
|
260
260
|
_moduleProvider = block;
|
|
261
261
|
_launchOptions = [launchOptions copy];
|
|
262
|
-
|
|
262
|
+
_inspectorPageDelegate = std::make_unique<RCTBridgePageTargetDelegate>(self);
|
|
263
263
|
|
|
264
264
|
[self setUp];
|
|
265
265
|
}
|
|
@@ -413,7 +413,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|
|
413
413
|
auto &inspectorFlags = facebook::react::jsinspector_modern::InspectorFlags::getInstance();
|
|
414
414
|
if (inspectorFlags.getEnableModernCDPRegistry() && !_inspectorPageId.has_value()) {
|
|
415
415
|
_inspectorTarget =
|
|
416
|
-
facebook::react::jsinspector_modern::
|
|
416
|
+
facebook::react::jsinspector_modern::PageTarget::create(*_inspectorPageDelegate, [](auto callback) {
|
|
417
417
|
RCTExecuteOnMainQueue(^{
|
|
418
418
|
callback();
|
|
419
419
|
});
|
|
@@ -526,7 +526,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|
|
526
526
|
[self.batchedBridge registerSegmentWithId:segmentId path:path];
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
-
- (facebook::react::jsinspector_modern::
|
|
529
|
+
- (facebook::react::jsinspector_modern::PageTarget *)inspectorTarget
|
|
530
530
|
{
|
|
531
531
|
return _inspectorTarget.get();
|
|
532
532
|
}
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -437,7 +437,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|
|
437
437
|
// pointer into a member of RCTBridge! But we only use it while _reactInstance exists, meaning we
|
|
438
438
|
// haven't been invalidated, and therefore RCTBridge hasn't been deallocated yet.
|
|
439
439
|
RCTAssertMainQueue();
|
|
440
|
-
facebook::react::jsinspector_modern::
|
|
440
|
+
facebook::react::jsinspector_modern::PageTarget *parentInspectorTarget = _parentBridge.inspectorTarget;
|
|
441
441
|
|
|
442
442
|
// Dispatch the instance initialization as soon as the initial module metadata has
|
|
443
443
|
// been collected (see initModules)
|
|
@@ -658,7 +658,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|
|
658
658
|
}
|
|
659
659
|
|
|
660
660
|
- (void)_initializeBridge:(std::shared_ptr<JSExecutorFactory>)executorFactory
|
|
661
|
-
parentInspectorTarget:(facebook::react::jsinspector_modern::
|
|
661
|
+
parentInspectorTarget:(facebook::react::jsinspector_modern::PageTarget *)parentInspectorTarget
|
|
662
662
|
{
|
|
663
663
|
if (!self.valid) {
|
|
664
664
|
return;
|
|
@@ -691,7 +691,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|
|
691
691
|
}
|
|
692
692
|
|
|
693
693
|
- (void)_initializeBridgeLocked:(std::shared_ptr<JSExecutorFactory>)executorFactory
|
|
694
|
-
parentInspectorTarget:(facebook::react::jsinspector_modern::
|
|
694
|
+
parentInspectorTarget:(facebook::react::jsinspector_modern::PageTarget *)parentInspectorTarget
|
|
695
695
|
{
|
|
696
696
|
std::lock_guard<std::mutex> guard(_moduleRegistryLock);
|
|
697
697
|
|
|
@@ -179,8 +179,8 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
|
|
|
179
179
|
|
|
180
180
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
181
181
|
{
|
|
182
|
-
if (_adapter
|
|
183
|
-
[_adapter.paperView removeReactSubview:
|
|
182
|
+
if (_adapter) {
|
|
183
|
+
[_adapter.paperView removeReactSubview:childComponentView];
|
|
184
184
|
} else {
|
|
185
185
|
[_viewsToBeUnmounted addObject:childComponentView];
|
|
186
186
|
}
|
|
@@ -1231,10 +1231,6 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
|
|
1231
1231
|
public void run() {
|
|
1232
1232
|
mMountNotificationScheduled.set(false);
|
|
1233
1233
|
|
|
1234
|
-
if (mDestroyed) {
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
1234
|
final @Nullable Binding binding = mBinding;
|
|
1239
1235
|
if (mountItems == null || binding == null) {
|
|
1240
1236
|
return;
|
package/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessDevSupportManager.java
CHANGED
|
@@ -119,7 +119,7 @@ class BridgelessDevSupportManager extends DevSupportManagerBase {
|
|
|
119
119
|
|
|
120
120
|
@Override
|
|
121
121
|
public void onJSBundleLoadedFromServer() {
|
|
122
|
-
|
|
122
|
+
// Not implemented
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
@Override
|
|
@@ -54,7 +54,7 @@ void Instance::initializeBridge(
|
|
|
54
54
|
std::shared_ptr<JSExecutorFactory> jsef,
|
|
55
55
|
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
56
56
|
std::shared_ptr<ModuleRegistry> moduleRegistry,
|
|
57
|
-
jsinspector_modern::
|
|
57
|
+
jsinspector_modern::PageTarget* parentInspectorTarget) {
|
|
58
58
|
callback_ = std::move(callback);
|
|
59
59
|
moduleRegistry_ = std::move(moduleRegistry);
|
|
60
60
|
parentInspectorTarget_ = parentInspectorTarget;
|
|
@@ -47,7 +47,7 @@ class RN_EXPORT Instance : private jsinspector_modern::InstanceTargetDelegate {
|
|
|
47
47
|
std::shared_ptr<JSExecutorFactory> jsef,
|
|
48
48
|
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
49
49
|
std::shared_ptr<ModuleRegistry> moduleRegistry,
|
|
50
|
-
jsinspector_modern::
|
|
50
|
+
jsinspector_modern::PageTarget* inspectorTarget = nullptr);
|
|
51
51
|
|
|
52
52
|
void initializeRuntime();
|
|
53
53
|
|
|
@@ -178,7 +178,7 @@ class RN_EXPORT Instance : private jsinspector_modern::InstanceTargetDelegate {
|
|
|
178
178
|
std::shared_ptr<JSCallInvoker> jsCallInvoker_ =
|
|
179
179
|
std::make_shared<JSCallInvoker>();
|
|
180
180
|
|
|
181
|
-
jsinspector_modern::
|
|
181
|
+
jsinspector_modern::PageTarget* parentInspectorTarget_{nullptr};
|
|
182
182
|
jsinspector_modern::InstanceTarget* inspectorTarget_{nullptr};
|
|
183
183
|
jsinspector_modern::RuntimeTarget* runtimeInspectorTarget_{nullptr};
|
|
184
184
|
};
|
|
@@ -102,7 +102,7 @@ class HermesRuntimeAgentDelegate::Impl final : public RuntimeAgentDelegate {
|
|
|
102
102
|
* \param executionContextDescription A description of the execution context
|
|
103
103
|
* represented by this runtime. This is used for disambiguating the
|
|
104
104
|
* source/destination of CDP messages when there are multiple runtimes
|
|
105
|
-
* (concurrently or over the life of a
|
|
105
|
+
* (concurrently or over the life of a Page).
|
|
106
106
|
* \param runtime The HermesRuntime that this agent is attached to.
|
|
107
107
|
* \param runtimeExecutor A callback for scheduling work on the JS thread.
|
|
108
108
|
* \c runtimeExecutor may drop scheduled work if the runtime is destroyed
|
|
@@ -155,7 +155,7 @@ class HermesRuntimeAgentDelegate::Impl final : public RuntimeAgentDelegate {
|
|
|
155
155
|
// TODO: Change to string::starts_with when we're on C++20.
|
|
156
156
|
if (req.method.rfind("Log.", 0) == 0) {
|
|
157
157
|
// Since we know Hermes doesn't do anything useful with Log messages, but
|
|
158
|
-
// our containing
|
|
158
|
+
// our containing PageAgent will, just bail out early.
|
|
159
159
|
// TODO: We need a way to negotiate this more dynamically with Hermes
|
|
160
160
|
// through the API.
|
|
161
161
|
return false;
|
|
@@ -33,7 +33,7 @@ class HermesRuntimeAgentDelegate : public RuntimeAgentDelegate {
|
|
|
33
33
|
* \param executionContextDescription A description of the execution context
|
|
34
34
|
* represented by this runtime. This is used for disambiguating the
|
|
35
35
|
* source/destination of CDP messages when there are multiple runtimes
|
|
36
|
-
* (concurrently or over the life of a
|
|
36
|
+
* (concurrently or over the life of a Page).
|
|
37
37
|
* \param runtime The HermesRuntime that this agent is attached to.
|
|
38
38
|
* \param runtimeExecutor A callback for scheduling work on the JS thread.
|
|
39
39
|
* \c runtimeExecutor may drop scheduled work if the runtime is destroyed
|
|
@@ -8,11 +8,11 @@ A debuggable entity that a debugger frontend can connect to.
|
|
|
8
8
|
|
|
9
9
|
### Target Delegate
|
|
10
10
|
|
|
11
|
-
An interface between a Target class and the underlying debuggable entity. For example,
|
|
11
|
+
An interface between a Target class and the underlying debuggable entity. For example, PageTargetDelegate is used by PageTarget to send page-related events to the native platform implementation.
|
|
12
12
|
|
|
13
13
|
### Target Controller
|
|
14
14
|
|
|
15
|
-
A private interface exposed by a Target class to its Sessions/Agents. For example,
|
|
15
|
+
A private interface exposed by a Target class to its Sessions/Agents. For example, PageTargetController is used by PageAgent to safely access the page's PageTargetDelegate, without exposing PageTarget's other private state.
|
|
16
16
|
|
|
17
17
|
### Session
|
|
18
18
|
|
|
@@ -47,7 +47,7 @@ class InstanceAgent final {
|
|
|
47
47
|
bool handleRequest(const cdp::PreparsedRequest& req);
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Replace the current RuntimeAgent
|
|
50
|
+
* Replace the current RuntimeAgent pageAgent_ with a new one
|
|
51
51
|
* connected to the new RuntimeTarget.
|
|
52
52
|
* \param runtime The new runtime target. May be nullptr to indicate
|
|
53
53
|
* there's no current debuggable runtime.
|
|
@@ -47,7 +47,7 @@ InstanceTarget::~InstanceTarget() {
|
|
|
47
47
|
// they hold an InstanceTarget& that we must guarantee is valid.
|
|
48
48
|
assert(
|
|
49
49
|
agents_.empty() &&
|
|
50
|
-
"InstanceAgent objects must be destroyed before their InstanceTarget. Did you call
|
|
50
|
+
"InstanceAgent objects must be destroyed before their InstanceTarget. Did you call PageTarget::unregisterInstance()?");
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
RuntimeTarget& InstanceTarget::registerRuntime(
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
#include <folly/dynamic.h>
|
|
9
9
|
#include <folly/json.h>
|
|
10
|
-
#include <jsinspector-modern/HostAgent.h>
|
|
11
|
-
#include <jsinspector-modern/HostTarget.h>
|
|
12
10
|
#include <jsinspector-modern/InstanceAgent.h>
|
|
11
|
+
#include <jsinspector-modern/PageAgent.h>
|
|
12
|
+
#include <jsinspector-modern/PageTarget.h>
|
|
13
13
|
|
|
14
14
|
#include <chrono>
|
|
15
15
|
|
|
@@ -27,19 +27,19 @@ namespace facebook::react::jsinspector_modern {
|
|
|
27
27
|
static constexpr auto kModernCDPBackendNotice =
|
|
28
28
|
ANSI_COLOR_BG_YELLOW ANSI_WEIGHT_BOLD
|
|
29
29
|
"NOTE:" ANSI_WEIGHT_RESET " You are using the " ANSI_STYLE_ITALIC
|
|
30
|
-
"modern" ANSI_STYLE_RESET " CDP backend for React Native (
|
|
30
|
+
"modern" ANSI_STYLE_RESET " CDP backend for React Native (PageTarget)."sv;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
PageAgent::PageAgent(
|
|
33
33
|
FrontendChannel frontendChannel,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
PageTargetController& targetController,
|
|
35
|
+
PageTarget::SessionMetadata sessionMetadata,
|
|
36
36
|
SessionState& sessionState)
|
|
37
37
|
: frontendChannel_(frontendChannel),
|
|
38
38
|
targetController_(targetController),
|
|
39
39
|
sessionMetadata_(std::move(sessionMetadata)),
|
|
40
40
|
sessionState_(sessionState) {}
|
|
41
41
|
|
|
42
|
-
void
|
|
42
|
+
void PageAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
43
43
|
bool shouldSendOKResponse = false;
|
|
44
44
|
bool isFinishedHandlingRequest = false;
|
|
45
45
|
|
|
@@ -113,7 +113,7 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
|
113
113
|
frontendChannel_(json);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
void
|
|
116
|
+
void PageAgent::sendInfoLogEntry(std::string_view text) {
|
|
117
117
|
frontendChannel_(
|
|
118
118
|
folly::toJson(folly::dynamic::object("method", "Log.entryAdded")(
|
|
119
119
|
"params",
|
|
@@ -127,7 +127,7 @@ void HostAgent::sendInfoLogEntry(std::string_view text) {
|
|
|
127
127
|
"level", "info")("text", text)))));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
void
|
|
130
|
+
void PageAgent::setCurrentInstanceAgent(
|
|
131
131
|
std::shared_ptr<InstanceAgent> instanceAgent) {
|
|
132
132
|
auto previousInstanceAgent = std::move(instanceAgent_);
|
|
133
133
|
instanceAgent_ = std::move(instanceAgent);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include "
|
|
10
|
+
#include "PageTarget.h"
|
|
11
11
|
#include "SessionState.h"
|
|
12
12
|
|
|
13
13
|
#include <jsinspector-modern/InspectorInterfaces.h>
|
|
@@ -19,32 +19,32 @@
|
|
|
19
19
|
|
|
20
20
|
namespace facebook::react::jsinspector_modern {
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class PageTarget;
|
|
23
23
|
class InstanceAgent;
|
|
24
24
|
class InstanceTarget;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* An Agent that handles requests from the Chrome DevTools Protocol for the
|
|
28
|
-
* given
|
|
28
|
+
* given page.
|
|
29
29
|
* The constructor, destructor and all public methods must be called on the
|
|
30
|
-
* same thread, which is also the thread where the associated
|
|
30
|
+
* same thread, which is also the thread where the associated PageTarget is
|
|
31
31
|
* constructed and managed.
|
|
32
32
|
*/
|
|
33
|
-
class
|
|
33
|
+
class PageAgent final {
|
|
34
34
|
public:
|
|
35
35
|
/**
|
|
36
36
|
* \param frontendChannel A channel used to send responses and events to the
|
|
37
37
|
* frontend.
|
|
38
|
-
* \param targetController An interface to the
|
|
38
|
+
* \param targetController An interface to the PageTarget that this agent is
|
|
39
39
|
* attached to. The caller is responsible for ensuring that the
|
|
40
|
-
*
|
|
40
|
+
* PageTargetDelegate and underlying PageTarget both outlive the agent.
|
|
41
41
|
* \param sessionMetadata Metadata about the session that created this agent.
|
|
42
42
|
* \param sessionState The state of the session that created this agent.
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
PageAgent(
|
|
45
45
|
FrontendChannel frontendChannel,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
PageTargetController& targetController,
|
|
47
|
+
PageTarget::SessionMetadata sessionMetadata,
|
|
48
48
|
SessionState& sessionState);
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -70,13 +70,13 @@ class HostAgent final {
|
|
|
70
70
|
* DevTools, the message will appear in the Console tab along with regular
|
|
71
71
|
* console messages. The difference between Log.entryAdded and
|
|
72
72
|
* Runtime.consoleAPICalled is that the latter requires an execution context
|
|
73
|
-
* ID, which does not exist at the
|
|
73
|
+
* ID, which does not exist at the Page level.
|
|
74
74
|
*/
|
|
75
75
|
void sendInfoLogEntry(std::string_view text);
|
|
76
76
|
|
|
77
77
|
FrontendChannel frontendChannel_;
|
|
78
|
-
|
|
79
|
-
const
|
|
78
|
+
PageTargetController& targetController_;
|
|
79
|
+
const PageTarget::SessionMetadata sessionMetadata_;
|
|
80
80
|
std::shared_ptr<InstanceAgent> instanceAgent_;
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
#include "
|
|
9
|
-
#include "HostAgent.h"
|
|
8
|
+
#include "PageTarget.h"
|
|
10
9
|
#include "InspectorInterfaces.h"
|
|
11
10
|
#include "InspectorUtilities.h"
|
|
12
11
|
#include "InstanceTarget.h"
|
|
12
|
+
#include "PageAgent.h"
|
|
13
13
|
#include "Parsing.h"
|
|
14
14
|
#include "SessionState.h"
|
|
15
15
|
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
namespace facebook::react::jsinspector_modern {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* A Session connected to a
|
|
25
|
-
*
|
|
24
|
+
* A Session connected to a PageTarget, passing CDP messages to and from a
|
|
25
|
+
* PageAgent which it owns.
|
|
26
26
|
*/
|
|
27
|
-
class
|
|
27
|
+
class PageTargetSession {
|
|
28
28
|
public:
|
|
29
|
-
explicit
|
|
29
|
+
explicit PageTargetSession(
|
|
30
30
|
std::unique_ptr<IRemoteConnection> remote,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
PageTargetController& targetController,
|
|
32
|
+
PageTarget::SessionMetadata sessionMetadata)
|
|
33
33
|
: remote_(std::make_shared<RAIIRemoteConnection>(std::move(remote))),
|
|
34
34
|
frontendChannel_(
|
|
35
35
|
[remoteWeak = std::weak_ptr(remote_)](std::string_view message) {
|
|
@@ -37,7 +37,7 @@ class HostTargetSession {
|
|
|
37
37
|
remote->onMessage(std::string(message));
|
|
38
38
|
}
|
|
39
39
|
}),
|
|
40
|
-
|
|
40
|
+
pageAgent_(
|
|
41
41
|
frontendChannel_,
|
|
42
42
|
targetController,
|
|
43
43
|
std::move(sessionMetadata),
|
|
@@ -67,7 +67,7 @@ class HostTargetSession {
|
|
|
67
67
|
// Catch exceptions that may arise from accessing dynamic params during
|
|
68
68
|
// request handling.
|
|
69
69
|
try {
|
|
70
|
-
|
|
70
|
+
pageAgent_.handleRequest(request);
|
|
71
71
|
} catch (const cdp::TypeError& e) {
|
|
72
72
|
frontendChannel_(folly::toJson(folly::dynamic::object("id", request.id)(
|
|
73
73
|
"error",
|
|
@@ -77,17 +77,17 @@ class HostTargetSession {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* Replace the current instance agent inside
|
|
80
|
+
* Replace the current instance agent inside pageAgent_ with a new one
|
|
81
81
|
* connected to the new InstanceTarget.
|
|
82
82
|
* \param instance The new instance target. May be nullptr to indicate
|
|
83
83
|
* there's no current instance.
|
|
84
84
|
*/
|
|
85
85
|
void setCurrentInstance(InstanceTarget* instance) {
|
|
86
86
|
if (instance) {
|
|
87
|
-
|
|
87
|
+
pageAgent_.setCurrentInstanceAgent(
|
|
88
88
|
instance->createAgent(frontendChannel_, state_));
|
|
89
89
|
} else {
|
|
90
|
-
|
|
90
|
+
pageAgent_.setCurrentInstanceAgent(nullptr);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -95,26 +95,26 @@ class HostTargetSession {
|
|
|
95
95
|
// Owned by this instance, but shared (weakly) with the frontend channel
|
|
96
96
|
std::shared_ptr<RAIIRemoteConnection> remote_;
|
|
97
97
|
FrontendChannel frontendChannel_;
|
|
98
|
-
|
|
98
|
+
PageAgent pageAgent_;
|
|
99
99
|
SessionState state_;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
std::shared_ptr<
|
|
103
|
-
|
|
102
|
+
std::shared_ptr<PageTarget> PageTarget::create(
|
|
103
|
+
PageTargetDelegate& delegate,
|
|
104
104
|
VoidExecutor executor) {
|
|
105
|
-
std::shared_ptr<
|
|
106
|
-
|
|
107
|
-
return
|
|
105
|
+
std::shared_ptr<PageTarget> pageTarget{new PageTarget(delegate)};
|
|
106
|
+
pageTarget->setExecutor(executor);
|
|
107
|
+
return pageTarget;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
PageTarget::PageTarget(PageTargetDelegate& delegate)
|
|
111
111
|
: delegate_(delegate),
|
|
112
112
|
executionContextManager_{std::make_shared<ExecutionContextManager>()} {}
|
|
113
113
|
|
|
114
|
-
std::unique_ptr<ILocalConnection>
|
|
114
|
+
std::unique_ptr<ILocalConnection> PageTarget::connect(
|
|
115
115
|
std::unique_ptr<IRemoteConnection> connectionToFrontend,
|
|
116
116
|
SessionMetadata sessionMetadata) {
|
|
117
|
-
auto session = std::make_shared<
|
|
117
|
+
auto session = std::make_shared<PageTargetSession>(
|
|
118
118
|
std::move(connectionToFrontend), controller_, std::move(sessionMetadata));
|
|
119
119
|
session->setCurrentInstance(currentInstance_.get());
|
|
120
120
|
sessions_.insert(std::weak_ptr(session));
|
|
@@ -122,44 +122,44 @@ std::unique_ptr<ILocalConnection> HostTarget::connect(
|
|
|
122
122
|
[session](std::string message) { (*session)(message); });
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
// Sessions are owned by InspectorPackagerConnection, not by
|
|
127
|
-
// they hold a
|
|
125
|
+
PageTarget::~PageTarget() {
|
|
126
|
+
// Sessions are owned by InspectorPackagerConnection, not by PageTarget, but
|
|
127
|
+
// they hold a PageTarget& that we must guarantee is valid.
|
|
128
128
|
assert(
|
|
129
129
|
sessions_.empty() &&
|
|
130
|
-
"
|
|
130
|
+
"PageTargetSession objects must be destroyed before their PageTarget. Did you call getInspectorInstance().removePage()?");
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
PageTargetDelegate::~PageTargetDelegate() {}
|
|
134
134
|
|
|
135
|
-
InstanceTarget&
|
|
135
|
+
InstanceTarget& PageTarget::registerInstance(InstanceTargetDelegate& delegate) {
|
|
136
136
|
assert(!currentInstance_ && "Only one instance allowed");
|
|
137
137
|
currentInstance_ = InstanceTarget::create(
|
|
138
138
|
executionContextManager_, delegate, makeVoidExecutor(executorFromThis()));
|
|
139
139
|
sessions_.forEach(
|
|
140
|
-
[currentInstance = &*currentInstance_](
|
|
140
|
+
[currentInstance = &*currentInstance_](PageTargetSession& session) {
|
|
141
141
|
session.setCurrentInstance(currentInstance);
|
|
142
142
|
});
|
|
143
143
|
return *currentInstance_;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
void
|
|
146
|
+
void PageTarget::unregisterInstance(InstanceTarget& instance) {
|
|
147
147
|
assert(
|
|
148
148
|
currentInstance_ && currentInstance_.get() == &instance &&
|
|
149
149
|
"Invalid unregistration");
|
|
150
150
|
sessions_.forEach(
|
|
151
|
-
[](
|
|
151
|
+
[](PageTargetSession& session) { session.setCurrentInstance(nullptr); });
|
|
152
152
|
currentInstance_.reset();
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
PageTargetController::PageTargetController(PageTarget& target)
|
|
156
156
|
: target_(target) {}
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
PageTargetDelegate& PageTargetController::getDelegate() {
|
|
159
159
|
return target_.getDelegate();
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
bool
|
|
162
|
+
bool PageTargetController::hasInstance() const {
|
|
163
163
|
return target_.hasInstance();
|
|
164
164
|
}
|
|
165
165
|
|