newsmemory-ios-sdk/Frameworks/ReactCommon.xcframework/ios-arm64/Headers/ReactCommon/TurboModuleBinding.h

66 lines
1.6 KiB
C
Raw Normal View History

2024-05-02 15:08:24 +00:00
/*
2024-10-29 07:36:43 +00:00
* Copyright (c) Meta Platforms, Inc. and affiliates.
2024-05-02 15:08:24 +00:00
*
* 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 <string>
#include <ReactCommon/LongLivedObject.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
namespace facebook {
namespace react {
class JSCallInvoker;
2024-10-29 07:36:43 +00:00
enum class TurboModuleBindingMode : uint8_t {
HostObject = 0,
Prototype = 1,
Eager = 2,
};
2024-05-02 15:08:24 +00:00
/**
* Represents the JavaScript binding for the TurboModule system.
*/
class TurboModuleBinding {
public:
/*
* Installs TurboModuleBinding into JavaScript runtime.
* Thread synchronization must be enforced externally.
*/
static void install(
jsi::Runtime &runtime,
const TurboModuleProviderFunctionType &&moduleProvider,
2024-10-29 07:36:43 +00:00
TurboModuleBindingMode bindingMode,
2024-05-02 15:08:24 +00:00
std::shared_ptr<LongLivedObjectCollection> longLivedObjectCollection);
2024-10-29 07:36:43 +00:00
private:
2024-05-02 15:08:24 +00:00
TurboModuleBinding(
const TurboModuleProviderFunctionType &&moduleProvider,
2024-10-29 07:36:43 +00:00
TurboModuleBindingMode bindingMode,
2024-05-02 15:08:24 +00:00
std::shared_ptr<LongLivedObjectCollection> longLivedObjectCollection);
virtual ~TurboModuleBinding();
/**
* A lookup function exposed to JS to get an instance of a TurboModule
* for the given name.
*/
2024-10-29 07:36:43 +00:00
jsi::Value getModule(
2024-05-02 15:08:24 +00:00
jsi::Runtime &runtime,
const jsi::Value &thisVal,
const jsi::Value *args,
size_t count);
TurboModuleProviderFunctionType moduleProvider_;
std::shared_ptr<LongLivedObjectCollection> longLivedObjectCollection_;
2024-10-29 07:36:43 +00:00
TurboModuleBindingMode bindingMode_;
2024-05-02 15:08:24 +00:00
};
} // namespace react
} // namespace facebook