Unbreak SurfaceRegistry users in bridge mode

Summary: Changelog: [Internal]

Reviewed By: nlutsenko

Differential Revision: D37250414

fbshipit-source-id: be3b98ba661c6f267d0d0dcac8d816584ef58c51
This commit is contained in:
Ramanpreet Nara
2022-06-17 15:06:31 -07:00
committed by Facebook GitHub Bot
parent 4a7e4b9ca6
commit 168f020d5e
@@ -44,13 +44,25 @@ void SurfaceRegistryBinding::startSurface(
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"runApplication",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
if (moduleName != "LogBox" &&
global.hasProperty(runtime, "RN$SurfaceRegistry")) {
auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry");
auto method = registry.getPropertyAsFunction(runtime, "renderSurface");
method.call(
runtime,
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"runApplication",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
}
}
}
@@ -86,13 +98,25 @@ void SurfaceRegistryBinding::setSurfaceProps(
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"setSurfaceProps",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
if (moduleName != "LogBox" &&
global.hasProperty(runtime, "RN$SurfaceRegistry")) {
auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry");
auto method = registry.getPropertyAsFunction(runtime, "setSurfaceProps");
method.call(
runtime,
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"setSurfaceProps",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
}
}
}