Preset the data-bridge-platform and data-bridge-components on the body element from the user-agent. This prevents css flashes before the native bridge is registered in the app.

This commit is contained in:
Jay Ohms
2026-03-17 09:59:45 -04:00
parent 768e7a3a6e
commit 09e4bb13d3
2 changed files with 24 additions and 1 deletions
+20
View File
@@ -43,6 +43,17 @@ class ApplicationPlatform < PlatformAgent
operating_system == "Windows"
end
def bridge_name
case
when native? && android? then :android
when native? && ios? then :ios
end
end
def bridge_components
extract_list_from_native_user_agent("bridge-components")
end
def type
if native? && android?
"native android"
@@ -67,4 +78,13 @@ class ApplicationPlatform < PlatformAgent
os =~ /Linux/ ? "Linux" : os
end
end
private
def extract_list_from_native_user_agent(prefix)
if native?
user_agent.to_s.match(/#{prefix}: \[(.+)\]/) { |matches| matches[1] }.to_s
else
""
end
end
end