first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
/*
* 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 <folly/executors/QueuedImmediateExecutor.h>
#include <hermes/hermes.h>
#include "JsiIntegrationTestGenericEngineAdapter.h"
namespace facebook::react::jsinspector_modern {
JsiIntegrationTestGenericEngineAdapter::JsiIntegrationTestGenericEngineAdapter(
folly::Executor& jsExecutor)
: runtime_{hermes::makeHermesRuntime()},
jsExecutor_{jsExecutor},
runtimeTargetDelegate_{
"Generic engine (" + runtime_->description() + ")"} {}
RuntimeTargetDelegate&
JsiIntegrationTestGenericEngineAdapter::getRuntimeTargetDelegate() {
return runtimeTargetDelegate_;
}
jsi::Runtime& JsiIntegrationTestGenericEngineAdapter::getRuntime()
const noexcept {
return *runtime_;
}
RuntimeExecutor JsiIntegrationTestGenericEngineAdapter::getRuntimeExecutor()
const noexcept {
return [&jsExecutor = jsExecutor_, &runtime = getRuntime()](auto fn) {
jsExecutor.add([fn, &runtime]() { fn(runtime); });
};
}
} // namespace facebook::react::jsinspector_modern

View File

@@ -0,0 +1,45 @@
/*
* 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 "../utils/InspectorFlagOverridesGuard.h"
#include <jsinspector-modern/FallbackRuntimeTargetDelegate.h>
#include <jsinspector-modern/RuntimeTarget.h>
#include <folly/executors/QueuedImmediateExecutor.h>
#include <jsi/jsi.h>
#include <memory>
namespace facebook::react::jsinspector_modern {
/**
* An engine adapter for JsiIntegrationTest that represents a generic
* JSI-compatible engine, with no engine-specific CDP support. Uses Hermes under
* the hood, without Hermes's CDP support.
*/
class JsiIntegrationTestGenericEngineAdapter {
public:
explicit JsiIntegrationTestGenericEngineAdapter(folly::Executor &jsExecutor);
static InspectorFlagOverrides getInspectorFlagOverrides() noexcept;
RuntimeTargetDelegate &getRuntimeTargetDelegate();
jsi::Runtime &getRuntime() const noexcept;
RuntimeExecutor getRuntimeExecutor() const noexcept;
private:
std::unique_ptr<jsi::Runtime> runtime_;
folly::Executor &jsExecutor_;
jsinspector_modern::FallbackRuntimeTargetDelegate runtimeTargetDelegate_;
};
} // namespace facebook::react::jsinspector_modern

View File

@@ -0,0 +1,52 @@
/*
* 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 "JsiIntegrationTestHermesEngineAdapter.h"
namespace facebook::react::jsinspector_modern {
JsiIntegrationTestHermesEngineAdapter::JsiIntegrationTestHermesEngineAdapter(
folly::Executor& jsExecutor)
: runtime_{hermes::makeHermesRuntime(
::hermes::vm::RuntimeConfig::Builder()
.withCompilationMode(
::hermes::vm::CompilationMode::ForceLazyCompilation)
.build())},
jsExecutor_{jsExecutor},
runtimeTargetDelegate_{runtime_} {
// NOTE: In React Native, registerForProfiling is called by
// HermesInstance::unstable_initializeOnJsThread, called from
// ReactInstance::initializeRuntime. Ideally, we should figure out how to
// manages this from inside the CDP backend,
runtime_->registerForProfiling();
}
RuntimeTargetDelegate&
JsiIntegrationTestHermesEngineAdapter::getRuntimeTargetDelegate() {
return runtimeTargetDelegate_;
}
jsi::Runtime& JsiIntegrationTestHermesEngineAdapter::getRuntime()
const noexcept {
return *runtime_;
}
RuntimeExecutor JsiIntegrationTestHermesEngineAdapter::getRuntimeExecutor()
const noexcept {
auto& jsExecutor = jsExecutor_;
return [runtimeWeak = std::weak_ptr(runtime_), &jsExecutor](auto fn) {
jsExecutor.add([runtimeWeak, fn]() {
auto runtime = runtimeWeak.lock();
if (!runtime) {
return;
}
fn(*runtime);
});
};
}
} // namespace facebook::react::jsinspector_modern

View File

@@ -0,0 +1,45 @@
/*
* 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 "../utils/InspectorFlagOverridesGuard.h"
#include <jsinspector-modern/RuntimeTarget.h>
#include <folly/executors/QueuedImmediateExecutor.h>
#include <hermes/hermes.h>
#include <hermes/inspector-modern/chrome/HermesRuntimeTargetDelegate.h>
#include <jsi/jsi.h>
#include <memory>
namespace facebook::react::jsinspector_modern {
/**
* An engine adapter for JsiIntegrationTest that uses Hermes (and Hermes'
* modern CDPAgent API).
*/
class JsiIntegrationTestHermesEngineAdapter {
public:
explicit JsiIntegrationTestHermesEngineAdapter(folly::Executor &jsExecutor);
static InspectorFlagOverrides getInspectorFlagOverrides() noexcept;
RuntimeTargetDelegate &getRuntimeTargetDelegate();
jsi::Runtime &getRuntime() const noexcept;
RuntimeExecutor getRuntimeExecutor() const noexcept;
private:
std::shared_ptr<facebook::hermes::HermesRuntime> runtime_;
folly::Executor &jsExecutor_;
HermesRuntimeTargetDelegate runtimeTargetDelegate_;
};
} // namespace facebook::react::jsinspector_modern