@@ -10,7 +10,7 @@ void RuntimeDecorator::decorateRuntime(jsi::Runtime &rt, std::string label) {
10
10
rt.global ().setProperty (rt, " _WORKLET" , jsi::Value (true ));
11
11
// This property will be used for debugging
12
12
rt.global ().setProperty (rt, " _LABEL" , jsi::String::createFromAscii (rt, label));
13
-
13
+
14
14
jsi::Object dummyGlobal (rt);
15
15
auto dummyFunction = [](
16
16
jsi::Runtime &rt,
@@ -21,12 +21,12 @@ void RuntimeDecorator::decorateRuntime(jsi::Runtime &rt, std::string label) {
21
21
return jsi::Value::undefined ();
22
22
};
23
23
jsi::Function __reanimatedWorkletInit = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " __reanimatedWorkletInit" ), 1 , dummyFunction);
24
-
24
+
25
25
dummyGlobal.setProperty (rt, " __reanimatedWorkletInit" , __reanimatedWorkletInit);
26
26
rt.global ().setProperty (rt, " global" , dummyGlobal);
27
-
27
+
28
28
rt.global ().setProperty (rt, " jsThis" , jsi::Value::undefined ());
29
-
29
+
30
30
auto callback = [](
31
31
jsi::Runtime &rt,
32
32
const jsi::Value &thisValue,
@@ -47,7 +47,7 @@ void RuntimeDecorator::decorateRuntime(jsi::Runtime &rt, std::string label) {
47
47
};
48
48
jsi::Value log = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " _log" ), 1 , callback);
49
49
rt.global ().setProperty (rt, " _log" , log);
50
-
50
+
51
51
auto setGlobalConsole = [](
52
52
jsi::Runtime &rt,
53
53
const jsi::Value &thisValue,
@@ -67,7 +67,8 @@ void RuntimeDecorator::decorateUIRuntime(jsi::Runtime &rt,
67
67
MeasuringFunction measure,
68
68
TimeProviderFunction getCurrentTime) {
69
69
RuntimeDecorator::decorateRuntime (rt, " UI" );
70
-
70
+ rt.global ().setProperty (rt, " _UI" , jsi::Value (true ));
71
+
71
72
auto clb = [updater](
72
73
jsi::Runtime &rt,
73
74
const jsi::Value &thisValue,
@@ -82,8 +83,8 @@ void RuntimeDecorator::decorateUIRuntime(jsi::Runtime &rt,
82
83
};
83
84
jsi::Value updateProps = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " _updateProps" ), 2 , clb);
84
85
rt.global ().setProperty (rt, " _updateProps" , updateProps);
85
-
86
-
86
+
87
+
87
88
auto clb2 = [requestFrame](
88
89
jsi::Runtime &rt,
89
90
const jsi::Value &thisValue,
@@ -98,7 +99,7 @@ void RuntimeDecorator::decorateUIRuntime(jsi::Runtime &rt,
98
99
};
99
100
jsi::Value requestAnimationFrame = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " requestAnimationFrame" ), 1 , clb2);
100
101
rt.global ().setProperty (rt, " requestAnimationFrame" , requestAnimationFrame);
101
-
102
+
102
103
auto clb3 = [scrollTo](
103
104
jsi::Runtime &rt,
104
105
const jsi::Value &thisValue,
@@ -114,7 +115,7 @@ void RuntimeDecorator::decorateUIRuntime(jsi::Runtime &rt,
114
115
};
115
116
jsi::Value scrollToFunction = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " _scrollTo" ), 4 , clb3);
116
117
rt.global ().setProperty (rt, " _scrollTo" , scrollToFunction);
117
-
118
+
118
119
auto clb4 = [measure](
119
120
jsi::Runtime &rt,
120
121
const jsi::Value &thisValue,
@@ -131,7 +132,7 @@ void RuntimeDecorator::decorateUIRuntime(jsi::Runtime &rt,
131
132
};
132
133
jsi::Value measureFunction = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " _measure" ), 1 , clb4);
133
134
rt.global ().setProperty (rt, " _measure" , measureFunction);
134
-
135
+
135
136
auto clb6 = [getCurrentTime](
136
137
jsi::Runtime &rt,
137
138
const jsi::Value &thisValue,
@@ -142,16 +143,21 @@ void RuntimeDecorator::decorateUIRuntime(jsi::Runtime &rt,
142
143
};
143
144
jsi::Value timeFun = jsi::Function::createFromHostFunction (rt, jsi::PropNameID::forAscii (rt, " _getCurrentTime" ), 0 , clb6);
144
145
rt.global ().setProperty (rt, " _getCurrentTime" , timeFun);
145
-
146
+
146
147
rt.global ().setProperty (rt, " _frameTimestamp" , jsi::Value::undefined ());
147
148
rt.global ().setProperty (rt, " _eventTimestamp" , jsi::Value::undefined ());
148
149
}
149
150
150
- bool RuntimeDecorator::isWorkletRuntime (jsi::Runtime& rt) {
151
- auto isUi = rt.global ().getProperty (rt, " _WORKLET " );
151
+ bool RuntimeDecorator::isUIRuntime (jsi::Runtime& rt) {
152
+ auto isUi = rt.global ().getProperty (rt, " _UI " );
152
153
return isUi.isBool () && isUi.getBool ();
153
154
}
154
155
156
+ bool RuntimeDecorator::isWorkletRuntime (jsi::Runtime& rt) {
157
+ auto isWorklet = rt.global ().getProperty (rt, " _WORKLET" );
158
+ return isWorklet.isBool () && isWorklet.getBool ();
159
+ }
160
+
155
161
bool RuntimeDecorator::isReactRuntime (jsi::Runtime& rt) {
156
162
return !isWorkletRuntime (rt);
157
163
}
0 commit comments