react-native 0.74.0-nightly-20240129-39cb02f6f → 1000.0.0
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/Animated/NativeAnimatedHelper.js +1 -1
- package/Libraries/Animated/nodes/AnimatedStyle.js +1 -1
- package/Libraries/Animated/useAnimatedProps.js +1 -1
- package/Libraries/AppDelegate/RCTAppDelegate.mm +2 -1
- package/Libraries/Blob/React-RCTBlob.podspec +1 -0
- package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroid.android.js +69 -0
- package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroid.d.ts +24 -0
- package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroid.js +33 -0
- package/Libraries/Components/PopupMenuAndroid/PopupMenuAndroidNativeComponent.js +13 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -3
- package/Libraries/Core/registerCallableModule.js +42 -0
- package/Libraries/Image/RCTImageLoader.mm +4 -11
- package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
- package/Libraries/ReactNative/BridgelessUIManager.js +31 -13
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -1
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -33
- package/Libraries/ReactNative/__mocks__/FabricUIManager.js +12 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +24543 -21110
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +4104 -3058
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4352 -3273
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +25038 -21457
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3721 -2600
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4024 -2869
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +43 -4
- package/Libraries/WebPerformance/Performance.js +1 -1
- package/React/Base/RCTBridge+Private.h +14 -0
- package/React/Base/RCTBridge.mm +6 -0
- package/React/Base/RCTKeyCommands.m +12 -1
- package/React/Base/RCTVersion.m +3 -3
- package/React/CoreModules/RCTAlertController.mm +2 -3
- package/React/CoreModules/RCTAppearance.mm +1 -1
- package/React/CoreModules/React-CoreModules.podspec +1 -0
- package/React/CxxBridge/RCTCxxBridge.mm +21 -3
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +22 -1
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +13 -2
- package/React/Fabric/RCTConversions.h +2 -18
- package/React/React-RCTFabric.podspec +1 -0
- package/React-Core.podspec +1 -3
- package/ReactAndroid/api/ReactAndroid.api +53 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/animated/DecayAnimation.java +2 -0
- package/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/animated/ModulusAnimatedNode.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/animated/ObjectAnimatedNode.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/animated/SpringAnimation.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +1 -3
- package/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt +5 -2
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +11 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +11 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +12 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/JSCExecutor.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +3 -3
- package/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java +3 -0
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +13 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +7 -0
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +11 -0
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +24 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/image/ScaleTypeStartInside.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/popupmenu/PopupMenuSelectionEvent.kt +37 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/popupmenu/ReactPopupMenuContainer.kt +49 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/popupmenu/ReactPopupMenuManager.kt +54 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +2 -2
- package/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp +2 -0
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +9 -1
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +4 -1
- package/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.cpp +7 -1
- package/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.h +2 -1
- package/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +16 -10
- package/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp +0 -3
- package/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.h +0 -1
- package/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultComponentsRegistry.cpp +7 -6
- package/ReactCommon/cxxreact/Instance.cpp +34 -18
- package/ReactCommon/cxxreact/Instance.h +13 -2
- package/ReactCommon/cxxreact/React-cxxreact.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/jsinspector-modern/InstanceAgent.cpp +34 -0
- package/ReactCommon/jsinspector-modern/InstanceAgent.h +54 -0
- package/ReactCommon/jsinspector-modern/InstanceTarget.cpp +25 -0
- package/ReactCommon/jsinspector-modern/InstanceTarget.h +58 -0
- package/ReactCommon/jsinspector-modern/PageAgent.cpp +65 -0
- package/ReactCommon/jsinspector-modern/PageAgent.h +13 -0
- package/ReactCommon/jsinspector-modern/PageTarget.cpp +41 -0
- package/ReactCommon/jsinspector-modern/PageTarget.h +28 -1
- package/ReactCommon/jsinspector-modern/React-jsinspector.podspec +12 -1
- package/ReactCommon/jsinspector-modern/ReactCdp.h +1 -0
- package/ReactCommon/jsinspector-modern/tests/InspectorMocks.h +2 -0
- package/ReactCommon/jsinspector-modern/tests/PageTargetTest.cpp +164 -10
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +5 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +6 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +18 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +3 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +5 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +2 -1
- package/ReactCommon/react/featureflags/tests/ReactNativeFeatureFlagsTest.cpp +4 -0
- package/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec +1 -0
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +6 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +3 -1
- package/ReactCommon/react/renderer/attributedstring/primitives.h +0 -86
- package/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h +0 -16
- package/ReactCommon/react/renderer/components/view/CSSTokenizer.cpp +187 -0
- package/ReactCommon/react/renderer/components/view/CSSTokenizer.h +101 -0
- package/ReactCommon/react/renderer/components/view/tests/CSSTokenizerTest.cpp +144 -0
- package/ReactCommon/react/renderer/core/ComponentDescriptor.h +0 -1
- package/ReactCommon/react/renderer/core/LayoutPrimitives.h +0 -17
- package/ReactCommon/react/renderer/core/propsConversions.h +0 -1
- package/ReactCommon/react/renderer/graphics/Color.h +7 -3
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +6 -1
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +55 -15
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +132 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.h +4 -18
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.mm +73 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.h +8 -2
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.mm +14 -3
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextPrimitivesConversions.h +4 -19
- package/ReactCommon/react/runtime/ReactInstance.cpp +15 -2
- package/ReactCommon/react/runtime/ReactInstance.h +13 -2
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +5 -3
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h +3 -1
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +10 -2
- package/ReactCommon/react/test_utils/ios/Shims/ShimRCTInstance.mm +5 -2
- package/ReactCommon/react/utils/hash_combine.h +8 -6
- package/gradle/libs.versions.toml +1 -1
- package/index.js +9 -0
- package/package.json +9 -9
- 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/src/private/featureflags/NativeReactNativeFeatureFlags.js +2 -1
- package/src/private/featureflags/ReactNativeFeatureFlags.js +42 -1
- package/src/private/specs/components/PopupMenuAndroidNativeComponent.js +47 -0
- package/template/package.json +5 -5
- package/ReactAndroid/src/main/jni/react/jni/OnLoad.h +0 -16
package/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.cpp
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated SignedSource<<
|
|
7
|
+
* @generated SignedSource<<5f99c47d357e45524b359e6517d1f2eb>>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -51,4 +51,10 @@ bool ReactNativeFeatureFlagsProviderHolder::batchRenderingUpdatesInEventLoop() {
|
|
|
51
51
|
return method(javaProvider_);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
bool ReactNativeFeatureFlagsProviderHolder::enableSpannableBuildingUnification() {
|
|
55
|
+
static const auto method =
|
|
56
|
+
getJClass()->getMethod<jboolean()>("enableSpannableBuildingUnification");
|
|
57
|
+
return method(javaProvider_);
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
} // namespace facebook::react
|
package/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.h
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated SignedSource<<
|
|
7
|
+
* @generated SignedSource<<6aaa06ae0c12de2f432374d0cd048460>>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -39,6 +39,7 @@ class ReactNativeFeatureFlagsProviderHolder
|
|
|
39
39
|
bool useModernRuntimeScheduler() override;
|
|
40
40
|
bool enableMicrotasks() override;
|
|
41
41
|
bool batchRenderingUpdatesInEventLoop() override;
|
|
42
|
+
bool enableSpannableBuildingUnification() override;
|
|
42
43
|
|
|
43
44
|
private:
|
|
44
45
|
jni::global_ref<jobject> javaProvider_;
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
#include <glog/logging.h>
|
|
11
11
|
|
|
12
12
|
#include <fb/glog_init.h>
|
|
13
|
-
#include <fb/log.h>
|
|
14
13
|
#include <fbjni/fbjni.h>
|
|
15
14
|
|
|
16
15
|
#include "CatalystInstanceImpl.h"
|
|
@@ -27,27 +26,29 @@
|
|
|
27
26
|
#define WITH_GLOGINIT 1
|
|
28
27
|
#endif
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
#ifdef WITH_XPLATINIT
|
|
30
|
+
#include <fb/xplat_init.h>
|
|
31
|
+
#endif
|
|
31
32
|
|
|
32
33
|
namespace facebook::react {
|
|
33
34
|
|
|
34
35
|
namespace {
|
|
35
36
|
|
|
36
|
-
struct JavaJSExecutor : public JavaClass<JavaJSExecutor> {
|
|
37
|
+
struct JavaJSExecutor : public jni::JavaClass<JavaJSExecutor> {
|
|
37
38
|
static constexpr auto kJavaDescriptor =
|
|
38
39
|
"Lcom/facebook/react/bridge/JavaJSExecutor;";
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
class ProxyJavaScriptExecutorHolder
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
class ProxyJavaScriptExecutorHolder
|
|
43
|
+
: public jni::
|
|
44
|
+
HybridClass<ProxyJavaScriptExecutorHolder, JavaScriptExecutorHolder> {
|
|
44
45
|
public:
|
|
45
46
|
static constexpr auto kJavaDescriptor =
|
|
46
47
|
"Lcom/facebook/react/bridge/ProxyJavaScriptExecutor;";
|
|
47
48
|
|
|
48
|
-
static local_ref<jhybriddata> initHybrid(
|
|
49
|
-
alias_ref<jclass>,
|
|
50
|
-
alias_ref<JavaJSExecutor::javaobject> executorInstance) {
|
|
49
|
+
static jni::local_ref<jhybriddata> initHybrid(
|
|
50
|
+
jni::alias_ref<jclass>,
|
|
51
|
+
jni::alias_ref<JavaJSExecutor::javaobject> executorInstance) {
|
|
51
52
|
return makeCxxInstance(std::make_shared<ProxyExecutorOneTimeFactory>(
|
|
52
53
|
make_global(executorInstance)));
|
|
53
54
|
}
|
|
@@ -67,11 +68,16 @@ class ProxyJavaScriptExecutorHolder : public HybridClass<
|
|
|
67
68
|
} // namespace
|
|
68
69
|
|
|
69
70
|
extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|
70
|
-
|
|
71
|
+
#ifdef WITH_XPLATINIT
|
|
72
|
+
return facebook::xplat::initialize(vm, [] {
|
|
73
|
+
#else
|
|
74
|
+
return jni::initialize(vm, [] {
|
|
75
|
+
#endif
|
|
71
76
|
#if WITH_GLOGINIT
|
|
72
77
|
gloginit::initialize();
|
|
73
78
|
FLAGS_minloglevel = 0;
|
|
74
79
|
#endif
|
|
80
|
+
|
|
75
81
|
ProxyJavaScriptExecutorHolder::registerNatives();
|
|
76
82
|
CatalystInstanceImpl::registerNatives();
|
|
77
83
|
CxxModuleWrapperBase::registerNatives();
|
|
@@ -11,10 +11,7 @@
|
|
|
11
11
|
#include <cxxreact/ModuleRegistry.h>
|
|
12
12
|
#include <cxxreact/SystraceSection.h>
|
|
13
13
|
#include <fb/assert.h>
|
|
14
|
-
// #include <fb/Environment.h>
|
|
15
14
|
#include <folly/json.h>
|
|
16
|
-
// #include <jni/LocalReference.h>
|
|
17
|
-
// #include <jni/LocalString.h>
|
|
18
15
|
|
|
19
16
|
#include <memory>
|
|
20
17
|
|
|
@@ -25,12 +25,13 @@ std::shared_ptr<const ComponentDescriptorProviderRegistry>
|
|
|
25
25
|
DefaultComponentsRegistry::sharedProviderRegistry() {
|
|
26
26
|
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if (DefaultComponentsRegistry::registerComponentDescriptorsFromEntryPoint) {
|
|
29
|
+
(DefaultComponentsRegistry::registerComponentDescriptorsFromEntryPoint)(
|
|
30
|
+
providerRegistry);
|
|
31
|
+
} else {
|
|
32
|
+
LOG(WARNING)
|
|
33
|
+
<< "Custom component descriptors were not configured from JNI_OnLoad";
|
|
34
|
+
}
|
|
34
35
|
|
|
35
36
|
return providerRegistry;
|
|
36
37
|
}
|
|
@@ -38,30 +38,46 @@ Instance::~Instance() {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
void Instance::unregisterFromInspector() {
|
|
42
|
+
if (inspectorTarget_) {
|
|
43
|
+
assert(parentInspectorTarget_);
|
|
44
|
+
parentInspectorTarget_->unregisterInstance(*inspectorTarget_);
|
|
45
|
+
parentInspectorTarget_ = nullptr;
|
|
46
|
+
inspectorTarget_ = nullptr;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
void Instance::initializeBridge(
|
|
42
51
|
std::unique_ptr<InstanceCallback> callback,
|
|
43
52
|
std::shared_ptr<JSExecutorFactory> jsef,
|
|
44
53
|
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
45
|
-
std::shared_ptr<ModuleRegistry> moduleRegistry
|
|
54
|
+
std::shared_ptr<ModuleRegistry> moduleRegistry,
|
|
55
|
+
jsinspector_modern::PageTarget* parentInspectorTarget) {
|
|
46
56
|
callback_ = std::move(callback);
|
|
47
57
|
moduleRegistry_ = std::move(moduleRegistry);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
parentInspectorTarget_ = parentInspectorTarget;
|
|
59
|
+
jsQueue->runOnQueueSync(
|
|
60
|
+
[this, &jsef, jsQueue, parentInspectorTarget]() mutable {
|
|
61
|
+
nativeToJsBridge_ = std::make_shared<NativeToJsBridge>(
|
|
62
|
+
jsef.get(), moduleRegistry_, jsQueue, callback_);
|
|
63
|
+
|
|
64
|
+
nativeToJsBridge_->initializeRuntime();
|
|
65
|
+
|
|
66
|
+
if (parentInspectorTarget) {
|
|
67
|
+
inspectorTarget_ = &parentInspectorTarget->registerInstance(*this);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* After NativeToJsBridge is created, the jsi::Runtime should exist.
|
|
72
|
+
* Also, the JS message queue thread exists. So, it's safe to
|
|
73
|
+
* schedule all queued up js Calls.
|
|
74
|
+
*/
|
|
75
|
+
jsCallInvoker_->setNativeToJsBridgeAndFlushCalls(nativeToJsBridge_);
|
|
76
|
+
|
|
77
|
+
std::scoped_lock lock(m_syncMutex);
|
|
78
|
+
m_syncReady = true;
|
|
79
|
+
m_syncCV.notify_all();
|
|
80
|
+
});
|
|
65
81
|
|
|
66
82
|
CHECK(nativeToJsBridge_);
|
|
67
83
|
}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
#include <ReactCommon/RuntimeExecutor.h>
|
|
16
16
|
#include <cxxreact/NativeToJsBridge.h>
|
|
17
|
+
#include <jsinspector-modern/ReactCdp.h>
|
|
17
18
|
|
|
18
19
|
#ifndef RN_EXPORT
|
|
19
20
|
#define RN_EXPORT __attribute__((visibility("default")))
|
|
@@ -38,14 +39,15 @@ struct InstanceCallback {
|
|
|
38
39
|
virtual void decrementPendingJSCalls() {}
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
class RN_EXPORT Instance {
|
|
42
|
+
class RN_EXPORT Instance : private jsinspector_modern::InstanceTargetDelegate {
|
|
42
43
|
public:
|
|
43
44
|
~Instance();
|
|
44
45
|
void initializeBridge(
|
|
45
46
|
std::unique_ptr<InstanceCallback> callback,
|
|
46
47
|
std::shared_ptr<JSExecutorFactory> jsef,
|
|
47
48
|
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
48
|
-
std::shared_ptr<ModuleRegistry> moduleRegistry
|
|
49
|
+
std::shared_ptr<ModuleRegistry> moduleRegistry,
|
|
50
|
+
jsinspector_modern::PageTarget* inspectorTarget = nullptr);
|
|
49
51
|
|
|
50
52
|
void initializeRuntime();
|
|
51
53
|
|
|
@@ -132,6 +134,12 @@ class RN_EXPORT Instance {
|
|
|
132
134
|
*/
|
|
133
135
|
RuntimeExecutor getRuntimeExecutor();
|
|
134
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Unregisters the instance from the inspector. This method must be called
|
|
139
|
+
* on the main (non-JS) thread.
|
|
140
|
+
*/
|
|
141
|
+
void unregisterFromInspector();
|
|
142
|
+
|
|
135
143
|
private:
|
|
136
144
|
void callNativeModules(folly::dynamic&& calls, bool isEndOfBatch);
|
|
137
145
|
void loadBundle(
|
|
@@ -169,6 +177,9 @@ class RN_EXPORT Instance {
|
|
|
169
177
|
|
|
170
178
|
std::shared_ptr<JSCallInvoker> jsCallInvoker_ =
|
|
171
179
|
std::make_shared<JSCallInvoker>();
|
|
180
|
+
|
|
181
|
+
jsinspector_modern::PageTarget* parentInspectorTarget_{nullptr};
|
|
182
|
+
jsinspector_modern::InstanceTarget* inspectorTarget_{nullptr};
|
|
172
183
|
};
|
|
173
184
|
|
|
174
185
|
} // namespace facebook::react
|
|
@@ -45,7 +45,7 @@ Pod::Spec.new do |s|
|
|
|
45
45
|
s.dependency "fmt", "9.1.0"
|
|
46
46
|
s.dependency "RCT-Folly", folly_version
|
|
47
47
|
s.dependency "glog"
|
|
48
|
-
s
|
|
48
|
+
add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
|
|
49
49
|
s.dependency "React-callinvoker", version
|
|
50
50
|
s.dependency "React-runtimeexecutor", version
|
|
51
51
|
s.dependency "React-perflogger", version
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated by scripts/set-rn-version.js
|
|
7
|
+
* @generated by scripts/releases/set-rn-version.js
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
#pragma once
|
|
@@ -18,7 +18,7 @@ constexpr struct {
|
|
|
18
18
|
int32_t Major = 0;
|
|
19
19
|
int32_t Minor = 74;
|
|
20
20
|
int32_t Patch = 0;
|
|
21
|
-
std::string_view Prerelease = "nightly-
|
|
21
|
+
std::string_view Prerelease = "nightly-20240131-82e9a5e4f";
|
|
22
22
|
} ReactNativeVersion;
|
|
23
23
|
|
|
24
24
|
} // namespace facebook::react
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include <jsinspector-modern/InstanceAgent.h>
|
|
9
|
+
|
|
10
|
+
namespace facebook::react::jsinspector_modern {
|
|
11
|
+
|
|
12
|
+
InstanceAgent::InstanceAgent(
|
|
13
|
+
FrontendChannel frontendChannel,
|
|
14
|
+
InstanceTarget& target)
|
|
15
|
+
: frontendChannel_(frontendChannel), target_(target) {
|
|
16
|
+
(void)target_;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bool InstanceAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
20
|
+
// NOTE: Our implementation of @cdp Runtime.getHeapUsage is a stub.
|
|
21
|
+
if (req.method == "Runtime.getHeapUsage") {
|
|
22
|
+
folly::dynamic res = folly::dynamic::object("id", req.id)(
|
|
23
|
+
"result", folly::dynamic::object("usedSize", 0)("totalSize", 0));
|
|
24
|
+
frontendChannel_(folly::toJson(res));
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
int InstanceAgent::getExecutionContextId() const {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <jsinspector-modern/InspectorInterfaces.h>
|
|
11
|
+
#include <jsinspector-modern/Parsing.h>
|
|
12
|
+
#include <functional>
|
|
13
|
+
|
|
14
|
+
namespace facebook::react::jsinspector_modern {
|
|
15
|
+
|
|
16
|
+
class InstanceTarget;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An Agent that handles requests from the Chrome DevTools Protocol for the
|
|
20
|
+
* given InstanceTarget.
|
|
21
|
+
*/
|
|
22
|
+
class InstanceAgent {
|
|
23
|
+
public:
|
|
24
|
+
/**
|
|
25
|
+
* \param frontendChannel A channel used to send responses and events to the
|
|
26
|
+
* frontend.
|
|
27
|
+
* \param target The InstanceTarget that this agent is attached to. The
|
|
28
|
+
* caller is responsible for ensuring that the InstanceTarget outlives this
|
|
29
|
+
* object.
|
|
30
|
+
*/
|
|
31
|
+
explicit InstanceAgent(
|
|
32
|
+
FrontendChannel frontendChannel,
|
|
33
|
+
InstanceTarget& target);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Handle a CDP request. The response will be sent over the provided
|
|
37
|
+
* \c FrontendChannel synchronously or asynchronously.
|
|
38
|
+
* \param req The parsed request.
|
|
39
|
+
*/
|
|
40
|
+
bool handleRequest(const cdp::PreparsedRequest& req);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get the ID of the execution context that this agent is associated with.
|
|
44
|
+
* \see
|
|
45
|
+
* https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-ExecutionContextId
|
|
46
|
+
*/
|
|
47
|
+
int getExecutionContextId() const;
|
|
48
|
+
|
|
49
|
+
private:
|
|
50
|
+
FrontendChannel frontendChannel_;
|
|
51
|
+
InstanceTarget& target_;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "InstanceAgent.h"
|
|
9
|
+
|
|
10
|
+
#include <jsinspector-modern/InstanceTarget.h>
|
|
11
|
+
|
|
12
|
+
namespace facebook::react::jsinspector_modern {
|
|
13
|
+
|
|
14
|
+
InstanceTarget::InstanceTarget(InstanceTargetDelegate& delegate)
|
|
15
|
+
: delegate_(delegate) {
|
|
16
|
+
(void)delegate_;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
InstanceTargetDelegate::~InstanceTargetDelegate() {}
|
|
20
|
+
|
|
21
|
+
std::unique_ptr<InstanceAgent> InstanceTarget::createAgent(
|
|
22
|
+
FrontendChannel channel) {
|
|
23
|
+
return std::make_unique<InstanceAgent>(channel, *this);
|
|
24
|
+
}
|
|
25
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <jsinspector-modern/InspectorInterfaces.h>
|
|
11
|
+
|
|
12
|
+
#include <list>
|
|
13
|
+
#include <optional>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react::jsinspector_modern {
|
|
16
|
+
|
|
17
|
+
class InstanceAgent;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Receives events from an InstanceTarget. This is a shared interface that
|
|
21
|
+
* each React Native platform needs to implement in order to integrate with
|
|
22
|
+
* the debugging stack.
|
|
23
|
+
*/
|
|
24
|
+
class InstanceTargetDelegate {
|
|
25
|
+
public:
|
|
26
|
+
InstanceTargetDelegate() = default;
|
|
27
|
+
InstanceTargetDelegate(const InstanceTargetDelegate&) = delete;
|
|
28
|
+
InstanceTargetDelegate(InstanceTargetDelegate&&) = default;
|
|
29
|
+
InstanceTargetDelegate& operator=(const InstanceTargetDelegate&) = delete;
|
|
30
|
+
InstanceTargetDelegate& operator=(InstanceTargetDelegate&&) = default;
|
|
31
|
+
|
|
32
|
+
virtual ~InstanceTargetDelegate();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A Target that represents a single instance of React Native.
|
|
37
|
+
*/
|
|
38
|
+
class InstanceTarget {
|
|
39
|
+
public:
|
|
40
|
+
/**
|
|
41
|
+
* \param delegate The object that will receive events from this target.
|
|
42
|
+
* The caller is responsible for ensuring that the delegate outlives this
|
|
43
|
+
* object.
|
|
44
|
+
*/
|
|
45
|
+
explicit InstanceTarget(InstanceTargetDelegate& delegate);
|
|
46
|
+
|
|
47
|
+
InstanceTarget(const InstanceTarget&) = delete;
|
|
48
|
+
InstanceTarget(InstanceTarget&&) = delete;
|
|
49
|
+
InstanceTarget& operator=(const InstanceTarget&) = delete;
|
|
50
|
+
InstanceTarget& operator=(InstanceTarget&&) = delete;
|
|
51
|
+
|
|
52
|
+
std::unique_ptr<InstanceAgent> createAgent(FrontendChannel channel);
|
|
53
|
+
|
|
54
|
+
private:
|
|
55
|
+
InstanceTargetDelegate& delegate_;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#include <folly/dynamic.h>
|
|
9
9
|
#include <folly/json.h>
|
|
10
|
+
#include <jsinspector-modern/InstanceAgent.h>
|
|
10
11
|
#include <jsinspector-modern/PageAgent.h>
|
|
11
12
|
#include <jsinspector-modern/PageTarget.h>
|
|
12
13
|
|
|
@@ -70,6 +71,38 @@ void PageAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
if (req.method == "Runtime.enable") {
|
|
75
|
+
runtimeEnabled_ = true;
|
|
76
|
+
|
|
77
|
+
folly::dynamic res = folly::dynamic::object("id", req.id)(
|
|
78
|
+
"result", folly::dynamic::object());
|
|
79
|
+
std::string json = folly::toJson(res);
|
|
80
|
+
frontendChannel_(json);
|
|
81
|
+
|
|
82
|
+
if (instanceAgent_) {
|
|
83
|
+
folly::dynamic params = folly::dynamic::object(
|
|
84
|
+
"context",
|
|
85
|
+
folly::dynamic::object("id", instanceAgent_->getExecutionContextId())(
|
|
86
|
+
"origin", "")("name", "React Native"));
|
|
87
|
+
folly::dynamic contextCreated = folly::dynamic::object(
|
|
88
|
+
"method", "Runtime.executionContextCreated")("params", params);
|
|
89
|
+
frontendChannel_(folly::toJson(contextCreated));
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (req.method == "Runtime.disable") {
|
|
94
|
+
runtimeEnabled_ = false;
|
|
95
|
+
folly::dynamic res = folly::dynamic::object("id", req.id)(
|
|
96
|
+
"result", folly::dynamic::object());
|
|
97
|
+
std::string json = folly::toJson(res);
|
|
98
|
+
frontendChannel_(json);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (instanceAgent_ && instanceAgent_->handleRequest(req)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
73
106
|
folly::dynamic res = folly::dynamic::object("id", req.id)(
|
|
74
107
|
"error",
|
|
75
108
|
folly::dynamic::object("code", -32601)(
|
|
@@ -92,4 +125,36 @@ void PageAgent::sendInfoLogEntry(std::string_view text) {
|
|
|
92
125
|
"level", "info")("text", text)))));
|
|
93
126
|
}
|
|
94
127
|
|
|
128
|
+
void PageAgent::setCurrentInstanceAgent(
|
|
129
|
+
std::unique_ptr<InstanceAgent> instanceAgent) {
|
|
130
|
+
auto previousInstanceAgent = std::move(instanceAgent_);
|
|
131
|
+
instanceAgent_ = std::move(instanceAgent);
|
|
132
|
+
if (!runtimeEnabled_) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (previousInstanceAgent != nullptr) {
|
|
136
|
+
auto executionContextId = previousInstanceAgent->getExecutionContextId();
|
|
137
|
+
folly::dynamic contextDestroyed =
|
|
138
|
+
folly::dynamic::object("method", "Runtime.executionContextDestroyed")(
|
|
139
|
+
"params",
|
|
140
|
+
folly::dynamic::object("executionContextId", executionContextId));
|
|
141
|
+
frontendChannel_(folly::toJson(contextDestroyed));
|
|
142
|
+
|
|
143
|
+
// Because we can only have a single instance, we can report all contexts
|
|
144
|
+
// as cleared.
|
|
145
|
+
folly::dynamic contextsCleared =
|
|
146
|
+
folly::dynamic::object("method", "Runtime.executionContextsCleared");
|
|
147
|
+
frontendChannel_(folly::toJson(contextsCleared));
|
|
148
|
+
}
|
|
149
|
+
if (instanceAgent_) {
|
|
150
|
+
folly::dynamic params = folly::dynamic::object(
|
|
151
|
+
"context",
|
|
152
|
+
folly::dynamic::object("id", instanceAgent_->getExecutionContextId())(
|
|
153
|
+
"origin", "")("name", "React Native"));
|
|
154
|
+
folly::dynamic contextCreated = folly::dynamic::object(
|
|
155
|
+
"method", "Runtime.executionContextCreated")("params", params);
|
|
156
|
+
frontendChannel_(folly::toJson(contextCreated));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
95
160
|
} // namespace facebook::react::jsinspector_modern
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include "PageTarget.h"
|
|
11
11
|
|
|
12
12
|
#include <jsinspector-modern/InspectorInterfaces.h>
|
|
13
|
+
#include <jsinspector-modern/InstanceAgent.h>
|
|
13
14
|
#include <jsinspector-modern/Parsing.h>
|
|
14
15
|
|
|
15
16
|
#include <functional>
|
|
@@ -18,6 +19,8 @@
|
|
|
18
19
|
namespace facebook::react::jsinspector_modern {
|
|
19
20
|
|
|
20
21
|
class PageTarget;
|
|
22
|
+
class InstanceAgent;
|
|
23
|
+
class InstanceTarget;
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* An Agent that handles requests from the Chrome DevTools Protocol for the
|
|
@@ -47,6 +50,14 @@ class PageAgent {
|
|
|
47
50
|
*/
|
|
48
51
|
void handleRequest(const cdp::PreparsedRequest& req);
|
|
49
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Replace the current InstanceAgent with the given one and notify the
|
|
55
|
+
* frontend about the new instance.
|
|
56
|
+
* \param agent The new InstanceAgent. May be null to signify that there is
|
|
57
|
+
* currently no active instance.
|
|
58
|
+
*/
|
|
59
|
+
void setCurrentInstanceAgent(std::unique_ptr<InstanceAgent> agent);
|
|
60
|
+
|
|
50
61
|
private:
|
|
51
62
|
/**
|
|
52
63
|
* Send a simple Log.entryAdded notification with the given
|
|
@@ -62,6 +73,8 @@ class PageAgent {
|
|
|
62
73
|
FrontendChannel frontendChannel_;
|
|
63
74
|
PageTargetController& targetController_;
|
|
64
75
|
const PageTarget::SessionMetadata sessionMetadata_;
|
|
76
|
+
std::unique_ptr<InstanceAgent> instanceAgent_;
|
|
77
|
+
bool runtimeEnabled_{false};
|
|
65
78
|
};
|
|
66
79
|
|
|
67
80
|
} // namespace facebook::react::jsinspector_modern
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#include "PageTarget.h"
|
|
9
|
+
#include "InspectorInterfaces.h"
|
|
9
10
|
#include "InspectorUtilities.h"
|
|
11
|
+
#include "InstanceTarget.h"
|
|
10
12
|
#include "PageAgent.h"
|
|
11
13
|
#include "Parsing.h"
|
|
12
14
|
|
|
@@ -72,6 +74,21 @@ class PageTargetSession {
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Replace the current instance agent inside pageAgent_ with a new one
|
|
79
|
+
* connected to the new InstanceTarget.
|
|
80
|
+
* \param instance The new instance target. May be nullptr to indicate there's
|
|
81
|
+
* no current instance.
|
|
82
|
+
*/
|
|
83
|
+
void setCurrentInstance(InstanceTarget* instance) {
|
|
84
|
+
if (instance) {
|
|
85
|
+
pageAgent_.setCurrentInstanceAgent(
|
|
86
|
+
instance->createAgent(frontendChannel_));
|
|
87
|
+
} else {
|
|
88
|
+
pageAgent_.setCurrentInstanceAgent(nullptr);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
75
92
|
private:
|
|
76
93
|
// Owned by this instance, but shared (weakly) with the frontend channel
|
|
77
94
|
std::shared_ptr<RAIIRemoteConnection> remote_;
|
|
@@ -86,6 +103,7 @@ std::unique_ptr<ILocalConnection> PageTarget::connect(
|
|
|
86
103
|
SessionMetadata sessionMetadata) {
|
|
87
104
|
auto session = std::make_shared<PageTargetSession>(
|
|
88
105
|
std::move(connectionToFrontend), controller_, std::move(sessionMetadata));
|
|
106
|
+
session->setCurrentInstance(currentInstance_ ? &*currentInstance_ : nullptr);
|
|
89
107
|
sessions_.push_back(std::weak_ptr(session));
|
|
90
108
|
return std::make_unique<CallbackLocalConnection>(
|
|
91
109
|
[session](std::string message) { (*session)(message); });
|
|
@@ -108,6 +126,25 @@ PageTarget::~PageTarget() {
|
|
|
108
126
|
|
|
109
127
|
PageTargetDelegate::~PageTargetDelegate() {}
|
|
110
128
|
|
|
129
|
+
InstanceTarget& PageTarget::registerInstance(InstanceTargetDelegate& delegate) {
|
|
130
|
+
assert(!currentInstance_ && "Only one instance allowed");
|
|
131
|
+
currentInstance_.emplace(delegate);
|
|
132
|
+
forEachSession(
|
|
133
|
+
[currentInstance = &*currentInstance_](PageTargetSession& session) {
|
|
134
|
+
session.setCurrentInstance(currentInstance);
|
|
135
|
+
});
|
|
136
|
+
return *currentInstance_;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
void PageTarget::unregisterInstance(InstanceTarget& instance) {
|
|
140
|
+
assert(
|
|
141
|
+
currentInstance_.has_value() && ¤tInstance_.value() == &instance &&
|
|
142
|
+
"Invalid unregistration");
|
|
143
|
+
forEachSession(
|
|
144
|
+
[](PageTargetSession& session) { session.setCurrentInstance(nullptr); });
|
|
145
|
+
currentInstance_.reset();
|
|
146
|
+
}
|
|
147
|
+
|
|
111
148
|
PageTargetController::PageTargetController(PageTarget& target)
|
|
112
149
|
: target_(target) {}
|
|
113
150
|
|
|
@@ -115,4 +152,8 @@ PageTargetDelegate& PageTargetController::getDelegate() {
|
|
|
115
152
|
return target_.getDelegate();
|
|
116
153
|
}
|
|
117
154
|
|
|
155
|
+
bool PageTargetController::hasInstance() const {
|
|
156
|
+
return target_.hasInstance();
|
|
157
|
+
}
|
|
158
|
+
|
|
118
159
|
} // namespace facebook::react::jsinspector_modern
|