-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathStableApi.h
More file actions
109 lines (85 loc) · 2.9 KB
/
Copy pathStableApi.h
File metadata and controls
109 lines (85 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once
/**
* Version of `react-native-worklets` which introduced current stable API.
* It can be used by libraries to verify they use a compatible version
* of `react-native-worklets` installed when integrating in C++.
*/
#define WORKLETS_STABLE_API_VERSION "0.8.0"
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
namespace facebook::jsi {
class Runtime;
class Value;
class Object;
} // namespace facebook::jsi
namespace worklets {
class WorkletRuntime;
class UIScheduler;
class Serializable {
public:
virtual facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) = 0;
virtual ~Serializable();
enum class ValueType : std::uint8_t {
UndefinedType,
NullType,
BooleanType,
NumberType,
BigIntType,
StringType,
ObjectType,
ArrayType,
MapType,
SetType,
WorkletType,
RemoteFunctionType,
HandleType,
HostObjectType,
HostFunctionType,
ArrayBufferType,
TurboModuleLikeType,
ImportType,
SynchronizableType,
CustomType,
SymbolType, /* unused */
ShareableType
};
explicit Serializable(ValueType valueType) : valueType_(valueType) {}
inline ValueType valueType() const {
return valueType_;
}
static std::shared_ptr<Serializable> undefined();
protected:
ValueType valueType_;
};
extern std::shared_ptr<WorkletRuntime> getWorkletRuntimeFromHolder(
facebook::jsi::Runtime &rt,
const facebook::jsi::Object &object);
extern std::shared_ptr<UIScheduler> getUISchedulerFromHolder(
facebook::jsi::Runtime &rt,
const facebook::jsi::Object &object);
extern facebook::jsi::Runtime &getJSIRuntimeFromWorkletRuntime(const std::shared_ptr<WorkletRuntime> &workletRuntime);
extern std::weak_ptr<WorkletRuntime> getWeakRuntimeFromJSIRuntime(facebook::jsi::Runtime &rt);
extern void scheduleOnUI(const std::shared_ptr<UIScheduler> &uiScheduler, const std::function<void()> &job);
extern std::string JSIValueToStdString(facebook::jsi::Runtime &rt, const facebook::jsi::Value &value);
extern std::shared_ptr<Serializable>
extractSerializable(facebook::jsi::Runtime &rt, const facebook::jsi::Value &value, const std::string &errorMessage);
extern std::shared_ptr<Serializable> extractSerializable(
facebook::jsi::Runtime &rt,
const facebook::jsi::Value &value,
const std::string &errorMessage,
const Serializable::ValueType expectedType);
extern void runSyncOnRuntime(
const std::shared_ptr<WorkletRuntime> &workletRuntime,
const std::shared_ptr<Serializable> &worklet);
extern void runSyncOnRuntime(
const std::shared_ptr<WorkletRuntime> &workletRuntime,
const std::shared_ptr<Serializable> &worklet,
const facebook::jsi::Value &arg0);
extern void runSyncOnRuntime(
const std::shared_ptr<WorkletRuntime> &workletRuntime,
const std::shared_ptr<Serializable> &worklet,
const facebook::jsi::Value &arg0,
const facebook::jsi::Value &arg1);
} // namespace worklets