iOS/Sources/App/WebView/WebViewExternalBusMessage.swift
Bruno Pantaleão Gonçalves 50fffc8e8f
Add external bus event handler to focus on specific HTML element (#4098)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-12-16 19:28:17 +00:00

53 lines
2.2 KiB
Swift

import Foundation
import Shared
/// External Bus message types used by the web view integration.
/// - See: Home Assistant External Bus docs: https://developers.home-assistant.io/docs/frontend/external-bus
/// - See: Frontend implementation:
/// https://github.com/home-assistant/frontend/blob/dev/src/external_app/external_messaging.ts
enum WebViewExternalBusMessage: String, CaseIterable {
case configGet = "config/get"
case configScreenShow = "config_screen/show"
case haptic
case connectionStatus = "connection-status"
case tagRead = "tag/read"
case tagWrite = "tag/write"
case themeUpdate = "theme-update"
case matterCommission = "matter/commission"
case threadImportCredentials = "thread/import_credentials"
case threadStoreCredentialInAppleKeychain = "thread/store_in_platform_keychain"
case barCodeScanner = "bar_code/scan"
case barCodeScannerClose = "bar_code/close"
case barCodeScannerNotify = "bar_code/notify"
case assistShow = "assist/show"
case scanForImprov = "improv/scan"
case improvConfigureDevice = "improv/configure_device"
case focusElement = "focus_element"
static var configResult: [String: Any] {
[
"hasSettingsScreen": !Current.isCatalyst,
"canWriteTag": Current.tags.isNFCAvailable,
"canCommissionMatter": Current.matter.isAvailable,
"canImportThreadCredentials": Current.matter.threadCredentialsSharingEnabled,
"hasBarCodeScanner": true,
"canTransferThreadCredentialsToKeychain": Current.matter
.threadCredentialsStoreInKeychainEnabled,
"hasAssist": true,
"canSetupImprov": true,
"downloadFileSupported": true,
"appVersion": "\(AppConstants.version) (\(AppConstants.build))",
]
}
}
enum WebViewExternalBusOutgoingMessage: String, CaseIterable {
case showSidebar = "sidebar/show"
case showAutomationEditor = "automation/editor/show"
case barCodeScanResult = "bar_code/scan_result"
case barCodeScanAborted = "bar_code/aborted"
case improvDiscoveredDevice = "improv/discovered_device"
case improvDiscoveredDeviceSetupDone = "improv/device_setup_done"
case navigate = "navigate"
}