@@ -25,11 +25,19 @@ void SurfaceRegistryBinding::startSurface(
25
25
parameters[" initialProps" ] = initalProps;
26
26
parameters[" fabric" ] = true ;
27
27
28
- if (runtime.global ().hasProperty (runtime, " RN$SurfaceRegistry" )) {
29
- auto registry =
30
- runtime.global ().getPropertyAsObject (runtime, " RN$SurfaceRegistry" );
31
- auto method = registry.getPropertyAsFunction (runtime, " renderSurface" );
28
+ auto global = runtime.global ();
29
+ auto isBridgeless = global.hasProperty (runtime, " RN$Bridgeless" ) &&
30
+ global.getProperty (runtime, " RN$Bridgeless" ).asBool ();
32
31
32
+ if (isBridgeless) {
33
+ if (!global.hasProperty (runtime, " RN$SurfaceRegistry" )) {
34
+ throw std::runtime_error (
35
+ " SurfaceRegistryBinding::startSurface: Failed to start Surface \" " +
36
+ moduleName + " \" . global.RN$SurfaceRegistry was not installed." );
37
+ }
38
+
39
+ auto registry = global.getPropertyAsObject (runtime, " RN$SurfaceRegistry" );
40
+ auto method = registry.getPropertyAsFunction (runtime, " renderSurface" );
33
41
method.call (
34
42
runtime,
35
43
{jsi::String::createFromUtf8 (runtime, moduleName),
@@ -58,9 +66,18 @@ void SurfaceRegistryBinding::setSurfaceProps(
58
66
parameters[" initialProps" ] = initalProps;
59
67
parameters[" fabric" ] = true ;
60
68
61
- if (runtime.global ().hasProperty (runtime, " RN$SurfaceRegistry" )) {
62
- auto registry =
63
- runtime.global ().getPropertyAsObject (runtime, " RN$SurfaceRegistry" );
69
+ auto global = runtime.global ();
70
+ auto isBridgeless = global.hasProperty (runtime, " RN$Bridgeless" ) &&
71
+ global.getProperty (runtime, " RN$Bridgeless" ).asBool ();
72
+
73
+ if (isBridgeless) {
74
+ if (!global.hasProperty (runtime, " RN$SurfaceRegistry" )) {
75
+ throw std::runtime_error (
76
+ " SurfaceRegistryBinding::setSurfaceProps: Failed to set Surface props for \" " +
77
+ moduleName + " \" . global.RN$SurfaceRegistry was not installed." );
78
+ }
79
+
80
+ auto registry = global.getPropertyAsObject (runtime, " RN$SurfaceRegistry" );
64
81
auto method = registry.getPropertyAsFunction (runtime, " setSurfaceProps" );
65
82
66
83
method.call (
@@ -83,7 +100,10 @@ void SurfaceRegistryBinding::stopSurface(
83
100
jsi::Runtime &runtime,
84
101
SurfaceId surfaceId) {
85
102
auto global = runtime.global ();
86
- if (global.hasProperty (runtime, " RN$Bridgeless" )) {
103
+ auto isBridgeless = global.hasProperty (runtime, " RN$Bridgeless" ) &&
104
+ global.getProperty (runtime, " RN$Bridgeless" ).asBool ();
105
+
106
+ if (isBridgeless) {
87
107
if (!global.hasProperty (runtime, " RN$stopSurface" )) {
88
108
// ReactFabric module has not been loaded yet; there's no surface to stop.
89
109
return ;
0 commit comments